KT-63627 [AA] Properly handle object declarations when traversing scopes in KtFirReferenceShortener

`KtClass` denotes only classes, interfaces and enums.
To handle object declarations, we now use
`KtClassOrObject` PSI type

^KT-63627 Fixed
This commit is contained in:
Roman Golyshev
2023-11-21 15:16:37 +01:00
committed by teamcity
parent 5096fd266e
commit 7d7256536c
15 changed files with 256 additions and 5 deletions
@@ -0,0 +1,14 @@
package test
class OuterClass {
class Nested
object NestedObject {
class Nested
<expr>fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.NestedObject.Nested,
) {}</expr>
}
}
@@ -0,0 +1,14 @@
Before shortening: fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.NestedObject.Nested,
) {}
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] test.OuterClass
[type] test.OuterClass.NestedObject.Nested
with SHORTEN_AND_IMPORT:
[type] test.OuterClass
[type] test.OuterClass.NestedObject.Nested
with SHORTEN_AND_STAR_IMPORT:
[type] test.OuterClass
[type] test.OuterClass.NestedObject.Nested
@@ -0,0 +1,14 @@
package test
class OuterClass {
class Nested
companion object {
class Nested
<expr>fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.Companion.Nested,
) {}</expr>
}
}
@@ -0,0 +1,14 @@
Before shortening: fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.Companion.Nested,
) {}
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] test.OuterClass
[type] test.OuterClass.Companion.Nested
with SHORTEN_AND_IMPORT:
[type] test.OuterClass
[type] test.OuterClass.Companion.Nested
with SHORTEN_AND_STAR_IMPORT:
[type] test.OuterClass
[type] test.OuterClass.Companion.Nested
@@ -0,0 +1,14 @@
package test
class OuterClass {
class Nested
companion object NamedCompanion {
class Nested
<expr>fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.NamedCompanion.Nested,
) {}</expr>
}
}
@@ -0,0 +1,14 @@
Before shortening: fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.NamedCompanion.Nested,
) {}
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] test.OuterClass
[type] test.OuterClass.NamedCompanion.Nested
with SHORTEN_AND_IMPORT:
[type] test.OuterClass
[type] test.OuterClass.NamedCompanion.Nested
with SHORTEN_AND_STAR_IMPORT:
[type] test.OuterClass
[type] test.OuterClass.NamedCompanion.Nested
@@ -0,0 +1,14 @@
package test
class OuterClass {
class Nested
object NestedObject {
class Nested
}
<expr>fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.NestedObject.Nested,
) {}</expr>
}
@@ -0,0 +1,14 @@
Before shortening: fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.NestedObject.Nested,
) {}
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] test.OuterClass.Nested
[type] test.OuterClass.NestedObject
with SHORTEN_AND_IMPORT:
[type] test.OuterClass.Nested
[type] test.OuterClass.NestedObject
with SHORTEN_AND_STAR_IMPORT:
[type] test.OuterClass.Nested
[type] test.OuterClass.NestedObject
@@ -0,0 +1,14 @@
package test
class OuterClass {
class Nested
companion object {
class Nested
}
<expr>fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.Companion.Nested,
) {}</expr>
}
@@ -0,0 +1,14 @@
Before shortening: fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.Companion.Nested,
) {}
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] test.OuterClass.Nested
[type] test.OuterClass.Companion
with SHORTEN_AND_IMPORT:
[type] test.OuterClass.Nested
[type] test.OuterClass.Companion
with SHORTEN_AND_STAR_IMPORT:
[type] test.OuterClass.Nested
[type] test.OuterClass.Companion
@@ -0,0 +1,14 @@
package test
class OuterClass {
class Nested
companion object NamedCompanion {
class Nested
}
<expr>fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.NamedCompanion.Nested,
) {}</expr>
}
@@ -0,0 +1,14 @@
Before shortening: fun usage(
first: test.OuterClass.Nested,
second: test.OuterClass.NamedCompanion.Nested,
) {}
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] test.OuterClass.Nested
[type] test.OuterClass.NamedCompanion
with SHORTEN_AND_IMPORT:
[type] test.OuterClass.Nested
[type] test.OuterClass.NamedCompanion
with SHORTEN_AND_STAR_IMPORT:
[type] test.OuterClass.Nested
[type] test.OuterClass.NamedCompanion