本文整理匯總了Java中org.eclipse.jdt.core.dom.ASTNode.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java ASTNode.equals方法的具體用法?Java ASTNode.equals怎麽用?Java ASTNode.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ASTNode
的用法示例。
在下文中一共展示了ASTNode.equals方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: evaluateFieldModifiers
import org.eclipse.jdt.core.dom.ASTNode; //導入方法依賴的package包/類
private int evaluateFieldModifiers(ASTNode newTypeDecl) {
if (fSenderBinding.isAnnotation()) {
return 0;
}
if (fSenderBinding.isInterface()) {
// for interface members copy the modifiers from an existing field
FieldDeclaration[] fieldDecls= ((TypeDeclaration) newTypeDecl).getFields();
if (fieldDecls.length > 0) {
return fieldDecls[0].getModifiers();
}
return 0;
}
int modifiers= 0;
if (fVariableKind == CONST_FIELD) {
modifiers |= Modifier.FINAL | Modifier.STATIC;
} else {
ASTNode parent= fOriginalNode.getParent();
if (parent instanceof QualifiedName) {
IBinding qualifierBinding= ((QualifiedName)parent).getQualifier().resolveBinding();
if (qualifierBinding instanceof ITypeBinding) {
modifiers |= Modifier.STATIC;
}
} else if (ASTResolving.isInStaticContext(fOriginalNode)) {
modifiers |= Modifier.STATIC;
}
}
ASTNode node= ASTResolving.findParentType(fOriginalNode, true);
if (newTypeDecl.equals(node)) {
modifiers |= Modifier.PRIVATE;
} else if (node instanceof AnonymousClassDeclaration) {
modifiers |= Modifier.PROTECTED;
} else {
modifiers |= Modifier.PUBLIC;
}
return modifiers;
}
示例2: guessTypeForReference
import org.eclipse.jdt.core.dom.ASTNode; //導入方法依賴的package包/類
public static Type guessTypeForReference(AST ast, ASTNode node) {
ASTNode parent= node.getParent();
while (parent != null) {
switch (parent.getNodeType()) {
case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
if (((VariableDeclarationFragment) parent).getInitializer() == node) {
return ASTNodeFactory.newType(ast, (VariableDeclaration) parent);
}
return null;
case ASTNode.SINGLE_VARIABLE_DECLARATION:
if (((VariableDeclarationFragment) parent).getInitializer() == node) {
return ASTNodeFactory.newType(ast, (VariableDeclaration) parent);
}
return null;
case ASTNode.ARRAY_ACCESS:
if (!((ArrayAccess) parent).getIndex().equals(node)) {
Type type= guessTypeForReference(ast, parent);
if (type != null) {
return ASTNodeFactory.newArrayType(type);
}
}
return null;
case ASTNode.FIELD_ACCESS:
if (node.equals(((FieldAccess) parent).getName())) {
node= parent;
parent= parent.getParent();
} else {
return null;
}
break;
case ASTNode.SUPER_FIELD_ACCESS:
case ASTNode.PARENTHESIZED_EXPRESSION:
node= parent;
parent= parent.getParent();
break;
case ASTNode.QUALIFIED_NAME:
if (node.equals(((QualifiedName) parent).getName())) {
node= parent;
parent= parent.getParent();
} else {
return null;
}
break;
default:
return null;
}
}
return null;
}
示例3: evaluateModifiers
import org.eclipse.jdt.core.dom.ASTNode; //導入方法依賴的package包/類
private int evaluateModifiers(ASTNode targetTypeDecl) {
if (getSenderBinding().isAnnotation()) {
return 0;
}
boolean isTargetInterface= getSenderBinding().isInterface();
if (isTargetInterface && !JavaModelUtil.is18OrHigher(getCompilationUnit().getJavaProject())) {
// only abstract methods are allowed for interface present in less than Java 1.8
return getInterfaceMethodModifiers(targetTypeDecl, true);
}
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);
boolean isParentInterface= node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface();
if (isTargetInterface || isParentInterface) {
if (expression == null && !targetTypeDecl.equals(node)) {
modifiers|= Modifier.STATIC;
if (isTargetInterface) {
modifiers|= getInterfaceMethodModifiers(targetTypeDecl, false);
} else {
modifiers|= Modifier.PROTECTED;
}
} else if (modifiers == Modifier.STATIC) {
modifiers= getInterfaceMethodModifiers(targetTypeDecl, false) | Modifier.STATIC;
} else {
modifiers= getInterfaceMethodModifiers(targetTypeDecl, true);
}
} else 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;
}