mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Move RemoveNoConstructorFix to frontend independent module
...and convert it to ModCommandAction. ^KTIJ-29525 GitOrigin-RevId: 24a801b95eab21cb8651e00aa5eef43b058d098a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b3f89ecc94
commit
9d313e6424
+30
@@ -0,0 +1,30 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.modcommand.ActionContext
|
||||
import com.intellij.modcommand.ModPsiUpdater
|
||||
import org.jetbrains.kotlin.idea.base.psi.replaced
|
||||
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.applicable.intentions.KotlinPsiUpdateModCommandAction
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import org.jetbrains.kotlin.psi.KtSuperTypeCallEntry
|
||||
import org.jetbrains.kotlin.psi.KtValueArgumentList
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
class RemoveNoConstructorFix(
|
||||
element: KtValueArgumentList,
|
||||
) : KotlinPsiUpdateModCommandAction.ElementBased<KtValueArgumentList, Unit>(element, Unit) {
|
||||
|
||||
override fun invoke(
|
||||
actionContext: ActionContext,
|
||||
element: KtValueArgumentList,
|
||||
elementContext: Unit,
|
||||
updater: ModPsiUpdater,
|
||||
) {
|
||||
val superTypeCallEntry = element.getStrictParentOfType<KtSuperTypeCallEntry>() ?: return
|
||||
val superTypeEntry = KtPsiFactory(actionContext.project).createSuperTypeEntry(superTypeCallEntry.firstChild.text)
|
||||
superTypeCallEntry.replaced(superTypeEntry)
|
||||
}
|
||||
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.constructor.call")
|
||||
}
|
||||
@@ -659,9 +659,9 @@ class QuickFixRegistrar : QuickFixContributor {
|
||||
WRONG_ANNOTATION_TARGET.registerFactory(AddAnnotationTargetFix, AddAnnotationUseSiteTargetFix)
|
||||
WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET.registerFactory(MoveReceiverAnnotationFix, AddAnnotationTargetFix)
|
||||
|
||||
NO_CONSTRUCTOR.registerFactory(RemoveNoConstructorFix)
|
||||
NO_CONSTRUCTOR.registerFactory(RemoveNoConstructorFixFactory)
|
||||
NO_CONSTRUCTOR.registerFactory(AddDefaultConstructorFix)
|
||||
NO_CONSTRUCTOR_WARNING.registerFactory(RemoveNoConstructorFix)
|
||||
NO_CONSTRUCTOR_WARNING.registerFactory(RemoveNoConstructorFixFactory)
|
||||
|
||||
ANNOTATION_USED_AS_ANNOTATION_ARGUMENT.registerFactory(RemoveAtFromAnnotationArgument)
|
||||
|
||||
|
||||
+7
-26
@@ -2,33 +2,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.modcommand.ModCommandAction
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.base.psi.replaced
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.classic.quickfixes.KotlinQuickFixAction
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import org.jetbrains.kotlin.psi.KtSuperTypeCallEntry
|
||||
import org.jetbrains.kotlin.psi.KtValueArgumentList
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
class RemoveNoConstructorFix(constructor: KtValueArgumentList) : KotlinQuickFixAction<KtValueArgumentList>(constructor) {
|
||||
|
||||
override fun getText() = KotlinBundle.message("remove.constructor.call")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val superTypeCallEntry = element?.getStrictParentOfType<KtSuperTypeCallEntry>() ?: return
|
||||
val superTypeEntry = KtPsiFactory(project).createSuperTypeEntry(superTypeCallEntry.firstChild.text)
|
||||
superTypeCallEntry.replaced(superTypeEntry)
|
||||
}
|
||||
|
||||
companion object : KotlinSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction<KtValueArgumentList>? =
|
||||
(diagnostic.psiElement as? KtValueArgumentList)?.let { RemoveNoConstructorFix(it) }
|
||||
}
|
||||
|
||||
internal object RemoveNoConstructorFixFactory : KotlinSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? =
|
||||
(diagnostic.psiElement as? KtValueArgumentList)
|
||||
?.let { RemoveNoConstructorFix(it) }
|
||||
?.let(ModCommandAction::asIntention)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user