mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Account for ditching of KtTypeReference from K2 diagnostics
Source elements may be generated from a plugin, in which case they will be fake sources ponting to arbitrary `KtElement`s. ^KT-68375 GitOrigin-RevId: 0535f1bd113ef9ac8417cf1f63d304229673377f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1ffec2b287
commit
1ca2a6d4ac
+2
-1
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.idea.quickfix.AddModifierFix
|
||||
import org.jetbrains.kotlin.idea.refactoring.canRefactorElement
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
||||
|
||||
object MakeSuperTypeOpenFixFactory {
|
||||
@@ -23,7 +24,7 @@ object MakeSuperTypeOpenFixFactory {
|
||||
|
||||
context(KaSession)
|
||||
private fun createQuickFixes(
|
||||
diagnostic: KaFirDiagnostic<KtTypeReference>,
|
||||
diagnostic: KaFirDiagnostic<KtElement>,
|
||||
): List<AddModifierFix> {
|
||||
val typeRef = diagnostic.psi as? KtTypeReference
|
||||
?: return emptyList()
|
||||
|
||||
+3
-1
@@ -19,11 +19,13 @@ import org.jetbrains.kotlin.idea.codeinsight.api.applicators.fixes.KotlinQuickFi
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import org.jetbrains.kotlin.psi.KtSuperTypeEntry
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
||||
|
||||
internal object SuperClassNotInitializedFactories {
|
||||
|
||||
val addParenthesis = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.SupertypeNotInitialized ->
|
||||
val typeReference = diagnostic.psi
|
||||
val typeReference = diagnostic.psi as? KtTypeReference
|
||||
?: return@ModCommandBased emptyList()
|
||||
val superTypeEntry = typeReference.parent as? KtSuperTypeEntry
|
||||
?: return@ModCommandBased emptyList()
|
||||
val superClassSymbol = typeReference.type.expandedSymbol as? KaNamedClassOrObjectSymbol
|
||||
|
||||
+2
-1
@@ -5,11 +5,12 @@ import org.jetbrains.kotlin.analysis.api.fir.diagnostics.KaFirDiagnostic
|
||||
import org.jetbrains.kotlin.analysis.api.types.KaClassType
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.applicators.fixes.KotlinQuickFixFactory
|
||||
import org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
||||
|
||||
internal object TypeOfAnnotationMemberFixFactory {
|
||||
|
||||
val typeOfAnnotationMemberFixFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.InvalidTypeOfAnnotationMember ->
|
||||
val typeReference = diagnostic.psi
|
||||
val typeReference = diagnostic.psi as? KtTypeReference ?: return@ModCommandBased emptyList()
|
||||
|
||||
val arrayElementType = typeReference.type.arrayElementType ?: return@ModCommandBased emptyList()
|
||||
if (!arrayElementType.isPrimitive) return@ModCommandBased emptyList()
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@
|
||||
|
||||
annotation class CollectionDefault(vararg val value = [1.0, 2.2]<caret>)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddTypeAnnotationToValueParameterFix
|
||||
/* IGNORE_K2 */
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.AddTypeAnnotationToValueParameterFixFactory$AddTypeAnnotationToValueParameterFix
|
||||
+1
-1
@@ -3,4 +3,4 @@
|
||||
|
||||
annotation class CollectionDefault(vararg val value: Double = [1.0, 2.2])
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddTypeAnnotationToValueParameterFix
|
||||
/* IGNORE_K2 */
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.AddTypeAnnotationToValueParameterFixFactory$AddTypeAnnotationToValueParameterFix
|
||||
+1
-1
@@ -3,4 +3,4 @@
|
||||
|
||||
annotation class CollectionDefault(vararg val value = [1, 2]<caret>)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddTypeAnnotationToValueParameterFix
|
||||
/* IGNORE_K2 */
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.AddTypeAnnotationToValueParameterFixFactory$AddTypeAnnotationToValueParameterFix
|
||||
+1
-1
@@ -3,4 +3,4 @@
|
||||
|
||||
annotation class CollectionDefault(vararg val value: Int = [1, 2])
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddTypeAnnotationToValueParameterFix
|
||||
/* IGNORE_K2 */
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.AddTypeAnnotationToValueParameterFixFactory$AddTypeAnnotationToValueParameterFix
|
||||
+1
-1
@@ -3,4 +3,4 @@
|
||||
|
||||
annotation class CollectionDefault(vararg val value = ["alpha", "beta"]<caret>)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddTypeAnnotationToValueParameterFix
|
||||
/* IGNORE_K2 */
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.AddTypeAnnotationToValueParameterFixFactory$AddTypeAnnotationToValueParameterFix
|
||||
+1
-1
@@ -3,4 +3,4 @@
|
||||
|
||||
annotation class CollectionDefault(vararg val value: String = ["alpha", "beta"])
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddTypeAnnotationToValueParameterFix
|
||||
/* IGNORE_K2 */
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.AddTypeAnnotationToValueParameterFixFactory$AddTypeAnnotationToValueParameterFix
|
||||
Reference in New Issue
Block a user