No members from anonymous objects etc
This commit is contained in:
+18
-1
@@ -25,7 +25,10 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper
|
||||
import org.jetbrains.kotlin.idea.core.targetDescriptors
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtObjectDeclaration
|
||||
import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
@@ -94,11 +97,25 @@ class StaticMembersCompletion(
|
||||
indicesHelper.getJavaStaticMembers(descriptorKindFilter, nameFilter).filterTo(result) { it !in alreadyAdded } //TODO: substitution
|
||||
}
|
||||
|
||||
indicesHelper.getObjectMembers(descriptorKindFilter, nameFilter).filterTo(result) { it !in alreadyAdded } //TODO: substitution
|
||||
indicesHelper.getObjectMembers(descriptorKindFilter, nameFilter) filter@ { declaration, objectDeclaration ->
|
||||
!declaration.hasModifier(KtTokens.OVERRIDE_KEYWORD) && objectDeclaration.isTopLevelOrCompanion()
|
||||
}.filterTo(result) {
|
||||
it !in alreadyAdded //TODO: substitution
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
+26
-2
@@ -2,13 +2,13 @@ package test
|
||||
|
||||
object KotlinObject {
|
||||
fun funFromObject() { }
|
||||
private fun privateFun(){}
|
||||
private fun funPrivate(){}
|
||||
}
|
||||
|
||||
class KotlinClass {
|
||||
companion object SomeName {
|
||||
fun funFromCompanionObject() { }
|
||||
private fun privateFun(){}
|
||||
private fun funPrivate(){}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,28 @@ class AnotherKotlinClass {
|
||||
private companion object {
|
||||
fun funFromPrivateCompanionObject() { }
|
||||
}
|
||||
|
||||
object Nested {
|
||||
fun fromNested(){}
|
||||
}
|
||||
}
|
||||
|
||||
interface I {
|
||||
fun fromInterface()
|
||||
}
|
||||
|
||||
object DefaultI : I {
|
||||
override fun fromInterface() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun foo() {
|
||||
val o = object : Runnable {
|
||||
override fun run() {
|
||||
fromAnonymous()
|
||||
}
|
||||
|
||||
fun fromAnonymous(){}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -1,11 +1,14 @@
|
||||
package first
|
||||
|
||||
fun testFun() {
|
||||
funFromO<caret>
|
||||
f<caret>
|
||||
}
|
||||
|
||||
// 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: "" }
|
||||
// ABSENT: privateFun
|
||||
// ABSENT: funPrivate
|
||||
// ABSENT: funFromPrivateCompanionObject
|
||||
// ABSENT: fromNested
|
||||
// ABSENT: fromInterface
|
||||
// ABSENT: fromAnonymous
|
||||
|
||||
Reference in New Issue
Block a user