No need to specially handle extensions from current file anymore (since searchScope for KotlinIndicesHelper includes current file)
This commit is contained in:
+1
-1
@@ -149,7 +149,7 @@ class BasicCompletionSession(
|
||||
}
|
||||
|
||||
if (callTypeAndReceiver.shouldCompleteCallableExtensions()) {
|
||||
filter = filter.exclude(topLevelExtensionsExclude) // completed via indices
|
||||
filter = filter.exclude(TopLevelExtensionsExclude) // completed via indices
|
||||
}
|
||||
|
||||
filter
|
||||
|
||||
@@ -27,7 +27,10 @@ import com.intellij.patterns.StandardPatterns
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.util.ProcessingContext
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.*
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.ModuleOrigin
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.OriginCapability
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolveScope
|
||||
import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper
|
||||
import org.jetbrains.kotlin.idea.core.*
|
||||
import org.jetbrains.kotlin.idea.imports.importableFqName
|
||||
@@ -36,7 +39,6 @@ import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isExtensionDeclaration
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
@@ -160,18 +162,11 @@ abstract class CompletionSession(
|
||||
declarationTranslator = { toFromOriginalFileMapper.toSyntheticFile(it) })
|
||||
}
|
||||
|
||||
// excludes top-level extensions except for ones declared in the current file - those that are fetched from indices
|
||||
protected val topLevelExtensionsExclude = object : DescriptorKindExclude() {
|
||||
val extensionsFromThisFile = file.declarations
|
||||
.filter { it.isExtensionDeclaration() }
|
||||
.map { it.resolveToDescriptor() }
|
||||
.toSet()
|
||||
|
||||
protected object TopLevelExtensionsExclude : DescriptorKindExclude() {
|
||||
override fun excludes(descriptor: DeclarationDescriptor): Boolean {
|
||||
if (descriptor !is CallableMemberDescriptor) return false
|
||||
if (descriptor.extensionReceiverParameter == null) return false
|
||||
if (descriptor in extensionsFromThisFile) return false
|
||||
if (descriptor.kind != CallableMemberDescriptor.Kind.DECLARATION) return false /* do not filter out synthetic extensions from packages */
|
||||
if (descriptor.kind != CallableMemberDescriptor.Kind.DECLARATION) return false /* do not filter out synthetic extensions */
|
||||
val containingPackage = descriptor.containingDeclaration as? PackageFragmentDescriptor ?: return false
|
||||
if (containingPackage.fqName.asString().startsWith("kotlinx.android.synthetic.")) return false // TODO: temporary solution for Android synthetic extensions
|
||||
return true
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ class SmartCompletionSession(
|
||||
// we do not include SAM-constructors because they are handled separately and adding them requires iterating of java classes
|
||||
var filter = DescriptorKindFilter.VALUES exclude SamConstructorDescriptorKindExclude
|
||||
|
||||
filter = filter exclude topLevelExtensionsExclude // handled via indices
|
||||
filter = filter exclude TopLevelExtensionsExclude // handled via indices
|
||||
|
||||
if (smartCompletion?.expectedInfos?.filterFunctionExpected()?.isNotEmpty() ?: false) {
|
||||
// if function type is expected we need classes to obtain their constructors
|
||||
|
||||
Reference in New Issue
Block a user