List<JCExpression> arguments = methodInvocation.getArguments();
: ((JCIdent) methodSelect).sym.owner.type; return invocationTree.getArguments().isEmpty() // 0 arguments
@Override public void visitApply(JCMethodInvocation tree) { JCExpression select = tree.getMethodSelect(); if (select != null && select.toString().equals("Refaster.emitCommentBefore")) { String commentLiteral = (String) ((JCLiteral) tree.getArguments().get(0)).getValue(); JCExpression expr = tree.getArguments().get(1); try { print("/* " + commentLiteral + " */ "); } catch (IOException e) { throw new RuntimeException(e); } expr.accept(this); } else { super.visitApply(tree); } }
AlternateConstructorInvocation aci = new AlternateConstructorInvocation(); fillList(node.getTypeArguments(), aci.rawConstructorTypeArguments(), FlagKey.TYPE_REFERENCE); fillList(node.getArguments(), aci.rawArguments()); set(node, aci); setConversionPositionInfo(aci, "this", getPosition(sel)); SuperConstructorInvocation sci = new SuperConstructorInvocation(); fillList(node.getTypeArguments(), sci.rawConstructorTypeArguments(), FlagKey.TYPE_REFERENCE); fillList(node.getArguments(), sci.rawArguments()); set(node, sci); setConversionPositionInfo(sci, "super", getPosition(sel)); SuperConstructorInvocation sci = new SuperConstructorInvocation(); fillList(node.getTypeArguments(), sci.rawConstructorTypeArguments(), FlagKey.TYPE_REFERENCE); fillList(node.getArguments(), sci.rawArguments()); sci.rawQualifier(toTree(((JCFieldAccess) sel).getExpression())); set(node, sci); fillList(node.getArguments(), inv.rawArguments()); set(node, inv);
AlternateConstructorInvocation aci = new AlternateConstructorInvocation(); fillList(node.getTypeArguments(), aci.rawConstructorTypeArguments(), FlagKey.TYPE_REFERENCE); fillList(node.getArguments(), aci.rawArguments()); set(node, aci); setConversionPositionInfo(aci, "this", getPosition(sel)); SuperConstructorInvocation sci = new SuperConstructorInvocation(); fillList(node.getTypeArguments(), sci.rawConstructorTypeArguments(), FlagKey.TYPE_REFERENCE); fillList(node.getArguments(), sci.rawArguments()); set(node, sci); setConversionPositionInfo(sci, "super", getPosition(sel)); SuperConstructorInvocation sci = new SuperConstructorInvocation(); fillList(node.getTypeArguments(), sci.rawConstructorTypeArguments(), FlagKey.TYPE_REFERENCE); fillList(node.getArguments(), sci.rawArguments()); sci.rawQualifier(toTree(((JCFieldAccess) sel).getExpression())); set(node, sci); fillList(node.getArguments(), inv.rawArguments()); set(node, inv);
AlternateConstructorInvocation aci = new AlternateConstructorInvocation(); fillList(node.getTypeArguments(), aci.rawConstructorTypeArguments(), FlagKey.TYPE_REFERENCE); fillList(node.getArguments(), aci.rawArguments()); set(node, aci); setConversionPositionInfo(aci, "this", getPosition(sel)); SuperConstructorInvocation sci = new SuperConstructorInvocation(); fillList(node.getTypeArguments(), sci.rawConstructorTypeArguments(), FlagKey.TYPE_REFERENCE); fillList(node.getArguments(), sci.rawArguments()); set(node, sci); setConversionPositionInfo(sci, "super", getPosition(sel)); SuperConstructorInvocation sci = new SuperConstructorInvocation(); fillList(node.getTypeArguments(), sci.rawConstructorTypeArguments(), FlagKey.TYPE_REFERENCE); fillList(node.getArguments(), sci.rawArguments()); sci.rawQualifier(toTree(((JCFieldAccess) sel).getExpression())); set(node, sci); fillList(node.getArguments(), inv.rawArguments()); set(node, inv);
List<JCExpression> arguments = methodInvocation.getArguments();
: ((JCIdent) methodSelect).sym.owner.type; return invocationTree.getArguments().isEmpty() // 0 arguments
private static void replaceAssert( SuggestedFix.Builder fix, AssertTree foundAssert, VisitorState state) { ExpressionTree expr = foundAssert.getCondition(); expr = (ExpressionTree) TreeInfo.skipParens((JCTree) expr); // case: "assert !expr" if (expr.getKind().equals(LOGICAL_COMPLEMENT)) { addFix(fix, ((JCUnary) expr).getExpression(), foundAssert, state, IS_FALSE); return; } // case: "assert expr1.equals(expr2)" if (instanceMethod().onClass(Any.INSTANCE).named("equals").matches(expr, state)) { JCMethodInvocation equalsCall = ((JCMethodInvocation) expr); JCExpression expr1 = ((JCFieldAccess) ((JCMethodInvocation) expr).meth).selected; JCExpression expr2 = equalsCall.getArguments().get(0); addFix( fix, expr1, foundAssert, state, String.format(IS_EQUAL_TO, normalizedSourceForExpression(expr2, state))); return; } // case: "assert expr1 == expr2" or "assert expr1 != expr2" if (expr.getKind().equals(Kind.EQUAL_TO) || expr.getKind().equals(Kind.NOT_EQUAL_TO)) { suggestFixForSameReference(fix, foundAssert, state, expr.getKind().equals(Kind.EQUAL_TO)); return; } // case: "assert expr", which didn't match any of the previous cases. addFix(fix, (JCExpression) expr, foundAssert, state, IS_TRUE); }
List<JCExpression> arguments = methodInvocation.getArguments(); Types types = state.getTypes(); if (arguments.size() != params.length()) {
@Override public Description matchMethodInvocation( MethodInvocationTree methodInvocationTree, VisitorState state) { if (!MATCHER.matches(methodInvocationTree, state)) { return Description.NO_MATCH; } if (methodInvocationTree.getArguments().size() % 2 == 0) { return Description.NO_MATCH; } JCMethodInvocation methodInvocation = (JCMethodInvocation) methodInvocationTree; List<JCExpression> arguments = methodInvocation.getArguments(); Type typeVargs = methodInvocation.varargsElement; if (typeVargs == null) { return Description.NO_MATCH; } Type typeVarargsArr = state.arrayTypeForType(typeVargs); Type lastArgType = ASTHelpers.getType(Iterables.getLast(arguments)); if (typeVarargsArr.equals(lastArgType)) { return Description.NO_MATCH; } return describeMatch(methodInvocationTree); } }
@Override public void printStat(JCTree tree) throws IOException { if (tree instanceof JCExpressionStatement && ((JCExpressionStatement) tree).getExpression() instanceof JCMethodInvocation) { JCMethodInvocation invocation = (JCMethodInvocation) ((JCExpressionStatement) tree).getExpression(); JCExpression select = invocation.getMethodSelect(); if (select != null && select.toString().equals("Refaster.emitComment")) { String commentLiteral = (String) ((JCLiteral) invocation.getArguments().get(0)).getValue(); print("// " + commentLiteral); return; } } super.printStat(tree); }
@Override public void visitApply(JCMethodInvocation tree) { JCExpression select = tree.getMethodSelect(); if (select != null && select.toString().equals("Refaster.emitCommentBefore")) { String commentLiteral = (String) ((JCLiteral) tree.getArguments().get(0)).getValue(); JCExpression expr = tree.getArguments().get(1); try { print("/* " + commentLiteral + " */ "); } catch (IOException e) { throw new RuntimeException(e); } expr.accept(this); } else { super.visitApply(tree); } }
if (invocationElement.getMethodName() .equals(JSweetConfig.INDEXED_SET_FUCTION_NAME)) { if (invocation.getArguments().size() == 3) { if ("this".equals(invocation.getArguments().get(0).toString())) { printIndent().print(invocation.args.tail.head).print(": ") .print(invocation.args.tail.tail.head).print(",").println(); .create(invocation); if (invocationElement.getMethodName().equals(JSweetConfig.INDEXED_SET_FUCTION_NAME)) { if (invocation.getArguments().size() == 3) { if ("this".equals(invocation.getArguments().get(0).toString())) { printIndent().print("target[").print(invocation.args.tail.head).print("]") .print(" = ").print(invocation.args.tail.tail.head).print(";")
isValid = false; if (isValid && invocation.getArguments() != null) { for (int i = 0; i < invocation.getArguments().size(); i++) { JCExpression expr = invocation.getArguments().get(i); if (Util.isConstant(expr)) { defaultValues.put(i, expr);
JCMethodInvocation compareTo = (JCMethodInvocation) parent; JCTree.JCExpression rhs = getOnlyElement(compareTo.getArguments());
sourceNode.getArguments().stream(), (formal, actual) -> {
private static void replaceAssert( SuggestedFix.Builder fix, AssertTree foundAssert, VisitorState state) { ExpressionTree expr = foundAssert.getCondition(); expr = (ExpressionTree) TreeInfo.skipParens((JCTree) expr); // case: "assert !expr" if (expr.getKind().equals(LOGICAL_COMPLEMENT)) { addFix(fix, ((JCUnary) expr).getExpression(), foundAssert, state, IS_FALSE); return; } // case: "assert expr1.equals(expr2)" if (instanceMethod().onClass(Any.INSTANCE).named("equals").matches(expr, state)) { JCMethodInvocation equalsCall = ((JCMethodInvocation) expr); JCExpression expr1 = ((JCFieldAccess) ((JCMethodInvocation) expr).meth).selected; JCExpression expr2 = equalsCall.getArguments().get(0); addFix( fix, expr1, foundAssert, state, String.format(IS_EQUAL_TO, normalizedSourceForExpression(expr2, state))); return; } // case: "assert expr1 == expr2" or "assert expr1 != expr2" if (expr.getKind().equals(Kind.EQUAL_TO) || expr.getKind().equals(Kind.NOT_EQUAL_TO)) { suggestFixForSameReference(fix, foundAssert, state, expr.getKind().equals(Kind.EQUAL_TO)); return; } // case: "assert expr", which didn't match any of the previous cases. addFix(fix, (JCExpression) expr, foundAssert, state, IS_TRUE); }
List<JCExpression> arguments = methodInvocation.getArguments(); Types types = state.getTypes(); if (arguments.size() != params.length()) {
@Override public void printStat(JCTree tree) throws IOException { if (tree instanceof JCExpressionStatement && ((JCExpressionStatement) tree).getExpression() instanceof JCMethodInvocation) { JCMethodInvocation invocation = (JCMethodInvocation) ((JCExpressionStatement) tree).getExpression(); JCExpression select = invocation.getMethodSelect(); if (select != null && select.toString().equals("Refaster.emitComment")) { String commentLiteral = (String) ((JCLiteral) invocation.getArguments().get(0)).getValue(); print("// " + commentLiteral); return; } } super.printStat(tree); }