private static boolean validateMethod(ExtractMethodInfoHelper helper) {
    MultiMap<PsiElement, @NlsContexts.DialogMessage String> conflicts = new MultiMap<>();
    GrMethod method = ExtractUtil.createMethod(helper);
    PsiClass owner = helper.getOwner();
    PsiMethod[] methods = ArrayUtil.mergeArrays(owner.getAllMethods(), new PsiMethod[]{method}, PsiMethod.ARRAY_FACTORY);
    final Map<PsiMethod, List<PsiMethod>> map = DuplicatesUtil.factorDuplicates(methods, new HashingStrategy<>() {
      @Override
      public int hashCode(@Nullable PsiMethod method) {
        return method == null ? 0 : method.getSignature(PsiSubstitutor.EMPTY).hashCode();
      }

      @Override
      public boolean equals(@Nullable PsiMethod method1, @Nullable PsiMethod method2) {
        return method1 == method2 ||
               (method1 != null &&
                method2 != null &&
                method1.getSignature(PsiSubstitutor.EMPTY).equals(method2.getSignature(PsiSubstitutor.EMPTY)));
      }
    });

    List<PsiMethod> list = map.get(method);
    if (list == null) return true;
    for (PsiMethod psiMethod : list) {
      if (psiMethod != method) {
        PsiClass containingClass = psiMethod.getContainingClass();
        if (containingClass == null) return true;
        String message = containingClass instanceof GroovyScriptClass
                         ? GroovyRefactoringBundle.message("method.is.already.defined.in.script",
                                                           GroovyRefactoringUtil.getMethodSignature(psiMethod),
                                                           RefactoringUIUtil.getDescription(containingClass, false))
                         : GroovyRefactoringBundle.message("method.is.already.defined.in.class",
                                                           GroovyRefactoringUtil.getMethodSignature(psiMethod),
                                                           RefactoringUIUtil.getDescription(containingClass, false));
        conflicts.putValue(psiMethod, message);
      }
    }

    return conflicts.isEmpty() || BaseRefactoringProcessor.processConflicts(helper.getProject(), conflicts);
  }
private static boolean validateMethod(ExtractMethodInfoHelper helper)