public static void invokeMethodByResolveResult(@Nullable GrExpression caller,
                                                 @NotNull GroovyResolveResult resolveResult,
                                                 @NotNull String methodName,
                                                 GrExpression @NotNull [] exprs,
                                                 GrNamedArgument @NotNull [] namedArgs,
                                                 GrClosableBlock @NotNull [] closureArgs,
                                                 @NotNull ExpressionGenerator expressionGenerator,
                                                 @NotNull GroovyPsiElement psiContext) {
    final PsiElement resolved = resolveResult.getElement();
    if (resolved instanceof PsiMethod) {
      final PsiSubstitutor substitutor = resolveResult.getSubstitutor();
      expressionGenerator.invokeMethodOn(((PsiMethod)resolved), caller, exprs, namedArgs, closureArgs, substitutor, psiContext);
      return;
    }
    //other case
    final StringBuilder builder = expressionGenerator.getBuilder();
    final ExpressionContext expressionContext = expressionGenerator.getContext();

    if (caller != null) {
      caller.accept(expressionGenerator);
      builder.append('.');
    }
    builder.append(methodName);
    final ArgumentListGenerator argumentListGenerator = new ArgumentListGenerator(builder, expressionContext);
    argumentListGenerator.generate(null, exprs, namedArgs, closureArgs, psiContext);
  }
public static void invokeMethodByResolveResult(@Nullable GrExpression caller,
                                                 @NotNull GroovyResolveResult resolveResult,
                                                 @NotNull String methodName,
                                                 GrExpression @NotNull [] exprs,
                                                 GrNamedArgument @NotNull [] namedArgs,
                                                 GrClosableBlock @NotNull [] closureArgs,
                                                 @NotNull ExpressionGenerator expressionGenerator,
                                                 @NotNull GroovyPsiElement psiContext)