void (@Nullable GrSignature signature, GrExpression @NotNull [] exprs, GrNamedArgument @NotNull [] namedArgs, GrClosableBlock @NotNull [] clArgs, @NotNull GroovyPsiElement context) { GrClosureSignatureUtil.ArgInfo<PsiElement>[] argInfos = signature == null ? null : GrClosureSignatureUtil.mapParametersToArguments(signature, namedArgs, exprs, clArgs, context, false, false); if (argInfos == null && signature != null) { argInfos = GrClosureSignatureUtil.mapParametersToArguments(signature, namedArgs, exprs, clArgs, context, true, true); } final PsiSubstitutor substitutor = signature == null ? PsiSubstitutor.EMPTY : signature.getSubstitutor(); if (argInfos == null || ArrayUtil.contains(null, argInfos)) { generateSimple(exprs, namedArgs, clArgs, context, substitutor); return; } final GrClosureParameter[] params = signature.getParameters(); final Project project = context.getProject(); myBuilder.append('('); boolean hasCommaAtEnd = false; for (int i = 0; i < argInfos.length; i++) { GrClosureSignatureUtil.ArgInfo<PsiElement> arg = argInfos[i]; if (arg == null) continue; final GrClosureParameter param = params[i]; boolean generated = arg.isMultiArg ? generateMultiArg(arg, param, substitutor, project, context) : generateSingeArg(arg, param); if (generated) { hasCommaAtEnd = true; myBuilder.append(", "); } } if (hasCommaAtEnd) { myBuilder.delete(myBuilder.length() - 2, myBuilder.length()); //myBuilder.removeFromTheEnd(2); } myBuilder.append(')'); }