Merge AnnotationLoader and ConstantLoader into single interface

Merge all implementation classes into single BinaryClassAnnotationAndConstantLoader
This commit is contained in:
Pavel V. Talanov
2014-11-27 15:47:23 +03:00
parent 1652157ec7
commit 39e1dfbcc0
18 changed files with 482 additions and 623 deletions
@@ -114,7 +114,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
property.setCompileTimeInitializer(
c.storageManager.createNullableLazyValue {
val container = c.containingDeclaration.asProtoContainer()
c.components.constantLoader.loadPropertyConstant(container, proto, c.nameResolver, AnnotatedCallableKind.PROPERTY)
c.components.annotationAndConstantLoader.loadPropertyConstant(container, proto, c.nameResolver, AnnotatedCallableKind.PROPERTY)
}
)
}
@@ -165,7 +165,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
return Annotations.EMPTY
}
return DeserializedAnnotations(c.storageManager) {
c.components.annotationLoader.loadCallableAnnotations(
c.components.annotationAndConstantLoader.loadCallableAnnotations(
c.containingDeclaration.asProtoContainer(), proto, c.nameResolver, kind
)
}
@@ -197,7 +197,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
return Annotations.EMPTY
}
return DeserializedAnnotations(c.storageManager) {
c.components.annotationLoader.loadValueParameterAnnotations(container, callable, c.nameResolver, kind, valueParameter)
c.components.annotationAndConstantLoader.loadValueParameterAnnotations(container, callable, c.nameResolver, kind, valueParameter)
}
}
@@ -19,16 +19,14 @@ package org.jetbrains.jet.descriptors.serialization.context
import org.jetbrains.jet.storage.StorageManager
import org.jetbrains.jet.lang.descriptors.*
import org.jetbrains.jet.descriptors.serialization.*
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationLoader
import org.jetbrains.jet.descriptors.serialization.descriptors.ConstantLoader
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationAndConstantLoader
import org.jetbrains.jet.lang.resolve.name.ClassId
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 annotationAndConstantLoader: AnnotationAndConstantLoader,
public val packageFragmentProvider: PackageFragmentProvider,
public val flexibleTypeCapabilitiesDeserializer: FlexibleTypeCapabilitiesDeserializer
) {
@@ -17,21 +17,23 @@
package org.jetbrains.jet.descriptors.serialization.descriptors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.descriptors.serialization.NameResolver;
import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import java.util.List;
public interface AnnotationLoader {
AnnotationLoader UNSUPPORTED = new AnnotationLoader() {
public interface AnnotationAndConstantLoader {
AnnotationAndConstantLoader UNSUPPORTED = new AnnotationAndConstantLoader() {
@NotNull
@Override
public List<AnnotationDescriptor> loadClassAnnotations(
@NotNull ProtoBuf.Class classProto,
@NotNull NameResolver nameResolver
) {
return notSupported();
return annotationsNotSupported();
}
@NotNull
@@ -42,7 +44,7 @@ public interface AnnotationLoader {
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind
) {
return notSupported();
return annotationsNotSupported();
}
@NotNull
@@ -54,11 +56,22 @@ public interface AnnotationLoader {
@NotNull AnnotatedCallableKind kind,
@NotNull ProtoBuf.Callable.ValueParameter proto
) {
return notSupported();
return annotationsNotSupported();
}
@Nullable
@Override
public CompileTimeConstant<?> loadPropertyConstant(
@NotNull ProtoContainer container,
@NotNull ProtoBuf.Callable proto,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind
) {
throw new UnsupportedOperationException("Constants are not supported");
}
@NotNull
private List<AnnotationDescriptor> notSupported() {
private List<AnnotationDescriptor> annotationsNotSupported() {
throw new UnsupportedOperationException("Annotations are not supported");
}
};
@@ -85,4 +98,12 @@ public interface AnnotationLoader {
@NotNull AnnotatedCallableKind kind,
@NotNull ProtoBuf.Callable.ValueParameter proto
);
@Nullable
CompileTimeConstant<?> loadPropertyConstant(
@NotNull ProtoContainer container,
@NotNull ProtoBuf.Callable proto,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind
);
}
@@ -1,46 +0,0 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.descriptors.serialization.descriptors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.descriptors.serialization.NameResolver;
import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
public interface ConstantLoader {
ConstantLoader UNSUPPORTED = new ConstantLoader() {
@Nullable
@Override
public CompileTimeConstant<?> loadPropertyConstant(
@NotNull ProtoContainer container,
@NotNull ProtoBuf.Callable proto,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind
) {
throw new UnsupportedOperationException("Constants are not supported");
}
};
@Nullable
CompileTimeConstant<?> loadPropertyConstant(
@NotNull ProtoContainer container,
@NotNull ProtoBuf.Callable proto,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind
);
}
@@ -70,7 +70,7 @@ public class DeserializedClassDescriptor(
Annotations.EMPTY
}
else DeserializedAnnotations(c.storageManager) {
c.components.annotationLoader.loadClassAnnotations(classProto, c.nameResolver)
c.components.annotationAndConstantLoader.loadClassAnnotations(classProto, c.nameResolver)
}
override fun getContainingDeclaration(): DeclarationDescriptor = containingDeclaration