本文整理匯總了Java中org.eclipse.jdt.core.dom.ASTNode.PARENTHESIZED_EXPRESSION屬性的典型用法代碼示例。如果您正苦於以下問題:Java ASTNode.PARENTHESIZED_EXPRESSION屬性的具體用法?Java ASTNode.PARENTHESIZED_EXPRESSION怎麽用?Java ASTNode.PARENTHESIZED_EXPRESSION使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.eclipse.jdt.core.dom.ASTNode
的用法示例。
在下文中一共展示了ASTNode.PARENTHESIZED_EXPRESSION屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseExpression
private void parseExpression(MethodInfo methodInfo, Expression expression) {
if (expression == null) {
return;
}//System.out.println(expression.toString()+" "+Annotation.nodeClassForType(expression.getNodeType()));
if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
List<Expression> expressions = ((ArrayInitializer) expression).expressions();
for (Expression expression2 : expressions) {
parseExpression(methodInfo, expression2);
}
}
if (expression.getNodeType() == ASTNode.CAST_EXPRESSION) {
parseExpression(methodInfo, ((CastExpression) expression).getExpression());
}
if (expression.getNodeType() == ASTNode.CONDITIONAL_EXPRESSION) {
parseExpression(methodInfo, ((ConditionalExpression) expression).getExpression());
parseExpression(methodInfo, ((ConditionalExpression) expression).getElseExpression());
parseExpression(methodInfo, ((ConditionalExpression) expression).getThenExpression());
}
if (expression.getNodeType() == ASTNode.INFIX_EXPRESSION) {
parseExpression(methodInfo, ((InfixExpression) expression).getLeftOperand());
parseExpression(methodInfo, ((InfixExpression) expression).getRightOperand());
}
if (expression.getNodeType() == ASTNode.INSTANCEOF_EXPRESSION) {
parseExpression(methodInfo, ((InstanceofExpression) expression).getLeftOperand());
}
if (expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION) {
parseExpression(methodInfo, ((ParenthesizedExpression) expression).getExpression());
}
if (expression.getNodeType() == ASTNode.POSTFIX_EXPRESSION) {
parseExpression(methodInfo, ((PostfixExpression) expression).getOperand());
}
if (expression.getNodeType() == ASTNode.PREFIX_EXPRESSION) {
parseExpression(methodInfo, ((PrefixExpression) expression).getOperand());
}
if (expression.getNodeType() == ASTNode.THIS_EXPRESSION) {
parseExpression(methodInfo, ((ThisExpression) expression).getQualifier());
}
if (expression.getNodeType() == ASTNode.METHOD_INVOCATION) {
List<Expression> arguments = ((MethodInvocation) expression).arguments();
IMethodBinding methodBinding = ((MethodInvocation) expression).resolveMethodBinding();
if (methodBinding != null)
methodInfo.methodCalls.add(methodBinding);
for (Expression exp : arguments)
parseExpression(methodInfo, exp);
parseExpression(methodInfo, ((MethodInvocation) expression).getExpression());
}
if (expression.getNodeType() == ASTNode.ASSIGNMENT) {
parseExpression(methodInfo, ((Assignment) expression).getLeftHandSide());
parseExpression(methodInfo, ((Assignment) expression).getRightHandSide());
}
if (expression.getNodeType() == ASTNode.QUALIFIED_NAME) {
if (((QualifiedName) expression).getQualifier().resolveTypeBinding() != null) {
String name = ((QualifiedName) expression).getQualifier().resolveTypeBinding().getQualifiedName() + "." + ((QualifiedName) expression).getName().getIdentifier();
methodInfo.fieldUsesSet.add(name);
}
parseExpression(methodInfo, ((QualifiedName) expression).getQualifier());
}
}
示例2: resolveExpressionBinding
/**
* Resolve the binding (<em>not</em> the type binding) for the expression or a nested expression
* (e.g. nested in parentheses, cast, ...).
*
* @param expression an expression node
* @param goIntoCast iff <code>true</code>, go into a CastExpression's expression to resolve
* @return the expression binding, or <code>null</code> if the expression has no binding or the
* binding could not be resolved
*
* @since 3.5
*/
public static IBinding resolveExpressionBinding(Expression expression, boolean goIntoCast) {
//TODO: search for callers of resolve*Binding() methods and replace with call to this method
// similar to StubUtility#getVariableNameSuggestions(int, IJavaProject, ITypeBinding, Expression, Collection)
switch (expression.getNodeType()) {
case ASTNode.SIMPLE_NAME:
case ASTNode.QUALIFIED_NAME:
return ((Name) expression).resolveBinding();
case ASTNode.FIELD_ACCESS:
return ((FieldAccess) expression).resolveFieldBinding();
case ASTNode.SUPER_FIELD_ACCESS:
return ((SuperFieldAccess) expression).resolveFieldBinding();
case ASTNode.METHOD_INVOCATION:
return ((MethodInvocation) expression).resolveMethodBinding();
case ASTNode.SUPER_METHOD_INVOCATION:
return ((SuperMethodInvocation) expression).resolveMethodBinding();
case ASTNode.CLASS_INSTANCE_CREATION:
return ((ClassInstanceCreation) expression).resolveConstructorBinding();
case ASTNode.MARKER_ANNOTATION:
case ASTNode.SINGLE_MEMBER_ANNOTATION:
case ASTNode.NORMAL_ANNOTATION:
return ((Annotation) expression).resolveAnnotationBinding();
case ASTNode.ARRAY_ACCESS:
return resolveExpressionBinding(((ArrayAccess) expression).getArray(), goIntoCast);
case ASTNode.CAST_EXPRESSION:
if (goIntoCast) {
return resolveExpressionBinding(((CastExpression) expression).getExpression(), true);
} else {
return null;
}
case ASTNode.PARENTHESIZED_EXPRESSION:
return resolveExpressionBinding(((ParenthesizedExpression) expression).getExpression(), goIntoCast);
case ASTNode.PREFIX_EXPRESSION:
return resolveExpressionBinding(((PrefixExpression) expression).getOperand(), goIntoCast);
case ASTNode.POSTFIX_EXPRESSION:
return resolveExpressionBinding(((PostfixExpression) expression).getOperand(), goIntoCast);
default:
return null;
}
}
示例3: 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;
}