diff --git a/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/AnnotationUsedAsAnnotationArgumentFixFactories.kt b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/AnnotationUsedAsAnnotationArgumentFixFactories.kt new file mode 100644 index 000000000000..d7951fd6d5db --- /dev/null +++ b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/AnnotationUsedAsAnnotationArgumentFixFactories.kt @@ -0,0 +1,13 @@ +// 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.RemoveAtFromAnnotationArgument + +internal object AnnotationUsedAsAnnotationArgumentFixFactories { + + val removeAtFromAnnotationArgumentFixFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.AnnotationUsedAsAnnotationArgument -> + listOf(RemoveAtFromAnnotationArgument(diagnostic.psi)) + } +} diff --git a/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/KotlinK2QuickFixRegistrar.kt b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/KotlinK2QuickFixRegistrar.kt index 0f4c5e343bc8..077e4c34d2f0 100644 --- a/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/KotlinK2QuickFixRegistrar.kt +++ b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/KotlinK2QuickFixRegistrar.kt @@ -364,6 +364,8 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() { registerFactory(ReplaceProtectedToPublishedApiCallFixFactory.protectedCallFromPublicInline) registerFactory(ReplaceProtectedToPublishedApiCallFixFactory.protectedCallFromPublicInlineError) + + registerFactory(AnnotationUsedAsAnnotationArgumentFixFactories.removeAtFromAnnotationArgumentFixFactory) } private val whenStatements = KtQuickFixesListBuilder.registerPsiQuickFix { diff --git a/plugins/kotlin/code-insight/fixes-k2/tests/test/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/HighLevelQuickFixTestGenerated.java b/plugins/kotlin/code-insight/fixes-k2/tests/test/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/HighLevelQuickFixTestGenerated.java index 3b5cbb9bbba8..c885f319d108 100644 --- a/plugins/kotlin/code-insight/fixes-k2/tests/test/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/HighLevelQuickFixTestGenerated.java +++ b/plugins/kotlin/code-insight/fixes-k2/tests/test/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/HighLevelQuickFixTestGenerated.java @@ -10742,7 +10742,39 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu } } + @RunWith(JUnit3RunnerWithInners.class) + @TestMetadata("../../../idea/tests/testData/quickfix/removeAtFromAnnotationArgument") + public static class RemoveAtFromAnnotationArgument extends AbstractHighLevelQuickFixTest { + @java.lang.Override + @org.jetbrains.annotations.NotNull + public final KotlinPluginMode getPluginMode() { + return KotlinPluginMode.K2; + } + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("arrayParam.kt") + public void testArrayParam() throws Exception { + runTest("../../../idea/tests/testData/quickfix/removeAtFromAnnotationArgument/arrayParam.kt"); + } + + @TestMetadata("brokenCode.kt") + public void testBrokenCode() throws Exception { + runTest("../../../idea/tests/testData/quickfix/removeAtFromAnnotationArgument/brokenCode.kt"); + } + + @TestMetadata("namedParam.kt") + public void testNamedParam() throws Exception { + runTest("../../../idea/tests/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("../../../idea/tests/testData/quickfix/removeAtFromAnnotationArgument/simple.kt"); + } + } @RunWith(JUnit3RunnerWithInners.class) @TestMetadata("../../../idea/tests/testData/quickfix/removeDefaultParameterValue") diff --git a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/arrayParam.kt b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/arrayParam.kt index 96839cc07993..9d7735dcd168 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/arrayParam.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/arrayParam.kt @@ -7,4 +7,7 @@ annotation class X(val value: Array) @X(arrayOf(Y(), @Y())) fun foo() { } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument +/* IGNORE_K2 */ +// KT-72831 +// KTIJ-31896 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/arrayParam.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/arrayParam.kt.after index 613ddb18ef70..ad5eb322482d 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/arrayParam.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/arrayParam.kt.after @@ -7,4 +7,7 @@ annotation class X(val value: Array) @X(arrayOf(Y(), Y())) fun foo() { } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument +/* IGNORE_K2 */ +// KT-72831 +// KTIJ-31896 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/brokenCode.kt b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/brokenCode.kt index 3aaf8e0365e8..410838c0f2cb 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/brokenCode.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/brokenCode.kt @@ -2,4 +2,7 @@ // DISABLE-ERRORS @Suppress({ @x y() }) fun test() {} -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument +/* IGNORE_K2 */ +// KT-72831 +// KTIJ-31896 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/brokenCode.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/brokenCode.kt.after index f813d9a2b18e..78d5c176ec5a 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/brokenCode.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/brokenCode.kt.after @@ -2,4 +2,7 @@ // DISABLE-ERRORS @Suppress({ x y() }) fun test() {} -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument +/* IGNORE_K2 */ +// KT-72831 +// KTIJ-31896 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt index d5e6ad368420..27f30e34d9f0 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt @@ -7,4 +7,5 @@ annotation class X(val value: Y, val y: Y) fun foo() { } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt.after index 7bef552dfad3..e901a89c8fa8 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt.after @@ -7,4 +7,5 @@ annotation class X(val value: Y, val y: Y) fun foo() { } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/simple.kt b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/simple.kt index 4b26182284c7..4b85e74a0ae7 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/simple.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/simple.kt @@ -6,4 +6,5 @@ annotation class X(val value: Y) @X(@Y()) fun foo() { } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/simple.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/simple.kt.after index e9cba6399b9d..c2c4caf900ed 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/simple.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/removeAtFromAnnotationArgument/simple.kt.after @@ -6,4 +6,5 @@ annotation class X(val value: Y) @X(Y()) fun foo() { } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.RemoveAtFromAnnotationArgument \ No newline at end of file diff --git a/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2QuickFixTests.kt b/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2QuickFixTests.kt index 19d962ae2990..8e905cd3cb95 100644 --- a/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2QuickFixTests.kt +++ b/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2QuickFixTests.kt @@ -167,7 +167,7 @@ internal fun MutableTWorkspace.generateK2FixTests() { model("$idea/quickfix/redundantVisibilityModifier", pattern = pattern, isIgnored = true) model("$idea/quickfix/removeAnnotation", pattern = pattern, isIgnored = true) model("$idea/quickfix/removeArgument", pattern = pattern) - model("$idea/quickfix/removeAtFromAnnotationArgument", pattern = pattern, isIgnored = true) + model("$idea/quickfix/removeAtFromAnnotationArgument", pattern = pattern) model("$idea/quickfix/removeDefaultParameterValue", pattern = pattern) model("$idea/quickfix/removeFinalUpperBound", pattern = pattern) model("$idea/quickfix/removeNoConstructor", pattern = pattern)