Repository: JetBrains/kotlin
File: idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt (Kotlin)

Code before:
        when {
            isRedundant ->
                KotlinBundle.message("remove.redundant.0.modifier", modifierText)
            modifier === KtTokens.ABSTRACT_KEYWORD || modifier === KtTokens.OPEN_KEYWORD ->
                KotlinBundle.message("make.0.not.1", getElementName(element), modifierText)
            else ->
                KotlinBundle.message("remove.0.modifier", modifierText, modifier)
        }
    }

    override fun getFamilyName() = KotlinBundle.message("remove.modifier")

    override fun getText() = text

    override fun isAvailableImpl(project: Project, editor: Editor?, file: PsiFile) = element?.hasModifier(modifier) == true

    override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) {
        invoke()
    }

    operator fun invoke() {
        element?.removeModifier(modifier)
    }

    companion object {
        @Deprecated(
            "For binary compatibility",
            replaceWith = ReplaceWith("createRemoveModifierFromListOwnerPsiBasedFactory(modifier, isRedundant)")
        )
        fun createRemoveModifierFromListOwnerFactory(
            modifier: KtModifierKeywordToken,
            isRedundant: Boolean = false
        ): KotlinSingleIntentionActionFactory =
            KotlinSingleIntentionActionFactory.createFromQuickFixesPsiBasedFactory(
                createRemoveModifierFromListOwnerPsiBasedFactory(modifier, isRedundant)
            )

        fun createRemoveModifierFromListOwnerPsiBasedFactory(
            modifier: KtModifierKeywordToken,
            isRedundant: Boolean = false
        ): QuickFixesPsiBasedFactory<PsiElement> =
            createRemoveModifierFromListOwnerFactoryByModifierListOwner(
                modifier,
                isRedundant
            ).coMap { PsiTreeUtil.getParentOfType(it, KtModifierListOwner::class.java, false) }

        fun createRemoveModifierFromListOwnerFactoryByModifierListOwner(
            modifier: KtModifierKeywordToken,
            isRedundant: Boolean = false
        ) = quickFixesPsiBasedFactory<KtModifierListOwner> {
            listOf(RemoveModifierFix(it, modifier, isRedundant))

Review comment (suggestion):
Super minor: I couldn't find a definitive answer on this, but the factories in `ChangeVariableMutabilityFix.Companion` have `UPPER_CASE_NAMES`. Which one is the correct naming convention? 🙂  https://kotlinlang.org/docs/coding-conventions.html#property-names seems to indicate it should be `removeRedundantModifier` since the property value has behavior.

Code after:
        when {
            isRedundant ->
                KotlinBundle.message("remove.redundant.0.modifier", modifierText)
            modifier === KtTokens.ABSTRACT_KEYWORD || modifier === KtTokens.OPEN_KEYWORD ->
                KotlinBundle.message("make.0.not.1", getElementName(element), modifierText)
            else ->
                KotlinBundle.message("remove.0.modifier", modifierText, modifier)
        }
    }

    override fun getFamilyName() = KotlinBundle.message("remove.modifier")

    override fun getText() = text

    override fun isAvailableImpl(project: Project, editor: Editor?, file: PsiFile) = element?.hasModifier(modifier) == true

    override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) {
        invoke()
    }

    operator fun invoke() {
        element?.removeModifier(modifier)
    }

    companion object {
        val removeRedundantModifier = createRemoveModifierFactory(isRedundant = true)
        val removeNonRedundantModifier = createRemoveModifierFactory(isRedundant = false)

        @Deprecated(
            "For binary compatibility",
            replaceWith = ReplaceWith("createRemoveModifierFromListOwnerPsiBasedFactory(modifier, isRedundant)")
        )
        fun createRemoveModifierFromListOwnerFactory(
            modifier: KtModifierKeywordToken,
            isRedundant: Boolean = false
        ): KotlinSingleIntentionActionFactory =
            KotlinSingleIntentionActionFactory.createFromQuickFixesPsiBasedFactory(
                createRemoveModifierFromListOwnerPsiBasedFactory(modifier, isRedundant)
            )

        fun createRemoveModifierFromListOwnerPsiBasedFactory(
            modifier: KtModifierKeywordToken,
            isRedundant: Boolean = false
        ): QuickFixesPsiBasedFactory<PsiElement> =
            createRemoveModifierFromListOwnerFactoryByModifierListOwner(
                modifier,
                isRedundant
            ).coMap { PsiTreeUtil.getParentOfType(it, KtModifierListOwner::class.java, false) }

        fun createRemoveModifierFromListOwnerFactoryByModifierListOwner(
            modifier: KtModifierKeywordToken,