"Static members" completion after "by"
This commit is contained in:
+10
-6
@@ -21,8 +21,8 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.idea.completion.LookupElementFactory
|
||||
import org.jetbrains.kotlin.idea.completion.decorateAsStaticMember
|
||||
import org.jetbrains.kotlin.idea.core.ExpectedInfo
|
||||
import org.jetbrains.kotlin.idea.core.fuzzyType
|
||||
import org.jetbrains.kotlin.idea.core.isVisible
|
||||
import org.jetbrains.kotlin.idea.core.multipleFuzzyTypes
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.util.fuzzyReturnType
|
||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import java.util.*
|
||||
|
||||
// adds java static members, enum members and members from companion object
|
||||
class StaticMembers(
|
||||
@@ -42,12 +42,16 @@ class StaticMembers(
|
||||
expectedInfos: Collection<ExpectedInfo>,
|
||||
context: KtSimpleNameExpression,
|
||||
enumEntriesToSkip: Set<DeclarationDescriptor>) {
|
||||
|
||||
val expectedInfosByClass = expectedInfos.groupBy {
|
||||
expectedInfo -> expectedInfo.fuzzyType?.type?.let { TypeUtils.getClassDescriptor(it) }
|
||||
val expectedInfosByClass = HashMap<ClassDescriptor, MutableList<ExpectedInfo>>()
|
||||
for (expectedInfo in expectedInfos) {
|
||||
for (fuzzyType in expectedInfo.multipleFuzzyTypes) {
|
||||
val classDescriptor = fuzzyType.type.constructor.declarationDescriptor as? ClassDescriptor ?: continue
|
||||
expectedInfosByClass.getOrPut(classDescriptor) { ArrayList() }.add(expectedInfo)
|
||||
}
|
||||
}
|
||||
|
||||
for ((classDescriptor, expectedInfosForClass) in expectedInfosByClass) {
|
||||
if (classDescriptor != null && !classDescriptor.name.isSpecial) {
|
||||
if (!classDescriptor.name.isSpecial) {
|
||||
addToCollection(collection, classDescriptor, expectedInfosForClass, context, enumEntriesToSkip)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -1,6 +1,10 @@
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class Property<TOwner, TValue>(owner: TOwner, value: TValue)
|
||||
class Property<TOwner, TValue>(owner: TOwner, value: TValue) {
|
||||
companion object {
|
||||
fun <TOwner, TValue> create(owner: TOwner, value: TValue) = Property<TOwner, TValue>(owner, value)
|
||||
}
|
||||
}
|
||||
|
||||
operator fun <TValue, TOwner> Property<TOwner, TValue>.getValue(thisRef: TOwner, property: KProperty<*>): TValue {
|
||||
throw Exception()
|
||||
@@ -14,3 +18,4 @@ class C {
|
||||
|
||||
// EXIST: { itemText: "createProperty", typeText: "Property<C, TValue>" }
|
||||
// EXIST: { itemText: "Property", tailText: "(owner: C, value: TValue) (<root>)" }
|
||||
// EXIST: { itemText:"Property.create", tailText:"(owner: C, value: TValue) (<root>)", typeText:"Property<C, TValue>" }
|
||||
|
||||
@@ -2,6 +2,10 @@ import kotlin.reflect.KProperty
|
||||
|
||||
class X1 {
|
||||
operator fun getValue(thisRef: C, property: KProperty<*>): String = ""
|
||||
|
||||
companion object {
|
||||
fun create() = X1()
|
||||
}
|
||||
}
|
||||
class X2 {
|
||||
operator fun getValue(thisRef: String, property: KProperty<*>): String = ""
|
||||
@@ -30,15 +34,19 @@ class C {
|
||||
}
|
||||
|
||||
// EXIST: lazy
|
||||
|
||||
// EXIST: createX1
|
||||
// ABSENT: createX2
|
||||
// EXIST: createX3
|
||||
// EXIST: createY1
|
||||
// ABSENT: createY2
|
||||
// EXIST: createY3
|
||||
|
||||
// EXIST: X1
|
||||
// ABSENT: X2
|
||||
// EXIST: X3
|
||||
// EXIST: Y1
|
||||
// ABSENT: Y2
|
||||
// ABSENT: Y3
|
||||
|
||||
// EXIST: { itemText:"X1.create", tailText:"() (<root>)", typeText:"X1", attributes:"" }
|
||||
|
||||
Reference in New Issue
Block a user