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()) {
|
if (callTypeAndReceiver.shouldCompleteCallableExtensions()) {
|
||||||
filter = filter.exclude(topLevelExtensionsExclude) // completed via indices
|
filter = filter.exclude(TopLevelExtensionsExclude) // completed via indices
|
||||||
}
|
}
|
||||||
|
|
||||||
filter
|
filter
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ import com.intellij.patterns.StandardPatterns
|
|||||||
import com.intellij.psi.search.GlobalSearchScope
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
import com.intellij.util.ProcessingContext
|
import com.intellij.util.ProcessingContext
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
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.codeInsight.ReferenceVariantsHelper
|
||||||
import org.jetbrains.kotlin.idea.core.*
|
import org.jetbrains.kotlin.idea.core.*
|
||||||
import org.jetbrains.kotlin.idea.imports.importableFqName
|
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.idea.util.*
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isExtensionDeclaration
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
@@ -160,18 +162,11 @@ abstract class CompletionSession(
|
|||||||
declarationTranslator = { toFromOriginalFileMapper.toSyntheticFile(it) })
|
declarationTranslator = { toFromOriginalFileMapper.toSyntheticFile(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
// excludes top-level extensions except for ones declared in the current file - those that are fetched from indices
|
protected object TopLevelExtensionsExclude : DescriptorKindExclude() {
|
||||||
protected val topLevelExtensionsExclude = object : DescriptorKindExclude() {
|
|
||||||
val extensionsFromThisFile = file.declarations
|
|
||||||
.filter { it.isExtensionDeclaration() }
|
|
||||||
.map { it.resolveToDescriptor() }
|
|
||||||
.toSet()
|
|
||||||
|
|
||||||
override fun excludes(descriptor: DeclarationDescriptor): Boolean {
|
override fun excludes(descriptor: DeclarationDescriptor): Boolean {
|
||||||
if (descriptor !is CallableMemberDescriptor) return false
|
if (descriptor !is CallableMemberDescriptor) return false
|
||||||
if (descriptor.extensionReceiverParameter == null) 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 */
|
||||||
if (descriptor.kind != CallableMemberDescriptor.Kind.DECLARATION) return false /* do not filter out synthetic extensions from packages */
|
|
||||||
val containingPackage = descriptor.containingDeclaration as? PackageFragmentDescriptor ?: return false
|
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
|
if (containingPackage.fqName.asString().startsWith("kotlinx.android.synthetic.")) return false // TODO: temporary solution for Android synthetic extensions
|
||||||
return true
|
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
|
// 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
|
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 (smartCompletion?.expectedInfos?.filterFunctionExpected()?.isNotEmpty() ?: false) {
|
||||||
// if function type is expected we need classes to obtain their constructors
|
// if function type is expected we need classes to obtain their constructors
|
||||||
|
|||||||
Reference in New Issue
Block a user