Track lookups in LazyJavaScope ans LazyJavaPackageScope
This commit is contained in:
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PackagePartProvider
|
import org.jetbrains.kotlin.descriptors.PackagePartProvider
|
||||||
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker
|
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker
|
||||||
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.load.java.JavaClassFinder
|
import org.jetbrains.kotlin.load.java.JavaClassFinder
|
||||||
import org.jetbrains.kotlin.load.java.components.ExternalAnnotationResolver
|
import org.jetbrains.kotlin.load.java.components.ExternalAnnotationResolver
|
||||||
import org.jetbrains.kotlin.load.java.components.ExternalSignatureResolver
|
import org.jetbrains.kotlin.load.java.components.ExternalSignatureResolver
|
||||||
@@ -49,7 +50,8 @@ class JavaResolverComponents(
|
|||||||
val sourceElementFactory: JavaSourceElementFactory,
|
val sourceElementFactory: JavaSourceElementFactory,
|
||||||
val moduleClassResolver: ModuleClassResolver,
|
val moduleClassResolver: ModuleClassResolver,
|
||||||
val packageMapper: PackagePartProvider,
|
val packageMapper: PackagePartProvider,
|
||||||
val supertypeLoopChecker: SupertypeLoopChecker
|
val supertypeLoopChecker: SupertypeLoopChecker,
|
||||||
|
val lookupTracker: LookupTracker
|
||||||
)
|
)
|
||||||
|
|
||||||
open class LazyJavaResolverContext(
|
open class LazyJavaResolverContext(
|
||||||
|
|||||||
+15
-9
@@ -16,10 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.load.java.lazy.descriptors
|
package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptorKindExclude
|
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptorKindExclude
|
||||||
@@ -29,7 +26,6 @@ import org.jetbrains.kotlin.load.java.lazy.resolveKotlinBinaryClass
|
|||||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||||
import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
||||||
import org.jetbrains.kotlin.load.kotlin.DeserializedDescriptorResolver
|
import org.jetbrains.kotlin.load.kotlin.DeserializedDescriptorResolver
|
||||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
|
|
||||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -103,11 +99,21 @@ public class LazyJavaPackageScope(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? =
|
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||||
if (SpecialNames.isSafeIdentifier(name)) classes(name) else null
|
if (!SpecialNames.isSafeIdentifier(name)) return null
|
||||||
|
|
||||||
override fun getProperties(name: Name, location: LookupLocation) = deserializedPackageScope().getProperties(name, location)
|
recordLookup(name, location)
|
||||||
override fun getFunctions(name: Name, location: LookupLocation) = deserializedPackageScope().getFunctions(name, location) + super.getFunctions(name, location)
|
return classes(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||||
|
recordLookup(name, location)
|
||||||
|
return deserializedPackageScope().getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||||
|
}
|
||||||
|
override fun getFunctions(name: Name, location: LookupLocation): List<FunctionDescriptor> {
|
||||||
|
recordLookup(name, location)
|
||||||
|
return deserializedPackageScope().getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + super.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||||
|
}
|
||||||
|
|
||||||
override fun addExtraDescriptors(result: MutableSet<DeclarationDescriptor>,
|
override fun addExtraDescriptors(result: MutableSet<DeclarationDescriptor>,
|
||||||
kindFilter: DescriptorKindFilter,
|
kindFilter: DescriptorKindFilter,
|
||||||
|
|||||||
+13
-2
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
|||||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
|
import org.jetbrains.kotlin.incremental.record
|
||||||
import org.jetbrains.kotlin.load.java.components.ExternalSignatureResolver
|
import org.jetbrains.kotlin.load.java.components.ExternalSignatureResolver
|
||||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
|
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
|
||||||
@@ -213,7 +214,10 @@ public abstract class LazyJavaScope(
|
|||||||
return ResolvedValueParameters(descriptors, synthesizedNames)
|
return ResolvedValueParameters(descriptors, synthesizedNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFunctions(name: Name, location: LookupLocation) = functions(name)
|
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||||
|
recordLookup(name, location)
|
||||||
|
return functions(name)
|
||||||
|
}
|
||||||
|
|
||||||
protected open fun getFunctionNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name>
|
protected open fun getFunctionNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name>
|
||||||
= memberIndex().getMethodNames(nameFilter)
|
= memberIndex().getMethodNames(nameFilter)
|
||||||
@@ -294,7 +298,10 @@ public abstract class LazyJavaScope(
|
|||||||
return propertyType
|
return propertyType
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> = properties(name)
|
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||||
|
recordLookup(name, location)
|
||||||
|
return properties(name)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getOwnDeclaredDescriptors() = getDescriptors()
|
override fun getOwnDeclaredDescriptors() = getDescriptors()
|
||||||
|
|
||||||
@@ -357,4 +364,8 @@ public abstract class LazyJavaScope(
|
|||||||
p.popIndent()
|
p.popIndent()
|
||||||
p.println("}")
|
p.println("}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected fun recordLookup(name: Name, from: LookupLocation) {
|
||||||
|
c.components.lookupTracker.record(from, this, name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ public class RuntimeModuleData private constructor(public val deserialization: D
|
|||||||
storageManager, ReflectJavaClassFinder(classLoader), reflectKotlinClassFinder, deserializedDescriptorResolver,
|
storageManager, ReflectJavaClassFinder(classLoader), reflectKotlinClassFinder, deserializedDescriptorResolver,
|
||||||
ExternalAnnotationResolver.EMPTY, ExternalSignatureResolver.DO_NOTHING, RuntimeErrorReporter, JavaResolverCache.EMPTY,
|
ExternalAnnotationResolver.EMPTY, ExternalSignatureResolver.DO_NOTHING, RuntimeErrorReporter, JavaResolverCache.EMPTY,
|
||||||
JavaPropertyInitializerEvaluator.DoNothing, SamConversionResolver, RuntimeSourceElementFactory, singleModuleClassResolver,
|
JavaPropertyInitializerEvaluator.DoNothing, SamConversionResolver, RuntimeSourceElementFactory, singleModuleClassResolver,
|
||||||
runtimePackageFacadeProvider, SupertypeLoopChecker.EMPTY
|
runtimePackageFacadeProvider, SupertypeLoopChecker.EMPTY, LookupTracker.DO_NOTHING
|
||||||
)
|
)
|
||||||
|
|
||||||
val lazyJavaPackageFragmentProvider =
|
val lazyJavaPackageFragmentProvider =
|
||||||
|
|||||||
Reference in New Issue
Block a user