Fixed special item after "super." not working for fake override super
This commit is contained in:
+4
-2
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.renderer.render
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.resolve.findOriginalTopMostOverriddenDescriptors
|
||||
import org.jetbrains.kotlin.synthetic.SamAdapterExtensionFunctionDescriptor
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -62,9 +63,10 @@ class LookupElementFactory(
|
||||
|
||||
private val superFunctions: Set<FunctionDescriptor> by lazy {
|
||||
inDescriptor.parentsWithSelf
|
||||
.takeWhile { it !is ClassDescriptor }
|
||||
.filterIsInstance<FunctionDescriptor>()
|
||||
.toList()
|
||||
.flatMap { it.overriddenDescriptors }
|
||||
.flatMap { it.findOriginalTopMostOverriddenDescriptors() }
|
||||
.toSet()
|
||||
}
|
||||
|
||||
@@ -155,7 +157,7 @@ class LookupElementFactory(
|
||||
|
||||
private fun createSuperFunctionCallWithArguments(descriptor: FunctionDescriptor): LookupElement? {
|
||||
if (descriptor.valueParameters.isEmpty()) return null
|
||||
if (descriptor !in superFunctions) return null
|
||||
if (descriptor.findOriginalTopMostOverriddenDescriptors().none { it in superFunctions }) return null
|
||||
|
||||
val argumentText = descriptor.valueParameters.map {
|
||||
(if (it.varargElementType != null) "*" else "") + it.name.render()
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.util.CallType
|
||||
import org.jetbrains.kotlin.idea.util.FuzzyType
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.resolve.getOriginalTopmostOverriddenDescriptors
|
||||
import org.jetbrains.kotlin.resolve.findOriginalTopMostOverriddenDescriptors
|
||||
|
||||
object PriorityWeigher : LookupElementWeigher("kotlin.priority") {
|
||||
override fun weigh(element: LookupElement, context: WeighingContext)
|
||||
@@ -251,7 +251,7 @@ class PreferContextElementsWeigher(private val context: DeclarationDescriptor) :
|
||||
private val contextElements = context.parentsWithSelf
|
||||
.takeWhile { it !is PackageFragmentDescriptor }
|
||||
.toList()
|
||||
.flatMap { if (it is CallableDescriptor) it.getOriginalTopmostOverriddenDescriptors() else listOf(it) }
|
||||
.flatMap { if (it is CallableDescriptor) it.findOriginalTopMostOverriddenDescriptors() else listOf(it) }
|
||||
.toSet()
|
||||
private val contextElementNames = contextElements.map { it.name }.toSet()
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
open class B<T> {
|
||||
open class A<T> {
|
||||
open fun xxx_foo(p1: T, vararg p2: String) {}
|
||||
open fun xxx_bar(p1: Int, p2: String) {}
|
||||
}
|
||||
|
||||
open class B<T> : A<T> {
|
||||
open val xxx_val: Int = 0
|
||||
}
|
||||
|
||||
@@ -11,8 +14,8 @@ class C : B<String>() {
|
||||
}
|
||||
|
||||
// WITH_ORDER
|
||||
// EXIST: { lookupString: "xxx_foo", itemText: "xxx_foo", tailText: "(p1, *p2)", typeText: "Unit", attributes: "bold" }
|
||||
// EXIST: { lookupString: "xxx_foo", itemText: "xxx_foo", tailText: "(p1: String, vararg p2: String)", typeText: "Unit", attributes: "bold" }
|
||||
// EXIST: { lookupString: "xxx_foo", itemText: "xxx_foo", tailText: "(p1, *p2)", typeText: "Unit", attributes: "" }
|
||||
// EXIST: { lookupString: "xxx_foo", itemText: "xxx_foo", tailText: "(p1: String, vararg p2: String)", typeText: "Unit", attributes: "" }
|
||||
// EXIST: { lookupString: "xxx_val", itemText: "xxx_val", tailText: null, typeText: "Int", attributes: "bold" }
|
||||
// EXIST: { lookupString: "xxx_bar", itemText: "xxx_bar", tailText: "(p1: Int, p2: String)", typeText: "Unit", attributes: "bold" }
|
||||
// EXIST: { lookupString: "xxx_bar", itemText: "xxx_bar", tailText: "(p1: Int, p2: String)", typeText: "Unit", attributes: "" }
|
||||
// NOTHING_ELSE
|
||||
|
||||
Reference in New Issue
Block a user