Java Code Examples for org.eclipse.jdt.core.dom.ASTNode#SUPER_METHOD_INVOCATION
The following examples show how to use
org.eclipse.jdt.core.dom.ASTNode#SUPER_METHOD_INVOCATION .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Invocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 7 votes |
public static Expression getExpression(ASTNode invocation) { switch (invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: return ((MethodInvocation)invocation).getExpression(); case ASTNode.SUPER_METHOD_INVOCATION: return null; case ASTNode.CONSTRUCTOR_INVOCATION: return null; case ASTNode.SUPER_CONSTRUCTOR_INVOCATION: return ((SuperConstructorInvocation)invocation).getExpression(); case ASTNode.CLASS_INSTANCE_CREATION: return ((ClassInstanceCreation)invocation).getExpression(); case ASTNode.ENUM_CONSTANT_DECLARATION: return null; default: throw new IllegalArgumentException(invocation.toString()); } }
Example 2
Source File: IntroduceIndirectionRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static ASTNode checkNode(ASTNode node) { if (node == null) return null; if (node.getNodeType() == ASTNode.SIMPLE_NAME) { node= node.getParent(); } else if (node.getNodeType() == ASTNode.EXPRESSION_STATEMENT) { node= ((ExpressionStatement) node).getExpression(); } switch (node.getNodeType()) { case ASTNode.METHOD_INVOCATION: case ASTNode.METHOD_DECLARATION: case ASTNode.SUPER_METHOD_INVOCATION: return node; } return null; }
Example 3
Source File: InlineMethodRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Creates a new inline method refactoring * @param unit the compilation unit or class file * @param node the compilation unit node * @param selectionStart start * @param selectionLength length * @return returns the refactoring */ public static InlineMethodRefactoring create(ITypeRoot unit, CompilationUnit node, int selectionStart, int selectionLength) { ASTNode target= RefactoringAvailabilityTester.getInlineableMethodNode(unit, node, selectionStart, selectionLength); if (target == null) return null; if (target.getNodeType() == ASTNode.METHOD_DECLARATION) { return new InlineMethodRefactoring(unit, (MethodDeclaration)target, selectionStart, selectionLength); } else { ICompilationUnit cu= (ICompilationUnit) unit; if (target.getNodeType() == ASTNode.METHOD_INVOCATION) { return new InlineMethodRefactoring(cu, (MethodInvocation)target, selectionStart, selectionLength); } else if (target.getNodeType() == ASTNode.SUPER_METHOD_INVOCATION) { return new InlineMethodRefactoring(cu, (SuperMethodInvocation)target, selectionStart, selectionLength); } else if (target.getNodeType() == ASTNode.CONSTRUCTOR_INVOCATION) { return new InlineMethodRefactoring(cu, (ConstructorInvocation)target, selectionStart, selectionLength); } } return null; }
Example 4
Source File: Invocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static ITypeBinding[] getInferredTypeArguments(Expression invocation) { IMethodBinding methodBinding; switch (invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: methodBinding= ((MethodInvocation) invocation).resolveMethodBinding(); return methodBinding == null ? null : methodBinding.getTypeArguments(); case ASTNode.SUPER_METHOD_INVOCATION: methodBinding= ((SuperMethodInvocation) invocation).resolveMethodBinding(); return methodBinding == null ? null : methodBinding.getTypeArguments(); case ASTNode.CLASS_INSTANCE_CREATION: Type type= ((ClassInstanceCreation) invocation).getType(); ITypeBinding typeBinding= type.resolveBinding(); return typeBinding == null ? null : typeBinding.getTypeArguments(); default: throw new IllegalArgumentException(invocation.toString()); } }
Example 5
Source File: Invocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static boolean isResolvedTypeInferredFromExpectedType(Expression invocation) { if (invocation == null) return false; switch (invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: return ((MethodInvocation) invocation).isResolvedTypeInferredFromExpectedType(); case ASTNode.SUPER_METHOD_INVOCATION: return ((SuperMethodInvocation) invocation).isResolvedTypeInferredFromExpectedType(); case ASTNode.CLASS_INSTANCE_CREATION: return ((ClassInstanceCreation) invocation).isResolvedTypeInferredFromExpectedType(); default: return false; } }
Example 6
Source File: Invocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static IMethodBinding resolveBinding(ASTNode invocation) { switch (invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: return ((MethodInvocation)invocation).resolveMethodBinding(); case ASTNode.SUPER_METHOD_INVOCATION: return ((SuperMethodInvocation)invocation).resolveMethodBinding(); case ASTNode.CONSTRUCTOR_INVOCATION: return ((ConstructorInvocation)invocation).resolveConstructorBinding(); case ASTNode.SUPER_CONSTRUCTOR_INVOCATION: return ((SuperConstructorInvocation)invocation).resolveConstructorBinding(); case ASTNode.CLASS_INSTANCE_CREATION: return ((ClassInstanceCreation)invocation).resolveConstructorBinding(); case ASTNode.ENUM_CONSTANT_DECLARATION: return ((EnumConstantDeclaration)invocation).resolveConstructorBinding(); default: throw new IllegalArgumentException(invocation.toString()); } }
Example 7
Source File: Invocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static boolean isInvocationWithArguments(ASTNode node) { switch (node.getNodeType()) { case ASTNode.METHOD_INVOCATION: case ASTNode.SUPER_METHOD_INVOCATION: case ASTNode.CONSTRUCTOR_INVOCATION: case ASTNode.SUPER_CONSTRUCTOR_INVOCATION: case ASTNode.CLASS_INSTANCE_CREATION: case ASTNode.ENUM_CONSTANT_DECLARATION: return true; default: return false; } }
Example 8
Source File: Invocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static ChildListPropertyDescriptor getArgumentsProperty(ASTNode invocation) { switch (invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: return MethodInvocation.ARGUMENTS_PROPERTY; case ASTNode.SUPER_METHOD_INVOCATION: return SuperMethodInvocation.ARGUMENTS_PROPERTY; case ASTNode.CONSTRUCTOR_INVOCATION: return ConstructorInvocation.ARGUMENTS_PROPERTY; case ASTNode.SUPER_CONSTRUCTOR_INVOCATION: return SuperConstructorInvocation.ARGUMENTS_PROPERTY; case ASTNode.CLASS_INSTANCE_CREATION: return ClassInstanceCreation.ARGUMENTS_PROPERTY; case ASTNode.ENUM_CONSTANT_DECLARATION: return EnumConstantDeclaration.ARGUMENTS_PROPERTY; default: throw new IllegalArgumentException(invocation.toString()); } }
Example 9
Source File: Invocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static List<Expression> getArguments(ASTNode invocation) { switch (invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: return ((MethodInvocation)invocation).arguments(); case ASTNode.SUPER_METHOD_INVOCATION: return ((SuperMethodInvocation)invocation).arguments(); case ASTNode.CONSTRUCTOR_INVOCATION: return ((ConstructorInvocation)invocation).arguments(); case ASTNode.SUPER_CONSTRUCTOR_INVOCATION: return ((SuperConstructorInvocation)invocation).arguments(); case ASTNode.CLASS_INSTANCE_CREATION: return ((ClassInstanceCreation)invocation).arguments(); case ASTNode.ENUM_CONSTANT_DECLARATION: return ((EnumConstantDeclaration)invocation).arguments(); default: throw new IllegalArgumentException(invocation.toString()); } }
Example 10
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static boolean isIntroduceIndirectionAvailable(final JavaTextSelection selection) throws JavaModelException { final IJavaElement[] elements= selection.resolveElementAtOffset(); if (elements.length == 1) return (elements[0] instanceof IMethod) && isIntroduceIndirectionAvailable(((IMethod) elements[0])); ASTNode[] selectedNodes= selection.resolveSelectedNodes(); if (selectedNodes == null || selectedNodes.length != 1) return false; switch (selectedNodes[0].getNodeType()) { case ASTNode.METHOD_DECLARATION: case ASTNode.METHOD_INVOCATION: case ASTNode.SUPER_METHOD_INVOCATION: return true; default: return false; } }
Example 11
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static ASTNode getInlineableMethodNode(ASTNode node, IJavaElement unit) { if (node == null) return null; switch (node.getNodeType()) { case ASTNode.SIMPLE_NAME: StructuralPropertyDescriptor locationInParent= node.getLocationInParent(); if (locationInParent == MethodDeclaration.NAME_PROPERTY) { return node.getParent(); } else if (locationInParent == MethodInvocation.NAME_PROPERTY || locationInParent == SuperMethodInvocation.NAME_PROPERTY) { return unit instanceof ICompilationUnit ? node.getParent() : null; // don't start on invocations in binary } return null; case ASTNode.EXPRESSION_STATEMENT: node= ((ExpressionStatement)node).getExpression(); } switch (node.getNodeType()) { case ASTNode.METHOD_DECLARATION: return node; case ASTNode.METHOD_INVOCATION: case ASTNode.SUPER_METHOD_INVOCATION: case ASTNode.CONSTRUCTOR_INVOCATION: return unit instanceof ICompilationUnit ? node : null; // don't start on invocations in binary } return null; }
Example 12
Source File: ExtractClassRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private Expression getAssignedValue(ParameterObjectFactory pof, String parameterName, IJavaProject javaProject, RefactoringStatus status, ASTRewrite rewrite, ParameterInfo pi, boolean useSuper, ITypeBinding typeBinding, Expression qualifier, ASTNode replaceNode, ITypeRoot typeRoot) { AST ast= rewrite.getAST(); boolean is50OrHigher= JavaModelUtil.is50OrHigher(javaProject); Expression assignedValue= handleSimpleNameAssignment(replaceNode, pof, parameterName, ast, javaProject, useSuper); if (assignedValue == null) { NullLiteral marker= qualifier == null ? null : ast.newNullLiteral(); Expression fieldReadAccess= pof.createFieldReadAccess(pi, parameterName, ast, javaProject, useSuper, marker); assignedValue= GetterSetterUtil.getAssignedValue(replaceNode, rewrite, fieldReadAccess, typeBinding, is50OrHigher); boolean markerReplaced= replaceMarker(rewrite, qualifier, assignedValue, marker); if (markerReplaced) { switch (qualifier.getNodeType()) { case ASTNode.METHOD_INVOCATION: case ASTNode.CLASS_INSTANCE_CREATION: case ASTNode.SUPER_METHOD_INVOCATION: case ASTNode.PARENTHESIZED_EXPRESSION: status.addWarning(RefactoringCoreMessages.ExtractClassRefactoring_warning_semantic_change, JavaStatusContext.create(typeRoot, replaceNode)); break; } } } return assignedValue; }
Example 13
Source File: Invocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static ListRewrite getInferredTypeArgumentsRewrite(ASTRewrite rewrite, Expression invocation) { switch (invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: return rewrite.getListRewrite(invocation, MethodInvocation.TYPE_ARGUMENTS_PROPERTY); case ASTNode.SUPER_METHOD_INVOCATION: return rewrite.getListRewrite(invocation, SuperMethodInvocation.TYPE_ARGUMENTS_PROPERTY); case ASTNode.CLASS_INSTANCE_CREATION: Type type= ((ClassInstanceCreation) invocation).getType(); return rewrite.getListRewrite(type, ParameterizedType.TYPE_ARGUMENTS_PROPERTY); default: throw new IllegalArgumentException(invocation.toString()); } }
Example 14
Source File: RefactoringAvailabilityTester.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static ASTNode getInlineableMethodNode(ASTNode node, IJavaElement unit) { if (node == null) { return null; } switch (node.getNodeType()) { case ASTNode.SIMPLE_NAME: StructuralPropertyDescriptor locationInParent = node.getLocationInParent(); if (locationInParent == MethodDeclaration.NAME_PROPERTY) { return node.getParent(); } else if (locationInParent == MethodInvocation.NAME_PROPERTY || locationInParent == SuperMethodInvocation.NAME_PROPERTY) { return unit instanceof ICompilationUnit ? node.getParent() : null; // don't start on invocations in binary } return null; case ASTNode.EXPRESSION_STATEMENT: node = ((ExpressionStatement) node).getExpression(); } switch (node.getNodeType()) { case ASTNode.METHOD_DECLARATION: return node; case ASTNode.METHOD_INVOCATION: case ASTNode.SUPER_METHOD_INVOCATION: case ASTNode.CONSTRUCTOR_INVOCATION: return unit instanceof ICompilationUnit ? node : null; // don't start on invocations in binary } return null; }
Example 15
Source File: Bindings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * 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 * * @see StubUtility#getVariableNameSuggestions(int, IJavaProject, ITypeBinding, Expression, java.util.Collection) * @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; } }
Example 16
Source File: CompilationUnitBuilder.java From j2cl with Apache License 2.0 | 4 votes |
private Expression convert(org.eclipse.jdt.core.dom.Expression expression) { switch (expression.getNodeType()) { case ASTNode.ARRAY_ACCESS: return convert((org.eclipse.jdt.core.dom.ArrayAccess) expression); case ASTNode.ARRAY_CREATION: return convert((org.eclipse.jdt.core.dom.ArrayCreation) expression); case ASTNode.ARRAY_INITIALIZER: return convert((org.eclipse.jdt.core.dom.ArrayInitializer) expression); case ASTNode.ASSIGNMENT: return convert((org.eclipse.jdt.core.dom.Assignment) expression); case ASTNode.BOOLEAN_LITERAL: return convert((org.eclipse.jdt.core.dom.BooleanLiteral) expression); case ASTNode.CAST_EXPRESSION: return convert((org.eclipse.jdt.core.dom.CastExpression) expression); case ASTNode.CHARACTER_LITERAL: return convert((org.eclipse.jdt.core.dom.CharacterLiteral) expression); case ASTNode.CLASS_INSTANCE_CREATION: return convert((org.eclipse.jdt.core.dom.ClassInstanceCreation) expression); case ASTNode.CONDITIONAL_EXPRESSION: return convert((org.eclipse.jdt.core.dom.ConditionalExpression) expression); case ASTNode.EXPRESSION_METHOD_REFERENCE: return convert((org.eclipse.jdt.core.dom.ExpressionMethodReference) expression); case ASTNode.CREATION_REFERENCE: return convert((org.eclipse.jdt.core.dom.CreationReference) expression); case ASTNode.TYPE_METHOD_REFERENCE: return convert((org.eclipse.jdt.core.dom.TypeMethodReference) expression); case ASTNode.SUPER_METHOD_REFERENCE: return convert((org.eclipse.jdt.core.dom.SuperMethodReference) expression); case ASTNode.FIELD_ACCESS: return convert((org.eclipse.jdt.core.dom.FieldAccess) expression); case ASTNode.INFIX_EXPRESSION: return convert((org.eclipse.jdt.core.dom.InfixExpression) expression); case ASTNode.INSTANCEOF_EXPRESSION: return convert((org.eclipse.jdt.core.dom.InstanceofExpression) expression); case ASTNode.LAMBDA_EXPRESSION: return convert((org.eclipse.jdt.core.dom.LambdaExpression) expression); case ASTNode.METHOD_INVOCATION: return convert((org.eclipse.jdt.core.dom.MethodInvocation) expression); case ASTNode.NULL_LITERAL: return NullLiteral.get(); case ASTNode.NUMBER_LITERAL: return convert((org.eclipse.jdt.core.dom.NumberLiteral) expression); case ASTNode.PARENTHESIZED_EXPRESSION: return convert((org.eclipse.jdt.core.dom.ParenthesizedExpression) expression); case ASTNode.POSTFIX_EXPRESSION: return convert((org.eclipse.jdt.core.dom.PostfixExpression) expression); case ASTNode.PREFIX_EXPRESSION: return convert((org.eclipse.jdt.core.dom.PrefixExpression) expression); case ASTNode.QUALIFIED_NAME: return convert((org.eclipse.jdt.core.dom.QualifiedName) expression); case ASTNode.SIMPLE_NAME: return convert((org.eclipse.jdt.core.dom.SimpleName) expression); case ASTNode.STRING_LITERAL: return convert((org.eclipse.jdt.core.dom.StringLiteral) expression); case ASTNode.SUPER_FIELD_ACCESS: return convert((org.eclipse.jdt.core.dom.SuperFieldAccess) expression); case ASTNode.SUPER_METHOD_INVOCATION: return convert((org.eclipse.jdt.core.dom.SuperMethodInvocation) expression); case ASTNode.THIS_EXPRESSION: return convert((org.eclipse.jdt.core.dom.ThisExpression) expression); case ASTNode.TYPE_LITERAL: return convert((org.eclipse.jdt.core.dom.TypeLiteral) expression); case ASTNode.VARIABLE_DECLARATION_EXPRESSION: return convert((org.eclipse.jdt.core.dom.VariableDeclarationExpression) expression); default: throw internalCompilerError( "Unexpected type for Expression: %s", expression.getClass().getName()); } }
Example 17
Source File: NewMethodCorrectionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected boolean isConstructor() { ASTNode node= getInvocationNode(); return node.getNodeType() != ASTNode.METHOD_INVOCATION && node.getNodeType() != ASTNode.SUPER_METHOD_INVOCATION; }
Example 18
Source File: Invocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static boolean isInvocation(ASTNode node) { int type= node.getNodeType(); return type == ASTNode.METHOD_INVOCATION || type == ASTNode.SUPER_METHOD_INVOCATION || type == ASTNode.CONSTRUCTOR_INVOCATION; }
Example 19
Source File: NewMethodCorrectionProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
@Override protected boolean isConstructor() { ASTNode node= getInvocationNode(); return node.getNodeType() != ASTNode.METHOD_INVOCATION && node.getNodeType() != ASTNode.SUPER_METHOD_INVOCATION; }