private static void showDialog(@NotNull PsiMethod method, @NotNull GrReferenceExpression ref, @NotNull Project project) {
    final String name = ref.getReferenceName();
    final List<PsiType> types = GroovyExpectedTypesProvider.getDefaultExpectedTypes(ref);

    PsiType unboxed = types.isEmpty() ? null : TypesUtil.unboxPrimitiveTypeWrapper(types.get(0));
    @NotNull final PsiType type = unboxed != null ? unboxed : PsiType.getJavaLangObject(ref.getManager(), ref.getResolveScope());

    if (method instanceof GrMethod) {
      GrMethodDescriptor descriptor = new GrMethodDescriptor((GrMethod)method);
      GrChangeSignatureDialog dialog = new GrChangeSignatureDialog(project, descriptor, true, ref);

      List<GrParameterInfo> parameters = dialog.getParameters();
      parameters.add(createParameterInfo(name, type));
      dialog.setParameterInfos(parameters);
      dialog.show();
    }
    else {
      JavaChangeSignatureDialog dialog = new JavaChangeSignatureDialog(project, method, false, ref);
      final List<ParameterInfoImpl> parameterInfos = new ArrayList<>(Arrays.asList(ParameterInfoImpl.fromMethod(method)));
      ParameterInfoImpl parameterInfo = ParameterInfoImpl.createNew()
        .withName(name)
        .withType(type)
        .withDefaultValue(PsiTypesUtil.getDefaultValueOfType(type));
      if (!method.isVarArgs()) {
        parameterInfos.add(parameterInfo);
      }
      else {
        parameterInfos.add(parameterInfos.size() - 1, parameterInfo);
      }
      dialog.setParameterInfos(parameterInfos);
      dialog.show();
    }
  }
private static void showDialog(@NotNull PsiMethod method, @NotNull GrReferenceExpression ref, @NotNull Project project)