This commit is contained in:
Valentin Kipyatkov
2015-10-25 12:03:29 +03:00
parent e1b8b21abb
commit 5f06f53bfd
45 changed files with 187 additions and 193 deletions
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.resolve.scopes.utils.collectAllFromImportingScopes
import org.jetbrains.kotlin.resolve.scopes.utils.getDescriptorsFromAllFiltered
import org.jetbrains.kotlin.resolve.scopes.utils.collectDescriptorsFiltered
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
import org.jetbrains.kotlin.types.KotlinType
@@ -162,7 +162,7 @@ public class ReferenceVariantsHelper(
descriptors.processAll(implicitReceiverTypes, implicitReceiverTypes, resolutionScope, callType, kindFilter, nameFilter)
// add non-instance members
descriptors.addAll(resolutionScope.getDescriptorsFromAllFiltered(kindFilter exclude DescriptorKindExclude.Extensions, nameFilter))
descriptors.addAll(resolutionScope.collectDescriptorsFiltered(kindFilter exclude DescriptorKindExclude.Extensions, nameFilter))
}
return descriptors
@@ -182,7 +182,7 @@ public class ReferenceVariantsHelper(
val lexicalScope = expression.getParentOfType<KtTypeReference>(strict = true)?.let {
context[BindingContext.LEXICAL_SCOPE, it]
} ?: return emptyList()
return lexicalScope.getDescriptorsFromAllFiltered(kindFilter, nameFilter)
return lexicalScope.collectDescriptorsFiltered(kindFilter, nameFilter)
}
}
@@ -274,7 +274,7 @@ public class ReferenceVariantsHelper(
filterToUse = filterToUse.withKinds(DescriptorKindFilter.NON_SINGLETON_CLASSIFIERS_MASK)
}
for (descriptor in scope.getDescriptorsFromAllFiltered(filterToUse, nameFilter)) {
for (descriptor in scope.collectDescriptorsFiltered(filterToUse, nameFilter)) {
if (descriptor is ClassDescriptor) {
if (descriptor.modality == Modality.ABSTRACT || descriptor.modality == Modality.SEALED) continue
if (!constructorFilter(descriptor)) continue
@@ -301,19 +301,19 @@ public class ReferenceVariantsHelper(
}
}
for (descriptor in resolutionScope.getDescriptorsFromAllFiltered(kindFilter exclude DescriptorKindExclude.NonExtensions, nameFilter)) {
for (descriptor in resolutionScope.collectDescriptorsFiltered(kindFilter exclude DescriptorKindExclude.NonExtensions, nameFilter)) {
// todo: sometimes resolution scope here is LazyJavaClassMemberScope. see ea.jetbrains.com/browser/ea_problems/72572
process(descriptor as CallableDescriptor)
}
if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK)) {
for (extension in resolutionScope.collectAllFromImportingScopes { it.getSyntheticExtensionProperties(receiverTypes) }) {
for (extension in resolutionScope.collectAllFromImportingScopes { it.getContributedSyntheticExtensionProperties(receiverTypes) }) {
process(extension)
}
}
if (kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK)) {
for (extension in resolutionScope.collectAllFromImportingScopes { it.getSyntheticExtensionFunctions(receiverTypes) }) {
for (extension in resolutionScope.collectAllFromImportingScopes { it.getContributedSyntheticExtensionFunctions(receiverTypes) }) {
process(extension)
}
}
@@ -335,6 +335,6 @@ public class ReferenceVariantsHelper(
nameFilter: (Name) -> Boolean
): Collection<DeclarationDescriptor> {
val resolutionScope = context[BindingContext.LEXICAL_SCOPE, expression] ?: return listOf()
return resolutionScope.getDescriptorsFromAllFiltered(DescriptorKindFilter.PACKAGES, nameFilter).filter(visibilityFilter)
return resolutionScope.collectDescriptorsFiltered(DescriptorKindFilter.PACKAGES, nameFilter).filter(visibilityFilter)
}
}
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.utils.getClassifier
import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.*
@@ -84,7 +84,7 @@ fun KotlinType.isResolvableInScope(scope: LexicalScope?, checkTypeParameters: Bo
if (descriptor == null || descriptor.getName().isSpecial()) return false
if (!checkTypeParameters && descriptor is TypeParameterDescriptor) return true
return scope != null && scope.getClassifier(descriptor.name, NoLookupLocation.FROM_IDE) == descriptor
return scope != null && scope.findClassifier(descriptor.name, NoLookupLocation.FROM_IDE) == descriptor
}
public fun KotlinType.approximateWithResolvableType(scope: LexicalScope?, checkTypeParameters: Boolean): KotlinType {
@@ -27,12 +27,12 @@ import org.jetbrains.kotlin.resolve.scopes.utils.collectAllFromMeAndParent
public fun LexicalScope.getAllAccessibleVariables(name: Name): Collection<VariableDescriptor> {
return getVariablesFromImplicitReceivers(name) + collectAllFromMeAndParent { it.getDeclaredVariables(name, NoLookupLocation.FROM_IDE) }
return getVariablesFromImplicitReceivers(name) + collectAllFromMeAndParent { it.getContributedVariables(name, NoLookupLocation.FROM_IDE) }
}
public fun LexicalScope.getAllAccessibleFunctions(name: Name): Collection<FunctionDescriptor> {
return getImplicitReceiversWithInstance().flatMap { it.type.memberScope.getFunctions(name, NoLookupLocation.FROM_IDE) } +
collectAllFromMeAndParent { it.getDeclaredFunctions(name, NoLookupLocation.FROM_IDE) }
collectAllFromMeAndParent { it.getContributedFunctions(name, NoLookupLocation.FROM_IDE) }
}
public fun LexicalScope.getVariablesFromImplicitReceivers(name: Name): Collection<VariableDescriptor> = getImplicitReceiversWithInstance().flatMap {