mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
[kotlin] Port RemoveSupertypeFix to K2
This quick fix is for the MANY_CLASSES_IN_SUPERTYPE_LIST error. ^KTIJ-29612 GitOrigin-RevId: f028565cd5a6cba1911db51ced7f9015ac545f0c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
309f90b973
commit
d2208e036e
+1
@@ -111,6 +111,7 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() {
|
||||
registerFactory(AddIsToWhenConditionFixFactory.addIsToWhenConditionFixFactory)
|
||||
registerFactory(MoveTypeAliasToTopLevelFixFactory.moveTypeAliasToTopLevelFixFactory)
|
||||
registerPsiQuickFixes(KaFirDiagnostic.InvalidIfAsExpression::class, AddIfElseBranchFix)
|
||||
registerFactory(RemoveSupertypeFixFactory.removeSupertypeFixFactory)
|
||||
}
|
||||
|
||||
private val addAbstract = KtQuickFixesListBuilder.registerPsiQuickFix {
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// 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.RemoveSupertypeFix
|
||||
import org.jetbrains.kotlin.psi.KtSuperTypeListEntry
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
internal object RemoveSupertypeFixFactory {
|
||||
|
||||
val removeSupertypeFixFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.ManyClassesInSupertypeList ->
|
||||
val superType = diagnostic.psi.getStrictParentOfType<KtSuperTypeListEntry>() ?: return@ModCommandBased emptyList()
|
||||
|
||||
listOf(RemoveSupertypeFix(superType))
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,5 @@ open class C1 {}
|
||||
open class C2 {}
|
||||
class C3: C1(), C2<caret>() {}
|
||||
|
||||
/* IGNORE_K2 */
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
@@ -3,5 +3,5 @@ open class C1 {}
|
||||
open class C2 {}
|
||||
class C3: C1() {}
|
||||
|
||||
/* IGNORE_K2 */
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
@@ -3,5 +3,5 @@ open class C1 {}
|
||||
open class C2 {}
|
||||
class C3: C1(),C2<caret>() {}
|
||||
|
||||
/* IGNORE_K2 */
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
@@ -3,5 +3,5 @@ open class C1 {}
|
||||
open class C2 {}
|
||||
class C3: C1() {}
|
||||
|
||||
/* IGNORE_K2 */
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
@@ -3,5 +3,5 @@ open class C1 {}
|
||||
open class C2 {}
|
||||
class C3: C1(), C2<caret> {}
|
||||
|
||||
/* IGNORE_K2 */
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
@@ -3,5 +3,5 @@ open class C1 {}
|
||||
open class C2 {}
|
||||
class C3: C1() {}
|
||||
|
||||
/* IGNORE_K2 */
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
@@ -3,5 +3,5 @@ open class C1 {}
|
||||
open class C2 {}
|
||||
class C3: C1(), /* Hello, world! */ C2<caret>() {}
|
||||
|
||||
/* IGNORE_K2 */
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
@@ -3,5 +3,5 @@ open class C1 {}
|
||||
open class C2 {}
|
||||
class C3: C1() /* Hello, world! */ {}
|
||||
|
||||
/* IGNORE_K2 */
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveSupertypeFix
|
||||
Reference in New Issue
Block a user