Java Code Examples for org.eclipse.jdt.core.dom.MethodInvocation#getName()
The following examples show how to use
org.eclipse.jdt.core.dom.MethodInvocation#getName() .
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: TypeResolver.java From KodeBeagle with Apache License 2.0 | 6 votes |
/** * Visits {@link SimpleName} AST nodes. Resolves the binding of the simple * name and looks for it in the {variableScope} map. If the binding * is found, this is a reference to a variable. * * @param node * the node to visit */ @Override public boolean visit(final SimpleName node) { if (node.getParent().getNodeType() == ASTNode.METHOD_INVOCATION) { final MethodInvocation invocation = (MethodInvocation) node .getParent(); if (invocation.getName() == node) { return true; } } // method declaration can have same name as variable but this does not mean it is binding to that variable // added particularly for enum if(node.getParent().getNodeType() == ASTNode.METHOD_DECLARATION){ return true; } addBindingData(node.getIdentifier(), node, nodeScopes.get(node)); return true; }
Example 2
Source File: CodeScopeBuilder.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public boolean visit(MethodInvocation node) { Expression receiver = node.getExpression(); if (receiver == null) { SimpleName name = node.getName(); if (fIgnoreBinding == null || !Bindings.equals(fIgnoreBinding, name.resolveBinding())) { node.getName().accept(this); } } else { receiver.accept(this); } accept(node.arguments()); return false; }
Example 3
Source File: MethodInvocationResolver.java From KodeBeagle with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public boolean visit(MethodInvocation node) { SimpleName methodName = node.getName(); List args = node.arguments(); Expression expression = node.getExpression(); Map<String, Integer> scopeBindings = getNodeScopes().get(node); String target = getTarget(expression); String targetType = translateTargetToType(target, scopeBindings); // Add only if you could guess the type of target, else ignore. // TODO: In case of a method in super type, this will still infer it as in "this". if (!targetType.isEmpty()) { List<String> argTypes = translateArgsToTypes(args, scopeBindings); if (!methodStack.empty()) { MethodDeclaration currentMethod = methodStack.peek(); MethodDecl methodDecl = getMethodDecl(currentMethod); List<MethodInvokRef> invoks = methodInvoks.get(methodDecl); if (invoks == null) { invoks = new ArrayList<>(); methodInvoks.put(methodDecl, invoks); } MethodInvokRef methodInvokRef = new MethodInvokRef(methodName.toString(), targetType, target, args .size(), node.getName().getStartPosition(), argTypes, methodName.getLength(), false, getReturnType(node)); invoks.add(methodInvokRef); } } return true; }
Example 4
Source File: JavaApproximateTypeInferencer.java From api-mining with GNU General Public License v3.0 | 5 votes |
/** * Visits {@link SimpleName} AST nodes. Resolves the binding of the simple * name and looks for it in the {@link #variableScope} map. If the binding * is found, this is a reference to a variable. * * @param node * the node to visit */ @Override public boolean visit(final SimpleName node) { if (node.getParent().getNodeType() == ASTNode.METHOD_INVOCATION) { final MethodInvocation invocation = (MethodInvocation) node.getParent(); if (invocation.getName() == node) { return true; } } addBindingData(node.getIdentifier(), node, variableNames.get(node)); return true; }
Example 5
Source File: CodeScopeBuilder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean visit(MethodInvocation node) { Expression receiver= node.getExpression(); if (receiver == null) { SimpleName name= node.getName(); if (fIgnoreBinding == null || !Bindings.equals(fIgnoreBinding, name.resolveBinding())) node.getName().accept(this); } else { receiver.accept(this); } accept(node.arguments()); return false; }
Example 6
Source File: ExceptionOccurrencesFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean visit(MethodInvocation node) { if (matches(node.resolveMethodBinding())) { SimpleName name= node.getName(); fResult.add(new OccurrenceLocation(name.getStartPosition(), name.getLength(), 0, fDescription)); } return super.visit(node); }
Example 7
Source File: MethodExitsFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean visit(MethodInvocation node) { if (isExitPoint(node.resolveMethodBinding())) { SimpleName name= node.getName(); fResult.add(new OccurrenceLocation(name.getStartPosition(), name.getLength(), 0, fExitDescription)); } return true; }
Example 8
Source File: ReferencedClassesParser.java From BUILD_file_generator with Apache License 2.0 | 4 votes |
@Override public boolean visit(MethodInvocation node) { visitExpressionIfName(node.getExpression()); if (node.getExpression() != null) { return true; } // node is of the form `methodName(...)`, and not eg., `Foo.methodName()`. org.eclipse.jdt.core.dom.SimpleName simpleName = node.getName(); if (compilationUnit.findDeclaringNode(simpleName.resolveBinding()) != null) { // simpleName is defined somewhere in this compilation unit - so no need to import it. return true; } // Do not report methods that appear in inner/anonymous classes that have a superclass: // Jade doesn't currently fetch inherited symbols for inner/anonymous classes, which // leads to inherited methods being imported. (b/35660499, b/35727475) // This isn't perfect because another class might call a same-named method; if this // becomes a problem, I'll use a blacklist. AbstractTypeDeclaration containingClass = getContainingClass(node); if (!(containingClass.getParent() instanceof CompilationUnit) && containingClass instanceof TypeDeclaration && ((TypeDeclaration) containingClass).getSuperclassType() != null) { return true; } if (isDescendantOfAnonymousClassDeclaration(node)) { return true; } // Work around Eclipse JDT Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=462192, // where `simpleName.resolveBinding() == null` happens even though 'simpleName' is // defined in the current compilation unit. Set<String> methods = methodsOfClass.get(containingClass); if (methods.isEmpty()) { methods.addAll(getMethodDeclarations(containingClass)); } if (!methods.contains(simpleName.getIdentifier())) { int startPosition = simpleName.getStartPosition(); symbols.put( simpleName.getIdentifier(), Metadata.create( compilationUnit.getLineNumber(startPosition), compilationUnit.getColumnNumber(startPosition), true)); } return true; }
Example 9
Source File: CodeStyleFix.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ @Override public boolean visit(final MethodInvocation node) { if (!fRemoveMethodQualifiers) return true; Expression expression= node.getExpression(); if (!(expression instanceof ThisExpression)) return true; final SimpleName name= node.getName(); if (name.resolveBinding() == null) return true; if (hasConflict(expression.getStartPosition(), name, ScopeAnalyzer.METHODS | ScopeAnalyzer.CHECK_VISIBILITY)) return true; Name qualifier= ((ThisExpression)expression).getQualifier(); if (qualifier != null) { ITypeBinding declaringClass= ((IMethodBinding)name.resolveBinding()).getDeclaringClass(); if (declaringClass == null) return true; ITypeBinding caller= getDeclaringType(node); if (caller == null) return true; ITypeBinding callee= (ITypeBinding)qualifier.resolveBinding(); if (callee == null) return true; if (callee.isAssignmentCompatible(declaringClass) && caller.isAssignmentCompatible(declaringClass)) return true; } fOperations.add(new CompilationUnitRewriteOperation() { @Override public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model) throws CoreException { ASTRewrite rewrite= cuRewrite.getASTRewrite(); TextEditGroup group= createTextEditGroup(FixMessages.CodeStyleFix_removeThis_groupDescription, cuRewrite); rewrite.remove(node.getExpression(), group); } }); return super.visit(node); }