Provide location parameter in delegations

This commit is contained in:
Zalim Bashorov
2015-07-17 15:06:40 +03:00
parent 41449c107e
commit df4f43267b
10 changed files with 27 additions and 27 deletions
@@ -43,15 +43,15 @@ class AllUnderImportsScope : JetScope {
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? {
return scopes.asSequence().map { it.getClassifier(name) }.filterNotNull().singleOrNull()
return scopes.asSequence().map { it.getClassifier(name, location) }.filterNotNull().singleOrNull()
}
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> {
return scopes.flatMap { it.getProperties(name) }
return scopes.flatMap { it.getProperties(name, location) }
}
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
return scopes.flatMap { it.getFunctions(name) }
return scopes.flatMap { it.getFunctions(name, location) }
}
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> {
@@ -236,7 +236,7 @@ class LazyImportScope(
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? {
return importResolver.selectSingleFromImports(name, LookupMode.ONLY_CLASSES_AND_PACKAGES) { scope, name ->
val descriptor = scope.getClassifier(name)
val descriptor = scope.getClassifier(name, location)
if (descriptor != null && isClassVisible(descriptor as ClassDescriptor/*no type parameter can be imported*/)) descriptor else null
}
}
@@ -248,14 +248,14 @@ class LazyImportScope(
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> {
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getProperties(name) }
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getProperties(name, location) }
}
override fun getLocalVariable(name: Name) = null
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getFunctions(name) }
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getFunctions(name, location) }
}
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> {
@@ -117,7 +117,7 @@ public open class LazyClassMemberScope(
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
// TODO: this should be handled by lazy function descriptors
val functions = super.getFunctions(name)
val functions = super.getFunctions(name, location)
resolveUnknownVisibilitiesForMembers(functions)
return functions
}
@@ -175,7 +175,7 @@ public open class LazyClassMemberScope(
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> {
// TODO: this should be handled by lazy property descriptors
val properties = super.getProperties(name)
val properties = super.getProperties(name, location)
resolveUnknownVisibilitiesForMembers(properties as Collection<CallableMemberDescriptor>)
return properties
}
@@ -159,7 +159,7 @@ public class WritableScopeImpl @jvmOverloads constructor(
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
checkMayRead()
return concatInOrder(functionsByName(name), workerScope.getFunctions(name))
return concatInOrder(functionsByName(name), workerScope.getFunctions(name, location))
}
override fun addClassifierDescriptor(classifierDescriptor: ClassifierDescriptor) {
@@ -170,7 +170,7 @@ public class WritableScopeImpl @jvmOverloads constructor(
checkMayRead()
return variableOrClassDescriptorByName(name) as? ClassifierDescriptor
?: workerScope.getClassifier(name)
?: workerScope.getClassifier(name, location)
}
override fun getImplicitReceiversHierarchy() = implicitReceiverHierarchy
@@ -273,14 +273,14 @@ public class WritableScopeImpl @jvmOverloads constructor(
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
checkMayRead()
return concatInOrder(functionsByName(name, descriptorLimit), workerScope.getFunctions(name))
return concatInOrder(functionsByName(name, descriptorLimit), workerScope.getFunctions(name, location))
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? {
checkMayRead()
return variableOrClassDescriptorByName(name, descriptorLimit) as? ClassifierDescriptor
?: workerScope.getClassifier(name)
?: workerScope.getClassifier(name, location)
}
override fun getOwnDeclaredDescriptors(): Collection<DeclarationDescriptor> = addedDescriptors.truncated(descriptorLimit)
@@ -72,8 +72,8 @@ public class LazyPackageFragmentScopeForJavaPackage(
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? = classes(name)
override fun getProperties(name: Name, location: UsageLocation) = deserializedPackageScope().getProperties(name)
override fun getFunctions(name: Name, location: UsageLocation) = deserializedPackageScope().getFunctions(name) + super.getFunctions(name)
override fun getProperties(name: Name, location: UsageLocation) = deserializedPackageScope().getProperties(name, location)
override fun getFunctions(name: Name, location: UsageLocation) = deserializedPackageScope().getFunctions(name, location) + super.getFunctions(name, location)
override fun addExtraDescriptors(result: MutableSet<DeclarationDescriptor>,
kindFilter: DescriptorKindFilter,
@@ -32,7 +32,7 @@ public abstract class AbstractScopeAdapter : JetScope {
}
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
return workerScope.getFunctions(name)
return workerScope.getFunctions(name, location)
}
override fun getPackage(name: Name): PackageViewDescriptor? {
@@ -40,11 +40,11 @@ public abstract class AbstractScopeAdapter : JetScope {
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? {
return workerScope.getClassifier(name)
return workerScope.getClassifier(name, location)
}
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> {
return workerScope.getProperties(name)
return workerScope.getProperties(name, location)
}
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> {
@@ -51,19 +51,19 @@ public open class ChainedScope(
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor?
= getFirstMatch { it.getClassifier(name) }
= getFirstMatch { it.getClassifier(name, location) }
override fun getPackage(name: Name): PackageViewDescriptor?
= getFirstMatch { it.getPackage(name) }
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor>
= getFromAllScopes { it.getProperties(name) }
= getFromAllScopes { it.getProperties(name, location) }
override fun getLocalVariable(name: Name): VariableDescriptor?
= getFirstMatch { it.getLocalVariable(name) }
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor>
= getFromAllScopes { it.getFunctions(name) }
= getFromAllScopes { it.getFunctions(name, location) }
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
= getFromAllScopes { it.getSyntheticExtensionProperties(receiverTypes, name) }
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.utils.Printer
public class FilteringScope(private val workerScope: JetScope, private val predicate: (DeclarationDescriptor) -> Boolean) : JetScope {
override fun getFunctions(name: Name, location: UsageLocation) = workerScope.getFunctions(name).filter(predicate)
override fun getFunctions(name: Name, location: UsageLocation) = workerScope.getFunctions(name, location).filter(predicate)
override fun getContainingDeclaration() = workerScope.getContainingDeclaration()
@@ -33,9 +33,9 @@ public class FilteringScope(private val workerScope: JetScope, private val predi
override fun getPackage(name: Name) = filterDescriptor(workerScope.getPackage(name))
override fun getClassifier(name: Name, location: UsageLocation) = filterDescriptor(workerScope.getClassifier(name))
override fun getClassifier(name: Name, location: UsageLocation) = filterDescriptor(workerScope.getClassifier(name, location))
override fun getProperties(name: Name, location: UsageLocation) = workerScope.getProperties(name).filter(predicate)
override fun getProperties(name: Name, location: UsageLocation) = workerScope.getProperties(name, location).filter(predicate)
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = workerScope.getSyntheticExtensionProperties(receiverTypes, name).filter(predicate)
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
import org.jetbrains.kotlin.name.Name
public class InnerClassesScopeWrapper(override val workerScope: JetScope) : AbstractScopeAdapter() {
override fun getClassifier(name: Name, location: UsageLocation) = workerScope.getClassifier(name) as? ClassDescriptor
override fun getClassifier(name: Name, location: UsageLocation) = workerScope.getClassifier(name, location) as? ClassDescriptor
override fun getDeclarationsByLabel(labelName: Name) = workerScope.getDeclarationsByLabel(labelName).filterIsInstance<ClassDescriptor>()
@@ -61,13 +61,13 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su
return result
}
override fun getProperties(name: Name, location: UsageLocation) = substitute(workerScope.getProperties(name))
override fun getProperties(name: Name, location: UsageLocation) = substitute(workerScope.getProperties(name, location))
override fun getLocalVariable(name: Name) = substitute(workerScope.getLocalVariable(name))
override fun getClassifier(name: Name, location: UsageLocation) = substitute(workerScope.getClassifier(name))
override fun getClassifier(name: Name, location: UsageLocation) = substitute(workerScope.getClassifier(name, location))
override fun getFunctions(name: Name, location: UsageLocation) = substitute(workerScope.getFunctions(name))
override fun getFunctions(name: Name, location: UsageLocation) = substitute(workerScope.getFunctions(name, location))
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name))