@Override public void endVisit(JParameterRef x, Context ctx) { int paramIndex = methodCall.getTarget().getParams().indexOf(x.getParameter()); assert paramIndex != -1; // Replace with a cloned call argument. CloneExpressionVisitor cloner = new CloneExpressionVisitor(); JExpression arg = methodCall.getArgs().get(paramIndex); JExpression clone = cloner.cloneExpression(arg); clone = maybeCast(clone, x.getType()); ctx.replaceMe(clone); }
@Override public void endVisit(JParameterRef x, Context ctx) { JParameter param = x.getParameter(); // If the expression has side-effects before a parameter reference, fail if (hasAssignment() || accessesField() || canThrowException()) { succeeded = false; } // If this parameter reference won't always execute, fail if (isInConditional()) { succeeded = false; } // Ensure this parameter is evaluated in the correct order relative to // other parameters. if (parameters.indexOf(param) == currentIndex) { currentIndex++; } else { succeeded = false; } super.endVisit(x, ctx); }
@Override public void endVisit(JParameterRef x, Context ctx) { if (x.getParameter() == parameter) { ctx.replaceMe(cloner.cloneExpression(expression)); } }