Track lookups in DeserializedMemberScope

This commit is contained in:
Zalim Bashorov
2015-09-22 21:04:38 +03:00
parent a5d8b47083
commit 47f1975879
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.serialization.deserialization.descriptors
import com.google.protobuf.MessageLite
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.incremental.record
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.KtScopeImpl
@@ -81,7 +82,10 @@ public abstract class DeserializedMemberScope protected constructor(
protected open fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<FunctionDescriptor>) {
}
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = functions(name)
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
recordLookup(name, location)
return functions(name)
}
private fun computeProperties(name: Name): Collection<VariableDescriptor> {
val protos = propertyProtos()[ProtoKey(name, isExtension = false)].orEmpty() +
@@ -98,9 +102,15 @@ public abstract class DeserializedMemberScope protected constructor(
protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
}
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> = properties.invoke(name)
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
recordLookup(name, location)
return properties.invoke(name)
}
override fun getClassifier(name: Name, location: LookupLocation) = getClassDescriptor(name)
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
recordLookup(name, location)
return getClassDescriptor(name)
}
protected abstract fun getClassDescriptor(name: Name): ClassifierDescriptor?
@@ -183,4 +193,8 @@ public abstract class DeserializedMemberScope protected constructor(
p.popIndent()
p.println("}")
}
private fun recordLookup(name: Name, from: LookupLocation) {
c.components.lookupTracker.record(from, this, name)
}
}