New J2K: do not print qualified names if corresponding qualifier can unambiguously resolved

This speeds up shortening qualified references phase
This commit is contained in:
Ilya Kirillov
2019-09-27 19:18:36 +03:00
parent 678cc35008
commit 043a669812
20 changed files with 148 additions and 56 deletions
+1 -2
View File
@@ -18,8 +18,7 @@ class A {
}
}
}
assert(element is PsiMethod
) { "Method accepts only kotlin functions/properties and java methods, but '" + element.getText().toString() + "' was found" }
assert(element is PsiMethod) { "Method accepts only kotlin functions/properties and java methods, but '" + element.getText().toString() + "' was found" }
return JetRefactoringUtil.formatPsiMethod(element as PsiMethod, true, false)
}
+1 -2
View File
@@ -1,4 +1,3 @@
// ERROR: Unresolved reference: Test
// !forceNotNullTypes: false
// !specifyLocalVariableTypeByDefault: true
package test
@@ -18,7 +17,7 @@ class Test(str: String) {
val test = "String2"
sout(test)
sout(dummy(test))
test.Test(test)
Test(test)
}
init {
+1 -2
View File
@@ -1,4 +1,3 @@
// ERROR: Unresolved reference: Test
// !specifyLocalVariableTypeByDefault: true
package test
@@ -17,7 +16,7 @@ class Test(str: String?) {
val test = "String2"
sout(test)
sout(dummy(test))
test.Test(test)
Test(test)
}
init {
@@ -1,3 +1,5 @@
import A.Nested
internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD)) {
internal class Nested(p: Int) {
companion object {
@@ -7,5 +9,5 @@ internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD
}
internal class B {
var nested: A.Nested? = null
var nested: Nested? = null
}
@@ -1,5 +1,7 @@
package pack
import pack.A.Nested
internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD)) {
internal class Nested(p: Int) {
companion object {
@@ -9,5 +11,5 @@ internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD
}
internal class B {
var nested: A.Nested? = null
var nested: Nested? = null
}
@@ -1,5 +1,7 @@
package pack
import pack.A.Nested
internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD)) {
internal class Nested(p: Int) {
companion object {
@@ -9,5 +11,5 @@ internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD
}
internal class B {
var nested: A.Nested? = null
var nested: Nested? = null
}
+3 -1
View File
@@ -1,3 +1,5 @@
import A.I
open class A {
interface I {
fun f()
@@ -6,5 +8,5 @@ open class A {
class B : A()
class Test {
var z: A.I? = null
var z: I? = null
}
+3 -1
View File
@@ -1,5 +1,7 @@
import Foo.SomeClass
internal interface FooInterface {
fun foo(): ArrayList<out Foo.SomeClass?>?
fun foo(): ArrayList<out SomeClass?>?
}
class Foo : FooInterface {
-1
View File
@@ -1,4 +1,3 @@
import java.util.Comparator
import java.util.stream.Collectors
internal class Test {
@@ -1,4 +1,3 @@
import java.util.Comparator
import java.util.stream.Collectors
internal class Test {
@@ -1,11 +1,13 @@
package demo
import demo.Foo.Bar
internal class Foo {
internal class Bar
}
internal class User {
fun main() {
val boo = Foo.Bar()
val boo = Bar()
}
}