Add necessary ResolutionScope::recordLookup implementations

This commit is contained in:
Denis Zharkov
2017-08-24 11:14:15 +03:00
parent 580a7e3e4d
commit 265794e712
5 changed files with 28 additions and 1 deletions
@@ -86,6 +86,10 @@ class AllUnderImportScope(
return scopes.flatMap { it.getContributedFunctions(name, location) }
}
override fun recordLookup(name: Name, location: LookupLocation) {
scopes.forEach { it.recordLookup(name, location) }
}
override fun printStructure(p: Printer) {
p.println(this::class.java.simpleName)
}
@@ -198,6 +198,13 @@ class LazyImportResolver(
}
fun definitelyDoesNotContainName(name: Name) = allNames?.let { name !in it } == true
fun recordLookup(name: Name, location: LookupLocation) {
if (allNames == null) return
indexedImports.importsForName(name).forEach {
getImportScope(it).recordLookup(name, location)
}
}
}
class LazyImportScope(
@@ -278,5 +285,10 @@ class LazyImportScope(
}
override fun definitelyDoesNotContainName(name: Name) = importResolver.definitelyDoesNotContainName(name)
override fun recordLookup(name: Name, location: LookupLocation) {
importResolver.recordLookup(name, location)
}
override fun computeImportedNames() = importResolver.allNames
}
@@ -57,6 +57,9 @@ abstract class AbstractScopeAdapter : MemberScope {
override fun getVariableNames() = workerScope.getVariableNames()
override fun getClassifierNames() = workerScope.getClassifierNames()
override fun recordLookup(name: Name, location: LookupLocation) {
workerScope.recordLookup(name, location)
}
override fun printScopeStructure(p: Printer) {
p.println(this::class.java.simpleName, " {")
@@ -45,6 +45,10 @@ class ChainedMemberScope(
override fun getVariableNames() = scopes.flatMapTo(mutableSetOf()) { it.getVariableNames() }
override fun getClassifierNames(): Set<Name>? = scopes.flatMapClassifierNamesOrNull()
override fun recordLookup(name: Name, location: LookupLocation) {
scopes.forEach { it.recordLookup(name, location) }
}
override fun toString() = debugName
override fun printScopeStructure(p: Printer) {
@@ -55,10 +55,14 @@ open class DeserializedPackageMemberScope(
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
c.components.lookupTracker.record(location, packageDescriptor, name)
recordLookup(name, location)
return super.getContributedClassifier(name, location)
}
override fun recordLookup(name: Name, location: LookupLocation) {
c.components.lookupTracker.record(location, packageDescriptor, name)
}
override fun getNonDeclaredFunctionNames(): Set<Name> = emptySet()
override fun getNonDeclaredVariableNames(): Set<Name> = emptySet()