public static void generateAllMethodSignaturesByClosureSignature(@NotNull String name,
                                                                   @NotNull GrSignature signature,
                                                                   PsiTypeParameter @NotNull [] typeParameters,
                                                                   @NotNull PsiSubstitutor substitutor,
                                                                   List<? super MethodSignature> result) {
    GrClosureParameter[] params = signature.getParameters();

    ArrayList<PsiType> newParams = new ArrayList<>(params.length);
    ArrayList<GrClosureParameter> opts = new ArrayList<>(params.length);
    ArrayList<Integer> optInds = new ArrayList<>(params.length);

    for (int i = 0; i < params.length; i++) {
      if (params[i].isOptional()) {
        opts.add(params[i]);
        optInds.add(i);
      }
      else {
        newParams.add(params[i].getType());
      }
    }

    result.add(generateSignature(name, newParams, typeParameters, substitutor));
    for (int i = 0; i < opts.size(); i++) {
      newParams.add(optInds.get(i), opts.get(i).getType());
      result.add(generateSignature(name, newParams, typeParameters, substitutor));
    }
  }
public static void generateAllMethodSignaturesByClosureSignature(@NotNull String name,
                                                                   @NotNull GrSignature signature,
                                                                   PsiTypeParameter @NotNull [] typeParameters,
                                                                   @NotNull PsiSubstitutor substitutor,
                                                                   List<? super MethodSignature> result)