当前位置: 首页>>代码示例>>Java>>正文


Java ASTNodes.isParent方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.corext.dom.ASTNodes.isParent方法的典型用法代码示例。如果您正苦于以下问题:Java ASTNodes.isParent方法的具体用法?Java ASTNodes.isParent怎么用?Java ASTNodes.isParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.corext.dom.ASTNodes的用法示例。


在下文中一共展示了ASTNodes.isParent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isLeftHandSideOfAssignment

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
static boolean isLeftHandSideOfAssignment(ASTNode node) {
	Assignment assignment = (Assignment) ASTNodes.getParent(node, ASTNode.ASSIGNMENT);
	if (assignment != null) {
		Expression leftHandSide = assignment.getLeftHandSide();
		if (leftHandSide == node) {
			return true;
		}
		if (ASTNodes.isParent(node, leftHandSide)) {
			switch (leftHandSide.getNodeType()) {
				case ASTNode.SIMPLE_NAME:
					return true;
				case ASTNode.FIELD_ACCESS:
					return node == ((FieldAccess) leftHandSide).getName();
				case ASTNode.QUALIFIED_NAME:
					return node == ((QualifiedName) leftHandSide).getName();
				case ASTNode.SUPER_FIELD_ACCESS:
					return node == ((SuperFieldAccess) leftHandSide).getName();
				default:
					return false;
			}
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:25,代码来源:SnippetFinder.java

示例2: isLeftHandSideOfAssignment

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
private static boolean isLeftHandSideOfAssignment(ASTNode node) {
  Assignment assignment = (Assignment) ASTNodes.getParent(node, ASTNode.ASSIGNMENT);
  if (assignment != null) {
    Expression leftHandSide = assignment.getLeftHandSide();
    if (leftHandSide == node) {
      return true;
    }
    if (ASTNodes.isParent(node, leftHandSide)) {
      switch (leftHandSide.getNodeType()) {
        case ASTNode.SIMPLE_NAME:
          return true;
        case ASTNode.FIELD_ACCESS:
          return node == ((FieldAccess) leftHandSide).getName();
        case ASTNode.QUALIFIED_NAME:
          return node == ((QualifiedName) leftHandSide).getName();
        case ASTNode.SUPER_FIELD_ACCESS:
          return node == ((SuperFieldAccess) leftHandSide).getName();
        default:
          return false;
      }
    }
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:SnippetFinder.java

示例3: visit

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
@Override
public boolean visit(BreakStatement node) {
	SimpleName label= node.getLabel();
	if (fDefiningLabel != null && isSameLabel(label) && ASTNodes.isParent(label, fDefiningLabel)) {
		fResult.add(label);
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:9,代码来源:LinkedNodeFinder.java

示例4: isDeclaredIn

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
public static boolean isDeclaredIn(
    VariableDeclaration tempDeclaration, Class<? extends ASTNode> astNodeClass) {
  ASTNode initializer = ASTNodes.getParent(tempDeclaration, astNodeClass);
  if (initializer == null) return false;
  ASTNode anonymous = ASTNodes.getParent(tempDeclaration, AnonymousClassDeclaration.class);
  if (anonymous == null) return true;
  // stupid code. Is to find out if the variable declaration isn't a field.
  if (ASTNodes.isParent(anonymous, initializer)) return false;
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:Checks.java

示例5: isBindingToTemp

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
private boolean isBindingToTemp(IVariableBinding variable) {
  if (variable.isField()) return false;
  if (!Modifier.isFinal(variable.getModifiers())) return false;
  ASTNode declaringNode = fCompilationUnitNode.findDeclaringNode(variable);
  if (declaringNode == null) return false;
  if (ASTNodes.isParent(declaringNode, fAnonymousInnerClassNode)) return false;
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:ConvertAnonymousToNestedRefactoring.java

示例6: getCommonParent

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
private ASTNode getCommonParent(ASTNode node1, ASTNode node2) {
  ASTNode parent = node1.getParent();
  while (parent != null && !ASTNodes.isParent(node2, parent)) {
    parent = parent.getParent();
  }
  return parent;
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:NewVariableCorrectionProposal.java

示例7: evaluateModifiers

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
private int evaluateModifiers(ASTNode targetTypeDecl) {
  if (getSenderBinding().isAnnotation()) {
    return 0;
  }
  if (getSenderBinding().isInterface()) {
    // for interface and annotation members copy the modifiers from an existing field
    MethodDeclaration[] methodDecls = ((TypeDeclaration) targetTypeDecl).getMethods();
    if (methodDecls.length > 0) {
      return methodDecls[0].getModifiers();
    }
    return 0;
  }
  ASTNode invocationNode = getInvocationNode();
  if (invocationNode instanceof MethodInvocation) {
    int modifiers = 0;
    Expression expression = ((MethodInvocation) invocationNode).getExpression();
    if (expression != null) {
      if (expression instanceof Name
          && ((Name) expression).resolveBinding().getKind() == IBinding.TYPE) {
        modifiers |= Modifier.STATIC;
      }
    } else if (ASTResolving.isInStaticContext(invocationNode)) {
      modifiers |= Modifier.STATIC;
    }
    ASTNode node = ASTResolving.findParentType(invocationNode);
    if (targetTypeDecl.equals(node)) {
      modifiers |= Modifier.PRIVATE;
    } else if (node instanceof AnonymousClassDeclaration
        && ASTNodes.isParent(node, targetTypeDecl)) {
      modifiers |= Modifier.PROTECTED;
      if (ASTResolving.isInStaticContext(node) && expression == null) {
        modifiers |= Modifier.STATIC;
      }
    } else {
      modifiers |= Modifier.PUBLIC;
    }
    return modifiers;
  }
  return Modifier.PUBLIC;
}
 
开发者ID:eclipse,项目名称:che,代码行数:41,代码来源:NewMethodCorrectionProposal.java


注:本文中的org.eclipse.jdt.internal.corext.dom.ASTNodes.isParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。