Smart completion includes object's from scope before searching for inheritors
#KT-6123 Fixed
This commit is contained in:
@@ -79,11 +79,18 @@ class SmartCompletion(val expression: JetSimpleNameExpression,
|
||||
val result = executeInternal() ?: return null
|
||||
// TODO: code could be more simple, see KT-5726
|
||||
val additionalItems = result.additionalItems.map(::postProcess)
|
||||
val inheritanceSearcher = result.inheritanceSearcher?.let {
|
||||
object : InheritanceItemsSearcher {
|
||||
override fun search(nameFilter: (String) -> Boolean, consumer: (LookupElement) -> Unit) {
|
||||
it.search(nameFilter, { consumer(postProcess(it)) })
|
||||
}
|
||||
}
|
||||
}
|
||||
val filter = result.declarationFilter
|
||||
return if (filter != null)
|
||||
Result({ filter(it).map(::postProcess) }, additionalItems, result.inheritanceSearcher)
|
||||
Result({ filter(it).map(::postProcess) }, additionalItems, inheritanceSearcher)
|
||||
else
|
||||
Result(null, additionalItems, result.inheritanceSearcher)
|
||||
Result(null, additionalItems, inheritanceSearcher)
|
||||
}
|
||||
|
||||
private fun executeInternal(): Result? {
|
||||
|
||||
@@ -62,7 +62,7 @@ class TypesWithSmartCasts(val bindingContext: BindingContext) {
|
||||
}
|
||||
return returnType.toList()
|
||||
}
|
||||
else if (descriptor is ClassDescriptor && descriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
else if (descriptor is ClassDescriptor && descriptor.getKind().isSingleton()) {
|
||||
return listOf(descriptor.getDefaultType())
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
trait I
|
||||
|
||||
object O : I
|
||||
|
||||
fun foo(): I = <caret>
|
||||
|
||||
// EXIST: { lookupString: "O", itemText: "O", tailText: " (<root>)" }
|
||||
// EXIST: foo
|
||||
// EXIST: object
|
||||
// NUMBER: 3
|
||||
@@ -0,0 +1,5 @@
|
||||
trait T
|
||||
|
||||
object OO : T
|
||||
|
||||
// ALLOW_AST_ACCESS
|
||||
@@ -0,0 +1,6 @@
|
||||
fun foo(): T = <caret>
|
||||
|
||||
// EXIST: foo
|
||||
// EXIST: { lookupString: "object", itemText: "object: T{...}" }
|
||||
// EXIST: { lookupString: "OO", itemText: "OO", tailText: " (<root>)" }
|
||||
// NUMBER: 3
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.jet.completion;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -624,6 +623,12 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Object.kt")
|
||||
public void testObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/smart/Object.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ObjectsFromType.kt")
|
||||
public void testObjectsFromType() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/smart/ObjectsFromType.kt");
|
||||
|
||||
@@ -77,4 +77,10 @@ public class MultiFileSmartCompletionTestGenerated extends AbstractMultiFileSmar
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NoObjectDuplication")
|
||||
public void testNoObjectDuplication() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/smartMultiFile/NoObjectDuplication/");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ package org.jetbrains.jet.completion.handlers;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user