mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Fix bind to element when binding type to shorter fqn
GitOrigin-RevId: c839c17d9ed0dc33fb25e86e81d0199e77e1073b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2e5cc82959
commit
c0162cd8fd
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: test/bar/Foo.kt
|
||||
// BIND_TO test.foo.bar.B
|
||||
package test.bar
|
||||
|
||||
import test.foo.bar.B
|
||||
|
||||
fun foo() {
|
||||
val x: test.foo.<caret>A = B()
|
||||
}
|
||||
|
||||
// FILE: test/foo/A.kt
|
||||
package test.foo
|
||||
|
||||
interface A { }
|
||||
|
||||
// FILE: test/foo/bar/B.kt
|
||||
package test.foo.bar
|
||||
|
||||
class B : A { }
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// FILE: test/bar/Foo.kt
|
||||
// BIND_TO test.foo.bar.B
|
||||
package test.bar
|
||||
|
||||
import test.foo.bar.B
|
||||
|
||||
fun foo() {
|
||||
val x: B = B()
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: test/bar/Foo.kt
|
||||
// BIND_TO test.B
|
||||
package test.bar
|
||||
|
||||
import test.B
|
||||
|
||||
fun foo() {
|
||||
val x: test.foo.<caret>A = B()
|
||||
}
|
||||
|
||||
// FILE: test/foo/A.kt
|
||||
package test.foo
|
||||
|
||||
interface A { }
|
||||
|
||||
// FILE: test/B.kt
|
||||
package test
|
||||
|
||||
class B : A { }
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// FILE: test/bar/Foo.kt
|
||||
// BIND_TO test.B
|
||||
package test.bar
|
||||
|
||||
import test.B
|
||||
|
||||
fun foo() {
|
||||
val x: <caret>B = B()
|
||||
}
|
||||
|
||||
+6
-1
@@ -117,7 +117,12 @@ internal class K2ReferenceMutateService : KtReferenceMutateServiceBase() {
|
||||
?: error("Could not create type from $fqName")
|
||||
replaced(newReference)
|
||||
} else {
|
||||
if (!fqName.isRoot) qualifier?.replaceWith(fqName.parent()) // do recursive short name replacement to preserve type arguments
|
||||
val parentFqn = fqName.parent()
|
||||
if (parentFqn.isRoot) {
|
||||
deleteQualifier()
|
||||
} else {
|
||||
qualifier?.replaceWith(parentFqn) // do recursive short name replacement to preserve type arguments
|
||||
}
|
||||
referenceExpression?.replaceShortName(fqName)?.parent as KtUserType
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -279,6 +279,16 @@ public abstract class K2BindToElementTestGenerated extends AbstractK2BindToEleme
|
||||
runTest("../../idea/tests/testData/refactoring/bindToElement/propertyTypeReference/FullyQualified.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("FullyQualifiedWithLongerFqn.kt")
|
||||
public void testFullyQualifiedWithLongerFqn() throws Exception {
|
||||
runTest("../../idea/tests/testData/refactoring/bindToElement/propertyTypeReference/FullyQualifiedWithLongerFqn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("FullyQualifiedWithShorterFqn.kt")
|
||||
public void testFullyQualifiedWithShorterFqn() throws Exception {
|
||||
runTest("../../idea/tests/testData/refactoring/bindToElement/propertyTypeReference/FullyQualifiedWithShorterFqn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("RootPkg.kt")
|
||||
public void testRootPkg() throws Exception {
|
||||
runTest("../../idea/tests/testData/refactoring/bindToElement/propertyTypeReference/RootPkg.kt");
|
||||
|
||||
Reference in New Issue
Block a user