Optimize Imports should remove unused import alias

#KT-17375 Fixed
This commit is contained in:
Dmitry Gridin
2019-04-29 17:04:53 +07:00
parent 7fe0503337
commit 96ed33e357
16 changed files with 90 additions and 66 deletions
@@ -1,4 +1,5 @@
import name
import name as names
val a = name
val a = name
val b = names
@@ -2,3 +2,4 @@ import name
import name as names
val a = name
val b = names
@@ -1,9 +1,8 @@
package test1
public class MyClass {
}
class MyClass
public fun MyClass.iterator(): Iterator<MyClass> {
operator fun MyClass.iterator(): Iterator<MyClass> {
return object: Iterator<MyClass> {
override fun next(): MyClass {
throw Exception()
@@ -1,5 +1,5 @@
// NAME_COUNT_TO_USE_STAR_IMPORT: 2
import p1.*
import p1.A
import p2.A
fun f() {
@@ -6,4 +6,3 @@ Additional checking of reference KtSimpleNameReference: A
Changed resolve of KtSimpleNameReference: A
Additional checking of reference KtInvokeFunctionReference: A("")
Additional checking of reference KtInvokeFunctionReference: A(1)
Trying to build import list again with import rules: +p2.A, +p1.*
@@ -1,20 +1,20 @@
/**
Comment 1
*/
*/
package sometest
import java.io as JavaIO
import java.text.Annotation as TextAnnotation
import java.io.File as JavaFile
import java.lang.Runnable as Task
import java.util.ArrayList
import java.util.HashSet
/**
Comment 2
*/
*/
class Action {
fun test(hash : HashSet<Int>) {
val some : TextAnnotation? = null
val test : ArrayList<Int>? = null
JavaIO.File(StringBuilder().append("Hello").toString())
fun test(hash: HashSet<Int>) {
val some: Task? = null
val test: ArrayList<Int>? = null
JavaFile(StringBuilder().append("Hello").toString())
}
}
@@ -1,20 +1,20 @@
/**
Comment 1
*/
*/
package sometest
import java.util.ArrayList
import java.util.HashSet
import java.io as JavaIO
import java.text.Annotation as TextAnnotation
import java.io.File as JavaFile
import java.lang.Runnable as Task
/**
Comment 2
*/
*/
class Action {
fun test(hash : HashSet<Int>) {
val some : TextAnnotation? = null
val test : ArrayList<Int>? = null
JavaIO.File(StringBuilder().append("Hello").toString())
fun test(hash: HashSet<Int>) {
val some: Task? = null
val test: ArrayList<Int>? = null
JavaFile(StringBuilder().append("Hello").toString())
}
}
@@ -0,0 +1,4 @@
Additional checking of reference Getter: JavaFile
Additional checking of reference KtSimpleNameReference: JavaFile
Changed resolve of KtSimpleNameReference: JavaFile
Additional checking of reference KtInvokeFunctionReference: JavaFile(StringBuilder().append("Hello").toString())
@@ -1,6 +1,4 @@
import java.util.ArrayList
import java.io as JavaIO
import java.util.ArrayList as SomeThing
class Action {
fun test() {