Combine Java package scope and Kotlin scopes in JvmPackageScope
Use it in LazyJavaPackageFragment#scope instead of a weird lazy chained scope. Also move lookup tracker records to it, to prevent them from being written in each package scope individually (this was hurting performance)
This commit is contained in:
+18
-2
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.impl.AbstractClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.EnumEntrySyntheticClassDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||
import org.jetbrains.kotlin.resolve.NonReportingOverrideStrategy
|
||||
@@ -192,8 +193,19 @@ class DeserializedClassDescriptor(
|
||||
computeDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
|
||||
}
|
||||
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = allDescriptors()
|
||||
override fun getContributedDescriptors(
|
||||
kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean
|
||||
): Collection<DeclarationDescriptor> = allDescriptors()
|
||||
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<SimpleFunctionDescriptor> {
|
||||
recordLookup(name, location)
|
||||
return super.getContributedFunctions(name, location)
|
||||
}
|
||||
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
recordLookup(name, location)
|
||||
return super.getContributedVariables(name, location)
|
||||
}
|
||||
|
||||
override fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<SimpleFunctionDescriptor>) {
|
||||
val fromSupertypes = ArrayList<SimpleFunctionDescriptor>()
|
||||
@@ -257,6 +269,10 @@ class DeserializedClassDescriptor(
|
||||
override fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) {
|
||||
result.addAll(classDescriptor.enumEntries?.all().orEmpty())
|
||||
}
|
||||
|
||||
private fun recordLookup(name: Name, from: LookupLocation) {
|
||||
c.components.lookupTracker.record(from, c.containingDeclaration, name)
|
||||
}
|
||||
}
|
||||
|
||||
private inner class NestedClassDescriptors {
|
||||
|
||||
+6
-14
@@ -17,9 +17,11 @@
|
||||
package org.jetbrains.kotlin.serialization.deserialization.descriptors
|
||||
|
||||
import com.google.protobuf.MessageLite
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
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.MemberScopeImpl
|
||||
@@ -78,10 +80,7 @@ abstract class DeserializedMemberScope protected constructor(
|
||||
protected open fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<SimpleFunctionDescriptor>) {
|
||||
}
|
||||
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<SimpleFunctionDescriptor> {
|
||||
recordLookup(name, location)
|
||||
return functions(name)
|
||||
}
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<SimpleFunctionDescriptor> = functions(name)
|
||||
|
||||
private fun computeProperties(name: Name): Collection<PropertyDescriptor> {
|
||||
val protos = propertyProtos()[ProtoKey(name, isExtension = false)].orEmpty() +
|
||||
@@ -98,10 +97,7 @@ abstract class DeserializedMemberScope protected constructor(
|
||||
protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
|
||||
}
|
||||
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
recordLookup(name, location)
|
||||
return properties.invoke(name)
|
||||
}
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> = properties(name)
|
||||
|
||||
protected abstract fun addClassDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean)
|
||||
|
||||
@@ -177,8 +173,4 @@ abstract class DeserializedMemberScope protected constructor(
|
||||
p.popIndent()
|
||||
p.println("}")
|
||||
}
|
||||
|
||||
protected fun recordLookup(name: Name, from: LookupLocation) {
|
||||
c.components.lookupTracker.record(from, c.containingDeclaration, name)
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -51,7 +51,6 @@ open class DeserializedPackageMemberScope(
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
if (SpecialNames.isSafeIdentifier(name) &&
|
||||
(name in classNames || c.components.fictitiousClassDescriptorFactory.shouldCreateClass(packageFqName, name))) {
|
||||
recordLookup(name, location)
|
||||
return getClassDescriptor(name)
|
||||
}
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user