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