diff --git a/plugins/kotlin/code-insight/intentions-k2/tests/test/org/jetbrains/kotlin/idea/k2/intentions/tests/K2IntentionTestGenerated.java b/plugins/kotlin/code-insight/intentions-k2/tests/test/org/jetbrains/kotlin/idea/k2/intentions/tests/K2IntentionTestGenerated.java
index 95578fa3c982..516d2f294168 100644
--- a/plugins/kotlin/code-insight/intentions-k2/tests/test/org/jetbrains/kotlin/idea/k2/intentions/tests/K2IntentionTestGenerated.java
+++ b/plugins/kotlin/code-insight/intentions-k2/tests/test/org/jetbrains/kotlin/idea/k2/intentions/tests/K2IntentionTestGenerated.java
@@ -7445,7 +7445,590 @@ public abstract class K2IntentionTestGenerated extends AbstractK2IntentionTest {
+ @RunWith(JUnit3RunnerWithInners.class)
+ @TestMetadata("../../../idea/tests/testData/intentions/convertToScope")
+ public abstract static class ConvertToScope extends AbstractK2IntentionTest {
+ @RunWith(JUnit3RunnerWithInners.class)
+ @TestMetadata("../../../idea/tests/testData/intentions/convertToScope/convertToAlso")
+ public static class ConvertToAlso extends AbstractK2IntentionTest {
+ @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("callExpression.kt")
+ public void testCallExpression() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/callExpression.kt");
+ }
+
+ @TestMetadata("callExpression2.kt")
+ public void testCallExpression2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/callExpression2.kt");
+ }
+
+ @TestMetadata("callExpression3.kt")
+ public void testCallExpression3() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/callExpression3.kt");
+ }
+
+ @TestMetadata("callExpression4.kt")
+ public void testCallExpression4() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/callExpression4.kt");
+ }
+
+ @TestMetadata("callExpression5.kt")
+ public void testCallExpression5() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/callExpression5.kt");
+ }
+
+ @TestMetadata("itParameter.kt")
+ public void testItParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/itParameter.kt");
+ }
+
+ @TestMetadata("itParameter2.kt")
+ public void testItParameter2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/itParameter2.kt");
+ }
+
+ @TestMetadata("methodChain.kt")
+ public void testMethodChain() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/methodChain.kt");
+ }
+
+ @TestMetadata("methodChainWithItParameter.kt")
+ public void testMethodChainWithItParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/methodChainWithItParameter.kt");
+ }
+
+ @TestMetadata("methodChainWithThisParameter.kt")
+ public void testMethodChainWithThisParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/methodChainWithThisParameter.kt");
+ }
+
+ @TestMetadata("normal.kt")
+ public void testNormal() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/normal.kt");
+ }
+
+ @TestMetadata("normal2.kt")
+ public void testNormal2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/normal2.kt");
+ }
+
+ @TestMetadata("normal3.kt")
+ public void testNormal3() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/normal3.kt");
+ }
+
+ @TestMetadata("normal4.kt")
+ public void testNormal4() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/normal4.kt");
+ }
+
+ @TestMetadata("onProperty.kt")
+ public void testOnProperty() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/onProperty.kt");
+ }
+
+ @TestMetadata("singleCall.kt")
+ public void testSingleCall() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/singleCall.kt");
+ }
+
+ @TestMetadata("untilItParameter.kt")
+ public void testUntilItParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/untilItParameter.kt");
+ }
+
+ @TestMetadata("var.kt")
+ public void testVar() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/var.kt");
+ }
+
+ @TestMetadata("withCommentAndSpaces.kt")
+ public void testWithCommentAndSpaces() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/withCommentAndSpaces.kt");
+ }
+
+ @TestMetadata("withDifficultRenaming.kt")
+ public void testWithDifficultRenaming() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/withDifficultRenaming.kt");
+ }
+
+ @TestMetadata("withNotSimpleInitializer.kt")
+ public void testWithNotSimpleInitializer() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/withNotSimpleInitializer.kt");
+ }
+
+ @TestMetadata("withNotSimpleInitializer2.kt")
+ public void testWithNotSimpleInitializer2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToAlso/withNotSimpleInitializer2.kt");
+ }
+ }
+
+ @RunWith(JUnit3RunnerWithInners.class)
+ @TestMetadata("../../../idea/tests/testData/intentions/convertToScope/convertToApply")
+ public static class ConvertToApply extends AbstractK2IntentionTest {
+ @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("binaryExpression.kt")
+ public void testBinaryExpression() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/binaryExpression.kt");
+ }
+
+ @TestMetadata("binaryExpression2.kt")
+ public void testBinaryExpression2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/binaryExpression2.kt");
+ }
+
+ @TestMetadata("binaryExpression3.kt")
+ public void testBinaryExpression3() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/binaryExpression3.kt");
+ }
+
+ @TestMetadata("binaryExpression4.kt")
+ public void testBinaryExpression4() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/binaryExpression4.kt");
+ }
+
+ @TestMetadata("binaryExpression5.kt")
+ public void testBinaryExpression5() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/binaryExpression5.kt");
+ }
+
+ @TestMetadata("callExpression.kt")
+ public void testCallExpression() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/callExpression.kt");
+ }
+
+ @TestMetadata("callExpression2.kt")
+ public void testCallExpression2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/callExpression2.kt");
+ }
+
+ @TestMetadata("callExpression3.kt")
+ public void testCallExpression3() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/callExpression3.kt");
+ }
+
+ @TestMetadata("callExpression4.kt")
+ public void testCallExpression4() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/callExpression4.kt");
+ }
+
+ @TestMetadata("callExpression5.kt")
+ public void testCallExpression5() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/callExpression5.kt");
+ }
+
+ @TestMetadata("methodChain.kt")
+ public void testMethodChain() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/methodChain.kt");
+ }
+
+ @TestMetadata("methodChainWithItParameter.kt")
+ public void testMethodChainWithItParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/methodChainWithItParameter.kt");
+ }
+
+ @TestMetadata("methodChainWithThisParameter.kt")
+ public void testMethodChainWithThisParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/methodChainWithThisParameter.kt");
+ }
+
+ @TestMetadata("normal.kt")
+ public void testNormal() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/normal.kt");
+ }
+
+ @TestMetadata("normal2.kt")
+ public void testNormal2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/normal2.kt");
+ }
+
+ @TestMetadata("normal3.kt")
+ public void testNormal3() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/normal3.kt");
+ }
+
+ @TestMetadata("normal4.kt")
+ public void testNormal4() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/normal4.kt");
+ }
+
+ @TestMetadata("onProperty.kt")
+ public void testOnProperty() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/onProperty.kt");
+ }
+
+ @TestMetadata("singleCall.kt")
+ public void testSingleCall() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/singleCall.kt");
+ }
+
+ @TestMetadata("thisParameter.kt")
+ public void testThisParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/thisParameter.kt");
+ }
+
+ @TestMetadata("thisParameter2.kt")
+ public void testThisParameter2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/thisParameter2.kt");
+ }
+
+ @TestMetadata("untilThisParameter.kt")
+ public void testUntilThisParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/untilThisParameter.kt");
+ }
+
+ @TestMetadata("var.kt")
+ public void testVar() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/var.kt");
+ }
+
+ @TestMetadata("withCommentAndSpaces.kt")
+ public void testWithCommentAndSpaces() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/withCommentAndSpaces.kt");
+ }
+
+ @TestMetadata("withDifficultRenaming.kt")
+ public void testWithDifficultRenaming() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/withDifficultRenaming.kt");
+ }
+
+ @TestMetadata("withNotSimpleInitializer.kt")
+ public void testWithNotSimpleInitializer() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/withNotSimpleInitializer.kt");
+ }
+
+ @TestMetadata("withNotSimpleInitializer2.kt")
+ public void testWithNotSimpleInitializer2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToApply/withNotSimpleInitializer2.kt");
+ }
+ }
+
+ @RunWith(JUnit3RunnerWithInners.class)
+ @TestMetadata("../../../idea/tests/testData/intentions/convertToScope/convertToRun")
+ public static class ConvertToRun extends AbstractK2IntentionTest {
+ @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("binaryExpression.kt")
+ public void testBinaryExpression() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/binaryExpression.kt");
+ }
+
+ @TestMetadata("binaryExpression2.kt")
+ public void testBinaryExpression2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/binaryExpression2.kt");
+ }
+
+ @TestMetadata("binaryExpression3.kt")
+ public void testBinaryExpression3() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/binaryExpression3.kt");
+ }
+
+ @TestMetadata("callExpression.kt")
+ public void testCallExpression() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/callExpression.kt");
+ }
+
+ @TestMetadata("callExpression2.kt")
+ public void testCallExpression2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/callExpression2.kt");
+ }
+
+ @TestMetadata("chainCallExpression.kt")
+ public void testChainCallExpression() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/chainCallExpression.kt");
+ }
+
+ @TestMetadata("insideLambdaExpression.kt")
+ public void testInsideLambdaExpression() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/insideLambdaExpression.kt");
+ }
+
+ @TestMetadata("itReceiver.kt")
+ public void testItReceiver() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/itReceiver.kt");
+ }
+
+ @TestMetadata("javaMethod.kt")
+ public void testJavaMethod() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/javaMethod.kt");
+ }
+
+ @TestMetadata("javaStaticMethod.kt")
+ public void testJavaStaticMethod() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/javaStaticMethod.kt");
+ }
+
+ @TestMetadata("methodChain.kt")
+ public void testMethodChain() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/methodChain.kt");
+ }
+
+ @TestMetadata("methodChainWithItParameter.kt")
+ public void testMethodChainWithItParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/methodChainWithItParameter.kt");
+ }
+
+ @TestMetadata("methodChainWithThisParameter.kt")
+ public void testMethodChainWithThisParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/methodChainWithThisParameter.kt");
+ }
+
+ @TestMetadata("nestedClass.kt")
+ public void testNestedClass() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/nestedClass.kt");
+ }
+
+ @TestMetadata("nestedObject.kt")
+ public void testNestedObject() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/nestedObject.kt");
+ }
+
+ @TestMetadata("normal.kt")
+ public void testNormal() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/normal.kt");
+ }
+
+ @TestMetadata("normal2.kt")
+ public void testNormal2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/normal2.kt");
+ }
+
+ @TestMetadata("normal3.kt")
+ public void testNormal3() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/normal3.kt");
+ }
+
+ @TestMetadata("normal4.kt")
+ public void testNormal4() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/normal4.kt");
+ }
+
+ @TestMetadata("normal5.kt")
+ public void testNormal5() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/normal5.kt");
+ }
+
+ @TestMetadata("onProperty.kt")
+ public void testOnProperty() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/onProperty.kt");
+ }
+
+ @TestMetadata("package.kt")
+ public void testPackage() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/package.kt");
+ }
+
+ @TestMetadata("singleCall.kt")
+ public void testSingleCall() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/singleCall.kt");
+ }
+
+ @TestMetadata("thisParameter.kt")
+ public void testThisParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/thisParameter.kt");
+ }
+
+ @TestMetadata("thisReceiver.kt")
+ public void testThisReceiver() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/thisReceiver.kt");
+ }
+
+ @TestMetadata("untilThisParameter.kt")
+ public void testUntilThisParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/untilThisParameter.kt");
+ }
+
+ @TestMetadata("withCommentAndSpaces.kt")
+ public void testWithCommentAndSpaces() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/withCommentAndSpaces.kt");
+ }
+
+ @TestMetadata("withDifficultRenaming.kt")
+ public void testWithDifficultRenaming() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/withDifficultRenaming.kt");
+ }
+
+ @TestMetadata("withNotSimpleInitializer.kt")
+ public void testWithNotSimpleInitializer() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/withNotSimpleInitializer.kt");
+ }
+
+ @TestMetadata("withNotSimpleInitializer2.kt")
+ public void testWithNotSimpleInitializer2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToRun/withNotSimpleInitializer2.kt");
+ }
+ }
+
+ @RunWith(JUnit3RunnerWithInners.class)
+ @TestMetadata("../../../idea/tests/testData/intentions/convertToScope/convertToWith")
+ public static class ConvertToWith extends AbstractK2IntentionTest {
+ @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("callExpression.kt")
+ public void testCallExpression() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/callExpression.kt");
+ }
+
+ @TestMetadata("callExpression2.kt")
+ public void testCallExpression2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/callExpression2.kt");
+ }
+
+ @TestMetadata("itReceiver.kt")
+ public void testItReceiver() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/itReceiver.kt");
+ }
+
+ @TestMetadata("javaMethod.kt")
+ public void testJavaMethod() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/javaMethod.kt");
+ }
+
+ @TestMetadata("javaStaticMethod.kt")
+ public void testJavaStaticMethod() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/javaStaticMethod.kt");
+ }
+
+ @TestMetadata("methodChain.kt")
+ public void testMethodChain() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/methodChain.kt");
+ }
+
+ @TestMetadata("methodChainWithItParameter.kt")
+ public void testMethodChainWithItParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/methodChainWithItParameter.kt");
+ }
+
+ @TestMetadata("methodChainWithThisParameter.kt")
+ public void testMethodChainWithThisParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/methodChainWithThisParameter.kt");
+ }
+
+ @TestMetadata("nestedClass.kt")
+ public void testNestedClass() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/nestedClass.kt");
+ }
+
+ @TestMetadata("nestedObject.kt")
+ public void testNestedObject() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/nestedObject.kt");
+ }
+
+ @TestMetadata("normal.kt")
+ public void testNormal() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/normal.kt");
+ }
+
+ @TestMetadata("normal2.kt")
+ public void testNormal2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/normal2.kt");
+ }
+
+ @TestMetadata("normal3.kt")
+ public void testNormal3() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/normal3.kt");
+ }
+
+ @TestMetadata("normal4.kt")
+ public void testNormal4() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/normal4.kt");
+ }
+
+ @TestMetadata("normal5.kt")
+ public void testNormal5() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/normal5.kt");
+ }
+
+ @TestMetadata("onProperty.kt")
+ public void testOnProperty() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/onProperty.kt");
+ }
+
+ @TestMetadata("package.kt")
+ public void testPackage() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/package.kt");
+ }
+
+ @TestMetadata("parameterExpression.kt")
+ public void testParameterExpression() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/parameterExpression.kt");
+ }
+
+ @TestMetadata("singleCall.kt")
+ public void testSingleCall() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/singleCall.kt");
+ }
+
+ @TestMetadata("thisParameter.kt")
+ public void testThisParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/thisParameter.kt");
+ }
+
+ @TestMetadata("thisReceiver.kt")
+ public void testThisReceiver() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/thisReceiver.kt");
+ }
+
+ @TestMetadata("untilThisParameter.kt")
+ public void testUntilThisParameter() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/untilThisParameter.kt");
+ }
+
+ @TestMetadata("withCommentAndSpaces.kt")
+ public void testWithCommentAndSpaces() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/withCommentAndSpaces.kt");
+ }
+
+ @TestMetadata("withDifficultRenaming.kt")
+ public void testWithDifficultRenaming() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/withDifficultRenaming.kt");
+ }
+
+ @TestMetadata("withNotSimpleInitializer.kt")
+ public void testWithNotSimpleInitializer() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/withNotSimpleInitializer.kt");
+ }
+
+ @TestMetadata("withNotSimpleInitializer2.kt")
+ public void testWithNotSimpleInitializer2() throws Exception {
+ runTest("../../../idea/tests/testData/intentions/convertToScope/convertToWith/withNotSimpleInitializer2.kt");
+ }
+ }
+ }
diff --git a/plugins/kotlin/code-insight/intentions-shared/kotlin.code-insight.intentions.shared.iml b/plugins/kotlin/code-insight/intentions-shared/kotlin.code-insight.intentions.shared.iml
index 95bd1b9c7d5b..9390cf6ef368 100644
--- a/plugins/kotlin/code-insight/intentions-shared/kotlin.code-insight.intentions.shared.iml
+++ b/plugins/kotlin/code-insight/intentions-shared/kotlin.code-insight.intentions.shared.iml
@@ -47,5 +47,7 @@
+
+
\ No newline at end of file
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToAlsoIntention/after.kt.template b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToAlsoIntention/after.kt.template
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToAlsoIntention/after.kt.template
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToAlsoIntention/after.kt.template
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToAlsoIntention/before.kt.template b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToAlsoIntention/before.kt.template
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToAlsoIntention/before.kt.template
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToAlsoIntention/before.kt.template
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToAlsoIntention/description.html b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToAlsoIntention/description.html
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToAlsoIntention/description.html
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToAlsoIntention/description.html
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToApplyIntention/after.kt.template b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToApplyIntention/after.kt.template
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToApplyIntention/after.kt.template
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToApplyIntention/after.kt.template
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToApplyIntention/before.kt.template b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToApplyIntention/before.kt.template
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToApplyIntention/before.kt.template
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToApplyIntention/before.kt.template
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToApplyIntention/description.html b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToApplyIntention/description.html
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToApplyIntention/description.html
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToApplyIntention/description.html
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToRunIntention/after.kt.template b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToRunIntention/after.kt.template
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToRunIntention/after.kt.template
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToRunIntention/after.kt.template
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToRunIntention/before.kt.template b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToRunIntention/before.kt.template
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToRunIntention/before.kt.template
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToRunIntention/before.kt.template
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToRunIntention/description.html b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToRunIntention/description.html
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToRunIntention/description.html
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToRunIntention/description.html
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToWithIntention/after.kt.template b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToWithIntention/after.kt.template
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToWithIntention/after.kt.template
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToWithIntention/after.kt.template
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToWithIntention/before.kt.template b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToWithIntention/before.kt.template
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToWithIntention/before.kt.template
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToWithIntention/before.kt.template
diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToWithIntention/description.html b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToWithIntention/description.html
similarity index 100%
rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/ConvertToWithIntention/description.html
rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/ConvertToWithIntention/description.html
diff --git a/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions.shared.xml b/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions.shared.xml
index 4557ce975437..0a180d8b9636 100644
--- a/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions.shared.xml
+++ b/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions.shared.xml
@@ -223,5 +223,33 @@
messages.KotlinBundle
group.names.kotlin
+
+
+ kotlin
+ org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToApplyIntention
+ messages.KotlinBundle
+ group.names.kotlin
+
+
+
+ kotlin
+ org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToAlsoIntention
+ messages.KotlinBundle
+ group.names.kotlin
+
+
+
+ kotlin
+ org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToWithIntention
+ messages.KotlinBundle
+ group.names.kotlin
+
+
+
+ kotlin
+ org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToRunIntention
+ messages.KotlinBundle
+ group.names.kotlin
+
\ No newline at end of file
diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToScopeIntention.kt b/plugins/kotlin/code-insight/intentions-shared/src/org/jetbrains/kotlin/idea/codeInsight/intentions/shared/ConvertToScopeIntention.kt
similarity index 79%
rename from plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToScopeIntention.kt
rename to plugins/kotlin/code-insight/intentions-shared/src/org/jetbrains/kotlin/idea/codeInsight/intentions/shared/ConvertToScopeIntention.kt
index 7f2947eab3f0..4e646005577e 100644
--- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToScopeIntention.kt
+++ b/plugins/kotlin/code-insight/intentions-shared/src/org/jetbrains/kotlin/idea/codeInsight/intentions/shared/ConvertToScopeIntention.kt
@@ -1,10 +1,13 @@
-// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
-
-package org.jetbrains.kotlin.idea.intentions
+// 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.codeInsight.intentions.shared
import com.intellij.java.refactoring.JavaRefactoringBundle
import com.intellij.openapi.editor.Editor
-import com.intellij.psi.*
+import com.intellij.psi.PsiClass
+import com.intellij.psi.PsiComment
+import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiPackage
+import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.impl.source.tree.LeafPsiElement
import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.psi.util.PsiTreeUtil
@@ -12,14 +15,28 @@ import com.intellij.refactoring.RefactoringBundle
import com.intellij.refactoring.util.CommonRefactoringUtil
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
-import org.jetbrains.kotlin.idea.intentions.ConvertToScopeIntention.ScopeFunction.*
-import org.jetbrains.kotlin.idea.references.mainReference
-import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchParameters
import org.jetbrains.kotlin.idea.base.util.useScope
import org.jetbrains.kotlin.idea.codeinsight.api.classic.intentions.SelfTargetingIntention
+import org.jetbrains.kotlin.idea.codeinsight.utils.callExpression
import org.jetbrains.kotlin.idea.codeinsight.utils.getLeftMostReceiverExpression
+import org.jetbrains.kotlin.idea.references.mainReference
+import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchParameters
import org.jetbrains.kotlin.lexer.KtTokens
-import org.jetbrains.kotlin.psi.*
+import org.jetbrains.kotlin.psi.KtBinaryExpression
+import org.jetbrains.kotlin.psi.KtBlockExpression
+import org.jetbrains.kotlin.psi.KtCallExpression
+import org.jetbrains.kotlin.psi.KtClassOrObject
+import org.jetbrains.kotlin.psi.KtConstantExpression
+import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
+import org.jetbrains.kotlin.psi.KtExpression
+import org.jetbrains.kotlin.psi.KtNameReferenceExpression
+import org.jetbrains.kotlin.psi.KtParenthesizedExpression
+import org.jetbrains.kotlin.psi.KtProperty
+import org.jetbrains.kotlin.psi.KtPsiFactory
+import org.jetbrains.kotlin.psi.KtQualifiedExpression
+import org.jetbrains.kotlin.psi.KtThisExpression
+import org.jetbrains.kotlin.psi.KtValueArgument
+import org.jetbrains.kotlin.psi.createExpressionByPattern
import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType
import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForReceiver
@@ -27,8 +44,8 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) : SelfTargetingIntention(
- KtExpression::class.java,
- KotlinBundle.lazyMessage("convert.to.0", scopeFunction.functionName)
+ KtExpression::class.java,
+ KotlinBundle.lazyMessage("convert.to.0", scopeFunction.functionName)
) {
enum class ScopeFunction(val functionName: String, val isParameterScope: Boolean) {
ALSO(functionName = "also", isParameterScope = true),
@@ -40,13 +57,13 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
}
private data class RefactoringTargetAndItsValueExpression(
- val targetElement: PsiElement,
- val targetElementValue: PsiElement
+ val targetElement: PsiElement,
+ val targetElementValue: PsiElement
)
private data class ScopedFunctionCallAndBlock(
- val scopeFunctionCall: KtExpression,
- val block: KtBlockExpression
+ val scopeFunctionCall: KtExpression,
+ val block: KtBlockExpression
)
override fun isApplicableTo(element: KtExpression, caretOffset: Int) = tryApplyTo(element, dryRun = true)
@@ -54,7 +71,7 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
override fun applyTo(element: KtExpression, editor: Editor?) {
if (!tryApplyTo(element, dryRun = false)) {
val message = RefactoringBundle.getCannotRefactorMessage(
- JavaRefactoringBundle.message("refactoring.is.not.supported.in.the.current.context", text)
+ JavaRefactoringBundle.message("refactoring.is.not.supported.in.the.current.context", text)
)
CommonRefactoringUtil.showErrorHint(element.project, editor, message, text, null)
}
@@ -114,7 +131,7 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
private fun removeRedundantThisQualifiers(block: KtBlockExpression) {
val thisDotSomethingExpressions = block.collectDescendantsOfType {
- it.receiverExpression is KtThisExpression && it.selectorExpression !== null
+ it.receiverExpression is KtThisExpression && it.selectorExpression !== null
}
thisDotSomethingExpressions.forEach { thisDotSomethingExpression ->
@@ -125,22 +142,22 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
}
private fun tryGetFirstElementToRefactoring(
- expressionToApply: KtExpression,
- firstTarget: PsiElement,
- lastTarget: PsiElement,
- referenceElement: PsiElement
+ expressionToApply: KtExpression,
+ firstTarget: PsiElement,
+ lastTarget: PsiElement,
+ referenceElement: PsiElement
): RefactoringTargetAndItsValueExpression? {
val property = expressionToApply.prevProperty()
val propertyOrFirst = when (scopeFunction) {
- ALSO, APPLY -> property
- RUN, WITH -> firstTarget
+ ScopeFunction.ALSO, ScopeFunction.APPLY -> property
+ ScopeFunction.RUN, ScopeFunction.WITH -> firstTarget
} ?: return null
val isCorrectFirstOrProperty = when (scopeFunction) {
- ALSO, APPLY -> propertyOrFirst is KtProperty && propertyOrFirst.name !== null && propertyOrFirst.initializer !== null
- RUN -> propertyOrFirst is KtDotQualifiedExpression
- WITH -> propertyOrFirst is KtDotQualifiedExpression
+ ScopeFunction.ALSO, ScopeFunction.APPLY -> propertyOrFirst is KtProperty && propertyOrFirst.name !== null && propertyOrFirst.initializer !== null
+ ScopeFunction.RUN -> propertyOrFirst is KtDotQualifiedExpression
+ ScopeFunction.WITH -> propertyOrFirst is KtDotQualifiedExpression
}
if (!isCorrectFirstOrProperty) return null
@@ -160,7 +177,7 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
}
val searchParameters = KotlinReferencesSearchParameters(
- element, element.useScope(), ignoreAccessScope = false
+ element, element.useScope(), ignoreAccessScope = false
)
val range = PsiTreeUtil.getElementsOfRange(firstTarget, lastTarget)
@@ -177,12 +194,12 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
private fun KtExpression.tryExtractReferenceName(): Pair? {
return when (scopeFunction) {
- ALSO, APPLY -> {
+ ScopeFunction.ALSO, ScopeFunction.APPLY -> {
val property = prevProperty()
val name = property?.name
if (name !== null) property to name else null
}
- RUN, WITH -> {
+ ScopeFunction.RUN, ScopeFunction.WITH -> {
val receiver = safeAs()?.getLeftMostReceiverExpression() as? KtNameReferenceExpression
val declaration = receiver?.mainReference?.resolve()?.takeUnless { it is PsiPackage } ?: return null
val selector = receiver.getQualifiedExpressionForReceiver()?.selectorExpression
@@ -195,7 +212,7 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
private fun KtExpression.collectTargetElementsRange(referenceName: String, greedy: Boolean): Pair? {
return when (scopeFunction) {
- ALSO, APPLY -> {
+ ScopeFunction.ALSO, ScopeFunction.APPLY -> {
val firstTarget = this as? KtProperty ?: this.prevProperty() ?: this
val lastTargetSequence = firstTarget.collectTargetElements(referenceName, forward = true)
@@ -209,7 +226,7 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
if (lastTarget !== null) firstTarget to lastTarget else null
}
- RUN, WITH -> {
+ ScopeFunction.RUN, ScopeFunction.WITH -> {
val firstTarget = collectTargetElements(referenceName, forward = false).lastOrNull() ?: this
@@ -267,7 +284,7 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
private fun createScopeFunctionCall(factory: KtPsiFactory, element: PsiElement): ScopedFunctionCallAndBlock? {
val scopeFunctionName = scopeFunction.functionName
val (scopeFunctionCall, callExpression) = when (scopeFunction) {
- ALSO, APPLY -> {
+ ScopeFunction.ALSO, ScopeFunction.APPLY -> {
if (element !is KtProperty) return null
val propertyName = element.name ?: return null
val initializer = element.initializer ?: return null
@@ -286,7 +303,7 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
val callExpression = (property.initializer as? KtDotQualifiedExpression)?.callExpression ?: return null
property to callExpression
}
- RUN -> {
+ ScopeFunction.RUN -> {
if (element !is KtDotQualifiedExpression) return null
val scopeFunctionCall = factory.createExpressionByPattern(
"$0.$scopeFunctionName {}",
@@ -295,7 +312,7 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
val callExpression = scopeFunctionCall.callExpression ?: return null
scopeFunctionCall to callExpression
}
- WITH -> {
+ ScopeFunction.WITH -> {
if (element !is KtDotQualifiedExpression) return null
val scopeFunctionCall = factory.createExpressionByPattern(
@@ -316,10 +333,19 @@ sealed class ConvertToScopeIntention(private val scopeFunction: ScopeFunction) :
}
}
-class ConvertToAlsoIntention : ConvertToScopeIntention(ALSO)
+private fun Sequence.lastWithPersistedElementOrNull(elementShouldPersist: KtExpression): PsiElement? {
+ var lastElement: PsiElement? = null
+ var checked = false
-class ConvertToApplyIntention : ConvertToScopeIntention(APPLY)
+ for (element in this) {
+ checked = checked || (element === elementShouldPersist)
+ lastElement = element
+ }
-class ConvertToRunIntention : ConvertToScopeIntention(RUN)
+ return if (checked) lastElement else null
+}
-class ConvertToWithIntention : ConvertToScopeIntention(WITH)
+class ConvertToAlsoIntention : ConvertToScopeIntention(ScopeFunction.ALSO)
+class ConvertToApplyIntention : ConvertToScopeIntention(ScopeFunction.APPLY)
+class ConvertToRunIntention : ConvertToScopeIntention(ScopeFunction.RUN)
+class ConvertToWithIntention : ConvertToScopeIntention(ScopeFunction.WITH)
\ No newline at end of file
diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt
index 5129262d330d..0bce32568d65 100644
--- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt
+++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt
@@ -183,18 +183,6 @@ val FunctionDescriptor.isOperatorOrCompatible: Boolean
return isOperator
}
-internal fun Sequence.lastWithPersistedElementOrNull(elementShouldPersist: KtExpression): PsiElement? {
- var lastElement: PsiElement? = null
- var checked = false
-
- for (element in this) {
- checked = checked || (element === elementShouldPersist)
- lastElement = element
- }
-
- return if (checked) lastElement else null
-}
-
fun KotlinType.reflectToRegularFunctionType(): KotlinType {
val isTypeAnnotatedWithExtensionFunctionType = annotations.findAnnotation(StandardNames.FqNames.extensionFunctionType) != null
val parameterCount = if (isTypeAnnotatedWithExtensionFunctionType) arguments.size - 2 else arguments.size - 1
diff --git a/plugins/kotlin/idea/tests/kotlin.idea.tests.iml b/plugins/kotlin/idea/tests/kotlin.idea.tests.iml
index a8c8ddd931f7..a9afc92fe52f 100644
--- a/plugins/kotlin/idea/tests/kotlin.idea.tests.iml
+++ b/plugins/kotlin/idea/tests/kotlin.idea.tests.iml
@@ -140,5 +140,6 @@
+
\ No newline at end of file
diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/propertyBased/KotlinIntentionPolicy.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/propertyBased/KotlinIntentionPolicy.kt
index 67aebcf17732..4f430b956c17 100644
--- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/propertyBased/KotlinIntentionPolicy.kt
+++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/propertyBased/KotlinIntentionPolicy.kt
@@ -7,7 +7,7 @@ import com.intellij.codeInsight.intention.IntentionActionDelegate
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiFile
import com.intellij.testFramework.propertyBased.IntentionPolicy
-import org.jetbrains.kotlin.idea.intentions.ConvertToScopeIntention
+import org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToScopeIntention
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.CreateCallableFromUsageFixBase
import org.jetbrains.kotlin.idea.refactoring.move.changePackage.ChangePackageIntention
@@ -27,10 +27,10 @@ internal class KotlinIntentionPolicy : IntentionPolicy() {
override fun shouldCheckPreview(action: IntentionAction): Boolean {
val unwrapped = IntentionActionDelegate.unwrap(action)
val skipPreview =
- action.familyName == "Create from usage" || // Starts template but may also perform modifications before that; thus not so easy to support
- unwrapped is ConvertToScopeIntention || // Performs reference search which must be run under progress. Probably we can generate diff excluding references?..
- unwrapped is CreateCallableFromUsageFixBase<*> || // Performs too much of complex stuff. Not sure whether it should start in write action...
- unwrapped is ChangePackageIntention // Just starts the template; no reasonable preview could be displayed
+ action.familyName == "Create from usage" || // Starts template but may also perform modifications before that; thus not so easy to support
+ unwrapped is ConvertToScopeIntention || // Performs reference search which must be run under progress. Probably we can generate diff excluding references?..
+ unwrapped is CreateCallableFromUsageFixBase<*> || // Performs too much of complex stuff. Not sure whether it should start in write action...
+ unwrapped is ChangePackageIntention // Just starts the template; no reasonable preview could be displayed
return !skipPreview
}
}
diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToAlso/.intention b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToAlso/.intention
index fd5cb528d26a..d743253501b3 100644
--- a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToAlso/.intention
+++ b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToAlso/.intention
@@ -1 +1 @@
-org.jetbrains.kotlin.idea.intentions.ConvertToAlsoIntention
+org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToAlsoIntention
diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToAlso/.k2Intention b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToAlso/.k2Intention
new file mode 100644
index 000000000000..d743253501b3
--- /dev/null
+++ b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToAlso/.k2Intention
@@ -0,0 +1 @@
+org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToAlsoIntention
diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToApply/.intention b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToApply/.intention
index f75db9df661a..90691f8ae57c 100644
--- a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToApply/.intention
+++ b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToApply/.intention
@@ -1 +1 @@
-org.jetbrains.kotlin.idea.intentions.ConvertToApplyIntention
+org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToApplyIntention
diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToApply/.k2Intention b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToApply/.k2Intention
new file mode 100644
index 000000000000..36f7a7e5aaa1
--- /dev/null
+++ b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToApply/.k2Intention
@@ -0,0 +1 @@
+org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToApplyIntention
\ No newline at end of file
diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToRun/.intention b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToRun/.intention
index bc70a083d5ca..37a89298fb50 100644
--- a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToRun/.intention
+++ b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToRun/.intention
@@ -1 +1 @@
-org.jetbrains.kotlin.idea.intentions.ConvertToRunIntention
+org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToRunIntention
diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToRun/.k2Intention b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToRun/.k2Intention
new file mode 100644
index 000000000000..37a89298fb50
--- /dev/null
+++ b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToRun/.k2Intention
@@ -0,0 +1 @@
+org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToRunIntention
diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToWith/.intention b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToWith/.intention
index 1f4f2f8021da..444274bc1371 100644
--- a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToWith/.intention
+++ b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToWith/.intention
@@ -1 +1 @@
-org.jetbrains.kotlin.idea.intentions.ConvertToWithIntention
+org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToWithIntention
diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToWith/.k2Intention b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToWith/.k2Intention
new file mode 100644
index 000000000000..444274bc1371
--- /dev/null
+++ b/plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToWith/.k2Intention
@@ -0,0 +1 @@
+org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToWithIntention
diff --git a/plugins/kotlin/idea/tests/testData/quickfix/optIn/invisibleAnnotationFir.kt b/plugins/kotlin/idea/tests/testData/quickfix/optIn/invisibleAnnotationFir.kt
index 22017558bae0..317023c47b49 100644
--- a/plugins/kotlin/idea/tests/testData/quickfix/optIn/invisibleAnnotationFir.kt
+++ b/plugins/kotlin/idea/tests/testData/quickfix/optIn/invisibleAnnotationFir.kt
@@ -2,6 +2,8 @@
// IGNORE_K1
// ERROR: This declaration needs opt-in. Its usage must be marked with '@Foo.Ann' or '@OptIn(Foo.Ann::class)'
// ACTION: Add import for 'Foo.bar'
+// ACTION: Convert to run
+// ACTION: Convert to with
object Foo {
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
private annotation class Ann
@@ -12,4 +14,4 @@ object Foo {
fun test() {
Foo.bar()
-}
\ No newline at end of file
+}
diff --git a/plugins/kotlin/plugin/k1/resources/META-INF/inspections-fe10.xml b/plugins/kotlin/plugin/k1/resources/META-INF/inspections-fe10.xml
index 64924bc5aac9..8f6a74951ab2 100644
--- a/plugins/kotlin/plugin/k1/resources/META-INF/inspections-fe10.xml
+++ b/plugins/kotlin/plugin/k1/resources/META-INF/inspections-fe10.xml
@@ -665,34 +665,6 @@
group.names.kotlin
-
- kotlin
- org.jetbrains.kotlin.idea.intentions.ConvertToApplyIntention
- messages.KotlinBundle
- group.names.kotlin
-
-
-
- kotlin
- org.jetbrains.kotlin.idea.intentions.ConvertToAlsoIntention
- messages.KotlinBundle
- group.names.kotlin
-
-
-
- kotlin
- org.jetbrains.kotlin.idea.intentions.ConvertToWithIntention
- messages.KotlinBundle
- group.names.kotlin
-
-
-
- kotlin
- org.jetbrains.kotlin.idea.intentions.ConvertToRunIntention
- messages.KotlinBundle
- group.names.kotlin
-
-
kotlin
org.jetbrains.kotlin.idea.intentions.MovePropertyToClassBodyIntention
diff --git a/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2IntentionTests.kt b/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2IntentionTests.kt
index c0ba260a8bc6..9addc469a2a0 100644
--- a/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2IntentionTests.kt
+++ b/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2IntentionTests.kt
@@ -151,7 +151,7 @@ internal fun MutableTWorkspace.generateK2IntentionTests() {
model("${idea}intentions/anonymousFunctionToLambda", pattern = pattern, isIgnored = true)
model("${idea}intentions/copyConcatenatedStringToClipboard", pattern = pattern, isIgnored = true)
model("${idea}intentions/inlayHints", pattern = pattern, isIgnored = true)
- model("${idea}intentions/convertToScope", pattern = pattern, isIgnored = true)
+ model("${idea}intentions/convertToScope", pattern = pattern)
model("${idea}intentions/implementAbstractMember", pattern = pattern, isIgnored = true)
model("${idea}intentions/replaceSizeZeroCheckWithIsEmpty", pattern = pattern, isIgnored = true)
model("${idea}intentions/movePropertyToClassBody", pattern = pattern, isIgnored = true)