Minor. Replace explicit lazy calculation call with delegation convention
This commit is contained in:
+10
-9
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScopeImpl
|
import org.jetbrains.kotlin.resolve.scopes.MemberScopeImpl
|
||||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext
|
import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext
|
||||||
|
import org.jetbrains.kotlin.storage.getValue
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -39,19 +40,19 @@ abstract class DeserializedMemberScope protected constructor(
|
|||||||
typeAliasList: Collection<ProtoBuf.TypeAlias>
|
typeAliasList: Collection<ProtoBuf.TypeAlias>
|
||||||
) : MemberScopeImpl() {
|
) : MemberScopeImpl() {
|
||||||
|
|
||||||
private val functionProtos =
|
private val functionProtos by
|
||||||
c.storageManager.createLazyValue {
|
c.storageManager.createLazyValue {
|
||||||
functionList.groupByName { it.name }
|
functionList.groupByName { it.name }
|
||||||
}
|
}
|
||||||
private val propertyProtos =
|
private val propertyProtos by
|
||||||
c.storageManager.createLazyValue {
|
c.storageManager.createLazyValue {
|
||||||
propertyList.groupByName { it.name }
|
propertyList.groupByName { it.name }
|
||||||
}
|
}
|
||||||
private val typeAliasProtos =
|
private val typeAliasProtos by
|
||||||
c.storageManager.createLazyValue {
|
c.storageManager.createLazyValue {
|
||||||
typeAliasList.groupByName { it.name }
|
typeAliasList.groupByName { it.name }
|
||||||
}
|
}
|
||||||
protected val typeAliasNames =
|
protected val typeAliasNames by
|
||||||
c.storageManager.createLazyValue {
|
c.storageManager.createLazyValue {
|
||||||
typeAliasList.map { c.nameResolver.getName(it.name) }
|
typeAliasList.map { c.nameResolver.getName(it.name) }
|
||||||
}
|
}
|
||||||
@@ -68,7 +69,7 @@ abstract class DeserializedMemberScope protected constructor(
|
|||||||
) = groupBy { c.nameResolver.getName(getNameIndex(it)) }
|
) = groupBy { c.nameResolver.getName(getNameIndex(it)) }
|
||||||
|
|
||||||
private fun computeFunctions(name: Name): Collection<SimpleFunctionDescriptor> {
|
private fun computeFunctions(name: Name): Collection<SimpleFunctionDescriptor> {
|
||||||
val protos = functionProtos()[name].orEmpty()
|
val protos = functionProtos[name].orEmpty()
|
||||||
|
|
||||||
val descriptors = protos.mapTo(linkedSetOf()) {
|
val descriptors = protos.mapTo(linkedSetOf()) {
|
||||||
c.memberDeserializer.loadFunction(it)
|
c.memberDeserializer.loadFunction(it)
|
||||||
@@ -84,7 +85,7 @@ abstract class DeserializedMemberScope protected constructor(
|
|||||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<SimpleFunctionDescriptor> = functions(name)
|
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<SimpleFunctionDescriptor> = functions(name)
|
||||||
|
|
||||||
private fun computeProperties(name: Name): Collection<PropertyDescriptor> {
|
private fun computeProperties(name: Name): Collection<PropertyDescriptor> {
|
||||||
val protos = propertyProtos()[name].orEmpty()
|
val protos = propertyProtos[name].orEmpty()
|
||||||
|
|
||||||
val descriptors = protos.mapTo(linkedSetOf()) {
|
val descriptors = protos.mapTo(linkedSetOf()) {
|
||||||
c.memberDeserializer.loadProperty(it)
|
c.memberDeserializer.loadProperty(it)
|
||||||
@@ -98,7 +99,7 @@ abstract class DeserializedMemberScope protected constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun computeTypeAliases(name: Name): Collection<TypeAliasDescriptor> {
|
private fun computeTypeAliases(name: Name): Collection<TypeAliasDescriptor> {
|
||||||
val protos = typeAliasProtos()[name].orEmpty()
|
val protos = typeAliasProtos[name].orEmpty()
|
||||||
val descriptors = protos.mapTo(linkedSetOf()) {
|
val descriptors = protos.mapTo(linkedSetOf()) {
|
||||||
c.memberDeserializer.loadTypeAlias(it)
|
c.memberDeserializer.loadTypeAlias(it)
|
||||||
}
|
}
|
||||||
@@ -147,7 +148,7 @@ abstract class DeserializedMemberScope protected constructor(
|
|||||||
) {
|
) {
|
||||||
if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK)) {
|
if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK)) {
|
||||||
addMembers(
|
addMembers(
|
||||||
propertyProtos().keys,
|
propertyProtos.keys,
|
||||||
nameFilter,
|
nameFilter,
|
||||||
result
|
result
|
||||||
) { getContributedVariables(it, location) }
|
) { getContributedVariables(it, location) }
|
||||||
@@ -155,7 +156,7 @@ abstract class DeserializedMemberScope protected constructor(
|
|||||||
|
|
||||||
if (kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK)) {
|
if (kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK)) {
|
||||||
addMembers(
|
addMembers(
|
||||||
functionProtos().keys,
|
functionProtos.keys,
|
||||||
nameFilter,
|
nameFilter,
|
||||||
result
|
result
|
||||||
) { getContributedFunctions(it, location) }
|
) { getContributedFunctions(it, location) }
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ open class DeserializedPackageMemberScope(
|
|||||||
result.addIfNotNull(getClassDescriptor(className))
|
result.addIfNotNull(getClassDescriptor(className))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (typeAliasName in typeAliasNames()) {
|
for (typeAliasName in typeAliasNames) {
|
||||||
if (nameFilter(typeAliasName)) {
|
if (nameFilter(typeAliasName)) {
|
||||||
result.addAll(getContributedTypeAliases(typeAliasName))
|
result.addAll(getContributedTypeAliases(typeAliasName))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user