Dropped BindingContext.RESOLUTION_SCOPE
This commit is contained in:
@@ -573,7 +573,7 @@ class ExpectedInfos(
|
||||
if (operationToken != KtTokens.IN_KEYWORD && operationToken != KtTokens.NOT_IN || expressionWithType != binaryExpression.right) return null
|
||||
|
||||
val leftOperandType = binaryExpression.left?.let { bindingContext.getType(it) } ?: return null
|
||||
val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType)!!
|
||||
val scope = expressionWithType.getResolutionScope(bindingContext, resolutionFacade)
|
||||
val detector = TypesWithContainsDetector(scope, leftOperandType, resolutionFacade)
|
||||
|
||||
val byTypeFilter = object : ByTypeFilter {
|
||||
|
||||
+2
-1
@@ -204,7 +204,8 @@ class SmartCompletion(
|
||||
.addTo(items, inheritanceSearchers, expectedInfos)
|
||||
|
||||
if (expression is KtSimpleNameExpression) {
|
||||
StaticMembers(bindingContext, lookupElementFactory).addToCollection(items, expectedInfos, expression, descriptorsToSkip)
|
||||
StaticMembers(bindingContext, lookupElementFactory, resolutionFacade)
|
||||
.addToCollection(items, expectedInfos, expression, descriptorsToSkip)
|
||||
}
|
||||
|
||||
ClassLiteralItems.addToCollection(items, expectedInfos, lookupElementFactory, isJvmModule)
|
||||
|
||||
+7
-4
@@ -27,7 +27,9 @@ import org.jetbrains.kotlin.idea.completion.ExpectedInfo
|
||||
import org.jetbrains.kotlin.idea.completion.LookupElementFactory
|
||||
import org.jetbrains.kotlin.idea.completion.fuzzyType
|
||||
import org.jetbrains.kotlin.idea.completion.shortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.getResolutionScope
|
||||
import org.jetbrains.kotlin.idea.core.isVisible
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.idea.util.fuzzyReturnType
|
||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||
@@ -40,8 +42,9 @@ import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
// adds java static members, enum members and members from companion object
|
||||
class StaticMembers(
|
||||
val bindingContext: BindingContext,
|
||||
val lookupElementFactory: LookupElementFactory
|
||||
private val bindingContext: BindingContext,
|
||||
private val lookupElementFactory: LookupElementFactory,
|
||||
private val resolutionFacade: ResolutionFacade
|
||||
) {
|
||||
public fun addToCollection(collection: MutableCollection<LookupElement>,
|
||||
expectedInfos: Collection<ExpectedInfo>,
|
||||
@@ -65,10 +68,10 @@ class StaticMembers(
|
||||
context: KtSimpleNameExpression,
|
||||
enumEntriesToSkip: Set<DeclarationDescriptor>) {
|
||||
|
||||
val scope = bindingContext[BindingContext.RESOLUTION_SCOPE, context] ?: return
|
||||
val containingDescriptor = context.getResolutionScope(bindingContext, resolutionFacade).ownerDescriptor
|
||||
|
||||
fun processMember(descriptor: DeclarationDescriptor) {
|
||||
if (descriptor is DeclarationDescriptorWithVisibility && !descriptor.isVisible(scope.getContainingDeclaration(), bindingContext, context)) return
|
||||
if (descriptor is DeclarationDescriptorWithVisibility && !descriptor.isVisible(containingDescriptor, bindingContext, context)) return
|
||||
|
||||
val matcher: (ExpectedInfo) -> ExpectedInfoMatch
|
||||
if (descriptor is CallableDescriptor) {
|
||||
|
||||
+5
-3
@@ -25,14 +25,15 @@ import org.jetbrains.kotlin.idea.util.FuzzyType
|
||||
import org.jetbrains.kotlin.idea.util.nullability
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectAllFromMeAndParent
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeNullability
|
||||
import java.util.*
|
||||
|
||||
class TypesWithContainsDetector(
|
||||
private val scope: KtScope,
|
||||
private val scope: LexicalScope,
|
||||
private val argumentType: KotlinType,
|
||||
private val resolutionFacade: ResolutionFacade
|
||||
) {
|
||||
@@ -41,7 +42,8 @@ class TypesWithContainsDetector(
|
||||
private val booleanType = resolutionFacade.moduleDescriptor.builtIns.booleanType
|
||||
private val heuristicSignatures = resolutionFacade.ideService<HeuristicSignatures>()
|
||||
|
||||
private val typesWithExtensionContains: Collection<KotlinType> = scope.getFunctions(containsName, NoLookupLocation.FROM_IDE)
|
||||
private val typesWithExtensionContains: Collection<KotlinType> = scope
|
||||
.collectAllFromMeAndParent { it.getDeclaredFunctions(containsName, NoLookupLocation.FROM_IDE) }
|
||||
.filter { it.getExtensionReceiverParameter() != null && isGoodContainsFunction(it, listOf()) }
|
||||
.map { it.getExtensionReceiverParameter()!!.getType() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user