From ca4f9754510dadcc294945224a5f19027ef65ac1 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Fri, 7 Aug 2015 14:50:47 +0300 Subject: [PATCH] Track lookups to package and class member scopes --- .../descriptors/AbstractLazyMemberScope.kt | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt index 28dbfdc8b1d..3f8415a83c5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt @@ -21,6 +21,8 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.VariableDescriptor +import org.jetbrains.kotlin.incremental.components.LookupLocation +import org.jetbrains.kotlin.incremental.record import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingTrace @@ -32,7 +34,6 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProvider import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl -import org.jetbrains.kotlin.resolve.scopes.LookupLocation import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.utils.Printer @@ -64,9 +65,15 @@ protected constructor( override fun getContainingDeclaration() = thisDescriptor - override fun getClassifier(name: Name, location: LookupLocation): ClassDescriptor? = classDescriptors(name).firstOrNull() + override fun getClassifier(name: Name, location: LookupLocation): ClassDescriptor? { + recordLookup(name, location) + return classDescriptors(name).firstOrNull() + } - override fun getFunctions(name: Name, location: LookupLocation): Collection = functionDescriptors(name) + override fun getFunctions(name: Name, location: LookupLocation): Collection { + recordLookup(name, location) + return functionDescriptors(name) + } private fun doGetFunctions(name: Name): Collection { val result = Sets.newLinkedHashSet() @@ -91,7 +98,10 @@ protected constructor( protected abstract fun getNonDeclaredFunctions(name: Name, result: MutableSet) - override fun getProperties(name: Name, location: LookupLocation): Collection = propertyDescriptors(name) + override fun getProperties(name: Name, location: LookupLocation): Collection { + recordLookup(name, location) + return propertyDescriptors(name) + } public fun doGetProperties(name: Name): Collection { val result = LinkedHashSet() @@ -177,4 +187,8 @@ protected constructor( p.popIndent() p.println("}") } + + private fun recordLookup(name: Name, from: LookupLocation) { + c.lookupTracker.record(from, this, name) + } }