Move: Fix lengthening of qualified type references

KT-14519 Fixed
This commit is contained in:
Alexey Sedunov
2018-01-31 17:30:02 +03:00
parent 1af21dd160
commit 27d4593fc4
7 changed files with 43 additions and 0 deletions
@@ -190,6 +190,16 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere
val shortName = fqName.shortName().asString()
val psiFactory = KtPsiFactory(this)
val parent = parent
if (parent is KtUserType && !fqName.isOneSegmentFQN()) {
val qualifier = parent.qualifier
val qualifierReference = qualifier?.referenceExpression as? KtNameReferenceExpression
if (qualifierReference != null && qualifier.typeArguments.isNotEmpty()) {
qualifierReference.changeQualifiedName(fqName.parent())
return this
}
}
var parentDelimiter = "."
val fqNameBase = when {
parent is KtCallElement -> {
@@ -0,0 +1,11 @@
package target
class OuterClass<T1> {
inner class InnerClass<T2>
class NestedClass<T3>
typealias NestedType<T> = NestedClass<T>
}
typealias OI<T1, T2> = OuterClass<T1>.InnerClass<T2> // (1)
typealias ON1<T1, T2> = OuterClass<T1>.NestedClass<T2> // (2)
typealias ON2<T1, T2> = OuterClass<T1>.NestedType<T2>
@@ -0,0 +1,11 @@
package source
class OuterClass<T1> {
inner class InnerClass<T2>
class NestedClass<T3>
typealias NestedType<T> = NestedClass<T>
}
typealias OI<T1, T2> = OuterClass<T1>.InnerClass<T2> // (1)
typealias ON1<T1, T2> = OuterClass<T1>.NestedClass<T2> // (2)
typealias ON2<T1, T2> = OuterClass<T1>.NestedType<T2>
@@ -0,0 +1,5 @@
{
"mainFile": "source/Foo.kt",
"type": "MOVE_FILES",
"targetPackage": "target"
}
@@ -307,6 +307,12 @@ public class MoveTestGenerated extends AbstractMoveTest {
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");
doTest(fileName);
}
@TestMetadata("kotlin/moveNestedClass/deepInnerToTopLevelWithOuterOuterThis/deepInnerToTopLevelWithOuterOuterThis.test")
public void testKotlin_moveNestedClass_deepInnerToTopLevelWithOuterOuterThis_DeepInnerToTopLevelWithOuterOuterThis() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveNestedClass/deepInnerToTopLevelWithOuterOuterThis/deepInnerToTopLevelWithOuterOuterThis.test");