@Override public Void visitMethodInvocation(MethodInvocationTree tree, Void unused) { if (getSymbol(tree).equals(methodSymbol)) { removeByIndex(tree.getArguments()); } return super.visitMethodInvocation(tree, null); }
@Override public Void visitMethodInvocation(MethodInvocationTree node, Void unused) { for (MethodPairing pairing : PAIRINGS) { if (pairing.ifCall().matches(node, state)) { if (!isField(getUltimateReceiver(node)) || isLastStatementInBlock(state.findPathToEnclosing(StatementTree.class))) { required.add(pairing); } } if (pairing.mustCall().matches(node, state)) { called.add(pairing); } } return super.visitMethodInvocation(node, null); } }.scan(state.getPath(), null);
@Override public Void visitMethodInvocation(MethodInvocationTree node, Void unused) { Description description = matchMethodInvocation(node, state.withPath(getCurrentPath())); if (description != Description.NO_MATCH) { state.reportMatch(description); } return super.visitMethodInvocation(node, null); }
@Override public Void visitMethodInvocation(MethodInvocationTree node, Void unused) { VisitorState subState = state.withPath(getCurrentPath()); ExpressionTree argument; ProblemUsage problemType; if (CHECK_NOT_NULL.matches(node, subState)) { argument = node.getArguments().get(0); problemType = ProblemUsage.CHECK_NOT_NULL; } else if (matchTestAssertions && ASSERT_NOT_NULL.matches(node, subState)) { argument = getLast(node.getArguments()); problemType = ProblemUsage.JUNIT; } else if (matchTestAssertions && TRUTH_NOT_NULL.matches(node, subState)) { argument = getOnlyElement(((MethodInvocationTree) getReceiver(node)).getArguments()); problemType = ProblemUsage.TRUTH; } else { return super.visitMethodInvocation(node, null); } getFixer(argument, subState) .map(f -> describeMatch(node, problemType.fix(f, node, subState))) .ifPresent(state::reportMatch); return super.visitMethodInvocation(node, null); }
@Override public Void visitMethodInvocation(MethodInvocationTree node, Void unused) { if (!EQUALS.matches(node, state)) { return null; } ExpressionTree argument = getOnlyElement(node.getArguments()); ExpressionTree receiver = getReceiver(node); if (receiver == null) { return null; } if (matchesEitherWay(argument, receiver, THIS_CLASS, otherClass)) { matchedGetClass = true; String replacement = String.format( "%s instanceof %s", parameter.getSimpleName(), classSymbol.getSimpleName()); if (getCurrentPath().getParentPath().getLeaf() instanceof UnaryTree) { replacement = String.format("(%s)", replacement); } fix.replace(node, replacement); } return super.visitMethodInvocation(node, null); }
@Override public Void visitMethodInvocation(MethodInvocationTree tree, Void unused) { if (getSymbol(tree).equals(methodSymbol)) { removeByIndex(tree.getArguments()); } return super.visitMethodInvocation(tree, null); }
public Void visitMethodInvocation(MethodInvocationTree node, Set<TypeMirror> p) { super.visitMethodInvocation(node, p); Element el = info.getTrees().getElement(getCurrentPath()); if (el != null && el.getKind() == ElementKind.METHOD) p.addAll(((ExecutableElement)el).getThrownTypes()); return null; }
@Override public Void visitMethodInvocation(MethodInvocationTree node, Void unused) { for (MethodPairing pairing : PAIRINGS) { if (pairing.ifCall().matches(node, state)) { if (!isField(getUltimateReceiver(node)) || isLastStatementInBlock(state.findPathToEnclosing(StatementTree.class))) { required.add(pairing); } } if (pairing.mustCall().matches(node, state)) { called.add(pairing); } } return super.visitMethodInvocation(node, null); } }.scan(state.getPath(), null);
@Override public Void visitMethodInvocation(MethodInvocationTree node, Void unused) { Description description = matchMethodInvocation(node, state.withPath(getCurrentPath())); if (description != Description.NO_MATCH) { state.reportMatch(description); } return super.visitMethodInvocation(node, null); }
@Override public Void visitMethodInvocation(MethodInvocationTree node, Void unused) { VisitorState subState = state.withPath(getCurrentPath()); ExpressionTree argument; ProblemUsage problemType; if (CHECK_NOT_NULL.matches(node, subState)) { argument = node.getArguments().get(0); problemType = ProblemUsage.CHECK_NOT_NULL; } else if (matchTestAssertions && ASSERT_NOT_NULL.matches(node, subState)) { argument = getLast(node.getArguments()); problemType = ProblemUsage.JUNIT; } else if (matchTestAssertions && TRUTH_NOT_NULL.matches(node, subState)) { argument = getOnlyElement(((MethodInvocationTree) getReceiver(node)).getArguments()); problemType = ProblemUsage.TRUTH; } else { return super.visitMethodInvocation(node, null); } getFixer(argument, subState) .map(f -> describeMatch(node, problemType.fix(f, node, subState))) .ifPresent(state::reportMatch); return super.visitMethodInvocation(node, null); }
@Override public Void visitMethodInvocation(MethodInvocationTree node, Void unused) { if (!EQUALS.matches(node, state)) { return null; } ExpressionTree argument = getOnlyElement(node.getArguments()); ExpressionTree receiver = getReceiver(node); if (receiver == null) { return null; } if (matchesEitherWay(argument, receiver, THIS_CLASS, otherClass)) { matchedGetClass = true; fix.replace( node, String.format( "%s instanceof %s", parameter.getSimpleName().toString(), classSymbol.getSimpleName().toString())); } return super.visitMethodInvocation(node, null); }
@Override public Void visitMethodInvocation(MethodInvocationTree node, Void ignore) { Element elt = TreeUtils.elementFromUse(node); if (!PurityUtils.hasPurityAnnotation(annoProvider, elt)) { purityResult.addNotBothReason(node, "call.method"); } else { boolean det = PurityUtils.isDeterministic(annoProvider, elt); boolean seFree = (assumeSideEffectFree || PurityUtils.isSideEffectFree(annoProvider, elt)); if (!det && !seFree) { purityResult.addNotBothReason(node, "call.method"); } else if (!det) { purityResult.addNotDetReason(node, "call.method"); } else if (!seFree) { purityResult.addNotSEFreeReason(node, "call.method"); } } return super.visitMethodInvocation(node, ignore); }