void (@NotNull PsiMethod methodWithOverrides, @NotNull List<? super IntentionAction> registrar) { PsiClass containingClass = methodWithOverrides.getContainingClass(); if (containingClass == null) return; boolean canBePulledUp = true; String name = JavaBundle.message("intention.name.pull.method.up", methodWithOverrides.getName()); if (containingClass instanceof PsiAnonymousClass) { final PsiClassType baseClassType = ((PsiAnonymousClass)containingClass).getBaseClassType(); final PsiClass baseClass = baseClassType.resolve(); if (baseClass == null) return; if (!BaseIntentionAction.canModify(baseClass)) return; if (!baseClass.hasModifierProperty(PsiModifier.ABSTRACT)) { name = JavaBundle.message("intention.name.pull.method.up.make.it.abstract", methodWithOverrides.getName()); } } else { final LinkedHashSet<PsiClass> classesToPullUp = new LinkedHashSet<>(); collectClassesToPullUp(classesToPullUp, containingClass.getExtendsListTypes()); collectClassesToPullUp(classesToPullUp, containingClass.getImplementsListTypes()); if (classesToPullUp.isEmpty()) { name = JavaBundle.message("intention.name.extract.method.to.new.interface", methodWithOverrides.getName()); canBePulledUp = false; } else if (classesToPullUp.size() == 1) { final PsiClass baseClass = classesToPullUp.iterator().next(); name = JavaBundle.message("intention.name.pull.method.up.and.make.it.abstract.conditionally", methodWithOverrides.getName(), baseClass.getName(), !baseClass.hasModifierProperty(PsiModifier.ABSTRACT) ? 0 : 1); } } registrar.add(new PullAsAbstractUpFix(methodWithOverrides, name)); if (canBePulledUp) { var supportProvider = LanguageRefactoringSupport.INSTANCE.forLanguage(JavaLanguage.INSTANCE); registrar.add(new RunRefactoringAction(supportProvider.getPullUpHandler(), JavaBundle.message("pull.members.up.fix.name"))); } if (! (containingClass instanceof PsiAnonymousClass)){ var supportProvider = LanguageRefactoringSupport.INSTANCE.forLanguage(JavaLanguage.INSTANCE); registrar.add(new RunRefactoringAction(supportProvider.getExtractInterfaceHandler(), JavaBundle.message("extract.interface.command.name"))); registrar.add(new RunRefactoringAction(supportProvider.getExtractSuperClassHandler(), JavaBundle.message("extract.superclass.command.name"))); } }