Take into account excluded fq-names when determining whether type has been imported by default.
Related to #KT-13447
This commit is contained in:
@@ -54,4 +54,8 @@ fun ImportPath.isImported(alreadyImported: ImportPath): Boolean {
|
||||
return if (isAllUnder || hasAlias()) this == alreadyImported else fqnPart().isImported(alreadyImported)
|
||||
}
|
||||
|
||||
fun ImportPath.isImported(imports: Iterable<ImportPath>): Boolean = imports.any { isImported(it) }
|
||||
private fun ImportPath.isImported(imports: Iterable<ImportPath>): Boolean = imports.any { isImported(it) }
|
||||
|
||||
fun ImportPath.isImported(imports: Iterable<ImportPath>, excludedFqNames: Iterable<FqName>): Boolean {
|
||||
return isImported(imports) && (isAllUnder || this.fqnPart() !in excludedFqNames)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fun some(e: IllegalArgumentException<caret>) {
|
||||
}
|
||||
|
||||
// INVOCATION_COUNT: 2
|
||||
// WITH_ORDER
|
||||
// EXIST: { lookupString:"IllegalArgumentException", typeText:"public typealias IllegalArgumentException = IllegalArgumentException defined in kotlin" }
|
||||
// EXIST: { lookupString:"IllegalArgumentException", tailText:" (java.lang)" }
|
||||
+6
@@ -2755,6 +2755,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("StandardKotlinTypeAliasFirst.kt")
|
||||
public void testStandardKotlinTypeAliasFirst() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/java/StandardKotlinTypeAliasFirst.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TopLevelFromStandardLibrary.kt")
|
||||
public void testTopLevelFromStandardLibrary() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/java/TopLevelFromStandardLibrary.kt");
|
||||
|
||||
@@ -57,8 +57,8 @@ class ImportInsertHelperImpl(private val project: Project) : ImportInsertHelper(
|
||||
get() = ImportPathComparator
|
||||
|
||||
override fun isImportedWithDefault(importPath: ImportPath, contextFile: KtFile): Boolean {
|
||||
val defaultImports = contextFile.platform.defaultModuleParameters.defaultImports
|
||||
return importPath.isImported(defaultImports)
|
||||
val moduleParameters = contextFile.platform.defaultModuleParameters
|
||||
return importPath.isImported(moduleParameters.defaultImports, moduleParameters.excludedImports)
|
||||
}
|
||||
|
||||
override fun mayImportOnShortenReferences(descriptor: DeclarationDescriptor): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user