mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Port MoveWhenElseBranchFix to K2
^KTIJ-29518 GitOrigin-RevId: 9a9b4c59ce3714c0c80a4ee3de54d1652d0ee91c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
afe0851840
commit
514b70a053
+1
@@ -127,6 +127,7 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() {
|
||||
registerFactory(AddDefaultConstructorFixFactory.addDefaultConstructorFixFactory)
|
||||
registerFactory(MakeClassAnAnnotationClassFixFactory.makeClassAnAnnotationClassFixFactory)
|
||||
registerFactory(WrongLongSuffixFixFactory.changeToCorrectLongSuffix)
|
||||
registerFactory(MoveWhenElseBranchFixFactory.moveWhenElseBranchFixFactory)
|
||||
}
|
||||
|
||||
private val addAbstract = KtQuickFixesListBuilder.registerPsiQuickFix {
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// 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.k2.codeinsight.fixes
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.fir.diagnostics.KaFirDiagnostic
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.applicators.fixes.KotlinQuickFixFactory
|
||||
import org.jetbrains.kotlin.idea.quickfix.MoveWhenElseBranchFix
|
||||
import org.jetbrains.kotlin.psi.KtWhenExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
|
||||
internal object MoveWhenElseBranchFixFactory {
|
||||
|
||||
val moveWhenElseBranchFixFactory = KotlinQuickFixFactory.IntentionBased { diagnostic: KaFirDiagnostic.ElseMisplacedInWhen ->
|
||||
val whenExpression = diagnostic.psi.getNonStrictParentOfType<KtWhenExpression>() ?: return@IntentionBased emptyList()
|
||||
|
||||
listOf(
|
||||
MoveWhenElseBranchFix(whenExpression)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,6 @@ fun test() {
|
||||
2 -> { /* some more code */ }
|
||||
}
|
||||
}
|
||||
/* IGNORE_K2 */
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MoveWhenElseBranchFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MoveWhenElseBranchFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MoveWhenElseBranchFix
|
||||
@@ -7,6 +7,6 @@ fun test() {
|
||||
el<caret>se -> { /* other code */ }
|
||||
}
|
||||
}
|
||||
/* IGNORE_K2 */
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MoveWhenElseBranchFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MoveWhenElseBranchFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MoveWhenElseBranchFix
|
||||
Reference in New Issue
Block a user