PsiSubstitutor (@NotNull PsiMethod derivedMethod, @NotNull PsiMethod baseMethod) { PsiSubstitutor substitutor; if (derivedMethod.getManager().areElementsEquivalent(derivedMethod, baseMethod)) { substitutor = PsiSubstitutor.EMPTY; } else { PsiClass baseClass = baseMethod.getContainingClass(); PsiClass derivedClass = derivedMethod.getContainingClass(); if (baseClass != null && InheritanceUtil.isInheritorOrSelf(derivedClass, baseClass, true)) { PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, derivedClass, PsiSubstitutor.EMPTY); MethodSignature superMethodSignature = baseMethod.getSignature(superClassSubstitutor); MethodSignature methodSignature = derivedMethod.getSignature(PsiSubstitutor.EMPTY); PsiSubstitutor superMethodSubstitutor = MethodSignatureUtil.getSuperMethodSignatureSubstitutor(methodSignature, superMethodSignature); substitutor = superMethodSubstitutor != null ? superMethodSubstitutor : superClassSubstitutor; } else { substitutor = PsiSubstitutor.EMPTY; } } return substitutor; }