Introduce DeserializationComponents
Decouple components from the state present in contexts, get rid of duplication of parameters in each context
This commit is contained in:
+7
-3
@@ -20,7 +20,7 @@ import org.jetbrains.jet.descriptors.serialization.context.DeserializationGlobal
|
||||
import org.jetbrains.jet.storage.StorageManager
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaPackageFragmentProvider
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationComponents
|
||||
|
||||
public class DeserializationGlobalContextForJava(
|
||||
storageManager: StorageManager,
|
||||
@@ -29,5 +29,9 @@ public class DeserializationGlobalContextForJava(
|
||||
annotationLoader: AnnotationDescriptorLoader,
|
||||
constantLoader: ConstantDescriptorLoader,
|
||||
packageFragmentProvider: LazyJavaPackageFragmentProvider
|
||||
) : DeserializationGlobalContext(storageManager, moduleDescriptor, classDataFinder, annotationLoader,
|
||||
constantLoader, packageFragmentProvider, JavaFlexibleTypeCapabilitiesDeserializer)
|
||||
) : DeserializationGlobalContext(
|
||||
DeserializationComponents(
|
||||
storageManager, moduleDescriptor, classDataFinder, annotationLoader, constantLoader, packageFragmentProvider,
|
||||
JavaFlexibleTypeCapabilitiesDeserializer
|
||||
)
|
||||
)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.lang.types.lang
|
||||
|
||||
import org.jetbrains.jet.descriptors.serialization.*
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationGlobalContext
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationLoader
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.ConstantLoader
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedPackageMemberScope
|
||||
@@ -33,6 +32,7 @@ import java.io.DataInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.util.ArrayList
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationComponents
|
||||
|
||||
class BuiltinsPackageFragment(storageManager: StorageManager, module: ModuleDescriptor)
|
||||
: PackageFragmentDescriptorImpl(module, KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) {
|
||||
@@ -41,13 +41,16 @@ class BuiltinsPackageFragment(storageManager: StorageManager, module: ModuleDesc
|
||||
|
||||
public val provider: PackageFragmentProvider = BuiltinsPackageFragmentProvider()
|
||||
|
||||
private val members: DeserializedPackageMemberScope = run {
|
||||
val deserializationContext = DeserializationGlobalContext(
|
||||
storageManager, module, BuiltInsClassDataFinder(), AnnotationLoader.UNSUPPORTED, // TODO: support annotations
|
||||
ConstantLoader.UNSUPPORTED, provider, FlexibleTypeCapabilitiesDeserializer.ThrowException
|
||||
).withNameResolver(nameResolver)
|
||||
DeserializedPackageMemberScope(this, loadPackage(), deserializationContext, { readClassNames() })
|
||||
}
|
||||
private val members: DeserializedPackageMemberScope =
|
||||
DeserializedPackageMemberScope(
|
||||
this,
|
||||
loadPackage(),
|
||||
DeserializationComponents(
|
||||
storageManager, module, BuiltInsClassDataFinder(), AnnotationLoader.UNSUPPORTED, // TODO: support annotations
|
||||
ConstantLoader.UNSUPPORTED, provider, FlexibleTypeCapabilitiesDeserializer.ThrowException
|
||||
).createContext().withNameResolver(nameResolver),
|
||||
{ readClassNames() }
|
||||
)
|
||||
|
||||
private fun loadPackage(): ProtoBuf.Package {
|
||||
val packageFilePath = BuiltInsSerializationUtil.getPackageFilePath(fqName)
|
||||
|
||||
+4
-4
@@ -17,20 +17,20 @@
|
||||
package org.jetbrains.jet.descriptors.serialization
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.storage.StorageManager
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedClassDescriptor
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationGlobalContext
|
||||
import kotlin.properties.Delegates
|
||||
import org.jetbrains.jet.lang.resolve.name.ClassId
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationComponents
|
||||
|
||||
public class ClassDeserializer(storageManager: StorageManager) {
|
||||
public class ClassDeserializer(components: DeserializationComponents) {
|
||||
// This should have been a constructor parameter, but this class and the context depend circularly on each other
|
||||
var globalContext: DeserializationGlobalContext by Delegates.notNull()
|
||||
|
||||
private val classes: (ClassKey) -> DeserializedClassDescriptor? = storageManager.createMemoizedFunctionWithNullableValues {
|
||||
private val classes: (ClassKey) -> DeserializedClassDescriptor? = components.storageManager.createMemoizedFunctionWithNullableValues {
|
||||
(key: ClassKey) ->
|
||||
val classId = key.classId
|
||||
val classData = key.classData ?: globalContext.classDataFinder.findClassData(classId)
|
||||
val classData = key.classData ?: components.classDataFinder.findClassData(classId)
|
||||
if (classData != null) {
|
||||
val outerClassContext =
|
||||
if (classId.isTopLevelClass()) null
|
||||
|
||||
+14
-6
@@ -19,6 +19,7 @@ package org.jetbrains.jet.descriptors.serialization;
|
||||
import kotlin.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationComponents;
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationContextWithTypes;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -46,6 +47,11 @@ public class MemberDeserializer {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DeserializationComponents getComponents() {
|
||||
return context.getComponents();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CallableMemberDescriptor loadCallable(@NotNull Callable proto) {
|
||||
Callable.CallableKind callableKind = Flags.CALLABLE_KIND.get(proto.getFlags());
|
||||
@@ -129,14 +135,14 @@ public class MemberDeserializer {
|
||||
|
||||
if (Flags.HAS_CONSTANT.get(flags)) {
|
||||
property.setCompileTimeInitializer(
|
||||
context.getStorageManager().createNullableLazyValue(new Function0<CompileTimeConstant<?>>() {
|
||||
getComponents().getStorageManager().createNullableLazyValue(new Function0<CompileTimeConstant<?>>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public CompileTimeConstant<?> invoke() {
|
||||
DeclarationDescriptor containingDeclaration = context.getContainingDeclaration();
|
||||
assert containingDeclaration instanceof ClassOrPackageFragmentDescriptor
|
||||
: "Only members in classes or package fragments should be serialized: " + containingDeclaration;
|
||||
return context.getConstantLoader().loadPropertyConstant(
|
||||
return getComponents().getConstantLoader().loadPropertyConstant(
|
||||
(ClassOrPackageFragmentDescriptor) containingDeclaration, proto,
|
||||
context.getNameResolver(), AnnotatedCallableKind.PROPERTY);
|
||||
}
|
||||
@@ -153,7 +159,7 @@ public class MemberDeserializer {
|
||||
private CallableMemberDescriptor loadFunction(@NotNull Callable proto) {
|
||||
int flags = proto.getFlags();
|
||||
DeserializedSimpleFunctionDescriptor function = DeserializedSimpleFunctionDescriptor.create(
|
||||
context.getContainingDeclaration(), proto, context.getAnnotationLoader(), context.getNameResolver()
|
||||
context.getContainingDeclaration(), proto, getComponents().getAnnotationLoader(), context.getNameResolver()
|
||||
);
|
||||
DeserializationContextWithTypes local = context.childContext(function, proto.getTypeParameterList());
|
||||
function.initialize(
|
||||
@@ -195,7 +201,9 @@ public class MemberDeserializer {
|
||||
|
||||
@NotNull
|
||||
private Annotations getAnnotations(@NotNull Callable proto, int flags, @NotNull AnnotatedCallableKind kind) {
|
||||
return getAnnotations(context.getContainingDeclaration(), proto, flags, kind, context.getAnnotationLoader(), context.getNameResolver());
|
||||
return getAnnotations(
|
||||
context.getContainingDeclaration(), proto, flags, kind, getComponents().getAnnotationLoader(), context.getNameResolver()
|
||||
);
|
||||
}
|
||||
|
||||
public static Annotations getAnnotations(
|
||||
@@ -221,7 +229,7 @@ public class MemberDeserializer {
|
||||
for (int i = 0; i < protos.size(); i++) {
|
||||
TypeParameter proto = protos.get(i);
|
||||
DeserializedTypeParameterDescriptor descriptor = new DeserializedTypeParameterDescriptor(
|
||||
context.getStorageManager(),
|
||||
getComponents().getStorageManager(),
|
||||
typeDeserializer,
|
||||
proto,
|
||||
context.getContainingDeclaration(),
|
||||
@@ -268,7 +276,7 @@ public class MemberDeserializer {
|
||||
@NotNull AnnotatedCallableKind kind,
|
||||
@NotNull Callable.ValueParameter valueParameter
|
||||
) {
|
||||
return Flags.HAS_ANNOTATIONS.get(valueParameter.getFlags()) ? context.getAnnotationLoader()
|
||||
return Flags.HAS_ANNOTATIONS.get(valueParameter.getFlags()) ? getComponents().getAnnotationLoader()
|
||||
.loadValueParameterAnnotations(classOrPackage, callable, context.getNameResolver(), kind, valueParameter)
|
||||
: Annotations.EMPTY;
|
||||
}
|
||||
|
||||
+14
-7
@@ -20,13 +20,13 @@ import kotlin.Function0;
|
||||
import kotlin.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationComponents;
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationContext;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedTypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.resolve.name.ClassId;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.storage.MemoizedFunctionToNullable;
|
||||
@@ -53,7 +53,7 @@ public class TypeDeserializer {
|
||||
this.debugName = debugName + (parent == null ? "" : ". Child of " + parent.debugName);
|
||||
this.context = context;
|
||||
|
||||
this.classDescriptors = context.getStorageManager().createMemoizedFunctionWithNullableValues(
|
||||
this.classDescriptors = getComponents().getStorageManager().createMemoizedFunctionWithNullableValues(
|
||||
new Function1<Integer, ClassDescriptor>() {
|
||||
@Override
|
||||
public ClassDescriptor invoke(Integer fqNameIndex) {
|
||||
@@ -62,6 +62,11 @@ public class TypeDeserializer {
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DeserializationComponents getComponents() {
|
||||
return context.getComponents();
|
||||
}
|
||||
|
||||
public void addTypeParameter(@NotNull DeserializedTypeParameterDescriptor typeParameterDescriptor) {
|
||||
typeParameterDescriptors.put(typeParameterDescriptor.getProtoId(), typeParameterDescriptor);
|
||||
}
|
||||
@@ -83,7 +88,7 @@ public class TypeDeserializer {
|
||||
public JetType type(@NotNull ProtoBuf.Type proto) {
|
||||
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
||||
String id = context.getNameResolver().getString(proto.getFlexibleTypeCapabilitiesId());
|
||||
FlexibleTypeCapabilities capabilities = context.getFlexibleTypeCapabilitiesDeserializer().capabilitiesById(id);
|
||||
FlexibleTypeCapabilities capabilities = getComponents().getFlexibleTypeCapabilitiesDeserializer().capabilitiesById(id);
|
||||
|
||||
if (capabilities == null) return ErrorUtils.createErrorType(new DeserializedType(proto) + ": Capabilities not found for id " + id);
|
||||
|
||||
@@ -139,8 +144,10 @@ public class TypeDeserializer {
|
||||
|
||||
@Nullable
|
||||
private ClassDescriptor computeClassDescriptor(int fqNameIndex) {
|
||||
ClassId classId = context.getNameResolver().getClassId(fqNameIndex);
|
||||
return SerializationPackage.findClassAcrossModuleDependencies(context.getModuleDescriptor(), classId);
|
||||
return SerializationPackage.findClassAcrossModuleDependencies(
|
||||
getComponents().getModuleDescriptor(),
|
||||
context.getNameResolver().getClassId(fqNameIndex)
|
||||
);
|
||||
}
|
||||
|
||||
private List<TypeProjection> typeArguments(List<ProtoBuf.Type.Argument> protos) {
|
||||
@@ -180,13 +187,13 @@ public class TypeDeserializer {
|
||||
this.typeProto = proto;
|
||||
this.arguments = typeArguments(proto.getArgumentList());
|
||||
|
||||
this.constructor = context.getStorageManager().createLazyValue(new Function0<TypeConstructor>() {
|
||||
this.constructor = getComponents().getStorageManager().createLazyValue(new Function0<TypeConstructor>() {
|
||||
@Override
|
||||
public TypeConstructor invoke() {
|
||||
return typeConstructor(typeProto);
|
||||
}
|
||||
});
|
||||
this.memberScope = context.getStorageManager().createLazyValue(new Function0<JetScope>() {
|
||||
this.memberScope = getComponents().getStorageManager().createLazyValue(new Function0<JetScope>() {
|
||||
@Override
|
||||
public JetScope invoke() {
|
||||
return computeMemberScope();
|
||||
|
||||
+15
-28
@@ -32,24 +32,28 @@ import org.jetbrains.jet.lang.resolve.name.ClassId
|
||||
import org.jetbrains.jet.descriptors.serialization.ClassDeserializer
|
||||
import org.jetbrains.jet.descriptors.serialization.FlexibleTypeCapabilitiesDeserializer
|
||||
|
||||
public open class DeserializationGlobalContext(
|
||||
public class DeserializationComponents(
|
||||
public val storageManager: StorageManager,
|
||||
public val moduleDescriptor: ModuleDescriptor,
|
||||
public val classDataFinder: ClassDataFinder,
|
||||
public val annotationLoader: AnnotationLoader,
|
||||
public val constantLoader: ConstantLoader,
|
||||
public val packageFragmentProvider: PackageFragmentProvider,
|
||||
public val flexibleTypeCapabilitiesDeserializer: FlexibleTypeCapabilitiesDeserializer,
|
||||
public val classDeserializer: ClassDeserializer = ClassDeserializer(storageManager)
|
||||
public val flexibleTypeCapabilitiesDeserializer: FlexibleTypeCapabilitiesDeserializer
|
||||
) {
|
||||
public fun createContext(): DeserializationGlobalContext = DeserializationGlobalContext(this)
|
||||
}
|
||||
|
||||
public open class DeserializationGlobalContext(
|
||||
public val components: DeserializationComponents,
|
||||
public val classDeserializer: ClassDeserializer = ClassDeserializer(components)
|
||||
) {
|
||||
{
|
||||
classDeserializer.globalContext = this
|
||||
}
|
||||
|
||||
public fun withNameResolver(nameResolver: NameResolver): DeserializationContext {
|
||||
return DeserializationContext(storageManager, moduleDescriptor, classDataFinder, annotationLoader,
|
||||
constantLoader, packageFragmentProvider, flexibleTypeCapabilitiesDeserializer,
|
||||
classDeserializer, nameResolver)
|
||||
return DeserializationContext(components, classDeserializer, nameResolver)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,45 +63,28 @@ fun DeserializationGlobalContext.deserializeClass(classId: ClassId): ClassDescri
|
||||
|
||||
|
||||
public open class DeserializationContext(
|
||||
storageManager: StorageManager,
|
||||
moduleDescriptor: ModuleDescriptor,
|
||||
classDataFinder: ClassDataFinder,
|
||||
annotationLoader: AnnotationLoader,
|
||||
constantLoader: ConstantLoader,
|
||||
packageFragmentProvider: PackageFragmentProvider,
|
||||
flexibleTypeCapabilitiesDeserializer: FlexibleTypeCapabilitiesDeserializer,
|
||||
components: DeserializationComponents,
|
||||
classDeserializer: ClassDeserializer,
|
||||
public val nameResolver: NameResolver
|
||||
) : DeserializationGlobalContext(storageManager, moduleDescriptor, classDataFinder, annotationLoader,
|
||||
constantLoader, packageFragmentProvider, flexibleTypeCapabilitiesDeserializer, classDeserializer) {
|
||||
) : DeserializationGlobalContext(components, classDeserializer) {
|
||||
fun withTypes(containingDeclaration: DeclarationDescriptor): DeserializationContextWithTypes {
|
||||
val typeDeserializer = TypeDeserializer(this, null, "Deserializer for ${containingDeclaration.getName()}")
|
||||
return withTypes(containingDeclaration, typeDeserializer)
|
||||
}
|
||||
|
||||
fun withTypes(containingDeclaration: DeclarationDescriptor, typeDeserializer: TypeDeserializer): DeserializationContextWithTypes {
|
||||
return DeserializationContextWithTypes(storageManager, moduleDescriptor, classDataFinder, annotationLoader,
|
||||
constantLoader, packageFragmentProvider, flexibleTypeCapabilitiesDeserializer,
|
||||
classDeserializer, nameResolver, containingDeclaration, typeDeserializer)
|
||||
return DeserializationContextWithTypes(components, classDeserializer, nameResolver, containingDeclaration, typeDeserializer)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class DeserializationContextWithTypes(
|
||||
storageManager: StorageManager,
|
||||
moduleDescriptor: ModuleDescriptor,
|
||||
classDataFinder: ClassDataFinder,
|
||||
annotationLoader: AnnotationLoader,
|
||||
constantLoader: ConstantLoader,
|
||||
packageFragmentProvider: PackageFragmentProvider,
|
||||
flexibleTypeCapabilitiesDeserializer: FlexibleTypeCapabilitiesDeserializer,
|
||||
components: DeserializationComponents,
|
||||
classDeserializer: ClassDeserializer,
|
||||
nameResolver: NameResolver,
|
||||
val containingDeclaration: DeclarationDescriptor,
|
||||
val typeDeserializer: TypeDeserializer
|
||||
) : DeserializationContext(storageManager, moduleDescriptor, classDataFinder, annotationLoader,
|
||||
constantLoader, packageFragmentProvider, flexibleTypeCapabilitiesDeserializer, classDeserializer, nameResolver) {
|
||||
) : DeserializationContext(components, classDeserializer, nameResolver) {
|
||||
val deserializer: MemberDeserializer = MemberDeserializer(this)
|
||||
|
||||
fun childContext(descriptor: DeclarationDescriptor, typeParameterProtos: List<TypeParameter>): DeserializationContextWithTypes {
|
||||
|
||||
+18
-14
@@ -42,7 +42,7 @@ public class DeserializedClassDescriptor(
|
||||
outerContext: DeserializationContext,
|
||||
private val classProto: ProtoBuf.Class
|
||||
) : ClassDescriptor, AbstractClassDescriptor(
|
||||
outerContext.storageManager,
|
||||
outerContext.components.storageManager,
|
||||
outerContext.nameResolver.getClassId(classProto.getFqName()).getRelativeClassName().shortName()
|
||||
) {
|
||||
private val modality = serialization.modality(Flags.MODALITY.get(classProto.getFlags()))
|
||||
@@ -51,7 +51,9 @@ public class DeserializedClassDescriptor(
|
||||
private val isInner = Flags.INNER.get(classProto.getFlags())
|
||||
|
||||
private val classId = outerContext.nameResolver.getClassId(classProto.getFqName())
|
||||
|
||||
val context = outerContext.withTypes(this).childContext(this, classProto.getTypeParameterList())
|
||||
private val components: DeserializationComponents get() = context.components
|
||||
|
||||
private val staticScope = StaticScopeForKotlinClass(this)
|
||||
private val typeConstructor = DeserializedClassTypeConstructor()
|
||||
@@ -59,16 +61,16 @@ public class DeserializedClassDescriptor(
|
||||
private val nestedClasses = NestedClassDescriptors()
|
||||
private val enumEntries = EnumEntryClassDescriptors()
|
||||
|
||||
private val containingDeclaration = context.storageManager.createLazyValue { computeContainingDeclaration() }
|
||||
private val annotations = context.storageManager.createLazyValue { computeAnnotations() }
|
||||
private val primaryConstructor = context.storageManager.createNullableLazyValue { computePrimaryConstructor() }
|
||||
private val classObjectDescriptor = context.storageManager.createNullableLazyValue { computeClassObjectDescriptor() }
|
||||
private val containingDeclaration = components.storageManager.createLazyValue { computeContainingDeclaration() }
|
||||
private val annotations = components.storageManager.createLazyValue { computeAnnotations() }
|
||||
private val primaryConstructor = components.storageManager.createNullableLazyValue { computePrimaryConstructor() }
|
||||
private val classObjectDescriptor = components.storageManager.createNullableLazyValue { computeClassObjectDescriptor() }
|
||||
|
||||
override fun getContainingDeclaration(): DeclarationDescriptor = containingDeclaration()
|
||||
|
||||
private fun computeContainingDeclaration(): DeclarationDescriptor {
|
||||
if (classId.isTopLevelClass()) {
|
||||
val fragments = context.packageFragmentProvider.getPackageFragments(classId.getPackageFqName())
|
||||
val fragments = components.packageFragmentProvider.getPackageFragments(classId.getPackageFqName())
|
||||
assert(fragments.size() == 1) { "there should be exactly one package: $fragments, class id is $classId" }
|
||||
return fragments.single()
|
||||
}
|
||||
@@ -91,7 +93,7 @@ public class DeserializedClassDescriptor(
|
||||
if (!Flags.HAS_ANNOTATIONS.get(classProto.getFlags())) {
|
||||
return Annotations.EMPTY
|
||||
}
|
||||
return context.annotationLoader.loadClassAnnotations(this, classProto)
|
||||
return components.annotationLoader.loadClassAnnotations(this, classProto)
|
||||
}
|
||||
|
||||
override fun getAnnotations(): Annotations = annotations()
|
||||
@@ -177,9 +179,11 @@ public class DeserializedClassDescriptor(
|
||||
override fun toString() = getName().toString()
|
||||
}
|
||||
|
||||
private inner class DeserializedClassMemberScope : DeserializedMemberScope(context, this@DeserializedClassDescriptor.classProto.getMemberList()) {
|
||||
private val classDescriptor: DeserializedClassDescriptor = this@DeserializedClassDescriptor
|
||||
private val allDescriptors = context.storageManager.createLazyValue { computeDescriptors(DescriptorKindFilter.ALL, JetScope.ALL_NAME_FILTER) }
|
||||
private inner class DeserializedClassMemberScope : DeserializedMemberScope(context, classProto.getMemberList()) {
|
||||
private val classDescriptor: DeserializedClassDescriptor get() = this@DeserializedClassDescriptor
|
||||
private val allDescriptors = components.storageManager.createLazyValue {
|
||||
computeDescriptors(DescriptorKindFilter.ALL, JetScope.ALL_NAME_FILTER)
|
||||
}
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = allDescriptors()
|
||||
@@ -248,7 +252,7 @@ public class DeserializedClassDescriptor(
|
||||
private inner class NestedClassDescriptors {
|
||||
private val nestedClassNames = nestedClassNames()
|
||||
|
||||
val findNestedClass = context.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
|
||||
val findNestedClass = components.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
|
||||
name ->
|
||||
if (nestedClassNames.contains(name)) {
|
||||
context.deserializeClass(classId.createNestedClassId(name))
|
||||
@@ -286,17 +290,17 @@ public class DeserializedClassDescriptor(
|
||||
return result
|
||||
}
|
||||
|
||||
val findEnumEntry = context.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
|
||||
val findEnumEntry = components.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
|
||||
name ->
|
||||
if (name in enumEntryNames) {
|
||||
EnumEntrySyntheticClassDescriptor.create(
|
||||
context.storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, SourceElement.NO_SOURCE
|
||||
components.storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, SourceElement.NO_SOURCE
|
||||
)
|
||||
}
|
||||
else null
|
||||
}
|
||||
|
||||
private val enumMemberNames = context.storageManager.createLazyValue { computeEnumMemberNames() }
|
||||
private val enumMemberNames = components.storageManager.createLazyValue { computeEnumMemberNames() }
|
||||
|
||||
private fun computeEnumMemberNames(): Collection<Name> {
|
||||
// NOTE: order of enum entry members should be irrelevant
|
||||
|
||||
+6
-3
@@ -45,9 +45,12 @@ public abstract class DeserializedMemberScope protected(
|
||||
}
|
||||
}
|
||||
|
||||
private val membersProtos = context.storageManager.createLazyValue { groupByKey(filteredMemberProtos(membersList)) }
|
||||
private val functions = context.storageManager.createMemoizedFunction<Name, Collection<FunctionDescriptor>> { computeFunctions(it) }
|
||||
private val properties = context.storageManager.createMemoizedFunction<Name, Collection<VariableDescriptor>> { computeProperties(it) }
|
||||
private val membersProtos =
|
||||
context.components.storageManager.createLazyValue { groupByKey(filteredMemberProtos(membersList)) }
|
||||
private val functions =
|
||||
context.components.storageManager.createMemoizedFunction<Name, Collection<FunctionDescriptor>> { computeFunctions(it) }
|
||||
private val properties =
|
||||
context.components.storageManager.createMemoizedFunction<Name, Collection<VariableDescriptor>> { computeProperties(it) }
|
||||
|
||||
protected open fun filteredMemberProtos(allMemberProtos: Collection<ProtoBuf.Callable>): Collection<ProtoBuf.Callable> = allMemberProtos
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public open class DeserializedPackageMemberScope(
|
||||
: DeserializedMemberScope(context.withTypes(packageDescriptor), proto.getMemberList()) {
|
||||
|
||||
private val packageFqName = packageDescriptor.fqName
|
||||
private val classNames = context.storageManager.createLazyValue(classNames)
|
||||
private val classNames = context.components.storageManager.createLazyValue(classNames)
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
= computeDescriptors(kindFilter, nameFilter)
|
||||
|
||||
+6
-3
@@ -32,7 +32,7 @@ import org.jetbrains.jet.lang.resolve.java.resolver.ErrorReporter
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaClass
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationGlobalContext
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationComponents
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import org.jetbrains.jet.descriptors.serialization.ClassData
|
||||
@@ -146,8 +146,11 @@ public class DeserializerForDecompiler(val packageDirectory: VirtualFile, val di
|
||||
moduleDescriptor.seal()
|
||||
moduleContainingMissingDependencies.seal()
|
||||
}
|
||||
val deserializationContext = DeserializationGlobalContext(storageManager, moduleDescriptor, classDataFinder, annotationLoader,
|
||||
constantLoader, packageFragmentProvider, JavaFlexibleTypeCapabilitiesDeserializer)
|
||||
|
||||
val deserializationContext = DeserializationComponents(
|
||||
storageManager, moduleDescriptor, classDataFinder, annotationLoader, constantLoader, packageFragmentProvider,
|
||||
JavaFlexibleTypeCapabilitiesDeserializer
|
||||
).createContext()
|
||||
|
||||
private fun createDummyPackageFragment(fqName: FqName): MutablePackageFragmentDescriptor {
|
||||
return MutablePackageFragmentDescriptor(moduleDescriptor, fqName)
|
||||
|
||||
Reference in New Issue
Block a user