void (@Nullable PsiClass aClass, @Nullable PsiMethod refactoredMethod, PsiMethod prototype, MultiMap<PsiElement, @DialogMessage String> conflicts) { if (prototype == null) return; String protoMethodInfo = getMethodPrototypeString(prototype); PsiMethod method = aClass != null ? aClass.findMethodBySignature(prototype, true) : null; if (method == null && aClass != null) { final MethodSignature signature = prototype.getSignature(PsiSubstitutor.EMPTY); for (PsiMethod classMethod : aClass.getMethods()) { if (MethodSignatureUtil.areSignaturesErasureEqual(signature, classMethod.getSignature(PsiSubstitutor.EMPTY))) { method = classMethod; protoMethodInfo = "with same erasure"; break; } } } if (method != null && method != refactoredMethod && !isStaticInterfaceMethods(aClass, refactoredMethod, method) && (!(method instanceof LightRecordCanonicalConstructor) || !(refactoredMethod instanceof LightRecordCanonicalConstructor))) { if (aClass.equals(method.getContainingClass())) { final String classDescr = aClass instanceof PsiAnonymousClass ? JavaRefactoringBundle.message("current.class") : RefactoringUIUtil.getDescription(aClass, false); conflicts.putValue(method, RefactoringBundle.message("method.0.is.already.defined.in.the.1", protoMethodInfo, classDescr)); } else { // method somewhere in base class if (JavaPsiFacade.getInstance(method.getProject()).getResolveHelper().isAccessible(method, aClass, null)) { String className = CommonRefactoringUtil.htmlEmphasize(DescriptiveNameUtil.getDescriptiveName(method.getContainingClass())); if (PsiUtil.getAccessLevel(prototype.getModifierList()) >= PsiUtil.getAccessLevel(method.getModifierList()) ) { boolean isMethodAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT); boolean isMyMethodAbstract = refactoredMethod != null && refactoredMethod.hasModifierProperty(PsiModifier.ABSTRACT); final String conflict = isMethodAbstract != isMyMethodAbstract ? JavaRefactoringBundle.message("method.0.will.implement.method.of.the.base.class", protoMethodInfo, className) : JavaRefactoringBundle.message("method.0.will.override.a.method.of.the.base.class", protoMethodInfo, className); conflicts.putValue(method, conflict); } else { // prototype is private, will be compile-error conflicts.putValue(method, JavaRefactoringBundle.message("method.0.will.hide.method.of.the.base.class", protoMethodInfo, className)); } } } } if (aClass != null && prototype.hasModifierProperty(PsiModifier.PRIVATE)) { ClassInheritorsSearch.search(aClass).forEach(aClass1 -> { final PsiMethod[] methods = aClass1.findMethodsBySignature(prototype, false); for (PsiMethod method1 : methods) { conflicts.putValue(method1, JavaBundle.message("conflict.message.method.will.override.method.base.class", RefactoringUIUtil.getDescription(method1, true), RefactoringUIUtil.getDescription(aClass, false))); } return true; }); } }