[kotlin] Add noinline quickfix: remove crossinline modifier
authorToshiaki Kameyama <kmymtsak@gmail.com>
Sat, 13 Aug 2022 04:34:40 +0000 (13:34 +0900)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Sat, 13 Aug 2022 09:08:05 +0000 (09:08 +0000)
^KTIJ-22302 Fixed

closes https://github.com/JetBrains/intellij-community/pull/2103

GitOrigin-RevId: 0c0e20d5befc0ab875cabec75d3c04bd4161b20d

plugins/kotlin/frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt
plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java
plugins/kotlin/idea/tests/testData/quickfix/addNoinline/withCrossinline.kt [new file with mode: 0644]
plugins/kotlin/idea/tests/testData/quickfix/addNoinline/withCrossinline.kt.after [new file with mode: 0644]

index fb92c91e52f3104abdd95b3273fedadc62c0e678..42dc416f56376c21352dfdac79a34b7004048681 100644 (file)
@@ -43,6 +43,10 @@ open class AddModifierFix(
                 }
             }
         }
+
+        if (modifier == KtTokens.NOINLINE_KEYWORD) {
+            element?.removeModifier(KtTokens.CROSSINLINE_KEYWORD)
+        }
     }
 
     override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) {
index 00b2ee5f195e8ccd1e098df10e2b0a42620976db..e08034eb964d92116525e0a90559a2bfe9a71f14 100644 (file)
@@ -1257,6 +1257,11 @@ public abstract class QuickFixTestGenerated extends AbstractQuickFixTest {
         public void testSuspend() throws Exception {
             runTest("testData/quickfix/addNoinline/suspend.kt");
         }
+
+        @TestMetadata("withCrossinline.kt")
+        public void testWithCrossinline() throws Exception {
+            runTest("testData/quickfix/addNoinline/withCrossinline.kt");
+        }
     }
 
     @RunWith(JUnit3RunnerWithInners.class)
diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addNoinline/withCrossinline.kt b/plugins/kotlin/idea/tests/testData/quickfix/addNoinline/withCrossinline.kt
new file mode 100644 (file)
index 0000000..016b048
--- /dev/null
@@ -0,0 +1,5 @@
+// "Add 'noinline' to parameter 'lambda'" "true"
+// WITH_STDLIB
+inline fun inlineFun(crossinline lambda: () -> Unit) {
+    <caret>lambda.toString()
+}
\ No newline at end of file
diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addNoinline/withCrossinline.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/addNoinline/withCrossinline.kt.after
new file mode 100644 (file)
index 0000000..e60514f
--- /dev/null
@@ -0,0 +1,5 @@
+// "Add 'noinline' to parameter 'lambda'" "true"
+// WITH_STDLIB
+inline fun inlineFun(noinline lambda: () -> Unit) {
+    lambda.toString()
+}
\ No newline at end of file