KTIJ-27139 [AA] Shorten qualified expressions only when the callee/type reference is in selection
If you want to shorten call like `foo.bar()` into `bar()`, then you need your range to intersect with `bar` callee reference. Having only `foo` in the range is not enough Same goes for the type references - to shorten `foo.Bar` into `Bar`, you need at least some intersection of your range with `Bar` reference ^KTIJ-27139 Fixed ^KTIJ-27015 Fixed
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
fun usage() {
|
||||
<expr>dependency</expr>.foo()
|
||||
}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
fun foo() {}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Before shortening: dependency
|
||||
with DO_NOT_SHORTEN:
|
||||
with SHORTEN_IF_ALREADY_IMPORTED:
|
||||
with SHORTEN_AND_IMPORT:
|
||||
with SHORTEN_AND_STAR_IMPORT:
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
fun usage() {
|
||||
dependency.<expr>foo()</expr>
|
||||
}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
fun foo() {}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
Before shortening: 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()
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
fun usage() {
|
||||
<expr>dependency</expr>.foo()
|
||||
}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
val foo: Int = 10
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Before shortening: dependency
|
||||
with DO_NOT_SHORTEN:
|
||||
with SHORTEN_IF_ALREADY_IMPORTED:
|
||||
with SHORTEN_AND_IMPORT:
|
||||
with SHORTEN_AND_STAR_IMPORT:
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
fun usage() {
|
||||
dependency.<expr>foo</expr>
|
||||
}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
val foo: Int = 10
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
Before shortening: 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
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
fun usage(foo: <expr>dependency</expr>.Foo) {}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
class Foo
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Before shortening: dependency
|
||||
with DO_NOT_SHORTEN:
|
||||
with SHORTEN_IF_ALREADY_IMPORTED:
|
||||
with SHORTEN_AND_IMPORT:
|
||||
with SHORTEN_AND_STAR_IMPORT:
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
fun usage(foo: dependency.<expr>Foo</expr>) {}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
class Foo
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
Before shortening: 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
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
fun usage() {
|
||||
<expr>dependency</expr>.Foo.bar()
|
||||
}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
object Foo {
|
||||
fun bar() {}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Before shortening: dependency
|
||||
with DO_NOT_SHORTEN:
|
||||
with SHORTEN_IF_ALREADY_IMPORTED:
|
||||
with SHORTEN_AND_IMPORT:
|
||||
with SHORTEN_AND_STAR_IMPORT:
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
fun usage() {
|
||||
dependency.<expr>Foo</expr>.bar()
|
||||
}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
object Foo {
|
||||
fun bar() {}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
Before shortening: 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
|
||||
Reference in New Issue
Block a user