Move: Fix scope of internal reference recovery in the case of file move

#KT-22282 Fixed
This commit is contained in:
Alexey Sedunov
2018-02-14 15:38:45 +03:00
parent 4537192e86
commit bdfc814389
7 changed files with 39 additions and 1 deletions
@@ -293,7 +293,12 @@ class MoveKotlinDeclarationsProcessor(
}
}
newDeclarations.forEach { newInternalUsages += restoreInternalUsages(it, oldToNewElementsMapping) }
val internalUsageScopes: List<KtElement> = if (descriptor.scanEntireFile) {
newDeclarations.map { it.containingKtFile }.distinct()
} else {
newDeclarations
}
internalUsageScopes.forEach { newInternalUsages += restoreInternalUsages(it, oldToNewElementsMapping) }
usagesToProcess += newInternalUsages
@@ -0,0 +1,11 @@
package my2
import my2.Foo.*
class Foo {
class Bar
}
fun main(args: Array<String>) {
val b = Bar()
}
@@ -0,0 +1,11 @@
package my
import my.Foo.*
class Foo {
class Bar
}
fun main(args: Array<String>) {
val b = Bar()
}
@@ -0,0 +1,5 @@
{
"mainFile": "my/test.kt",
"type": "MOVE_FILES",
"targetPackage": "my2"
}
@@ -307,6 +307,12 @@ public class MoveTestGenerated extends AbstractMoveTest {
doTest(fileName);
}
@TestMetadata("kotlin/moveFile/selfReferenceInImport/selfReferenceInImport.test")
public void testKotlin_moveFile_selfReferenceInImport_SelfReferenceInImport() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveFile/selfReferenceInImport/selfReferenceInImport.test");
doTest(fileName);
}
@TestMetadata("kotlin/moveFile/typeRefWithArguments/typeRefWithArguments.test")
public void testKotlin_moveFile_typeRefWithArguments_TypeRefWithArguments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/typeRefWithArguments.test");