mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Convert MoveReceiverAnnotationFix to ModCommandAction
^KTIJ-29515 GitOrigin-RevId: 8765dfdda26132ae4bf5e6d45ee64f4cfafcd026
This commit is contained in:
committed by
intellij-monorepo-bot
parent
48661fdc29
commit
96753eba04
+12
-9
@@ -1,23 +1,26 @@
|
||||
// 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.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.modcommand.ActionContext
|
||||
import com.intellij.modcommand.ModPsiUpdater
|
||||
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.classic.quickfixes.KotlinQuickFixAction
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.applicable.intentions.KotlinPsiUpdateModCommandAction
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
|
||||
class MoveReceiverAnnotationFix(element: KtAnnotationEntry) : KotlinQuickFixAction<KtAnnotationEntry>(element) {
|
||||
class MoveReceiverAnnotationFix(
|
||||
element: KtAnnotationEntry,
|
||||
) : KotlinPsiUpdateModCommandAction.ElementBased<KtAnnotationEntry, Unit>(element, Unit) {
|
||||
|
||||
override fun getFamilyName() = KotlinBundle.message("move.annotation.to.receiver.type")
|
||||
override fun getText() = familyName
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
override fun invoke(
|
||||
actionContext: ActionContext,
|
||||
element: KtAnnotationEntry,
|
||||
elementContext: Unit,
|
||||
updater: ModPsiUpdater,
|
||||
) {
|
||||
val declaration = element.getParentOfType<KtCallableDeclaration>(true) ?: return
|
||||
val receiverTypeRef = declaration.receiverTypeReference ?: return
|
||||
|
||||
|
||||
+1
-1
@@ -18,6 +18,6 @@ internal object MoveReceiverAnnotationFixFactory : KotlinSingleIntentionActionFa
|
||||
val declaration = entry.getParentOfType<KtCallableDeclaration>(true) ?: return null
|
||||
if (declaration.receiverTypeReference == null) return null
|
||||
|
||||
return MoveReceiverAnnotationFix(entry)
|
||||
return MoveReceiverAnnotationFix(entry).asIntention()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user