mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Port TypeOfAnnotationMemberFix to K2
This quick fix is for the INVALID_TYPE_OF_ANNOTATION_MEMBER error. ^KTIJ-29542 GitOrigin-RevId: b908ccd2bfe2e54031bdfff75d817608575f8ead
This commit is contained in:
committed by
intellij-monorepo-bot
parent
89404d5a6c
commit
40f0a6d833
+1
@@ -94,6 +94,7 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() {
|
||||
registerFactory(AddStarProjectionsFixFactory.addStarProjectionsFixFactory)
|
||||
registerFactory(AddTypeAnnotationToValueParameterFixFactory.addTypeAnnotationToValueParameterFixFactory)
|
||||
registerFactory(ChangeToFunctionInvocationFixFactory.changeToFunctionInvocationFixFactory)
|
||||
registerFactory(TypeOfAnnotationMemberFixFactory.typeOfAnnotationMemberFixFactory)
|
||||
}
|
||||
|
||||
private val addAbstract = KtQuickFixesListBuilder.registerPsiQuickFix {
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// 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.KtFirDiagnostic
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtNonErrorClassType
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.applicators.fixes.KotlinQuickFixFactory
|
||||
import org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
|
||||
internal object TypeOfAnnotationMemberFixFactory {
|
||||
|
||||
val typeOfAnnotationMemberFixFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KtFirDiagnostic.InvalidTypeOfAnnotationMember ->
|
||||
val typeReference = diagnostic.psi
|
||||
|
||||
val arrayElementType = typeReference.getKtType().getArrayElementType() ?: return@ModCommandBased emptyList()
|
||||
if (!arrayElementType.isPrimitive) return@ModCommandBased emptyList()
|
||||
|
||||
val classId = (arrayElementType as KtNonErrorClassType).classId
|
||||
val fixedArrayTypeText = "${classId.shortClassName}Array"
|
||||
|
||||
listOf(
|
||||
TypeOfAnnotationMemberFix(typeReference, fixedArrayTypeText)
|
||||
)
|
||||
}
|
||||
}
|
||||
+51
@@ -5957,7 +5957,58 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu
|
||||
|
||||
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../../../idea/tests/testData/quickfix/typeOfAnnotationMember")
|
||||
public static class TypeOfAnnotationMember extends AbstractHighLevelQuickFixTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("boolean.kt")
|
||||
public void testBoolean() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/typeOfAnnotationMember/boolean.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("byte.kt")
|
||||
public void testByte() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/typeOfAnnotationMember/byte.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("char.kt")
|
||||
public void testChar() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/typeOfAnnotationMember/char.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("float.kt")
|
||||
public void testFloat() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/typeOfAnnotationMember/float.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("int.kt")
|
||||
public void testInt() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/typeOfAnnotationMember/int.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("long.kt")
|
||||
public void testLong() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/typeOfAnnotationMember/long.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("short.kt")
|
||||
public void testShort() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/typeOfAnnotationMember/short.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("star.kt")
|
||||
public void testStar() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/typeOfAnnotationMember/star.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("string.kt")
|
||||
public void testString() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/typeOfAnnotationMember/string.kt");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val boo: <caret>Array<Boolean>,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val boo: BooleanArray,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val b: <caret>Array<Byte>,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val b: ByteArray,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val c: <caret>Array<Char>,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val c: CharArray,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val f: <caret>Array<Float>,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val f: FloatArray,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val i: <caret>Array<Int>,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val i: IntArray,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val l: <caret>Array<Long>,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val l: LongArray,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val s: <caret>Array<Short>,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
@@ -3,4 +3,5 @@ annotation class SuperAnnotation(
|
||||
val s: ShortArray,
|
||||
val str: Array<String>
|
||||
)
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.TypeOfAnnotationMemberFix
|
||||
+1
-1
@@ -193,7 +193,7 @@ internal fun MutableTWorkspace.generateK2FixTests() {
|
||||
model("$idea/quickfix/tooLongCharLiteralToString", pattern = pattern, isIgnored = true)
|
||||
model("$idea/quickfix/typeImports", pattern = pattern, isIgnored = true)
|
||||
model("$idea/quickfix/typeInferenceExpectedTypeMismatch", pattern = pattern, isIgnored = true)
|
||||
model("$idea/quickfix/typeOfAnnotationMember", pattern = pattern, isIgnored = true)
|
||||
model("$idea/quickfix/typeOfAnnotationMember", pattern = pattern)
|
||||
model("$idea/quickfix/typeParameters", pattern = pattern, isIgnored = true)
|
||||
model("$idea/quickfix/typeProjection", pattern = pattern, isIgnored = true)
|
||||
model("$idea/quickfix/unnecessaryLateinit", pattern = pattern, isIgnored = true)
|
||||
|
||||
Reference in New Issue
Block a user