Rename "context" -> "c" in deserialization for brevity
This commit is contained in:
@@ -156,7 +156,7 @@ class LazyOperationsLog(
|
|||||||
}
|
}
|
||||||
o.javaClass.getSimpleName() == "DeserializedType" -> {
|
o.javaClass.getSimpleName() == "DeserializedType" -> {
|
||||||
val typeDeserializer = o.field<TypeDeserializer>("typeDeserializer")
|
val typeDeserializer = o.field<TypeDeserializer>("typeDeserializer")
|
||||||
val context = typeDeserializer.field<DeserializationContext>("context")
|
val context = typeDeserializer.field<DeserializationContext>("c")
|
||||||
val typeProto = o.field<ProtoBuf.Type>("typeProto")
|
val typeProto = o.field<ProtoBuf.Type>("typeProto")
|
||||||
val text = when (typeProto.getConstructor().getKind()) {
|
val text = when (typeProto.getConstructor().getKind()) {
|
||||||
ProtoBuf.Type.Constructor.Kind.CLASS -> context.nameResolver.getFqName(typeProto.getConstructor().getId()).asString()
|
ProtoBuf.Type.Constructor.Kind.CLASS -> context.nameResolver.getFqName(typeProto.getConstructor().getId()).asString()
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ public class ClassDeserializer(private val components: DeserializationComponents
|
|||||||
components.createContext(fragments.single(), classData.getNameResolver())
|
components.createContext(fragments.single(), classData.getNameResolver())
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
deserializeClass(classId.getOuterClassId())?.context ?: return null
|
deserializeClass(classId.getOuterClassId())?.c ?: return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeserializedClassDescriptor(outerContext, classData.getClassProto(), classData.getNameResolver())
|
return DeserializedClassDescriptor(outerContext, classData.getClassProto(), classData.getNameResolver())
|
||||||
|
|||||||
+4
-4
@@ -24,18 +24,18 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
|||||||
import org.jetbrains.jet.lang.types.*
|
import org.jetbrains.jet.lang.types.*
|
||||||
|
|
||||||
class DeserializedType(
|
class DeserializedType(
|
||||||
context: DeserializationContext,
|
c: DeserializationContext,
|
||||||
private val typeProto: ProtoBuf.Type
|
private val typeProto: ProtoBuf.Type
|
||||||
) : AbstractJetType(), LazyType {
|
) : AbstractJetType(), LazyType {
|
||||||
private val typeDeserializer = context.typeDeserializer
|
private val typeDeserializer = c.typeDeserializer
|
||||||
|
|
||||||
private val constructor = context.components.storageManager.createLazyValue {
|
private val constructor = c.components.storageManager.createLazyValue {
|
||||||
typeDeserializer.typeConstructor(typeProto)
|
typeDeserializer.typeConstructor(typeProto)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val arguments = typeDeserializer.typeArguments(typeProto.getArgumentList())
|
private val arguments = typeDeserializer.typeArguments(typeProto.getArgumentList())
|
||||||
|
|
||||||
private val memberScope = context.components.storageManager.createLazyValue {
|
private val memberScope = c.components.storageManager.createLazyValue {
|
||||||
computeMemberScope()
|
computeMemberScope()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-26
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.jet.descriptors.serialization
|
package org.jetbrains.jet.descriptors.serialization
|
||||||
|
|
||||||
import org.jetbrains.jet.descriptors.serialization.*
|
import org.jetbrains.jet.descriptors.serialization.*
|
||||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationComponents
|
|
||||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationContext
|
import org.jetbrains.jet.descriptors.serialization.context.DeserializationContext
|
||||||
import org.jetbrains.jet.descriptors.serialization.descriptors.*
|
import org.jetbrains.jet.descriptors.serialization.descriptors.*
|
||||||
import org.jetbrains.jet.lang.descriptors.*
|
import org.jetbrains.jet.lang.descriptors.*
|
||||||
@@ -27,9 +26,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorFactory
|
|||||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable
|
import org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable
|
||||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.CallableKind.*
|
import org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.CallableKind.*
|
||||||
|
|
||||||
public class MemberDeserializer(private val context: DeserializationContext) {
|
public class MemberDeserializer(private val c: DeserializationContext) {
|
||||||
private val components: DeserializationComponents get() = context.components
|
|
||||||
|
|
||||||
public fun loadCallable(proto: Callable): CallableMemberDescriptor {
|
public fun loadCallable(proto: Callable): CallableMemberDescriptor {
|
||||||
val callableKind = Flags.CALLABLE_KIND.get(proto.getFlags())
|
val callableKind = Flags.CALLABLE_KIND.get(proto.getFlags())
|
||||||
return when (callableKind) {
|
return when (callableKind) {
|
||||||
@@ -44,18 +41,18 @@ public class MemberDeserializer(private val context: DeserializationContext) {
|
|||||||
val flags = proto.getFlags()
|
val flags = proto.getFlags()
|
||||||
|
|
||||||
val property = DeserializedPropertyDescriptor(
|
val property = DeserializedPropertyDescriptor(
|
||||||
context.containingDeclaration, null,
|
c.containingDeclaration, null,
|
||||||
getAnnotations(proto, flags, AnnotatedCallableKind.PROPERTY),
|
getAnnotations(proto, flags, AnnotatedCallableKind.PROPERTY),
|
||||||
modality(Flags.MODALITY.get(flags)),
|
modality(Flags.MODALITY.get(flags)),
|
||||||
visibility(Flags.VISIBILITY.get(flags)),
|
visibility(Flags.VISIBILITY.get(flags)),
|
||||||
Flags.CALLABLE_KIND.get(flags) == Callable.CallableKind.VAR,
|
Flags.CALLABLE_KIND.get(flags) == Callable.CallableKind.VAR,
|
||||||
context.nameResolver.getName(proto.getName()),
|
c.nameResolver.getName(proto.getName()),
|
||||||
memberKind(Flags.MEMBER_KIND.get(flags)),
|
memberKind(Flags.MEMBER_KIND.get(flags)),
|
||||||
proto,
|
proto,
|
||||||
context.nameResolver
|
c.nameResolver
|
||||||
)
|
)
|
||||||
|
|
||||||
val local = context.childContext(property, proto.getTypeParameterList())
|
val local = c.childContext(property, proto.getTypeParameterList())
|
||||||
property.setType(
|
property.setType(
|
||||||
local.typeDeserializer.type(proto.getReturnType()),
|
local.typeDeserializer.type(proto.getReturnType()),
|
||||||
local.typeDeserializer.getOwnTypeParameters(),
|
local.typeDeserializer.getOwnTypeParameters(),
|
||||||
@@ -115,9 +112,9 @@ public class MemberDeserializer(private val context: DeserializationContext) {
|
|||||||
|
|
||||||
if (Flags.HAS_CONSTANT.get(flags)) {
|
if (Flags.HAS_CONSTANT.get(flags)) {
|
||||||
property.setCompileTimeInitializer(
|
property.setCompileTimeInitializer(
|
||||||
components.storageManager.createNullableLazyValue {
|
c.components.storageManager.createNullableLazyValue {
|
||||||
val container = context.containingDeclaration.asClassOrPackage()
|
val container = c.containingDeclaration.asClassOrPackage()
|
||||||
components.constantLoader.loadPropertyConstant(container, proto, context.nameResolver, AnnotatedCallableKind.PROPERTY)
|
c.components.constantLoader.loadPropertyConstant(container, proto, c.nameResolver, AnnotatedCallableKind.PROPERTY)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -129,8 +126,8 @@ public class MemberDeserializer(private val context: DeserializationContext) {
|
|||||||
|
|
||||||
private fun loadFunction(proto: Callable): CallableMemberDescriptor {
|
private fun loadFunction(proto: Callable): CallableMemberDescriptor {
|
||||||
val annotations = getAnnotations(proto, proto.getFlags(), AnnotatedCallableKind.FUNCTION)
|
val annotations = getAnnotations(proto, proto.getFlags(), AnnotatedCallableKind.FUNCTION)
|
||||||
val function = DeserializedSimpleFunctionDescriptor.create(context.containingDeclaration, proto, context.nameResolver, annotations)
|
val function = DeserializedSimpleFunctionDescriptor.create(c.containingDeclaration, proto, c.nameResolver, annotations)
|
||||||
val local = context.childContext(function, proto.getTypeParameterList())
|
val local = c.childContext(function, proto.getTypeParameterList())
|
||||||
function.initialize(
|
function.initialize(
|
||||||
if (proto.hasReceiverType()) local.typeDeserializer.type(proto.getReceiverType()) else null,
|
if (proto.hasReceiverType()) local.typeDeserializer.type(proto.getReceiverType()) else null,
|
||||||
getDispatchReceiverParameter(),
|
getDispatchReceiverParameter(),
|
||||||
@@ -144,16 +141,16 @@ public class MemberDeserializer(private val context: DeserializationContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? {
|
private fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? {
|
||||||
return (context.containingDeclaration as? ClassDescriptor)?.getThisAsReceiverParameter()
|
return (c.containingDeclaration as? ClassDescriptor)?.getThisAsReceiverParameter()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadConstructor(proto: Callable): CallableMemberDescriptor {
|
private fun loadConstructor(proto: Callable): CallableMemberDescriptor {
|
||||||
val classDescriptor = context.containingDeclaration as ClassDescriptor
|
val classDescriptor = c.containingDeclaration as ClassDescriptor
|
||||||
val descriptor = ConstructorDescriptorImpl.create(
|
val descriptor = ConstructorDescriptorImpl.create(
|
||||||
classDescriptor, getAnnotations(proto, proto.getFlags(), AnnotatedCallableKind.FUNCTION), // TODO: primary
|
classDescriptor, getAnnotations(proto, proto.getFlags(), AnnotatedCallableKind.FUNCTION), // TODO: primary
|
||||||
true, SourceElement.NO_SOURCE
|
true, SourceElement.NO_SOURCE
|
||||||
)
|
)
|
||||||
val local = context.childContext(descriptor, listOf())
|
val local = c.childContext(descriptor, listOf())
|
||||||
descriptor.initialize(
|
descriptor.initialize(
|
||||||
classDescriptor.getTypeConstructor().getParameters(),
|
classDescriptor.getTypeConstructor().getParameters(),
|
||||||
local.memberDeserializer.valueParameters(proto, AnnotatedCallableKind.FUNCTION),
|
local.memberDeserializer.valueParameters(proto, AnnotatedCallableKind.FUNCTION),
|
||||||
@@ -167,24 +164,24 @@ public class MemberDeserializer(private val context: DeserializationContext) {
|
|||||||
if (!Flags.HAS_ANNOTATIONS.get(flags)) {
|
if (!Flags.HAS_ANNOTATIONS.get(flags)) {
|
||||||
return Annotations.EMPTY
|
return Annotations.EMPTY
|
||||||
}
|
}
|
||||||
return DeserializedAnnotations(components.storageManager) {
|
return DeserializedAnnotations(c.components.storageManager) {
|
||||||
components.annotationLoader.loadCallableAnnotations(
|
c.components.annotationLoader.loadCallableAnnotations(
|
||||||
context.containingDeclaration.asClassOrPackage(), proto, context.nameResolver, kind
|
c.containingDeclaration.asClassOrPackage(), proto, c.nameResolver, kind
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun valueParameters(callable: Callable, kind: AnnotatedCallableKind): List<ValueParameterDescriptor> {
|
private fun valueParameters(callable: Callable, kind: AnnotatedCallableKind): List<ValueParameterDescriptor> {
|
||||||
val containerOfCallable = context.containingDeclaration.getContainingDeclaration().asClassOrPackage()
|
val containerOfCallable = c.containingDeclaration.getContainingDeclaration().asClassOrPackage()
|
||||||
|
|
||||||
return callable.getValueParameterList().withIndices().map { val (i, proto) = it
|
return callable.getValueParameterList().withIndices().map { val (i, proto) = it
|
||||||
ValueParameterDescriptorImpl(
|
ValueParameterDescriptorImpl(
|
||||||
context.containingDeclaration, null, i,
|
c.containingDeclaration, null, i,
|
||||||
getParameterAnnotations(containerOfCallable, callable, kind, proto),
|
getParameterAnnotations(containerOfCallable, callable, kind, proto),
|
||||||
context.nameResolver.getName(proto.getName()),
|
c.nameResolver.getName(proto.getName()),
|
||||||
context.typeDeserializer.type(proto.getType()),
|
c.typeDeserializer.type(proto.getType()),
|
||||||
Flags.DECLARES_DEFAULT_VALUE.get(proto.getFlags()),
|
Flags.DECLARES_DEFAULT_VALUE.get(proto.getFlags()),
|
||||||
if (proto.hasVarargElementType()) context.typeDeserializer.type(proto.getVarargElementType()) else null,
|
if (proto.hasVarargElementType()) c.typeDeserializer.type(proto.getVarargElementType()) else null,
|
||||||
SourceElement.NO_SOURCE
|
SourceElement.NO_SOURCE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -199,8 +196,8 @@ public class MemberDeserializer(private val context: DeserializationContext) {
|
|||||||
if (!Flags.HAS_ANNOTATIONS.get(valueParameter.getFlags())) {
|
if (!Flags.HAS_ANNOTATIONS.get(valueParameter.getFlags())) {
|
||||||
return Annotations.EMPTY
|
return Annotations.EMPTY
|
||||||
}
|
}
|
||||||
return DeserializedAnnotations(components.storageManager) {
|
return DeserializedAnnotations(c.components.storageManager) {
|
||||||
components.annotationLoader.loadValueParameterAnnotations(classOrPackage, callable, context.nameResolver, kind, valueParameter)
|
c.components.annotationLoader.loadValueParameterAnnotations(classOrPackage, callable, c.nameResolver, kind, valueParameter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -26,23 +26,23 @@ import org.jetbrains.jet.utils.*
|
|||||||
import java.util.LinkedHashMap
|
import java.util.LinkedHashMap
|
||||||
|
|
||||||
public class TypeDeserializer(
|
public class TypeDeserializer(
|
||||||
private val context: DeserializationContext,
|
private val c: DeserializationContext,
|
||||||
private val parent: TypeDeserializer?,
|
private val parent: TypeDeserializer?,
|
||||||
private val typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
private val typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
||||||
private val debugName: String
|
private val debugName: String
|
||||||
) {
|
) {
|
||||||
private val classDescriptors: (Int) -> ClassDescriptor? = context.components.storageManager.createMemoizedFunctionWithNullableValues {
|
private val classDescriptors: (Int) -> ClassDescriptor? = c.components.storageManager.createMemoizedFunctionWithNullableValues {
|
||||||
fqNameIndex -> computeClassDescriptor(fqNameIndex)
|
fqNameIndex -> computeClassDescriptor(fqNameIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val typeParameterDescriptors = context.components.storageManager.createLazyValue {
|
private val typeParameterDescriptors = c.components.storageManager.createLazyValue {
|
||||||
if (typeParameterProtos.isEmpty()) {
|
if (typeParameterProtos.isEmpty()) {
|
||||||
mapOf<Int, TypeParameterDescriptor>()
|
mapOf<Int, TypeParameterDescriptor>()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val result = LinkedHashMap<Int, TypeParameterDescriptor>()
|
val result = LinkedHashMap<Int, TypeParameterDescriptor>()
|
||||||
for ((index, proto) in typeParameterProtos.withIndices()) {
|
for ((index, proto) in typeParameterProtos.withIndices()) {
|
||||||
result[proto.getId()] = DeserializedTypeParameterDescriptor(context, proto, index)
|
result[proto.getId()] = DeserializedTypeParameterDescriptor(c, proto, index)
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
@@ -52,21 +52,21 @@ public class TypeDeserializer(
|
|||||||
|
|
||||||
fun type(proto: ProtoBuf.Type): JetType {
|
fun type(proto: ProtoBuf.Type): JetType {
|
||||||
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
||||||
val id = context.nameResolver.getString(proto.getFlexibleTypeCapabilitiesId())
|
val id = c.nameResolver.getString(proto.getFlexibleTypeCapabilitiesId())
|
||||||
val capabilities = context.components.flexibleTypeCapabilitiesDeserializer.capabilitiesById(id)
|
val capabilities = c.components.flexibleTypeCapabilitiesDeserializer.capabilitiesById(id)
|
||||||
|
|
||||||
if (capabilities == null) {
|
if (capabilities == null) {
|
||||||
return ErrorUtils.createErrorType("${DeserializedType(context, proto)}: Capabilities not found for id $id")
|
return ErrorUtils.createErrorType("${DeserializedType(c, proto)}: Capabilities not found for id $id")
|
||||||
}
|
}
|
||||||
|
|
||||||
return DelegatingFlexibleType.create(
|
return DelegatingFlexibleType.create(
|
||||||
DeserializedType(context, proto),
|
DeserializedType(c, proto),
|
||||||
DeserializedType(context, proto.getFlexibleUpperBound()),
|
DeserializedType(c, proto.getFlexibleUpperBound()),
|
||||||
capabilities
|
capabilities
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeserializedType(context, proto)
|
return DeserializedType(c, proto)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun typeConstructor(proto: ProtoBuf.Type): TypeConstructor {
|
fun typeConstructor(proto: ProtoBuf.Type): TypeConstructor {
|
||||||
@@ -74,7 +74,7 @@ public class TypeDeserializer(
|
|||||||
val id = constructorProto.getId()
|
val id = constructorProto.getId()
|
||||||
return typeConstructor(constructorProto) ?: ErrorUtils.createErrorType(
|
return typeConstructor(constructorProto) ?: ErrorUtils.createErrorType(
|
||||||
if (constructorProto.getKind() == ProtoBuf.Type.Constructor.Kind.CLASS)
|
if (constructorProto.getKind() == ProtoBuf.Type.Constructor.Kind.CLASS)
|
||||||
context.nameResolver.getClassId(id).asSingleFqName().asString()
|
c.nameResolver.getClassId(id).asSingleFqName().asString()
|
||||||
else
|
else
|
||||||
"Unknown type parameter $id"
|
"Unknown type parameter $id"
|
||||||
).getConstructor()
|
).getConstructor()
|
||||||
@@ -91,7 +91,7 @@ public class TypeDeserializer(
|
|||||||
parent?.typeParameterTypeConstructor(proto)
|
parent?.typeParameterTypeConstructor(proto)
|
||||||
|
|
||||||
private fun computeClassDescriptor(fqNameIndex: Int): ClassDescriptor? =
|
private fun computeClassDescriptor(fqNameIndex: Int): ClassDescriptor? =
|
||||||
context.components.moduleDescriptor.findClassAcrossModuleDependencies(context.nameResolver.getClassId(fqNameIndex))
|
c.components.moduleDescriptor.findClassAcrossModuleDependencies(c.nameResolver.getClassId(fqNameIndex))
|
||||||
|
|
||||||
fun typeArguments(protos: List<ProtoBuf.Type.Argument>): List<TypeProjection> =
|
fun typeArguments(protos: List<ProtoBuf.Type.Argument>): List<TypeProjection> =
|
||||||
protos.map { proto ->
|
protos.map { proto ->
|
||||||
|
|||||||
+25
-25
@@ -51,8 +51,7 @@ public class DeserializedClassDescriptor(
|
|||||||
private val kind = classKind(Flags.CLASS_KIND.get(classProto.getFlags()))
|
private val kind = classKind(Flags.CLASS_KIND.get(classProto.getFlags()))
|
||||||
private val isInner = Flags.INNER.get(classProto.getFlags())
|
private val isInner = Flags.INNER.get(classProto.getFlags())
|
||||||
|
|
||||||
val context = outerContext.childContext(this, classProto.getTypeParameterList(), nameResolver)
|
val c = outerContext.childContext(this, classProto.getTypeParameterList(), nameResolver)
|
||||||
private val components: DeserializationComponents get() = context.components
|
|
||||||
|
|
||||||
private val classId = nameResolver.getClassId(classProto.getFqName())
|
private val classId = nameResolver.getClassId(classProto.getFqName())
|
||||||
|
|
||||||
@@ -63,15 +62,16 @@ public class DeserializedClassDescriptor(
|
|||||||
private val enumEntries = EnumEntryClassDescriptors()
|
private val enumEntries = EnumEntryClassDescriptors()
|
||||||
|
|
||||||
private val containingDeclaration = outerContext.containingDeclaration
|
private val containingDeclaration = outerContext.containingDeclaration
|
||||||
private val primaryConstructor = components.storageManager.createNullableLazyValue { computePrimaryConstructor() }
|
private val primaryConstructor = c.components.storageManager.createNullableLazyValue { computePrimaryConstructor() }
|
||||||
private val classObjectDescriptor = components.storageManager.createNullableLazyValue { computeClassObjectDescriptor() }
|
private val classObjectDescriptor = c.components.storageManager.createNullableLazyValue { computeClassObjectDescriptor() }
|
||||||
|
|
||||||
private val annotations = if (!Flags.HAS_ANNOTATIONS.get(classProto.getFlags())) {
|
private val annotations =
|
||||||
Annotations.EMPTY
|
if (!Flags.HAS_ANNOTATIONS.get(classProto.getFlags())) {
|
||||||
}
|
Annotations.EMPTY
|
||||||
else DeserializedAnnotations(components.storageManager) {
|
}
|
||||||
components.annotationLoader.loadClassAnnotations(this, classProto)
|
else DeserializedAnnotations(c.components.storageManager) {
|
||||||
}
|
c.components.annotationLoader.loadClassAnnotations(this, classProto)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getContainingDeclaration(): DeclarationDescriptor = containingDeclaration
|
override fun getContainingDeclaration(): DeclarationDescriptor = containingDeclaration
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ public class DeserializedClassDescriptor(
|
|||||||
return descriptor
|
return descriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.memberDeserializer.loadCallable(constructorProto.getData()) as ConstructorDescriptor
|
return c.memberDeserializer.loadCallable(constructorProto.getData()) as ConstructorDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = primaryConstructor()
|
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = primaryConstructor()
|
||||||
@@ -121,10 +121,10 @@ public class DeserializedClassDescriptor(
|
|||||||
throw IllegalStateException("Object should have a serialized class object: $classId")
|
throw IllegalStateException("Object should have a serialized class object: $classId")
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeserializedClassDescriptor(context, classObjectProto.getData(), context.nameResolver)
|
return DeserializedClassDescriptor(c, classObjectProto.getData(), c.nameResolver)
|
||||||
}
|
}
|
||||||
|
|
||||||
return components.deserializeClass(classId.createNestedClassId(getClassObjectName(getName())))
|
return c.components.deserializeClass(classId.createNestedClassId(getClassObjectName(getName())))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getClassObjectDescriptor(): ClassDescriptor? = classObjectDescriptor()
|
override fun getClassObjectDescriptor(): ClassDescriptor? = classObjectDescriptor()
|
||||||
@@ -132,7 +132,7 @@ public class DeserializedClassDescriptor(
|
|||||||
private fun computeSuperTypes(): Collection<JetType> {
|
private fun computeSuperTypes(): Collection<JetType> {
|
||||||
val supertypes = ArrayList<JetType>(classProto.getSupertypeCount())
|
val supertypes = ArrayList<JetType>(classProto.getSupertypeCount())
|
||||||
for (supertype in classProto.getSupertypeList()) {
|
for (supertype in classProto.getSupertypeList()) {
|
||||||
supertypes.add(context.typeDeserializer.type(supertype))
|
supertypes.add(c.typeDeserializer.type(supertype))
|
||||||
}
|
}
|
||||||
return supertypes
|
return supertypes
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ public class DeserializedClassDescriptor(
|
|||||||
private inner class DeserializedClassTypeConstructor : AbstractClassTypeConstructor() {
|
private inner class DeserializedClassTypeConstructor : AbstractClassTypeConstructor() {
|
||||||
private val supertypes = computeSuperTypes()
|
private val supertypes = computeSuperTypes()
|
||||||
|
|
||||||
override fun getParameters() = context.typeDeserializer.getOwnTypeParameters()
|
override fun getParameters() = c.typeDeserializer.getOwnTypeParameters()
|
||||||
|
|
||||||
override fun getSupertypes(): Collection<JetType> {
|
override fun getSupertypes(): Collection<JetType> {
|
||||||
// We cannot have error supertypes because subclasses inherit error functions from them
|
// We cannot have error supertypes because subclasses inherit error functions from them
|
||||||
@@ -168,9 +168,9 @@ public class DeserializedClassDescriptor(
|
|||||||
override fun toString() = getName().toString()
|
override fun toString() = getName().toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class DeserializedClassMemberScope : DeserializedMemberScope(context, classProto.getMemberList()) {
|
private inner class DeserializedClassMemberScope : DeserializedMemberScope(c, classProto.getMemberList()) {
|
||||||
private val classDescriptor: DeserializedClassDescriptor get() = this@DeserializedClassDescriptor
|
private val classDescriptor: DeserializedClassDescriptor get() = this@DeserializedClassDescriptor
|
||||||
private val allDescriptors = components.storageManager.createLazyValue {
|
private val allDescriptors = c.components.storageManager.createLazyValue {
|
||||||
computeDescriptors(DescriptorKindFilter.ALL, JetScope.ALL_NAME_FILTER)
|
computeDescriptors(DescriptorKindFilter.ALL, JetScope.ALL_NAME_FILTER)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,17 +241,17 @@ public class DeserializedClassDescriptor(
|
|||||||
private inner class NestedClassDescriptors {
|
private inner class NestedClassDescriptors {
|
||||||
private val nestedClassNames = nestedClassNames()
|
private val nestedClassNames = nestedClassNames()
|
||||||
|
|
||||||
val findNestedClass = components.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
|
val findNestedClass = c.components.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
|
||||||
name ->
|
name ->
|
||||||
if (name in nestedClassNames) {
|
if (name in nestedClassNames) {
|
||||||
components.deserializeClass(classId.createNestedClassId(name))
|
c.components.deserializeClass(classId.createNestedClassId(name))
|
||||||
}
|
}
|
||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun nestedClassNames(): Set<Name> {
|
private fun nestedClassNames(): Set<Name> {
|
||||||
val result = LinkedHashSet<Name>()
|
val result = LinkedHashSet<Name>()
|
||||||
val nameResolver = context.nameResolver
|
val nameResolver = c.nameResolver
|
||||||
for (index in classProto.getNestedClassNameList()) {
|
for (index in classProto.getNestedClassNameList()) {
|
||||||
result.add(nameResolver.getName(index!!))
|
result.add(nameResolver.getName(index!!))
|
||||||
}
|
}
|
||||||
@@ -272,24 +272,24 @@ public class DeserializedClassDescriptor(
|
|||||||
if (getKind() != ClassKind.ENUM_CLASS) return setOf()
|
if (getKind() != ClassKind.ENUM_CLASS) return setOf()
|
||||||
|
|
||||||
val result = LinkedHashSet<Name>()
|
val result = LinkedHashSet<Name>()
|
||||||
val nameResolver = context.nameResolver
|
val nameResolver = c.nameResolver
|
||||||
for (index in classProto.getEnumEntryList()) {
|
for (index in classProto.getEnumEntryList()) {
|
||||||
result.add(nameResolver.getName(index!!))
|
result.add(nameResolver.getName(index!!))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
val findEnumEntry = components.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
|
val findEnumEntry = c.components.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
|
||||||
name ->
|
name ->
|
||||||
if (name in enumEntryNames) {
|
if (name in enumEntryNames) {
|
||||||
EnumEntrySyntheticClassDescriptor.create(
|
EnumEntrySyntheticClassDescriptor.create(
|
||||||
components.storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, SourceElement.NO_SOURCE
|
c.components.storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, SourceElement.NO_SOURCE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
|
|
||||||
private val enumMemberNames = components.storageManager.createLazyValue { computeEnumMemberNames() }
|
private val enumMemberNames = c.components.storageManager.createLazyValue { computeEnumMemberNames() }
|
||||||
|
|
||||||
private fun computeEnumMemberNames(): Collection<Name> {
|
private fun computeEnumMemberNames(): Collection<Name> {
|
||||||
// NOTE: order of enum entry members should be irrelevant
|
// NOTE: order of enum entry members should be irrelevant
|
||||||
@@ -304,7 +304,7 @@ public class DeserializedClassDescriptor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val nameResolver = context.nameResolver
|
val nameResolver = c.nameResolver
|
||||||
return classProto.getMemberList().mapTo(result) { nameResolver.getName(it.getName()) }
|
return classProto.getMemberList().mapTo(result) { nameResolver.getName(it.getName()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -29,9 +29,9 @@ import org.jetbrains.jet.descriptors.serialization.context.DeserializationContex
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
public abstract class DeserializedMemberScope protected(
|
public abstract class DeserializedMemberScope protected(
|
||||||
protected val context: DeserializationContext,
|
protected val c: DeserializationContext,
|
||||||
membersList: Collection<ProtoBuf.Callable>)
|
membersList: Collection<ProtoBuf.Callable>
|
||||||
: JetScope {
|
) : JetScope {
|
||||||
|
|
||||||
private data class ProtoKey(val name: Name, val kind: Kind, val isExtension: Boolean)
|
private data class ProtoKey(val name: Name, val kind: Kind, val isExtension: Boolean)
|
||||||
private enum class Kind { FUNCTION PROPERTY }
|
private enum class Kind { FUNCTION PROPERTY }
|
||||||
@@ -45,11 +45,11 @@ public abstract class DeserializedMemberScope protected(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val membersProtos =
|
private val membersProtos =
|
||||||
context.components.storageManager.createLazyValue { groupByKey(filteredMemberProtos(membersList)) }
|
c.components.storageManager.createLazyValue { groupByKey(filteredMemberProtos(membersList)) }
|
||||||
private val functions =
|
private val functions =
|
||||||
context.components.storageManager.createMemoizedFunction<Name, Collection<FunctionDescriptor>> { computeFunctions(it) }
|
c.components.storageManager.createMemoizedFunction<Name, Collection<FunctionDescriptor>> { computeFunctions(it) }
|
||||||
private val properties =
|
private val properties =
|
||||||
context.components.storageManager.createMemoizedFunction<Name, Collection<VariableDescriptor>> { computeProperties(it) }
|
c.components.storageManager.createMemoizedFunction<Name, Collection<VariableDescriptor>> { computeProperties(it) }
|
||||||
|
|
||||||
protected open fun filteredMemberProtos(allMemberProtos: Collection<ProtoBuf.Callable>): Collection<ProtoBuf.Callable> = allMemberProtos
|
protected open fun filteredMemberProtos(allMemberProtos: Collection<ProtoBuf.Callable>): Collection<ProtoBuf.Callable> = allMemberProtos
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public abstract class DeserializedMemberScope protected(
|
|||||||
val map = LinkedHashMap<ProtoKey, MutableList<ProtoBuf.Callable>>()
|
val map = LinkedHashMap<ProtoKey, MutableList<ProtoBuf.Callable>>()
|
||||||
for (memberProto in membersList) {
|
for (memberProto in membersList) {
|
||||||
val key = ProtoKey(
|
val key = ProtoKey(
|
||||||
context.nameResolver.getName(memberProto.getName()),
|
c.nameResolver.getName(memberProto.getName()),
|
||||||
Flags.CALLABLE_KIND[memberProto.getFlags()].toKind(),
|
Flags.CALLABLE_KIND[memberProto.getFlags()].toKind(),
|
||||||
memberProto.hasReceiverType()
|
memberProto.hasReceiverType()
|
||||||
)
|
)
|
||||||
@@ -77,7 +77,7 @@ public abstract class DeserializedMemberScope protected(
|
|||||||
|
|
||||||
[suppress("UNCHECKED_CAST")]
|
[suppress("UNCHECKED_CAST")]
|
||||||
return memberProtos.mapTo(LinkedHashSet<D>()) { memberProto ->
|
return memberProtos.mapTo(LinkedHashSet<D>()) { memberProto ->
|
||||||
context.memberDeserializer.loadCallable(memberProto) as D
|
c.memberDeserializer.loadCallable(memberProto) as D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ public abstract class DeserializedMemberScope protected(
|
|||||||
|
|
||||||
override fun getLocalVariable(name: Name): VariableDescriptor? = null
|
override fun getLocalVariable(name: Name): VariableDescriptor? = null
|
||||||
|
|
||||||
override fun getContainingDeclaration() = context.containingDeclaration
|
override fun getContainingDeclaration() = c.containingDeclaration
|
||||||
|
|
||||||
override fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor> = listOf()
|
override fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor> = listOf()
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -36,12 +36,12 @@ public open class DeserializedPackageMemberScope(
|
|||||||
) : DeserializedMemberScope(components.createContext(packageDescriptor, nameResolver), proto.getMemberList()) {
|
) : DeserializedMemberScope(components.createContext(packageDescriptor, nameResolver), proto.getMemberList()) {
|
||||||
|
|
||||||
private val packageFqName = packageDescriptor.fqName
|
private val packageFqName = packageDescriptor.fqName
|
||||||
private val classNames = context.components.storageManager.createLazyValue(classNames)
|
private val classNames = c.components.storageManager.createLazyValue(classNames)
|
||||||
|
|
||||||
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||||
= computeDescriptors(kindFilter, nameFilter)
|
= computeDescriptors(kindFilter, nameFilter)
|
||||||
|
|
||||||
override fun getClassDescriptor(name: Name) = context.components.deserializeClass(ClassId(packageFqName, name))
|
override fun getClassDescriptor(name: Name) = c.components.deserializeClass(ClassId(packageFqName, name))
|
||||||
|
|
||||||
override fun addClassDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) {
|
override fun addClassDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) {
|
||||||
for (className in classNames()) {
|
for (className in classNames()) {
|
||||||
|
|||||||
+5
-5
@@ -34,16 +34,16 @@ public class DeserializedTypeParameterDescriptor extends AbstractLazyTypeParamet
|
|||||||
private final ProtoBuf.TypeParameter proto;
|
private final ProtoBuf.TypeParameter proto;
|
||||||
private final TypeDeserializer typeDeserializer;
|
private final TypeDeserializer typeDeserializer;
|
||||||
|
|
||||||
public DeserializedTypeParameterDescriptor(@NotNull DeserializationContext context, @NotNull ProtoBuf.TypeParameter proto, int index) {
|
public DeserializedTypeParameterDescriptor(@NotNull DeserializationContext c, @NotNull ProtoBuf.TypeParameter proto, int index) {
|
||||||
super(context.getComponents().getStorageManager(),
|
super(c.getComponents().getStorageManager(),
|
||||||
context.getContainingDeclaration(),
|
c.getContainingDeclaration(),
|
||||||
context.getNameResolver().getName(proto.getName()),
|
c.getNameResolver().getName(proto.getName()),
|
||||||
SerializationPackage.variance(proto.getVariance()),
|
SerializationPackage.variance(proto.getVariance()),
|
||||||
proto.getReified(),
|
proto.getReified(),
|
||||||
index,
|
index,
|
||||||
SourceElement.NO_SOURCE);
|
SourceElement.NO_SOURCE);
|
||||||
this.proto = proto;
|
this.proto = proto;
|
||||||
this.typeDeserializer = context.getTypeDeserializer();
|
this.typeDeserializer = c.getTypeDeserializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user