private void call(String method, Expression... args) { builderExpr = new MethodCallExpression( builderExpr, method, new ArgumentListExpression(args)); }
public static ArgumentListExpression args(Expression... expressions) { List<Expression> args = new ArrayList<Expression>(); Collections.addAll(args, expressions); return new ArgumentListExpression(args); }
private Expression adjustedArgList(Expression skip, List<Expression> origArgs) { List<Expression> newArgs = new ArrayList<Expression>(origArgs.size() - 1); for (Expression origArg : origArgs) { if (skip != origArg) { newArgs.add(origArg); } } return new ArgumentListExpression(newArgs); }
public MethodCallExpression setThrownException(Expression value) { return new MethodCallExpression(getSpecificationContext(), SpecificationContext.SET_THROWN_EXCEPTION, new ArgumentListExpression(value)); }
public static ArgumentListExpression args(String... names) { List<Expression> vars = new ArrayList<Expression>(); for (String name : names) { vars.add(varX(name)); } return new ArgumentListExpression(vars); }
public static ArgumentListExpression makeArgumentList(Expression arguments) { ArgumentListExpression ae; if (arguments instanceof ArgumentListExpression) { ae = (ArgumentListExpression) arguments; } else if (arguments instanceof TupleExpression) { TupleExpression te = (TupleExpression) arguments; ae = new ArgumentListExpression(te.getExpressions()); } else { ae = new ArgumentListExpression(); ae.addExpression(arguments); } return ae; }
private ExpressionStatement register() { ExpressionStatement result = new ExpressionStatement( new MethodCallExpression( resources.getMockInvocationMatcher(), MockController.ADD_INTERACTION, new ArgumentListExpression(builderExpr))); result.setSourcePosition(stat); return result; }
protected Expression enumArguments(AST elist) { List<Expression> expressionList = new ArrayList<Expression>(); for (AST node = elist; node != null; node = node.getNextSibling()) { Expression expression = expression(node); expressionList.add(expression); } ArgumentListExpression argumentListExpression = new ArgumentListExpression(expressionList); configureAST(argumentListExpression, elist); return argumentListExpression; }
@Override public void expand() { List<Expression> args = new ArrayList<>(); args.add(inferredName); args.add(inferredType); args.addAll(AstUtil.getArgumentList(methodCallExpr)); ArgumentListExpression argsExpr = new ArgumentListExpression(args); AstUtil.copySourcePosition(methodCallExpr.getArguments(), argsExpr); methodCallExpr.setArguments(argsExpr); methodCallExpr.setMethod(new ConstantExpression(methodName + "Impl")); }
private Expression transformRegularConstructor(final ListExpression expr, final MethodNode target) { // can be replaced with a direct constructor call List<Expression> transformedArgs = transformArguments(expr); ConstructorCallExpression cce = new ConstructorCallExpression( target.getDeclaringClass(), new ArgumentListExpression(transformedArgs) ); cce.setSourcePosition(expr); cce.putNodeMetaData(DIRECT_METHOD_CALL_TARGET, target); return cce; }
private Statement throwAssertionFailedError(AnnotationNode annotationNode) { ThrowStatement throwStatement = new ThrowStatement( new ConstructorCallExpression(ASSERTION_FAILED_ERROR_TYPE, new ArgumentListExpression( new ConstantExpression("Method is marked with @NotYetImplemented but passes unexpectedly")))); throwStatement.setSourcePosition(annotationNode); return throwStatement; } }
private Expression findStaticPropertyAccessorByFullName(ClassNode staticImportType, String accessorMethodName) { // anything will do as we only check size == 1 ArgumentListExpression dummyArgs = new ArgumentListExpression(); dummyArgs.addExpression(new EmptyExpression()); return findStaticMethod(staticImportType, accessorMethodName, (inLeftExpression ? dummyArgs : ArgumentListExpression.EMPTY_ARGUMENTS)); }
private Expression record(Expression expr) { // replace expr with $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(recordCount++), <expr>) return AstUtil.createDirectMethodCall( new VariableExpression(SpockNames.VALUE_RECORDER), resources.getAstNodeCache().ValueRecorder_Record, new ArgumentListExpression( AstUtil.createDirectMethodCall( new VariableExpression(SpockNames.VALUE_RECORDER), resources.getAstNodeCache().ValueRecorder_StartRecordingValue, new ArgumentListExpression(new ConstantExpression(recordCount++)) ), expr)); }
@Override @SuppressWarnings("unchecked") public void visitArgumentlistExpression(ArgumentListExpression expr) { ArgumentListExpression conversion = new ArgumentListExpression( convertAll(expr.getExpressions())); conversion.setSourcePosition(expr); result = recordNa(conversion); }
public Expression transformExpression(ExpressionTransformer transformer) { Expression ret = new ArgumentListExpression(transformExpressions(getExpressions(), transformer)); ret.setSourcePosition(this); ret.copyNodeMetaData(this); return ret; }
private Expression realizeNas(Expression expr) { return AstUtil.createDirectMethodCall( new VariableExpression(SpockNames.VALUE_RECORDER), resources.getAstNodeCache().ValueRecorder_RealizeNas, new ArgumentListExpression(new ConstantExpression(recordCount), expr)); }
private void createBuilder() { // ExpressionStatements w/ label have wrong source position, // but source position of the contained expression is OK Expression expr = stat.getExpression(); builderExpr = new ConstructorCallExpression( resources.getAstNodeCache().InteractionBuilder, new ArgumentListExpression( Arrays.<Expression> asList( new ConstantExpression(expr.getLineNumber()), new ConstantExpression(expr.getColumnNumber()), new ConstantExpression(resources.getSourceText(expr))))); }
private void makeDynamicGetProperty(final Expression receiver, final String methodName, final boolean safe) { MethodNode target = safe?INVOKERHELPER_GETPROPERTYSAFE_METHOD:INVOKERHELPER_GETPROPERTY_METHOD; MethodCallExpression mce = new MethodCallExpression( new ClassExpression(INVOKERHELPER_TYPE), target.getName(), new ArgumentListExpression(receiver, new ConstantExpression(methodName)) ); mce.setSafe(false); mce.setImplicitThis(false); mce.setMethodTarget(target); mce.visit(controller.getAcg()); }
private Expression copyLhsVariableExpressions(DeclarationExpression declExpr) { if (declExpr.isMultipleAssignmentDeclaration()) { ArgumentListExpression result = new ArgumentListExpression(); for (Expression expr : declExpr.getTupleExpression().getExpressions()) { result.addExpression(copyVarExpr((VariableExpression) expr)); } return result; } return copyVarExpr(declExpr.getVariableExpression()); }
private MethodCallExpression referenceToCurrentClosure() { return new MethodCallExpression( new VariableExpression("this"), new ConstantExpression("each"), new ArgumentListExpression( new PropertyExpression( new ClassExpression(ClassHelper.makeWithoutCaching(Closure.class)), new ConstantExpression("IDENTITY") ) ) ); }