mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] k2: port ConvertToScopeIntention
^KTIJ-30410 fixed GitOrigin-RevId: ca8fa24fc94b4f7bd4df50d3be4ddf1958061204
This commit is contained in:
committed by
intellij-monorepo-bot
parent
251a9a2af3
commit
546024017c
+583
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+2
@@ -47,5 +47,7 @@
|
||||
<orderEntry type="module" module-name="kotlin.code-insight.impl-base" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
|
||||
<orderEntry type="module" module-name="kotlin.refactorings.common" />
|
||||
<orderEntry type="module" module-name="intellij.java" />
|
||||
<orderEntry type="module" module-name="kotlin.base.analysis" />
|
||||
</component>
|
||||
</module>
|
||||
+28
@@ -223,5 +223,33 @@
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToApplyIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToAlsoIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToWithIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToRunIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
+63
-37
@@ -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>(
|
||||
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<KtDotQualifiedExpression> {
|
||||
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<PsiElement, String>? {
|
||||
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<KtDotQualifiedExpression>()?.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<PsiElement, PsiElement>? {
|
||||
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<PsiElement>.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)
|
||||
@@ -183,18 +183,6 @@ val FunctionDescriptor.isOperatorOrCompatible: Boolean
|
||||
return isOperator
|
||||
}
|
||||
|
||||
internal fun Sequence<PsiElement>.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
|
||||
|
||||
@@ -140,5 +140,6 @@
|
||||
<orderEntry type="module" module-name="kotlin.bundled-compiler-plugins-support" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.navbar.testFramework" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.execution.dashboard" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.code-insight.intentions.shared" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
+5
-5
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ConvertToAlsoIntention
|
||||
org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToAlsoIntention
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToAlsoIntention
|
||||
+1
-1
@@ -1 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ConvertToApplyIntention
|
||||
org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToApplyIntention
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToApplyIntention
|
||||
+1
-1
@@ -1 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ConvertToRunIntention
|
||||
org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToRunIntention
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToRunIntention
|
||||
+1
-1
@@ -1 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ConvertToWithIntention
|
||||
org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToWithIntention
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.codeInsight.intentions.shared.ConvertToWithIntention
|
||||
@@ -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<caret>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,34 +665,6 @@
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.ConvertToApplyIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.ConvertToAlsoIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.ConvertToWithIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.ConvertToRunIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.MovePropertyToClassBodyIntention</className>
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user