Simplify AnnotationAndConstantLoader, use NameResolver from ProtoContainer

This commit is contained in:
Alexander Udalov
2015-09-30 20:12:02 +03:00
parent 3a7a48a079
commit 4f21caecc4
9 changed files with 39 additions and 73 deletions
@@ -34,7 +34,6 @@ public interface AnnotationAndConstantLoader<A, C, T> {
List<T> loadCallableAnnotations(
@NotNull ProtoContainer container,
@NotNull ProtoBuf.Callable proto,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind
);
@@ -42,7 +41,6 @@ public interface AnnotationAndConstantLoader<A, C, T> {
List<A> loadValueParameterAnnotations(
@NotNull ProtoContainer container,
@NotNull ProtoBuf.Callable callable,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind,
int parameterIndex,
@NotNull ProtoBuf.ValueParameter proto
@@ -52,7 +50,6 @@ public interface AnnotationAndConstantLoader<A, C, T> {
List<A> loadExtensionReceiverParameterAnnotations(
@NotNull ProtoContainer container,
@NotNull ProtoBuf.Callable callable,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind
);
@@ -66,7 +63,6 @@ public interface AnnotationAndConstantLoader<A, C, T> {
C loadPropertyConstant(
@NotNull ProtoContainer container,
@NotNull ProtoBuf.Callable proto,
@NotNull NameResolver nameResolver,
@NotNull JetType expectedType
);
}
@@ -129,7 +129,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
property.setCompileTimeInitializer(
c.storageManager.createNullableLazyValue {
val container = c.containingDeclaration.asProtoContainer()!!
c.components.annotationAndConstantLoader.loadPropertyConstant(container, proto, c.nameResolver, property.getReturnType())
c.components.annotationAndConstantLoader.loadPropertyConstant(container, proto, property.returnType)
}
)
}
@@ -184,9 +184,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
}
return DeserializedAnnotationsWithPossibleTargets(c.storageManager) {
c.containingDeclaration.asProtoContainer()?.let {
c.components.annotationAndConstantLoader.loadCallableAnnotations(
it, proto, c.nameResolver, kind
)
c.components.annotationAndConstantLoader.loadCallableAnnotations(it, proto, kind)
}.orEmpty()
}
}
@@ -200,7 +198,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
if (proto.hasReceiverType()) {
c.containingDeclaration.asProtoContainer()?.let {
c.components.annotationAndConstantLoader
.loadExtensionReceiverParameterAnnotations(it, proto, c.nameResolver, receiverTargetedKind)
.loadExtensionReceiverParameterAnnotations(it, proto, receiverTargetedKind)
.map { AnnotationWithTarget(it, AnnotationUseSiteTarget.RECEIVER) }
}.orEmpty()
}
@@ -234,9 +232,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
valueParameter: ProtoBuf.ValueParameter
): Annotations {
return DeserializedAnnotations(c.storageManager) {
c.components.annotationAndConstantLoader.loadValueParameterAnnotations(
container, callable, c.nameResolver, kind, index, valueParameter
)
c.components.annotationAndConstantLoader.loadValueParameterAnnotations(container, callable, kind, index, valueParameter)
}
}
@@ -28,9 +28,6 @@ public data class ProtoContainer(
assert((classProto != null) xor (packageFqName != null))
}
fun getFqName(nameResolver: NameResolver): FqName {
if (packageFqName != null) return packageFqName
return nameResolver.getClassId(classProto!!.getFqName()).asSingleFqName()
}
fun getFqName(): FqName =
packageFqName ?: nameResolver.getClassId(classProto!!.getFqName()).asSingleFqName()
}