List of usage examples for org.eclipse.jdt.core.dom MethodInvocation getName
public SimpleName getName()
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(MethodInvocation node) { if (node.getExpression() != null) { node.getExpression().accept(this); this.fBuffer.append(".");//$NON-NLS-1$ }/*from www . ja v a2 s .c o m*/ if (node.getAST().apiLevel() >= JLS3) { if (!node.typeArguments().isEmpty()) { this.fBuffer.append("<");//$NON-NLS-1$ for (Iterator<Type> it = node.typeArguments().iterator(); it.hasNext();) { Type t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ } } this.fBuffer.append(">");//$NON-NLS-1$ } } node.getName().accept(this); this.fBuffer.append("(");//$NON-NLS-1$ for (Iterator<Expression> it = node.arguments().iterator(); it.hasNext();) { Expression e = it.next(); e.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ } } this.fBuffer.append(")");//$NON-NLS-1$ return false; }
From source file:boa.datagen.util.Java7Visitor.java
License:Apache License
@Override public boolean visit(MethodInvocation node) { boa.types.Ast.Expression.Builder b = boa.types.Ast.Expression.newBuilder(); // b.setPosition(pos.build()); b.setKind(boa.types.Ast.Expression.ExpressionKind.METHODCALL); b.setMethod(node.getName().getFullyQualifiedName()); if (node.getExpression() != null) { node.getExpression().accept(this); b.addExpressions(expressions.pop()); }//from w ww . j a v a 2 s . com for (Object a : node.arguments()) { ((org.eclipse.jdt.core.dom.Expression) a).accept(this); b.addMethodArgs(expressions.pop()); } for (Object t : node.typeArguments()) { boa.types.Ast.Type.Builder tb = boa.types.Ast.Type.newBuilder(); tb.setName(getIndex(typeName((org.eclipse.jdt.core.dom.Type) t))); tb.setKind(boa.types.Ast.TypeKind.GENERIC); b.addGenericParameters(tb.build()); } expressions.push(b.build()); return false; }
From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java
License:Open Source License
@Override public boolean visit(final MethodInvocation pNode) { final SimpleName lName = pNode.getName(); final IBinding lBinding = lName.resolveBinding(); if (ASTCrawler.checkForNull(lBinding)) return false; final IMethodBinding lMethod = (IMethodBinding) lBinding; this.addCallRelation(pNode, lMethod, Modifier.isStatic(lMethod.getModifiers())); return true;/*from w ww.j av a2s . co m*/ }
From source file:ca.mcgill.cs.swevo.ppa.PPAASTUtil.java
License:Open Source License
/** * Return true if 1) this is a method invocation and 2) one of the parameter * is not full./*w w w .j a v a 2s.c o m*/ * * Always return false if this is a method invocation from Object and that * is final. * * @param node * @return */ public static boolean isUnsafeMethod(SimpleName node) { boolean isUnsafe = false; ASTNode parent = node.getParent(); if (parent instanceof MethodInvocation) { MethodInvocation mi = (MethodInvocation) parent; if (mi.getName() == node) { if (!checkObjectFinalMethod(mi)) { for (Object arg : mi.arguments()) { Expression exp = (Expression) arg; if (PPABindingsUtil .getSafetyValue(PPABindingsUtil.getTypeBinding(exp)) < PPABindingsUtil.FULL_TYPE) { isUnsafe = true; break; } } if (!isUnsafe) { ITypeBinding containerType = PPABindingsUtil.getTypeBinding(getContainer(mi)); isUnsafe = PPABindingsUtil.getSafetyValue(containerType) < PPABindingsUtil.FULL_TYPE; } } } } return isUnsafe; }
From source file:ch.acanda.eclipse.pmd.java.resolution.design.UseNotifyAllInsteadOfNotifyQuickFix.java
License:Open Source License
/** * Replaces {@code x.notify()} with {@code x.notifyAll()}. *///from www.j a va2s . c o m @Override protected boolean apply(final MethodInvocation node) { node.getName().setIdentifier("notifyAll"); return true; }
From source file:ch.acanda.eclipse.pmd.java.resolution.stringandstringbuffer.UnnecessaryCaseChangeQuickFix.java
License:Open Source License
private Expression removeCaseChange(final MethodInvocation withCaseChange) { final String identifier = withCaseChange.getName().getIdentifier(); if ("toUpperCase".equals(identifier) || "toLowerCase".equals(identifier)) { return copy(withCaseChange.getExpression()); }//from w ww . j ava2 s . c om return copy(withCaseChange); }
From source file:changetypes.ASTVisitorAtomicChange.java
License:Open Source License
public boolean visit(MethodInvocation node) { IMethodBinding mmtb = node.resolveMethodBinding(); if (this.mtbStack.isEmpty()) { return true; }/*from w ww . j a va 2s . c om*/ try { if (node.getExpression() != null) { if (mmtb.getDeclaringClass().getQualifiedName().startsWith("java.awt.geom.Path2D")) { Expression e = node.getExpression(); ITypeBinding itb = e.resolveTypeBinding(); this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding) this.mtbStack.peek()), getQualifiedName(itb) + "#" + getSimpleName(mmtb))); break label179; } } this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding) this.mtbStack.peek()), getQualifiedName(mmtb))); } catch (Exception localException) { System.err.println("Cannot resolve method invocation \"" + node.getName().toString() + "\""); } label179: return true; }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
public boolean visit(MethodInvocation node) { if (node.getExpression() != null) { node.getExpression().accept(this); this.buffer.append(".");//$NON-NLS-1$ }/* w w w. j a v a 2 s. c o m*/ if (node.getAST().apiLevel() >= AST.JLS3) { if (!node.typeArguments().isEmpty()) { this.buffer.append("<");//$NON-NLS-1$ for (Iterator it = node.typeArguments().iterator(); it.hasNext();) { Type t = (Type) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(">");//$NON-NLS-1$ } } node.getName().accept(this); this.buffer.append("(");//$NON-NLS-1$ for (Iterator it = node.arguments().iterator(); it.hasNext();) { Expression e = (Expression) it.next(); e.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(")");//$NON-NLS-1$ return false; }
From source file:com.bsiag.eclipse.jdt.java.formatter.linewrap.WrapPreparator.java
License:Open Source License
@Override public boolean visit(MethodInvocation node) { handleArguments(node.arguments(), this.options.alignment_for_arguments_in_method_invocation); boolean isInvocationChainRoot = !(node.getParent() instanceof MethodInvocation) || node.getLocationInParent() != MethodInvocation.EXPRESSION_PROPERTY; if (isInvocationChainRoot) { Expression expression = node; MethodInvocation invocation = node; while (expression instanceof MethodInvocation) { invocation = (MethodInvocation) expression; expression = invocation.getExpression(); if (expression != null) this.wrapIndexes.add(this.tm.firstIndexBefore(invocation.getName(), TokenNameDOT)); }// ww w. j a v a2 s . c o m Collections.reverse(this.wrapIndexes); this.wrapParentIndex = (expression != null) ? this.tm.lastIndexIn(expression, -1) : this.tm.lastIndexIn(invocation, -1); this.wrapGroupEnd = this.tm.firstIndexIn(node.getName(), -1); handleWrap(this.options.alignment_for_selector_in_method_invocation); } return true; }
From source file:com.bsiag.eclipse.jdt.java.formatter.SpacePreparator.java
License:Open Source License
@Override public boolean visit(MethodInvocation node) { handleTypeArguments(node.typeArguments()); handleInvocation(node, node.getName()); handleCommas(node.arguments(), this.options.insert_space_before_comma_in_method_invocation_arguments, this.options.insert_space_after_comma_in_method_invocation_arguments); return true;/* w w w . j a va2s. co m*/ }