KT-33979 KT-34150 Remove filtering overridden object members and nested objects
- ^KT-33979 Fixed - ^KT-34150 Fixed - Also, in extension completion check descriptor instance first
This commit is contained in:
committed by
Roman Golyshev
parent
2552540f71
commit
66ffdf1b2d
+3
-16
@@ -28,8 +28,6 @@ import org.jetbrains.kotlin.idea.core.targetDescriptors
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.util.CallType
|
||||
import org.jetbrains.kotlin.idea.util.substituteExtensionIfCallable
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtObjectDeclaration
|
||||
@@ -102,9 +100,8 @@ class StaticMembersCompletion(
|
||||
val descriptorKindFilter = DescriptorKindFilter.CALLABLES exclude DescriptorKindExclude.Extensions
|
||||
val nameFilter: (String) -> Boolean = { prefixMatcher.prefixMatches(it) }
|
||||
|
||||
val filter = { declaration: KtNamedDeclaration, objectDeclaration: KtObjectDeclaration ->
|
||||
!declaration.hasModifier(KtTokens.OVERRIDE_KEYWORD) && objectDeclaration.isTopLevelOrCompanion()
|
||||
}
|
||||
val filter = { _: KtNamedDeclaration, _: KtObjectDeclaration -> true }
|
||||
|
||||
indicesHelper.processObjectMembers(descriptorKindFilter, nameFilter, filter) {
|
||||
if (it !in alreadyAdded) {
|
||||
processor(it)
|
||||
@@ -127,22 +124,12 @@ class StaticMembersCompletion(
|
||||
val filter = { _: KtNamedDeclaration, _: KtObjectDeclaration -> true }
|
||||
|
||||
indicesHelper.processObjectMembers(descriptorKindFilter, nameFilter, filter) {
|
||||
if (it !in alreadyAdded && it is CallableDescriptor) {
|
||||
if (it is CallableDescriptor && it !in alreadyAdded) {
|
||||
processor(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun KtObjectDeclaration.isTopLevelOrCompanion(): Boolean {
|
||||
if (isCompanion()) {
|
||||
val owner = parent.parent as? KtClass ?: return false
|
||||
return owner.isTopLevel()
|
||||
}
|
||||
else {
|
||||
return isTopLevel()
|
||||
}
|
||||
}
|
||||
|
||||
fun completeFromImports(file: KtFile, collector: LookupElementsCollector) {
|
||||
val factory = decoratedLookupElementFactory(ItemPriority.STATIC_MEMBER_FROM_IMPORTS)
|
||||
membersFromImports(file)
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ fun testFun() {
|
||||
// INVOCATION_COUNT: 2
|
||||
// EXIST: { allLookupStrings: "funFromObject", itemText: "KotlinObject.funFromObject", tailText: "() (test)", typeText: "Unit", attributes: "" }
|
||||
// EXIST: { allLookupStrings: "funFromCompanionObject", itemText: "KotlinClass.funFromCompanionObject", tailText: "() (test)", typeText: "Unit", attributes: "" }
|
||||
// EXIST: { allLookupStrings: "fromNested", itemText: "Nested.fromNested", tailText: "() (test.AnotherKotlinClass)", typeText: "Unit", attributes: "" }
|
||||
// EXIST: { allLookupStrings: "fromInterface", itemText: "DefaultI.fromInterface", tailText: "() (test)", typeText: "Unit", attributes: "" }
|
||||
// ABSENT: funPrivate
|
||||
// ABSENT: funFromPrivateCompanionObject
|
||||
// ABSENT: fromNested
|
||||
// ABSENT: fromInterface
|
||||
// ABSENT: fromAnonymous
|
||||
|
||||
Reference in New Issue
Block a user