public static Expression create(String source) { AstBuilder b = new AstBuilder(); List<ASTNode> astNodes = b.buildFromString(CompilePhase.CONVERSION, true, source); BlockStatement block = (BlockStatement) astNodes.get(0); return ((ExpressionStatement) block.getStatements().get(0)).getExpression(); }
public static Expression createArgumentList(String source) { AstBuilder b = new AstBuilder(); String call = "m(" + source + ")"; List<ASTNode> astNodes = b.buildFromString(CompilePhase.CONVERSION, true, call); BlockStatement block = (BlockStatement) astNodes.get(0); MethodCallExpression mce = (MethodCallExpression) ((ExpressionStatement) block.getStatements().get(0)).getExpression(); ArgumentListExpression args = (ArgumentListExpression) mce.getArguments(); return args; }