KTIJ-28080 [AA] Move selection checking to ElementsToShortenCollector.findClassifierQualifierToShorten

This way, even if the whole qualifier is not selected, but some of its
parts are, the reference shortener will correctly find and shorten
those parts

^KTIJ-28080 Fixed
This commit is contained in:
Roman Golyshev
2024-01-05 15:13:50 +01:00
committed by teamcity
parent 3b448b284c
commit 93f1555322
13 changed files with 201 additions and 5 deletions
@@ -0,0 +1,17 @@
// FILE: main.kt
package test
fun usage(
foo: _root_ide_package_.dependency.Foo
) {
<expr>"random expr"</expr>
_root_ide_package_.dependency.Foo.bar()
}
// FILE: dependency.kt
package dependency
object Foo {
fun bar() {}
}
@@ -0,0 +1,6 @@
Before shortening: "random expr"
with default settings:
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
with SHORTEN_AND_STAR_IMPORT:
@@ -0,0 +1,11 @@
// FILE: main.kt
package test
fun usage(foo: <expr>dependency.Foo</expr>.Bar) {}
// FILE: dependency.kt
package dependency
class Foo {
class Bar
}
@@ -0,0 +1,9 @@
Before shortening: dependency.Foo
with default settings:
[type] dependency.Foo
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] dependency.Foo
with SHORTEN_AND_STAR_IMPORT:
[type] dependency.Foo
@@ -0,0 +1,15 @@
// FILE: main.kt
package test
import dependency.Foo
fun usage(foo: <expr>dependency.Foo.Bar</expr>.Baz) {}
// FILE: dependency.kt
package dependency
class Foo {
class Bar {
class Baz
}
}
@@ -0,0 +1,10 @@
Before shortening: dependency.Foo.Bar
with default settings:
[type] dependency.Foo
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] dependency.Foo
with SHORTEN_AND_IMPORT:
[type] dependency.Foo.Bar
with SHORTEN_AND_STAR_IMPORT:
[type] dependency.Foo.Bar
@@ -0,0 +1,15 @@
// FILE: main.kt
package test
fun usage() {
<expr>dependency.Foo</expr>.Bar.baz()
}
// FILE: dependency.kt
package dependency
object Foo {
object Bar {
fun baz() {}
}
}
@@ -0,0 +1,9 @@
Before shortening: dependency.Foo
with default settings:
[qualifier] dependency.Foo
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[qualifier] dependency.Foo
with SHORTEN_AND_STAR_IMPORT:
[qualifier] dependency.Foo
@@ -0,0 +1,19 @@
// FILE: main.kt
package test
import dependency.Foo
fun usage() {
<expr>dependency.Foo.Bar</expr>.Baz.qux()
}
// FILE: dependency.kt
package dependency
object Foo {
class Bar {
object Baz {
fun qux() {}
}
}
}
@@ -0,0 +1,10 @@
Before shortening: dependency.Foo.Bar
with default settings:
[qualifier] dependency.Foo
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[qualifier] dependency.Foo
with SHORTEN_AND_IMPORT:
[qualifier] dependency.Foo.Bar
with SHORTEN_AND_STAR_IMPORT:
[qualifier] dependency.Foo.Bar