GrMethodCallExpression (GroovyPsiElementFactory factory, GrApplicationStatement app) { final GrCommandArgumentList list = app.getArgumentList(); final GrMethodCallExpression prototype = (GrMethodCallExpression)factory.createExpressionFromText("foo()"); prototype.getInvokedExpression().replace(app.getInvokedExpression()); final GrArgumentList pList = prototype.getArgumentList(); final PsiElement anchor = pList.getRightParen(); for (GroovyPsiElement arg : list.getAllArguments()) { pList.addBefore(arg, anchor); } return prototype; }