diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/Weighers.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/Weighers.kt index dbd13a35214..74023b41fb9 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/Weighers.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/Weighers.kt @@ -230,6 +230,7 @@ object PreferMatchingItemWeigher : LookupElementWeigher("kotlin.preferMatching", keywordExactMatch, defaultExactMatch, functionExactMatch, + notImportedExactMatch, specialExactMatch, notExactMatch } @@ -248,6 +249,7 @@ object PreferMatchingItemWeigher : LookupElementWeigher("kotlin.preferMatching", val smartCompletionPriority = element.getUserData(SMART_COMPLETION_ITEM_PRIORITY_KEY) when { smartCompletionPriority != null && smartCompletionPriority != SmartCompletionItemPriority.DEFAULT -> Weight.specialExactMatch + element.getUserData(NOT_IMPORTED_KEY) != null -> Weight.notImportedExactMatch o.descriptor is FunctionDescriptor -> Weight.functionExactMatch else -> Weight.defaultExactMatch } diff --git a/idea/idea-completion/testData/basic/multifile/ExactMatchPreferImported/ExactMatchPreferImported.dependency1.kt b/idea/idea-completion/testData/basic/multifile/ExactMatchPreferImported/ExactMatchPreferImported.dependency1.kt new file mode 100644 index 00000000000..7cc1b3002ea --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ExactMatchPreferImported/ExactMatchPreferImported.dependency1.kt @@ -0,0 +1,3 @@ +package other + +class TODO \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/ExactMatchPreferImported/ExactMatchPreferImported.dependency2.kt b/idea/idea-completion/testData/basic/multifile/ExactMatchPreferImported/ExactMatchPreferImported.dependency2.kt new file mode 100644 index 00000000000..2b56fef1c85 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ExactMatchPreferImported/ExactMatchPreferImported.dependency2.kt @@ -0,0 +1,3 @@ +package kotlin + +public inline fun TODO(): Nothing = throw NotImplementedError() diff --git a/idea/idea-completion/testData/basic/multifile/ExactMatchPreferImported/ExactMatchPreferImported.kt b/idea/idea-completion/testData/basic/multifile/ExactMatchPreferImported/ExactMatchPreferImported.kt new file mode 100644 index 00000000000..c121a34c20f --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ExactMatchPreferImported/ExactMatchPreferImported.kt @@ -0,0 +1,5 @@ +fun foo(): Any? = TODO + +// WITH_ORDER +// EXIST: { itemText: "TODO", tailText:"() (kotlin)" } +// EXIST: { itemText: "TODO", tailText:" (other)" } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java index e7a422edd92..4b5a72d3761 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java @@ -95,6 +95,12 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ doTest(fileName); } + @TestMetadata("ExactMatchPreferImported") + public void testExactMatchPreferImported() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/ExactMatchPreferImported/"); + doTest(fileName); + } + @TestMetadata("ExcludedClass") public void testExcludedClass() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/ExcludedClass/");