GrExpression[] (String name, GrExpression[] exprs, GrNamedArgument[] namedArgs, GrClosableBlock[] clArgs, GroovyPsiElement psiContext) { GrExpression[] result = new GrExpression[2]; result[0] = factory.createExpressionFromText("\"" + name + "\""); StringBuilder builder = new StringBuilder(); builder.append('['); if (namedArgs.length > 0) { builder.append('['); for (GrNamedArgument namedArg : namedArgs) { builder.append(namedArg.getText()).append(','); } builder.delete(builder.length() - 1, builder.length()); //builder.removeFromTheEnd(1); builder.append("],"); } for (GrExpression expr : exprs) { builder.append(expr.getText()).append(','); } for (GrClosableBlock clArg : clArgs) { builder.append(clArg.getText()).append(','); } if (namedArgs.length + exprs.length + clArgs.length > 0) builder.delete(builder.length() - 1, builder.length()); //if (namedArgs.length + exprs.length + clArgs.length > 0) builder.removeFromTheEnd(1); builder.append("] as Object[]"); result[1] = factory.createExpressionFromText(builder.toString(), psiContext); return result; }