diff --git a/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/AddEmptyArgumentListFixFactory.kt b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/AddEmptyArgumentListFixFactory.kt new file mode 100644 index 000000000000..9d87f7caa0ac --- /dev/null +++ b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/AddEmptyArgumentListFixFactory.kt @@ -0,0 +1,16 @@ +// 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.AddEmptyArgumentListFix +import org.jetbrains.kotlin.psi.KtCallExpression + +internal object AddEmptyArgumentListFixFactory { + + val addEmptyArgumentListFixFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.ModifierFormForNonBuiltInSuspend -> + listOfNotNull( + (diagnostic.psi as? KtCallExpression)?.let { AddEmptyArgumentListFix(it) } + ) + } +} 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 79ba7b8963fc..ed18cc03b812 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 @@ -122,6 +122,7 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() { registerFactory(LiftAssignmentOutOfTryFixFactory.liftAssignmentOutOfTryFix) registerFactory(RenameModToRemFixFactory.deprecatedBinaryModFactory) registerFactory(RenameModToRemFixFactory.forbiddenBinaryModFactory) + registerFactory(AddEmptyArgumentListFixFactory.addEmptyArgumentListFixFactory) } private val addAbstract = 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 2c194321d4d1..8b4bc3cd7a5e 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 @@ -5736,7 +5736,24 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu } } + @RunWith(JUnit3RunnerWithInners.class) + @TestMetadata("../../../idea/tests/testData/quickfix/addEmptyArgumentList") + public static class AddEmptyArgumentList 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("suspend.kt") + public void testSuspend() throws Exception { + runTest("../../../idea/tests/testData/quickfix/addEmptyArgumentList/suspend.kt"); + } + } @RunWith(JUnit3RunnerWithInners.class) @TestMetadata("../../../idea/tests/testData/quickfix/addEqEqTrue") diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEmptyArgumentList/suspend.kt b/plugins/kotlin/idea/tests/testData/quickfix/addEmptyArgumentList/suspend.kt index 458a759afb43..61e09c9297c2 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/addEmptyArgumentList/suspend.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEmptyArgumentList/suspend.kt @@ -4,4 +4,5 @@ fun suspend(fn: () -> Unit) {} fun callSuspend() { suspend { } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEmptyArgumentListFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEmptyArgumentListFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEmptyArgumentListFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEmptyArgumentList/suspend.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/addEmptyArgumentList/suspend.kt.after index 2c0cc4ccd2d6..45d8978fd250 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/addEmptyArgumentList/suspend.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEmptyArgumentList/suspend.kt.after @@ -4,4 +4,5 @@ fun suspend(fn: () -> Unit) {} fun callSuspend() { suspend() { } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEmptyArgumentListFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEmptyArgumentListFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEmptyArgumentListFix \ 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 cf898c0c5b74..574e8e0aff18 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 @@ -68,7 +68,7 @@ internal fun MutableTWorkspace.generateK2FixTests() { model("$idea/quickfix/addDataModifier", pattern = pattern) model("$idea/quickfix/addDefaultConstructor", pattern = pattern, isIgnored = true) model("$idea/quickfix/addElseBranchToIf", pattern = pattern) - model("$idea/quickfix/addEmptyArgumentList", pattern = pattern, isIgnored = true) + model("$idea/quickfix/addEmptyArgumentList", pattern = pattern) model("$idea/quickfix/addEqEqTrue", pattern = pattern) model("$idea/quickfix/addFunModifier", pattern = pattern) model("$idea/quickfix/addGenericUpperBound", pattern = pattern, isIgnored = true)