本文整理匯總了Java中org.eclipse.jdt.core.dom.ASTNode.SINGLE_VARIABLE_DECLARATION屬性的典型用法代碼示例。如果您正苦於以下問題:Java ASTNode.SINGLE_VARIABLE_DECLARATION屬性的具體用法?Java ASTNode.SINGLE_VARIABLE_DECLARATION怎麽用?Java ASTNode.SINGLE_VARIABLE_DECLARATION使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.eclipse.jdt.core.dom.ASTNode
的用法示例。
在下文中一共展示了ASTNode.SINGLE_VARIABLE_DECLARATION屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hasSideEffect
private static boolean hasSideEffect(SimpleName reference) {
ASTNode parent= reference.getParent();
while (parent instanceof QualifiedName) {
parent= parent.getParent();
}
if (parent instanceof FieldAccess) {
parent= parent.getParent();
}
ASTNode node= null;
int nameParentType= parent.getNodeType();
if (nameParentType == ASTNode.ASSIGNMENT) {
Assignment assignment= (Assignment) parent;
node= assignment.getRightHandSide();
} else if (nameParentType == ASTNode.SINGLE_VARIABLE_DECLARATION) {
SingleVariableDeclaration decl= (SingleVariableDeclaration)parent;
node= decl.getInitializer();
if (node == null) {
return false;
}
} else if (nameParentType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
node= parent;
} else {
return false;
}
ArrayList<Expression> sideEffects= new ArrayList<>();
node.accept(new SideEffectFinder(sideEffects));
return sideEffects.size() > 0;
}
示例2: guessTypeForReference
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;
}