GrExpression (PsiSubstitutor substitutor, List<? extends PsiElement> arguments, @Nullable PsiType type, final Project project) { StringBuilder argText = new StringBuilder(); argText.append("["); for (PsiElement argument : arguments) { argText.append(argument.getText()).append(", "); } if (!arguments.isEmpty()) { argText.delete(argText.length() - 2, argText.length()); } argText.append("]"); if (type instanceof PsiArrayType) { type = substitutor.substitute(type); String typeText = type.getCanonicalText(); if (type instanceof PsiEllipsisType) { typeText = typeText.replace("...", "[]"); } argText.append(" as ").append(typeText); } return GroovyPsiElementFactory.getInstance(project).createExpressionFromText(argText.toString()); }