Minor
This commit is contained in:
@@ -55,9 +55,6 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
|||||||
if (aliasName != null) {
|
if (aliasName != null) {
|
||||||
aliasImports.put(aliasName, path.fqnPart())
|
aliasImports.put(aliasName, path.fqnPart())
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
//TODO: detect other "special" imports
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.aliasImports = aliasImports
|
this.aliasImports = aliasImports
|
||||||
}
|
}
|
||||||
@@ -105,7 +102,7 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
|||||||
else {
|
else {
|
||||||
val useCount = incUseCount(parentFqName)
|
val useCount = incUseCount(parentFqName)
|
||||||
|
|
||||||
if (descriptor is ClassifierDescriptor) {
|
if (descriptor is ClassDescriptor) {
|
||||||
classNames.add(fqName)
|
classNames.add(fqName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +141,7 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: drop unused aliases
|
//TODO: drop unused aliases?
|
||||||
aliasImports.mapTo(importsToGenerate) { ImportPath(it.getValue(), false, it.getKey())}
|
aliasImports.mapTo(importsToGenerate) { ImportPath(it.getValue(), false, it.getKey())}
|
||||||
|
|
||||||
val sortedImportsToGenerate = importsToGenerate.sortBy(importInsertHelper.importSortComparator)
|
val sortedImportsToGenerate = importsToGenerate.sortBy(importInsertHelper.importSortComparator)
|
||||||
@@ -186,7 +183,7 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
|||||||
val targets = reference.resolveToDescriptors()
|
val targets = reference.resolveToDescriptors()
|
||||||
for (target in targets) {
|
for (target in targets) {
|
||||||
if (!target.canBeReferencedViaImport()) continue
|
if (!target.canBeReferencedViaImport()) continue
|
||||||
if (target is PackageViewDescriptor && target.getFqName().parent() == FqName.ROOT) continue // no need to import top-level packages (TODO: is that always true?)
|
if (target is PackageViewDescriptor && target.getFqName().parent() == FqName.ROOT) continue // no need to import top-level packages
|
||||||
|
|
||||||
if (!target.isExtension) { // for non-extension targets, count only non-qualified simple name usages
|
if (!target.isExtension) { // for non-extension targets, count only non-qualified simple name usages
|
||||||
if (element !is JetNameReferenceExpression) continue
|
if (element !is JetNameReferenceExpression) continue
|
||||||
|
|||||||
Reference in New Issue
Block a user