Refine search
ASTNode clone0(AST target) { MethodInvocation result = new MethodInvocation(target); result.setSourceRange(getStartPosition(), getLength()); result.setName((SimpleName) getName().clone(target)); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); } result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); return result; }
@Override final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == ARGUMENTS_PROPERTY) { return arguments(); } if (property == TYPE_ARGUMENTS_PROPERTY) { return typeArguments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
public boolean isEnumNameMethodInvocation (MethodInvocation node) { return node.getName().getIdentifier().equals("name") && node.getExpression() != null && node.getExpression().resolveTypeBinding().isEnum(); }
protected void appendExpression(Expression expression) { MethodInvocation appendInvocation= fAst.newMethodInvocation(); if (temporaryExpression != null) appendInvocation.setExpression(temporaryExpression); else appendInvocation.setExpression(fAst.newSimpleName(fBuilderVariableName)); appendInvocation.setName(fAst.newSimpleName(APPEND_METHOD_NAME)); appendInvocation.arguments().add(expression); temporaryExpression= appendInvocation; }
CompilationUnit cu = ast.newCompilationUnit(); PackageDeclaration p1 = ast.newPackageDeclaration(); p1.setName(ast.newSimpleName("foo")); cu.setPackage(p1); MethodInvocation mi = ast.newMethodInvocation(); mi.setName(ast.newSimpleName("x")); ExpressionStatement e = ast.newExpressionStatement(mi);
@Override public boolean visit(MethodInvocation node) { handleArguments(node.arguments(), this.options.alignment_for_arguments_in_method_invocation); handleTypeArguments(node.typeArguments()); 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)); this.secondaryWrapIndexes.add(this.tm.firstIndexIn(invocation.getName(), TokenNameIdentifier)); } } 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; }
if (methodInvocation.getParent() instanceof Statement) { if ("append".equals(methodInvocation.getName().getIdentifier())) { //$NON-NLS-1$ Expression expression= methodInvocation.getExpression(); IBinding binding= ((SimpleName)expression).resolveBinding(); if (binding instanceof IVariableBinding) { String typeName= ((IVariableBinding)binding).getType().getQualifiedName();
@Override public boolean visit(SimpleName node) { IBinding nodeBinding= node.resolveBinding(); if (fElementVariable != null && fElementVariable.equals(nodeBinding)) { fMakeFinal= false; } if (nodeBinding == fIteratorVariable) { if (node.getLocationInParent() == MethodInvocation.EXPRESSION_PROPERTY) { MethodInvocation invocation= (MethodInvocation) node.getParent(); String name= invocation.getName().getIdentifier(); if (name.equals("next") || name.equals("nextElement")) { //$NON-NLS-1$ //$NON-NLS-2$ nextInvocationCount[0]++; Expression left= null; if (invocation.getLocationInParent() == Assignment.RIGHT_HAND_SIDE_PROPERTY) { left= ((Assignment) invocation.getParent()).getLeftHandSide(); } else if (invocation.getLocationInParent() == VariableDeclarationFragment.INITIALIZER_PROPERTY) { left= ((VariableDeclarationFragment) invocation.getParent()).getName(); } return visitElementVariable(left); } } otherInvocationThenNext[0]= true; } return true; }
if (!(debugMI.getParent() instanceof ExpressionStatement)) { continue; IfStatement ifs = ast.newIfStatement(); SimpleName sn; try { sn = (SimpleName) debugMI.getExpression(); } catch (RuntimeException e) { logger.log("Error occurs at MI: " + debugMI + " , file: " + file.getPath()); MethodInvocation isDebugEnabled = ast.newMethodInvocation(); isDebugEnabled.setExpression(ast.newSimpleName(sn.getIdentifier())); isDebugEnabled.setName(ast.newSimpleName("isDebugEnabled")); ifs.setExpression(isDebugEnabled);
@Override public boolean visit(MethodInvocation node) { evalQualifyingExpression(node.getExpression(), node.getName()); doVisitChildren(node.typeArguments()); doVisitChildren(node.arguments()); return false; }
public boolean visit(MethodInvocation invocation) { if (invocation.getExpression() == null) qualifyUnqualifiedMemberNameIfNecessary(invocation.getName()); else invocation.getExpression().accept(this); for (Iterator it= invocation.arguments().iterator(); it.hasNext();) ((Expression) it.next()).accept(this); return false; }
public static void getArrayAccessProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { CompilationUnit root= context.getASTRoot(); ASTNode selectedNode= problem.getCoveringNode(root); if (!(selectedNode instanceof MethodInvocation)) { return; } MethodInvocation decl= (MethodInvocation) selectedNode; SimpleName nameNode= decl.getName(); String methodName= nameNode.getIdentifier(); IBinding[] bindings= (new ScopeAnalyzer(root)).getDeclarationsInScope(nameNode, ScopeAnalyzer.METHODS); for (int i= 0; i < bindings.length; i++) { String currName= bindings[i].getName(); if (NameMatcher.isSimilarName(methodName, currName)) { String label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_arraychangetomethod_description, BasicElementLabels.getJavaElementName(currName)); proposals.add(new RenameNodeCorrectionProposal(label, context.getCompilationUnit(), nameNode.getStartPosition(), nameNode.getLength(), currName, IProposalRelevance.ARRAY_CHANGE_TO_METHOD)); } } // always suggest 'length' String lengthId= "length"; //$NON-NLS-1$ String label= CorrectionMessages.UnresolvedElementsSubProcessor_arraychangetolength_description; int offset= nameNode.getStartPosition(); int length= decl.getStartPosition() + decl.getLength() - offset; proposals.add(new RenameNodeCorrectionProposal(label, context.getCompilationUnit(), offset, length, lengthId, IProposalRelevance.ARRAY_CHANGE_TO_LENGTH)); }
@Override public boolean visit(MethodInvocation mi) { if (mi.getParent() instanceof ExpressionStatement && mi.getName().getIdentifier().equals("error") && mi.arguments().size() == 1 && mi.getExpression() instanceof SimpleName && mi.getExpression().toString().contains("log")) { if (isOnCaught(mi, type)) { addHit(mi); correctMI(mi); } } return true; } };
@Override int treeSize() { return memSize() + (this.optionalExpression == null ? 0 : getExpression().treeSize()) + (this.typeArguments == null ? 0 : this.typeArguments.listSize()) + (this.methodName == null ? 0 : getName().treeSize()) + (this.arguments == null ? 0 : this.arguments.listSize()); } }
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; }
@Override protected SimpleName getNewName(ASTRewrite rewrite) { ASTNode invocationNode= getInvocationNode(); String name; if (invocationNode instanceof MethodInvocation) { name= ((MethodInvocation)invocationNode).getName().getIdentifier(); } else if (invocationNode instanceof SuperMethodInvocation) { name= ((SuperMethodInvocation)invocationNode).getName().getIdentifier(); } else { name= getSenderBinding().getName(); // name of the class } AST ast= rewrite.getAST(); SimpleName newNameNode= ast.newSimpleName(name); return newNameNode; }
protected void rewrite(MethodInvocation node, ITypeBinding type) { Expression exp= node.getExpression(); if (exp == null) { Type result= fCuRewrite.getImportRewrite().addImport(type, fCuRewrite.getAST()); fCuRewrite.getImportRemover().registerAddedImport(type.getQualifiedName()); exp= ASTNodeFactory.newName(fCuRewrite.getAST(), ASTFlattener.asString(result)); fCuRewrite.getASTRewrite().set(node, MethodInvocation.EXPRESSION_PROPERTY, exp, fCuRewrite.createGroupDescription(REFERENCE_UPDATE)); fNeedsImport= true; } else if (exp instanceof Name) { rewriteName((Name)exp, type); } else { rewriteExpression(node, exp, type); } fProcessed.add(node.getName()); }
@Override public boolean visit(MethodInvocation mi) { if (mi.getName().getIdentifier().equals("getLogger") && mi.arguments().size() == 1 && AstUtils.tryGetConcreteType(cu) != null) { Object firstArg = mi.arguments().get(0); if (firstArg instanceof TypeLiteral) { String typeName = ((TypeLiteral) firstArg).getType().toString(); if (!typeName.equals(AstUtils.tryGetConcreteType(cu).getName().getIdentifier())) { addHit(mi); // Print out problem locations [line, path] System.out.printf("Line %d in %s\n", cu.getLineNumber(mi.getStartPosition()), file.getPath()); } } } return true; } });
@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; }
@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; }