Smart completion of inheritors: correct filtering of duplicates
This commit is contained in:
@@ -204,7 +204,8 @@ class TypeInstantiationItems(
|
|||||||
lookupElement = lookupElement.assignSmartCompletionPriority(SmartCompletionItemPriority.INSTANTIATION)
|
lookupElement = lookupElement.assignSmartCompletionPriority(SmartCompletionItemPriority.INSTANTIATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
lookupElement = object: LookupElementDecorator<LookupElement>(lookupElement) {
|
//TODO: cannot use lookupElement from context due to KT-6344
|
||||||
|
class InstantiationLookupElement(lookupElement: LookupElement) : LookupElementDecorator<LookupElement>(lookupElement) {
|
||||||
override fun getLookupString() = lookupString
|
override fun getLookupString() = lookupString
|
||||||
|
|
||||||
override fun getAllLookupStrings() = allLookupStrings
|
override fun getAllLookupStrings() = allLookupStrings
|
||||||
@@ -223,9 +224,20 @@ class TypeInstantiationItems(
|
|||||||
override fun handleInsert(context: InsertionContext) {
|
override fun handleInsert(context: InsertionContext) {
|
||||||
insertHandler.handleInsert(context, getDelegate())
|
insertHandler.handleInsert(context, getDelegate())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other === this) return true
|
||||||
|
if (other !is InstantiationLookupElement) return false
|
||||||
|
if (getLookupString() != other.getLookupString()) return false
|
||||||
|
val presentation1 = LookupElementPresentation()
|
||||||
|
val presentation2 = LookupElementPresentation()
|
||||||
|
renderElement(presentation1)
|
||||||
|
other.renderElement(presentation2)
|
||||||
|
return presentation1.getItemText() == presentation2.getItemText() && presentation1.getTailText() == presentation2.getTailText()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lookupElement.addTail(tail)
|
return InstantiationLookupElement(lookupElement).addTail(tail)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addSamConstructorItem(collection: MutableCollection<LookupElement>, `class`: ClassDescriptor, tail: Tail?) {
|
private fun addSamConstructorItem(collection: MutableCollection<LookupElement>, `class`: ClassDescriptor, tail: Tail?) {
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
class X
|
||||||
|
class Y
|
||||||
|
|
||||||
|
trait T1
|
||||||
|
trait T2<T>
|
||||||
|
trait T3<T>
|
||||||
|
|
||||||
|
class C1 : T1
|
||||||
|
class C2<T> : T2<T>, T3<T>
|
||||||
|
class C3 : T1, T2<X>
|
||||||
|
|
||||||
|
fun foo(p: T1){}
|
||||||
|
fun foo(p: T2<X>){}
|
||||||
|
fun foo(p: T3<Y>){}
|
||||||
|
|
||||||
|
// ALLOW_AST_ACCESS
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
fun bar() {
|
||||||
|
foo(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: { lookupString: "object", itemText: "object: T1{...}" }
|
||||||
|
// EXIST: { lookupString: "object", itemText: "object: T2<X>{...}" }
|
||||||
|
// EXIST: { lookupString: "object", itemText: "object: T3<Y>{...}" }
|
||||||
|
// EXIST: { lookupString: "C1", itemText: "C1" }
|
||||||
|
// EXIST: { lookupString: "C2", itemText: "C2<X>" }
|
||||||
|
// EXIST: { lookupString: "C2", itemText: "C2<Y>" }
|
||||||
|
// EXIST: { lookupString: "C3", itemText: "C3" }
|
||||||
|
// NUMBER: 7
|
||||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.completion;
|
|||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
|
import org.jetbrains.jet.test.InnerTestClasses;
|
||||||
import org.jetbrains.jet.test.TestMetadata;
|
import org.jetbrains.jet.test.TestMetadata;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ public class MultiFileSmartCompletionTestGenerated extends AbstractMultiFileSmar
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("InheritorsAndMultipleExpectedTypes")
|
||||||
|
public void testInheritorsAndMultipleExpectedTypes() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/smartMultiFile/InheritorsAndMultipleExpectedTypes/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("JavaStaticMethodArgument")
|
@TestMetadata("JavaStaticMethodArgument")
|
||||||
public void testJavaStaticMethodArgument() throws Exception {
|
public void testJavaStaticMethodArgument() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/");
|
||||||
|
|||||||
Reference in New Issue
Block a user