ModCommand (@NotNull ActionContext context, @NotNull PsiClass subclass) { PsiClass parentClass = myParentClassPointer.getElement(); if (parentClass == null) return ModCommand.nop(); boolean parentIsInterface = parentClass.isInterface(); boolean subclassIsInterface = subclass.isInterface(); if (!parentIsInterface && subclassIsInterface) return ModCommand.nop(); List<ModCommandAction> fixes; if (subclassIsInterface) { fixes = List.of(new ExtendSealedClassVariantAction(PsiModifier.SEALED, myParentClassPointer, subclass), new ExtendSealedClassVariantAction(PsiModifier.NON_SEALED, myParentClassPointer, subclass)); } else { fixes = List.of(new ExtendSealedClassVariantAction(PsiModifier.FINAL, myParentClassPointer, subclass), new ExtendSealedClassVariantAction(PsiModifier.SEALED, myParentClassPointer, subclass), new ExtendSealedClassVariantAction(PsiModifier.NON_SEALED, myParentClassPointer, subclass)); } int extendsImplements = subclass.isInterface() || !parentClass.isInterface() ? 1 : 2; //noinspection DialogTitleCapitalization String name = QuickFixBundle.message("extend.sealed.title", subclass.getName(), extendsImplements, parentClass.getName()); return new ModChooseAction(name, fixes); }