public static @NotNull List<PsiMethod> overrideOrImplementMethod(@NotNull PsiClass aClass,
                                                                   @NotNull PsiMethod method,
                                                                   @NotNull PsiSubstitutor substitutor,
                                                                   boolean toCopyJavaDoc,
                                                                   boolean insertOverrideIfPossible) throws IncorrectOperationException {
    if (!method.isValid() || !substitutor.isValid()) return Collections.emptyList();

    List<PsiMethod> results = new ArrayList<>();
    for (final MethodImplementor implementor : getImplementors()) {
      final PsiMethod[] prototypes = implementor.createImplementationPrototypes(aClass, method);
      for (PsiMethod prototype : prototypes) {
        implementor.createDecorator(aClass, method, toCopyJavaDoc, insertOverrideIfPossible).consume(prototype);
        results.add(prototype);
      }
    }

    if (results.isEmpty()) {
      PsiMethod method1 = GenerateMembersUtil.substituteGenericMethod(method, substitutor, aClass);

      PsiClass copyClass = copyClass(aClass);
      PsiMethod result = (PsiMethod)copyClass.addBefore(method1, copyClass.getRBrace());
      if (PsiUtil.isAnnotationMethod(result)) {
        PsiAnnotationMemberValue defaultValue = ((PsiAnnotationMethod)result).getDefaultValue();
        if (defaultValue != null) {
          PsiElement defaultKeyword = defaultValue;
          while (!(defaultKeyword instanceof PsiKeyword) && defaultKeyword != null) {
            defaultKeyword = defaultKeyword.getPrevSibling();
          }
          if (defaultKeyword == null) defaultKeyword = defaultValue;
          defaultValue.getParent().deleteChildRange(defaultKeyword, defaultValue);
        }
      }
      Consumer<PsiMethod> decorator = createDefaultDecorator(aClass, method, toCopyJavaDoc, insertOverrideIfPossible);
      decorator.consume(result);
      results.add(result);
    }

    results.removeIf(m -> aClass.findMethodBySignature(m, false) != null);

    return results;
  }
public static @NotNull List<PsiMethod> overrideOrImplementMethod(@NotNull PsiClass aClass,
                                                                   @NotNull PsiMethod method,
                                                                   @NotNull PsiSubstitutor substitutor,
                                                                   boolean toCopyJavaDoc,
                                                                   boolean insertOverrideIfPossible)