From e91c6650dbcd2d2148121517b68b13f520dcf901 Mon Sep 17 00:00:00 2001 From: Frederik Haselmeier Date: Mon, 25 Nov 2024 14:28:00 +0100 Subject: [PATCH] [kotlin] Added ability to move nested declarations using K2 move refactoring The nested declarations are first converted to be effectively static if they capture an outer class. ^KTIJ-28862 fixed GitOrigin-RevId: c035ba0350702f8934a1258b408521afc8736ea8 --- .../messages/KotlinBundle.properties | 2 +- .../refactoring/move/MoveTestGenerated.java | 60 ++++++++ .../moveMemberToTopLevel/function.kt.after.k2 | 6 + .../tests/testData/quickfix/optIn/override.kt | 2 + .../deepInnerToTopLevel/after/foo.kt | 6 + .../deepInnerToTopLevel/after/test.kt | 10 ++ .../deepInnerToTopLevel/before/test.kt | 14 ++ .../deepInnerToTopLevel/conflicts.txt | 2 + .../deepInnerToTopLevel.test | 8 ++ .../dropEmptyCompanion/after/foo.kt | 3 + .../dropEmptyCompanion/after/test.kt | 4 + .../dropEmptyCompanion/before/test.kt | 7 + .../dropEmptyCompanion.test | 7 + .../externalFunctionUsage/after/foo.kt | 5 + .../externalFunctionUsage/after/test.kt | 9 ++ .../externalFunctionUsage/before/test.kt | 12 ++ .../externalFunctionUsage.test | 8 ++ .../after/foo.kt | 5 + .../after/test.kt | 9 ++ .../before/test.kt | 12 ++ .../externalFunctionUsageContextReceiver.test | 8 ++ .../after/bar/JavaClass.java | 7 + .../after/bar/foo.kt | 5 + .../after/bar/test.kt | 5 + .../before/bar/JavaClass.java | 7 + .../before/bar/test.kt | 8 ++ .../externalFunctionUsageFromJava.test | 8 ++ .../implicitReceiver/after/foo.kt | 5 + .../implicitReceiver/after/test.kt | 6 + .../implicitReceiver/before/test.kt | 9 ++ .../implicitReceiver/implicitReceiver.test | 8 ++ .../implicitRefToCompanionObject/after/foo.kt | 6 + .../after/test.kt | 7 + .../before/test.kt | 11 ++ .../implicitRefToCompanionObject.test | 7 + .../moveToTopLevel/nameClash/after/foo.kt | 5 + .../moveToTopLevel/nameClash/after/test.kt | 9 ++ .../moveToTopLevel/nameClash/before/test.kt | 12 ++ .../moveToTopLevel/nameClash/conflicts.txt | 1 + .../moveToTopLevel/nameClash/nameClash.test | 8 ++ .../outerInstanceAddParameter/after/foo.kt | 5 + .../outerInstanceAddParameter/after/test.kt | 5 + .../outerInstanceAddParameter/before/test.kt | 8 ++ .../outerInstanceAddParameter.test | 8 ++ .../after/foo.kt | 5 + .../after/test.kt | 5 + .../before/test.kt | 8 ++ .../outerInstanceDontAddParameter.test | 7 + .../moveWithInstanceReference/after/foo.kt | 3 + .../moveWithInstanceReference/after/test.kt | 5 + .../moveWithInstanceReference/before/test.kt | 6 + .../moveWithInstanceReference/conflicts.txt | 1 + .../moveWithInstanceReference.test | 7 + .../moveWithoutInstanceReference/after/foo.kt | 3 + .../after/test.kt | 4 + .../before/test.kt | 5 + .../moveWithoutInstanceReference.test | 7 + ...aseMoveDeclarationsRefactoringProcessor.kt | 4 +- ...eNestedDeclarationsRefactoringProcessor.kt | 115 ++++++++++++---- .../processor/conflict/nameClashConflict.kt | 2 +- .../k2/refactoring/move/ui/K2MoveModel.kt | 27 ++-- .../move/AbstractK2MoveNestedTest.kt | 6 +- .../k2/refactoring/move/K2MoveModelTest.kt | 130 ++++++++++++++++-- .../move/K2MoveNestedTestGenerated.java | 60 ++++++++ .../codeinsight/GenerateK2IntentionTests.kt | 2 +- 65 files changed, 712 insertions(+), 59 deletions(-) create mode 100644 plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/function.kt.after.k2 create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/conflicts.txt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/deepInnerToTopLevel.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/dropEmptyCompanion.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/externalFunctionUsage.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/externalFunctionUsageContextReceiver.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/JavaClass.java create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/before/bar/JavaClass.java create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/before/bar/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/externalFunctionUsageFromJava.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/implicitReceiver.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/implicitRefToCompanionObject.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/conflicts.txt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/nameClash.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/outerInstanceAddParameter.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/outerInstanceDontAddParameter.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/conflicts.txt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/moveWithInstanceReference.test create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/after/foo.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/after/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/before/test.kt create mode 100644 plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/moveWithoutInstanceReference.test diff --git a/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties b/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties index 1a0e7b320bfb..6ff34391f0cb 100644 --- a/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties +++ b/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties @@ -930,7 +930,7 @@ text.move.declaration.no.support.for.companion.objects=Move declaration is not s text.move.declaration.no.support.for.enums=Move declaration is not supported for enum entries text.move.file.no.support.for.file.target=Move files is not supported for non-directory target text.move.declaration.no.support.for.nested.declarations=Move declaration is not supported for nested declarations -text.move.declaration.only.support.for.nested.classes=Move declaration is not supported for nested declarations other than nested classes +text.move.declaration.only.support.for.some.nested.declarations=Move declaration is not supported for nested declarations other than nested classes, functions and properties text.move.declaration.only.support.for.single.elements=Move declaration is not supported for multiple nested declarations text.move.declaration.no.support.for.multi.file=Moving declarations from different files is not supported text.move.declaration.supports.only.top.levels.and.nested.classes=Move declaration is only supported for top-level declarations and nested classes diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java index 8c5935f4e3b9..6960ecc27717 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java @@ -1071,6 +1071,56 @@ public abstract class MoveTestGenerated extends AbstractMoveTest { runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToObject/moveToObject.test"); } + @TestMetadata("kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/deepInnerToTopLevel.test") + public void testKotlin_moveMethod_moveToTopLevel_deepInnerToTopLevel_DeepInnerToTopLevel() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/deepInnerToTopLevel.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/dropEmptyCompanion.test") + public void testKotlin_moveMethod_moveToTopLevel_dropEmptyCompanion_DropEmptyCompanion() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/dropEmptyCompanion.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/externalFunctionUsageContextReceiver.test") + public void testKotlin_moveMethod_moveToTopLevel_externalFunctionUsageContextReceiver_ExternalFunctionUsageContextReceiver() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/externalFunctionUsageContextReceiver.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/externalFunctionUsageFromJava.test") + public void testKotlin_moveMethod_moveToTopLevel_externalFunctionUsageFromJava_ExternalFunctionUsageFromJava() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/externalFunctionUsageFromJava.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/externalFunctionUsage.test") + public void testKotlin_moveMethod_moveToTopLevel_externalFunctionUsage_ExternalFunctionUsage() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/externalFunctionUsage.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/implicitReceiver/implicitReceiver.test") + public void testKotlin_moveMethod_moveToTopLevel_implicitReceiver_ImplicitReceiver() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/implicitReceiver.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/implicitRefToCompanionObject.test") + public void testKotlin_moveMethod_moveToTopLevel_implicitRefToCompanionObject_ImplicitRefToCompanionObject() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/implicitRefToCompanionObject.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/nameClash/nameClash.test") + public void testKotlin_moveMethod_moveToTopLevel_nameClash_NameClash() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/nameClash.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/outerInstanceAddParameter.test") + public void testKotlin_moveMethod_moveToTopLevel_outerInstanceAddParameter_OuterInstanceAddParameter() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/outerInstanceAddParameter.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/outerInstanceDontAddParameter.test") + public void testKotlin_moveMethod_moveToTopLevel_outerInstanceDontAddParameter_OuterInstanceDontAddParameter() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/outerInstanceDontAddParameter.test"); + } + @TestMetadata("kotlin/moveNestedClass/callableReferences/nestedToAnotherClass/nestedToAnotherClass.test") public void testKotlin_moveNestedClass_callableReferences_nestedToAnotherClass_NestedToAnotherClass() throws Exception { runTest("testData/refactoring/moveNested/kotlin/moveNestedClass/callableReferences/nestedToAnotherClass/nestedToAnotherClass.test"); @@ -1215,5 +1265,15 @@ public abstract class MoveTestGenerated extends AbstractMoveTest { public void testKotlin_moveNestedClass_protectedClass_ProtectedClass() throws Exception { runTest("testData/refactoring/moveNested/kotlin/moveNestedClass/protectedClass/protectedClass.test"); } + + @TestMetadata("kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/moveWithInstanceReference.test") + public void testKotlin_moveProperty_moveToTopLevel_moveWithInstanceReference_MoveWithInstanceReference() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/moveWithInstanceReference.test"); + } + + @TestMetadata("kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/moveWithoutInstanceReference.test") + public void testKotlin_moveProperty_moveToTopLevel_moveWithoutInstanceReference_MoveWithoutInstanceReference() throws Exception { + runTest("testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/moveWithoutInstanceReference.test"); + } } } diff --git a/plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/function.kt.after.k2 b/plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/function.kt.after.k2 new file mode 100644 index 000000000000..822e60720c9a --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/intentions/moveMemberToTopLevel/function.kt.after.k2 @@ -0,0 +1,6 @@ +// WITH_STDLIB + +object A { +} + +private fun foo() = 1 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/optIn/override.kt b/plugins/kotlin/idea/tests/testData/quickfix/optIn/override.kt index 477badbd2082..476395016a0d 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/optIn/override.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/optIn/override.kt @@ -1,8 +1,10 @@ +// IGNORE_K1 // "Propagate 'MyExperimentalAPI' opt-in requirement to containing class 'Derived'" "false" // COMPILER_ARGUMENTS: -opt-in=kotlin.RequiresOptIn // WITH_STDLIB // ACTION: Enable a trailing comma by default in the formatter // ACTION: Go To Super Method +// ACTION: Move to top level // ACTION: Opt in for 'MyExperimentalAPI' in containing file 'override.kt' // ACTION: Opt in for 'MyExperimentalAPI' in module 'light_idea_test_case' // ACTION: Opt in for 'MyExperimentalAPI' on 'foo' diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/after/foo.kt new file mode 100644 index 000000000000..ee0cec7f4809 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/after/foo.kt @@ -0,0 +1,6 @@ +package bar + +fun foo(test: Test.Test2.Test3): Int { + println(this@Test2) + return Test.a + test.b +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/after/test.kt new file mode 100644 index 000000000000..16672715ec48 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/after/test.kt @@ -0,0 +1,10 @@ +package bar + +class Test { + val a: Int = 5 + inner class Test2 { + inner class Test3 { + val b: Int = 5 + } + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/before/test.kt new file mode 100644 index 000000000000..7898e8c438bd --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/before/test.kt @@ -0,0 +1,14 @@ +package bar + +class Test { + val a: Int = 5 + inner class Test2 { + inner class Test3 { + val b: Int = 5 + fun foo(): Int { + println(this@Test2) + return a + b + } + } + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/conflicts.txt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/conflicts.txt new file mode 100644 index 000000000000..b8333dc16c77 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/conflicts.txt @@ -0,0 +1,2 @@ +Indirect outer instances won't be extracted: a +Indirect outer instances won't be extracted: this@Test2 diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/deepInnerToTopLevel.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/deepInnerToTopLevel.test new file mode 100644 index 000000000000..1a1ce5660e55 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/deepInnerToTopLevel.test @@ -0,0 +1,8 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "outerInstanceParameter": "test", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/after/foo.kt new file mode 100644 index 000000000000..c767c7e22148 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/after/foo.kt @@ -0,0 +1,3 @@ +package bar + +fun foo(): Int = 5 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/after/test.kt new file mode 100644 index 000000000000..d9f58b5c68e6 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/after/test.kt @@ -0,0 +1,4 @@ +package bar + +class Test { +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/before/test.kt new file mode 100644 index 000000000000..88f00820f6ad --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/before/test.kt @@ -0,0 +1,7 @@ +package bar + +class Test { + companion object { + fun foo(): Int = 5 + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/dropEmptyCompanion.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/dropEmptyCompanion.test new file mode 100644 index 000000000000..e04bef3acef5 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/dropEmptyCompanion.test @@ -0,0 +1,7 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/after/foo.kt new file mode 100644 index 000000000000..b8f14e7bde92 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/after/foo.kt @@ -0,0 +1,5 @@ +package bar + +fun foo(test: Test, b: Int): Int { + return test.a + b +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/after/test.kt new file mode 100644 index 000000000000..18c197b662bf --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/after/test.kt @@ -0,0 +1,9 @@ +package bar + +class Test { + val a: Int = 5 +} + +fun outside(test: Test): Int { + return foo(test, 5) +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/before/test.kt new file mode 100644 index 000000000000..48355be4a79f --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/before/test.kt @@ -0,0 +1,12 @@ +package bar + +class Test { + val a: Int = 5 + fun foo(b: Int): Int { + return a + b + } +} + +fun outside(test: Test): Int { + return test.foo(5) +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/externalFunctionUsage.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/externalFunctionUsage.test new file mode 100644 index 000000000000..1a1ce5660e55 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/externalFunctionUsage.test @@ -0,0 +1,8 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "outerInstanceParameter": "test", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/after/foo.kt new file mode 100644 index 000000000000..b8f14e7bde92 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/after/foo.kt @@ -0,0 +1,5 @@ +package bar + +fun foo(test: Test, b: Int): Int { + return test.a + b +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/after/test.kt new file mode 100644 index 000000000000..fc9b56c97a3f --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/after/test.kt @@ -0,0 +1,9 @@ +package bar + +class Test { + val a: Int = 5 +} + +fun Test.outside(): Int { + return foo(this, 5) +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/before/test.kt new file mode 100644 index 000000000000..df2ec5552625 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/before/test.kt @@ -0,0 +1,12 @@ +package bar + +class Test { + val a: Int = 5 + fun foo(b: Int): Int { + return a + b + } +} + +fun Test.outside(): Int { + return foo(5) +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/externalFunctionUsageContextReceiver.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/externalFunctionUsageContextReceiver.test new file mode 100644 index 000000000000..1a1ce5660e55 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/externalFunctionUsageContextReceiver.test @@ -0,0 +1,8 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "outerInstanceParameter": "test", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/JavaClass.java b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/JavaClass.java new file mode 100644 index 000000000000..72b480709b8b --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/JavaClass.java @@ -0,0 +1,7 @@ +package bar; + +class JavaClass { + public void test() { + new Test().foo(5); + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/foo.kt new file mode 100644 index 000000000000..b8f14e7bde92 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/foo.kt @@ -0,0 +1,5 @@ +package bar + +fun foo(test: Test, b: Int): Int { + return test.a + b +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/test.kt new file mode 100644 index 000000000000..c10b891079ae --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/after/bar/test.kt @@ -0,0 +1,5 @@ +package bar + +class Test { + val a: Int = 5 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/before/bar/JavaClass.java b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/before/bar/JavaClass.java new file mode 100644 index 000000000000..72b480709b8b --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/before/bar/JavaClass.java @@ -0,0 +1,7 @@ +package bar; + +class JavaClass { + public void test() { + new Test().foo(5); + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/before/bar/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/before/bar/test.kt new file mode 100644 index 000000000000..a995201fa5e3 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/before/bar/test.kt @@ -0,0 +1,8 @@ +package bar + +class Test { + val a: Int = 5 + fun foo(b: Int): Int { + return a + b + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/externalFunctionUsageFromJava.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/externalFunctionUsageFromJava.test new file mode 100644 index 000000000000..b43acee773be --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/externalFunctionUsageFromJava.test @@ -0,0 +1,8 @@ +{ + "mainFile": "bar/test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "outerInstanceParameter": "test", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/after/foo.kt new file mode 100644 index 000000000000..2de231d97546 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/after/foo.kt @@ -0,0 +1,5 @@ +package bar + +fun foo(test: Test): Int { + return test.test() +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/after/test.kt new file mode 100644 index 000000000000..50dde850d7c8 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/after/test.kt @@ -0,0 +1,6 @@ +package bar + +class Test { + fun test(): Int = 5 + +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/before/test.kt new file mode 100644 index 000000000000..a850e5fbecdd --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/before/test.kt @@ -0,0 +1,9 @@ +package bar + +class Test { + fun test(): Int = 5 + + fun foo(): Int { + return test() + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/implicitReceiver.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/implicitReceiver.test new file mode 100644 index 000000000000..1a1ce5660e55 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/implicitReceiver.test @@ -0,0 +1,8 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "outerInstanceParameter": "test", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/after/foo.kt new file mode 100644 index 000000000000..764ce45af108 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/after/foo.kt @@ -0,0 +1,6 @@ +package bar + +fun foo(): Int { + // TODO: The .Companion parts here can be removed after KT-64842 is fixed + return Test.Companion.a + Test.Companion.a +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/after/test.kt new file mode 100644 index 000000000000..7d652067b8f0 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/after/test.kt @@ -0,0 +1,7 @@ +package bar + +class Test { + companion object { + val a: Int = 5 + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/before/test.kt new file mode 100644 index 000000000000..ad9dd1a33ab0 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/before/test.kt @@ -0,0 +1,11 @@ +package bar + +class Test { + companion object { + val a: Int = 5 + fun foo(): Int { + // TODO: The .Companion parts here can be removed after KT-64842 is fixed + return a + a + } + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/implicitRefToCompanionObject.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/implicitRefToCompanionObject.test new file mode 100644 index 000000000000..e04bef3acef5 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/implicitRefToCompanionObject.test @@ -0,0 +1,7 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/after/foo.kt new file mode 100644 index 000000000000..7848568ed942 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/after/foo.kt @@ -0,0 +1,5 @@ +package bar + +fun foo(test: Test, b: Int): Int { + return test.a + test.a +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/after/test.kt new file mode 100644 index 000000000000..a68e158c7c50 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/after/test.kt @@ -0,0 +1,9 @@ +package bar + +class Test { + val a: Int = 5 +} + +fun foo(test: Test, b: Int): Int { + return 5 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/before/test.kt new file mode 100644 index 000000000000..f2a5b2c8d378 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/before/test.kt @@ -0,0 +1,12 @@ +package bar + +class Test { + val a: Int = 5 + fun foo(b: Int): Int { + return a + a + } +} + +fun foo(test: Test, b: Int): Int { + return 5 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/conflicts.txt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/conflicts.txt new file mode 100644 index 000000000000..47b2acff43f5 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/conflicts.txt @@ -0,0 +1 @@ +Following declarations would clash: to move class test.A.C and destination class test.C declared in scope test \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/nameClash.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/nameClash.test new file mode 100644 index 000000000000..1a1ce5660e55 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/nameClash.test @@ -0,0 +1,8 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "outerInstanceParameter": "test", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/after/foo.kt new file mode 100644 index 000000000000..2b49a0266339 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/after/foo.kt @@ -0,0 +1,5 @@ +package bar + +fun foo(test: Test): Int { + return test.a + test.a +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/after/test.kt new file mode 100644 index 000000000000..c10b891079ae --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/after/test.kt @@ -0,0 +1,5 @@ +package bar + +class Test { + val a: Int = 5 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/before/test.kt new file mode 100644 index 000000000000..e07c20672d6c --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/before/test.kt @@ -0,0 +1,8 @@ +package bar + +class Test { + val a: Int = 5 + fun foo(): Int { + return a + a + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/outerInstanceAddParameter.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/outerInstanceAddParameter.test new file mode 100644 index 000000000000..1a1ce5660e55 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/outerInstanceAddParameter.test @@ -0,0 +1,8 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "outerInstanceParameter": "test", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/after/foo.kt new file mode 100644 index 000000000000..c1129d6d8dc3 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/after/foo.kt @@ -0,0 +1,5 @@ +package bar + +fun foo(): Int { + return Test.a + Test.a +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/after/test.kt new file mode 100644 index 000000000000..ca57afadbed3 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/after/test.kt @@ -0,0 +1,5 @@ +package bar + +class Test { + val a: Int +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/before/test.kt new file mode 100644 index 000000000000..9ddedfcdf6a1 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/before/test.kt @@ -0,0 +1,8 @@ +package bar + +class Test { + val a: Int + fun foo(): Int { + return a + a + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/outerInstanceDontAddParameter.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/outerInstanceDontAddParameter.test new file mode 100644 index 000000000000..e04bef3acef5 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/outerInstanceDontAddParameter.test @@ -0,0 +1,7 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/after/foo.kt new file mode 100644 index 000000000000..de4905ffd59c --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/after/foo.kt @@ -0,0 +1,3 @@ +package bar + +val foo: Int = Test.b + Test.b \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/after/test.kt new file mode 100644 index 000000000000..1bb753ed702a --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/after/test.kt @@ -0,0 +1,5 @@ +package bar + +class Test { + val b: Int = 5 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/before/test.kt new file mode 100644 index 000000000000..9e9e02f009fb --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/before/test.kt @@ -0,0 +1,6 @@ +package bar + +class Test { + val b: Int = 5 + val foo: Int = b + b +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/conflicts.txt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/conflicts.txt new file mode 100644 index 000000000000..19f3ccabd563 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/conflicts.txt @@ -0,0 +1 @@ +Usages of outer class instance inside of property 'foo' won't be processed diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/moveWithInstanceReference.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/moveWithInstanceReference.test new file mode 100644 index 000000000000..e04bef3acef5 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/moveWithInstanceReference.test @@ -0,0 +1,7 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/after/foo.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/after/foo.kt new file mode 100644 index 000000000000..1df967df31be --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/after/foo.kt @@ -0,0 +1,3 @@ +package bar + +val foo: Int = 5 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/after/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/after/test.kt new file mode 100644 index 000000000000..d9f58b5c68e6 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/after/test.kt @@ -0,0 +1,4 @@ +package bar + +class Test { +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/before/test.kt b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/before/test.kt new file mode 100644 index 000000000000..532b24e66b8f --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/before/test.kt @@ -0,0 +1,5 @@ +package bar + +class Test { + val foo: Int = 5 +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/moveWithoutInstanceReference.test b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/moveWithoutInstanceReference.test new file mode 100644 index 000000000000..e04bef3acef5 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/moveWithoutInstanceReference.test @@ -0,0 +1,7 @@ +{ + "mainFile": "test.kt", + "type": "MOVE_KOTLIN_NESTED_DECLARATION", + "withRuntime": "true", + "enabledInK1": "false", + "enabledInK2": "true" +} \ No newline at end of file diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/K2BaseMoveDeclarationsRefactoringProcessor.kt b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/K2BaseMoveDeclarationsRefactoringProcessor.kt index 52cae3f3ea49..d62861860917 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/K2BaseMoveDeclarationsRefactoringProcessor.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/K2BaseMoveDeclarationsRefactoringProcessor.kt @@ -46,7 +46,7 @@ abstract class K2BaseMoveDeclarationsRefactoringProcessor) {} + protected open fun collectConflicts(moveDescriptor: K2MoveDescriptor,allUsages: MutableSet) {} override fun findUsages(): Array { if (!operationDescriptor.searchReferences) return emptyArray() @@ -97,7 +97,7 @@ abstract class K2BaseMoveDeclarationsRefactoringProcessor() + protected val conflicts: MultiMap = MultiMap() override fun preprocessUsages(refUsages: Ref>): Boolean { val usages = refUsages.get() diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/K2MoveNestedDeclarationsRefactoringProcessor.kt b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/K2MoveNestedDeclarationsRefactoringProcessor.kt index 7fc7f0309938..b2853a4798e3 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/K2MoveNestedDeclarationsRefactoringProcessor.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/K2MoveNestedDeclarationsRefactoringProcessor.kt @@ -9,6 +9,7 @@ import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.analysis.api.KaExperimentalApi import org.jetbrains.kotlin.analysis.api.analyze import org.jetbrains.kotlin.analysis.api.renderer.types.impl.KaTypeRendererForSource +import org.jetbrains.kotlin.analysis.api.symbols.KaClassSymbol import org.jetbrains.kotlin.asJava.toLightClass import org.jetbrains.kotlin.asJava.unwrapped import org.jetbrains.kotlin.idea.base.analysis.api.utils.shortenReferences @@ -26,14 +27,35 @@ class K2MoveNestedDeclarationsRefactoringProcessor( operationDescriptor: K2MoveOperationDescriptor.NestedDeclarations, ) : K2BaseMoveDeclarationsRefactoringProcessor(operationDescriptor) { private fun findInternalUsages(moveSource: K2MoveSourceDescriptor<*>): List { - val classToMove = moveSource.elements.singleOrNull() as? KtClass ?: return emptyList() - return collectOuterInstanceReferences(classToMove) + val declarationToMove = moveSource.elements.singleOrNull() as? KtNamedDeclaration ?: return emptyList() + return collectOuterInstanceReferences(declarationToMove) } override fun getUsages(moveDescriptor: K2MoveDescriptor): List { return super.getUsages(moveDescriptor) + findInternalUsages(moveDescriptor.source) } + private enum class MoveType { + CLASS, PROPERTY, FUNCTION, UNKNOWN + } + + private val moveType: MoveType by lazy { + when (operationDescriptor.sourceElements.singleOrNull()) { + is KtClass -> MoveType.CLASS + is KtProperty -> MoveType.PROPERTY + is KtNamedFunction -> MoveType.FUNCTION + else -> MoveType.UNKNOWN + } + } + private val elementToMove = operationDescriptor.sourceElements.single() + + private fun willLoseOuterInstanceReference(): Boolean { + // For properties, any outer instance reference is a conflict because we do not process them. + val canReferenceOuterInstance = moveType != MoveType.PROPERTY && operationDescriptor.outerInstanceParameterName != null + // For anything else, it is a conflict if it is contained in a class rather than an object + return !canReferenceOuterInstance && elementToMove.containingClassOrObject !is KtObjectDeclaration + } + override fun collectConflicts( moveDescriptor: K2MoveDescriptor, allUsages: MutableSet @@ -55,7 +77,18 @@ class K2MoveNestedDeclarationsRefactoringProcessor( true } - is OuterInstanceReferenceUsageInfo -> usage.reportConflictIfAny(conflicts) + is OuterInstanceReferenceUsageInfo -> { + if (moveType == MoveType.PROPERTY) { + // For properties, any outer instance reference is a conflict because we do not process them. + conflicts.putValue( + element, + KotlinBundle.message("usages.of.outer.class.instance.inside.of.property.0.won.t.be.processed", elementToMove.nameAsSafeName.asString()) + ) + true + } else { + usage.reportConflictIfAny(conflicts) + } + } else -> false } @@ -73,17 +106,17 @@ class K2MoveNestedDeclarationsRefactoringProcessor( val outerInstanceParameterName = operationDescriptor.outerInstanceParameterName ?: return val psiFactory = KtPsiFactory(project) val newOuterInstanceRef = psiFactory.createExpression(outerInstanceParameterName) - val classToMove = moveSource.elements.singleOrNull() as? KtClass + val declarationToMove = moveSource.elements.singleOrNull() as? KtNamedDeclaration for (usage in usages) { if (usage is MoveRenameUsageInfo) { - val referencedNestedClass = usage.referencedElement?.unwrapped as? KtClassOrObject - if (referencedNestedClass == classToMove) { - val outerClass = referencedNestedClass?.containingClassOrObject + val referencedNestedDeclaration = usage.referencedElement?.unwrapped as? KtNamedDeclaration + if (declarationToMove != null && referencedNestedDeclaration == declarationToMove) { + val outerClass = referencedNestedDeclaration.containingClassOrObject val lightOuterClass = outerClass?.toLightClass() if (lightOuterClass != null) { MoveInnerClassUsagesHandler.EP_NAME - .forLanguage(usage.element?.language ?: return) + .forLanguage(usage.element?.language ?: continue) ?.correctInnerClassUsage(usage, lightOuterClass, outerInstanceParameterName) } } @@ -106,26 +139,49 @@ class K2MoveNestedDeclarationsRefactoringProcessor( moveDescriptor: K2MoveDescriptor, originalDeclaration: KtNamedDeclaration ) { + val containingClass = originalDeclaration.containingClassOrObject + val psiFactory = KtPsiFactory(originalDeclaration.project) + val outerInstanceParameterName = operationDescriptor.outerInstanceParameterName with(originalDeclaration) { operationDescriptor.newClassName?.let { setName(it) } - if (this is KtClass) { - // TODO: Potentially allow for moving into classes - if (hasModifier(KtTokens.INNER_KEYWORD)) removeModifier(KtTokens.INNER_KEYWORD) - if (hasModifier(KtTokens.PROTECTED_KEYWORD)) removeModifier(KtTokens.PROTECTED_KEYWORD) + when (this) { + is KtClass -> { + // TODO: Potentially allow for moving into classes + if (hasModifier(KtTokens.INNER_KEYWORD)) removeModifier(KtTokens.INNER_KEYWORD) + if (hasModifier(KtTokens.PROTECTED_KEYWORD)) removeModifier(KtTokens.PROTECTED_KEYWORD) - operationDescriptor.outerInstanceParameterName?.let { outerInstanceParameterName -> - val containingClass = containingClassOrObject ?: return - analyze(originalDeclaration) { - // Use the fully qualified type because we have not moved it to the new location yet - val type = containingClass.classSymbol?.defaultType?.render( - renderer = KaTypeRendererForSource.WITH_QUALIFIED_NAMES, - position = Variance.INVARIANT - ) ?: return - val parameter = KtPsiFactory(project).createParameter("private val $outerInstanceParameterName: $type") - createPrimaryConstructorParameterListIfAbsent().addParameter(parameter) + if (outerInstanceParameterName != null) { + val containingClass = containingClassOrObject ?: return + analyze(originalDeclaration) { + // Use the fully qualified type because we have not moved it to the new location yet + val type = containingClass.classSymbol?.defaultType?.render( + renderer = KaTypeRendererForSource.WITH_QUALIFIED_NAMES, + position = Variance.INVARIANT + ) ?: return + val parameter = KtPsiFactory(project).createParameter("private val $outerInstanceParameterName: $type") + createPrimaryConstructorParameterListIfAbsent().addParameter(parameter) + } } } + is KtNamedFunction -> { + if (outerInstanceParameterName != null) { + val outerInstanceType = analyze(originalDeclaration) { + val type = (containingClass?.symbol as? KaClassSymbol)?.defaultType ?: return@analyze null + type.render(KaTypeRendererForSource.WITH_QUALIFIED_NAMES, Variance.INVARIANT) + } + if (outerInstanceType == null) return + valueParameterList?.addParameterBefore( + psiFactory.createParameter( + "${outerInstanceParameterName}: $outerInstanceType" + ), + valueParameterList?.parameters?.firstOrNull() + ) + } + } + is KtProperty -> { + + } } } } @@ -136,9 +192,16 @@ class K2MoveNestedDeclarationsRefactoringProcessor( newDeclaration: PsiElement ) { val outerInstanceParameterName = operationDescriptor.outerInstanceParameterName ?: return - if (originalDeclaration !is KtClass || newDeclaration !is KtClass) return - val primaryConstructor = newDeclaration.primaryConstructor ?: return - val addedParameter = primaryConstructor.valueParameters.firstOrNull { it.name == outerInstanceParameterName } ?: return - shortenReferences(addedParameter) + when (newDeclaration) { + is KtClass -> { + val primaryConstructor = newDeclaration.primaryConstructor ?: return + val addedParameter = primaryConstructor.valueParameters.firstOrNull { it.name == outerInstanceParameterName } ?: return + shortenReferences(addedParameter) + } + is KtNamedFunction -> { + val addedParameter = newDeclaration.valueParameterList?.parameters?.firstOrNull() ?: return + shortenReferences(addedParameter) + } + } } } \ No newline at end of file diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/conflict/nameClashConflict.kt b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/conflict/nameClashConflict.kt index a48bda2f08d2..1a06ec3e2aa8 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/conflict/nameClashConflict.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/processor/conflict/nameClashConflict.kt @@ -190,7 +190,7 @@ internal fun checkNameClashConflicts( "text.declarations.clash.move.0.destination.1.declared.in.scope.2", renderedDeclaration, conflictingSymbol.renderForConflict(), - conflictingScope.renderForConflict(), + conflictingScope.renderForConflict().ifBlank { "default" }, ) conflicts.putValue(declaration, message) } diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/ui/K2MoveModel.kt b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/ui/K2MoveModel.kt index 369fe9441a80..8d362df7c415 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/ui/K2MoveModel.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/move/ui/K2MoveModel.kt @@ -229,7 +229,7 @@ sealed class K2MoveModel { override val target: K2MoveTargetModel.File, override val inSourceRoot: Boolean, outerClassName: String?, - internal val isInnerClass: Boolean, + internal val needsInstanceReference: Boolean, override val moveCallBack: MoveCallback? = null ) : K2MoveModel() { @@ -237,11 +237,11 @@ sealed class K2MoveModel { return super.isValidRefactoring() && isValidDeclarationsRefactoring(source, target) } - var passOuterClass: Boolean = isInnerClass + private var passOuterClass: Boolean = needsInstanceReference var outerClassInstanceParameterName: String = outerClassName?.decapitalizeAsciiOnly() ?: "instance" override fun buildPanel(panel: Panel) = with(panel) { - if (isInnerClass) { + if (needsInstanceReference) { lateinit var selected: ComponentPredicate row { selected = checkBox(KotlinBundle.message("pass.outer.class.instance.as.parameter")) @@ -270,7 +270,7 @@ sealed class K2MoveModel { searchReferences = searchReferences.state, dirStructureMatchesPkg = true, newClassName = null, - outerInstanceParameterName = outerClassInstanceParameterName, + outerInstanceParameterName = outerClassInstanceParameterName.takeIf { needsInstanceReference }, moveCallBack = moveCallBack ) } @@ -323,15 +323,16 @@ sealed class K2MoveModel { if (!CommonRefactoringUtil.checkReadOnlyStatusRecursively(project, elements.toList(), true)) return null if (elementsToMove.any { it.parentOfType(withSelf = false) != null }) { - if (elementsToMove.size != 1) { + val singleElementToMove = elementsToMove.singleOrNull() + if (singleElementToMove == null) { val message = RefactoringBundle.getCannotRefactorMessage( KotlinBundle.message("text.move.declaration.only.support.for.single.elements") ) CommonRefactoringUtil.showErrorHint(project, editor, message, MOVE_DECLARATIONS, null) return null - } else if (elementsToMove.single() !is KtClassOrObject) { + } else if (singleElementToMove !is KtClassOrObject && singleElementToMove !is KtNamedFunction && singleElementToMove !is KtProperty) { val message = RefactoringBundle.getCannotRefactorMessage( - KotlinBundle.message("text.move.declaration.only.support.for.nested.classes") + KotlinBundle.message("text.move.declaration.only.support.for.some.nested.declarations") ) CommonRefactoringUtil.showErrorHint(project, editor, message, MOVE_DECLARATIONS, null) return null @@ -409,18 +410,20 @@ sealed class K2MoveModel { val psiDirectory = containingFile.containingDirectory ?: error("No directory found") K2MoveTargetModel.File(sourceFileName(), containingFile.packageFqName, psiDirectory) } - val singleClassToMove = (elementsToMove.singleOrNull() as? KtClassOrObject) + val singleDeclarationToMove = (elementsToMove.singleOrNull() as? KtNamedDeclaration) .takeIf { it !is KtObjectDeclaration || !it.isCompanion() } - val outerClassName = (singleClassToMove?.parent?.parent as? KtClassOrObject?)?.name + val outerClassName = (singleDeclarationToMove?.parent?.parent as? KtClassOrObject?)?.name - if (singleClassToMove?.containingClassOrObject != null) { + if (singleDeclarationToMove?.containingClassOrObject != null) { + val needsInstanceReference = (singleDeclarationToMove is KtClass && singleDeclarationToMove.isInner()) || + (singleDeclarationToMove is KtNamedFunction && singleDeclarationToMove.containingClassOrObject !is KtObjectDeclaration) NestedDeclarations( project = project, source = source, target = target, inSourceRoot = inSourceRoot, - isInnerClass = singleClassToMove is KtClass && singleClassToMove.isInner(), - outerClassName = outerClassName, + needsInstanceReference = needsInstanceReference, + outerClassName = outerClassName.takeIf { needsInstanceReference }, moveCallBack = moveCallBack ) } else { diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/AbstractK2MoveNestedTest.kt b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/AbstractK2MoveNestedTest.kt index 662066aaaffe..39d43a2fffdd 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/AbstractK2MoveNestedTest.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/AbstractK2MoveNestedTest.kt @@ -21,8 +21,8 @@ import org.jetbrains.kotlin.idea.k2.refactoring.move.processor.K2MoveNestedDecla import org.jetbrains.kotlin.idea.refactoring.runRefactoringTest import org.jetbrains.kotlin.idea.util.sourceRoot import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType abstract class AbstractK2MoveNestedTest : AbstractMultifileMoveRefactoringTest() { @@ -37,9 +37,9 @@ internal object K2MoveNestedRefactoringAction : KotlinMoveRefactoringAction { val project = mainFile.project val type = config.getString("type") when (type) { - "MOVE_KOTLIN_NESTED_CLASS" -> { + "MOVE_KOTLIN_NESTED_CLASS", "MOVE_KOTLIN_NESTED_DECLARATION" -> { val project = mainFile.project - val elementToMove = elementsAtCaret.single().getNonStrictParentOfType()!! + val elementToMove = elementsAtCaret.single().getNonStrictParentOfType()!! val fileName = (elementToMove.name!!) + ".kt" val targetPackageFqName = config.getNullableString("targetPackage")?.let { FqName(it) diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/K2MoveModelTest.kt b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/K2MoveModelTest.kt index 9eab1a617e79..40140282d83f 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/K2MoveModelTest.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/K2MoveModelTest.kt @@ -11,9 +11,7 @@ import org.jetbrains.kotlin.idea.KotlinFileType import org.jetbrains.kotlin.idea.base.plugin.KotlinPluginMode import org.jetbrains.kotlin.idea.k2.refactoring.move.ui.K2MoveModel import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.psi.KtClass -import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.psi.KtNamedDeclaration +import org.jetbrains.kotlin.psi.* class K2MoveModelTest : KotlinLightCodeInsightFixtureTestCase() { override val pluginMode: KotlinPluginMode @@ -336,6 +334,23 @@ class K2MoveModelTest : KotlinLightCodeInsightFixtureTestCase() { } } + fun `test move multiple nested class should fail`() { + myFixture.configureByText(KotlinFileType.INSTANCE, """ + package foo + + class Outer { + class Foo { } + class Bar { } + } + """.trimIndent()) + val outerClass = myFixture.elementAtCaret as KtClass + val nestedClasses = outerClass.declarations.filterIsInstance() + assertEquals(2, nestedClasses.size) + assertThrows(RefactoringErrorHintException::class.java) { + K2MoveModel.create(nestedClasses.toTypedArray(), null) + } + } + fun `test move nested class`() { myFixture.configureByText(KotlinFileType.INSTANCE, """ package foo @@ -354,8 +369,7 @@ class K2MoveModelTest : KotlinLightCodeInsightFixtureTestCase() { assert(sourceElement is KtClass && sourceElement.name == "Bar") val targetElement = moveDeclarationsModel.target.pkgName assertEquals("foo", targetElement.asString()) - assertEquals(false, moveDeclarationsModel.passOuterClass) - assertEquals(false, moveDeclarationsModel.isInnerClass) + assertEquals(false, moveDeclarationsModel.needsInstanceReference) } fun `test move nested inner class`() { @@ -376,26 +390,71 @@ class K2MoveModelTest : KotlinLightCodeInsightFixtureTestCase() { assert(sourceElement is KtClass && sourceElement.name == "Bar") val targetElement = moveDeclarationsModel.target.pkgName assertEquals("foo", targetElement.asString()) - assertEquals(true, moveDeclarationsModel.passOuterClass) assertEquals("outerFoo", moveDeclarationsModel.outerClassInstanceParameterName) - assertEquals(true, moveDeclarationsModel.isInnerClass) + assertEquals(true, moveDeclarationsModel.needsInstanceReference) } - fun `test move instance method should fail`() { + fun `test move instance method`() { myFixture.configureByText(KotlinFileType.INSTANCE, """ package foo - class Foo { + class OuterFoo { fun foo() { } } """.trimIndent()) val instanceMethod = myFixture.elementAtCaret as KtNamedDeclaration + val moveModel = K2MoveModel.create(arrayOf(instanceMethod), null) + assertInstanceOf(moveModel) + assertTrue(moveModel!!.isValidRefactoring()) + val moveDeclarationsModel = moveModel as K2MoveModel.NestedDeclarations + assertSize(1, moveDeclarationsModel.source.elements) + val sourceElement = moveDeclarationsModel.source.elements.firstOrNull() + assert(sourceElement is KtFunction && sourceElement.name == "foo") + val targetElement = moveDeclarationsModel.target.pkgName + assertEquals("foo", targetElement.asString()) + assertEquals("outerFoo", moveDeclarationsModel.outerClassInstanceParameterName) + assertEquals(true, moveDeclarationsModel.needsInstanceReference) + } + + fun `test move multiple instance methods should fail`() { + myFixture.configureByText(KotlinFileType.INSTANCE, """ + package foo + + class Outer { + fun foo() {} + fun bar() {} + } + """.trimIndent()) + val outerClass = myFixture.elementAtCaret as KtClass + val nestedFunctions = outerClass.declarations.filterIsInstance() + assertEquals(2, nestedFunctions.size) assertThrows(RefactoringErrorHintException::class.java) { - K2MoveModel.create(arrayOf(instanceMethod), null) + K2MoveModel.create(nestedFunctions.toTypedArray(), null) } } - fun `test move companion object method should fail`() { + fun `test move object method`() { + myFixture.configureByText(KotlinFileType.INSTANCE, """ + package foo + + object OuterFoo { + fun foo() { } + } + """.trimIndent()) + val instanceMethod = myFixture.elementAtCaret as KtNamedDeclaration + val moveModel = K2MoveModel.create(arrayOf(instanceMethod), null) + assertInstanceOf(moveModel) + assertTrue(moveModel!!.isValidRefactoring()) + val moveDeclarationsModel = moveModel as K2MoveModel.NestedDeclarations + assertSize(1, moveDeclarationsModel.source.elements) + val sourceElement = moveDeclarationsModel.source.elements.firstOrNull() + assert(sourceElement is KtFunction && sourceElement.name == "foo") + val targetElement = moveDeclarationsModel.target.pkgName + assertEquals("foo", targetElement.asString()) + assertEquals(false, moveDeclarationsModel.needsInstanceReference) + } + + fun `test move companion object method`() { myFixture.configureByText(KotlinFileType.INSTANCE, """ package foo @@ -405,9 +464,54 @@ class K2MoveModelTest : KotlinLightCodeInsightFixtureTestCase() { } } """.trimIndent()) - val companionObjectMethod = myFixture.elementAtCaret as KtNamedDeclaration + val instanceMethod = myFixture.elementAtCaret as KtNamedDeclaration + val moveModel = K2MoveModel.create(arrayOf(instanceMethod), null) + assertInstanceOf(moveModel) + assertTrue(moveModel!!.isValidRefactoring()) + val moveDeclarationsModel = moveModel as K2MoveModel.NestedDeclarations + assertSize(1, moveDeclarationsModel.source.elements) + val sourceElement = moveDeclarationsModel.source.elements.firstOrNull() + assert(sourceElement is KtFunction && sourceElement.name == "foo") + val targetElement = moveDeclarationsModel.target.pkgName + assertEquals("foo", targetElement.asString()) + assertEquals(false, moveDeclarationsModel.needsInstanceReference) + } + + fun `test move member property`() { + myFixture.configureByText(KotlinFileType.INSTANCE, """ + package foo + + class Foo { + val foo = 5 + } + """.trimIndent()) + val instanceProperty = myFixture.elementAtCaret as KtNamedDeclaration + val moveModel = K2MoveModel.create(arrayOf(instanceProperty), null) + assertInstanceOf(moveModel) + assertTrue(moveModel!!.isValidRefactoring()) + val moveDeclarationsModel = moveModel as K2MoveModel.NestedDeclarations + assertSize(1, moveDeclarationsModel.source.elements) + val sourceElement = moveDeclarationsModel.source.elements.firstOrNull() + assert(sourceElement is KtProperty && sourceElement.name == "foo") + val targetElement = moveDeclarationsModel.target.pkgName + assertEquals("foo", targetElement.asString()) + assertEquals(false, moveDeclarationsModel.needsInstanceReference) + } + + fun `test move multiple member properties should fal`() { + myFixture.configureByText(KotlinFileType.INSTANCE, """ + package foo + + class Outer { + val foo = 5 + val bar = 5 + } + """.trimIndent()) + val outerClass = myFixture.elementAtCaret as KtClass + val nestedProperties = outerClass.declarations.filterIsInstance() + assertEquals(2, nestedProperties.size) assertThrows(RefactoringErrorHintException::class.java) { - K2MoveModel.create(arrayOf(companionObjectMethod), null) + K2MoveModel.create(nestedProperties.toTypedArray(), null) } } diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/K2MoveNestedTestGenerated.java b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/K2MoveNestedTestGenerated.java index b6f4aff7c7c2..7dd7fa80941a 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/K2MoveNestedTestGenerated.java +++ b/plugins/kotlin/refactorings/kotlin.refactorings.move.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/move/K2MoveNestedTestGenerated.java @@ -195,6 +195,56 @@ public class K2MoveNestedTestGenerated extends AbstractK2MoveNestedTest { runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToObject/moveToObject.test"); } + @TestMetadata("kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/deepInnerToTopLevel.test") + public void testKotlin_moveMethod_moveToTopLevel_deepInnerToTopLevel_DeepInnerToTopLevel() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/deepInnerToTopLevel/deepInnerToTopLevel.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/dropEmptyCompanion.test") + public void testKotlin_moveMethod_moveToTopLevel_dropEmptyCompanion_DropEmptyCompanion() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/dropEmptyCompanion/dropEmptyCompanion.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/externalFunctionUsageContextReceiver.test") + public void testKotlin_moveMethod_moveToTopLevel_externalFunctionUsageContextReceiver_ExternalFunctionUsageContextReceiver() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageContextReceiver/externalFunctionUsageContextReceiver.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/externalFunctionUsageFromJava.test") + public void testKotlin_moveMethod_moveToTopLevel_externalFunctionUsageFromJava_ExternalFunctionUsageFromJava() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsageFromJava/externalFunctionUsageFromJava.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/externalFunctionUsage.test") + public void testKotlin_moveMethod_moveToTopLevel_externalFunctionUsage_ExternalFunctionUsage() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/externalFunctionUsage/externalFunctionUsage.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/implicitReceiver/implicitReceiver.test") + public void testKotlin_moveMethod_moveToTopLevel_implicitReceiver_ImplicitReceiver() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitReceiver/implicitReceiver.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/implicitRefToCompanionObject.test") + public void testKotlin_moveMethod_moveToTopLevel_implicitRefToCompanionObject_ImplicitRefToCompanionObject() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/implicitRefToCompanionObject/implicitRefToCompanionObject.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/nameClash/nameClash.test") + public void testKotlin_moveMethod_moveToTopLevel_nameClash_NameClash() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/nameClash/nameClash.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/outerInstanceAddParameter.test") + public void testKotlin_moveMethod_moveToTopLevel_outerInstanceAddParameter_OuterInstanceAddParameter() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceAddParameter/outerInstanceAddParameter.test"); + } + + @TestMetadata("kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/outerInstanceDontAddParameter.test") + public void testKotlin_moveMethod_moveToTopLevel_outerInstanceDontAddParameter_OuterInstanceDontAddParameter() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveMethod/moveToTopLevel/outerInstanceDontAddParameter/outerInstanceDontAddParameter.test"); + } + @TestMetadata("kotlin/moveNestedClass/callableReferences/nestedToAnotherClass/nestedToAnotherClass.test") public void testKotlin_moveNestedClass_callableReferences_nestedToAnotherClass_NestedToAnotherClass() throws Exception { runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveNestedClass/callableReferences/nestedToAnotherClass/nestedToAnotherClass.test"); @@ -339,4 +389,14 @@ public class K2MoveNestedTestGenerated extends AbstractK2MoveNestedTest { public void testKotlin_moveNestedClass_protectedClass_ProtectedClass() throws Exception { runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveNestedClass/protectedClass/protectedClass.test"); } + + @TestMetadata("kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/moveWithInstanceReference.test") + public void testKotlin_moveProperty_moveToTopLevel_moveWithInstanceReference_MoveWithInstanceReference() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithInstanceReference/moveWithInstanceReference.test"); + } + + @TestMetadata("kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/moveWithoutInstanceReference.test") + public void testKotlin_moveProperty_moveToTopLevel_moveWithoutInstanceReference_MoveWithoutInstanceReference() throws Exception { + runTest("../../idea/tests/testData/refactoring/moveNested/kotlin/moveProperty/moveToTopLevel/moveWithoutInstanceReference/moveWithoutInstanceReference.test"); + } } 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 aec9f1d849d2..0afc275df3c4 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 @@ -156,7 +156,7 @@ internal fun MutableTWorkspace.generateK2IntentionTests() { //model("${idea}intentions/loopToCallChain/filter", pattern = pattern, isIgnored = true) //model("${idea}intentions/loopToCallChain/introduceIndex", pattern = pattern, isIgnored = true) //model("${idea}intentions/loopToCallChain/indexOf", pattern = pattern, isIgnored = true) - model("${idea}intentions/moveMemberToTopLevel", pattern = pattern, isIgnored = true) + model("${idea}intentions/moveMemberToTopLevel", pattern = pattern) model("${idea}intentions/anonymousFunctionToLambda", pattern = pattern) model("${idea}intentions/copyConcatenatedStringToClipboard", pattern = pattern, isIgnored = true) model("${idea}intentions/inlayHints", pattern = pattern, isIgnored = true)