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
@@ -36,26 +36,26 @@ public class AnnotationLoaderForKotlinJavaScriptStubBuilder() : AnnotationAndCon
override fun loadCallableAnnotations(
container: ProtoContainer,
proto: ProtoBuf.Callable,
nameResolver: NameResolver,
kind: AnnotatedCallableKind
): List<ClassIdWithTarget> {
return proto.getExtension(JsProtoBuf.callableAnnotation).orEmpty().map { ClassIdWithTarget(nameResolver.getClassId(it.id), null) }
}
): List<ClassIdWithTarget> =
proto.getExtension(JsProtoBuf.callableAnnotation).orEmpty().map {
ClassIdWithTarget(container.nameResolver.getClassId(it.id), null)
}
override fun loadValueParameterAnnotations(
container: ProtoContainer,
callable: ProtoBuf.Callable,
nameResolver: NameResolver,
kind: AnnotatedCallableKind,
parameterIndex: Int,
proto: ProtoBuf.ValueParameter
): List<ClassId> =
proto.getExtension(JsProtoBuf.parameterAnnotation).orEmpty().map { nameResolver.getClassId(it.id) }
proto.getExtension(JsProtoBuf.parameterAnnotation).orEmpty().map {
container.nameResolver.getClassId(it.id)
}
override fun loadExtensionReceiverParameterAnnotations(
container: ProtoContainer,
callable: ProtoBuf.Callable,
nameResolver: NameResolver,
kind: AnnotatedCallableKind
): List<ClassId> = emptyList()
@@ -68,7 +68,6 @@ public class AnnotationLoaderForKotlinJavaScriptStubBuilder() : AnnotationAndCon
override fun loadPropertyConstant(
container: ProtoContainer,
proto: ProtoBuf.Callable,
nameResolver: NameResolver,
expectedType: JetType
): Unit {}
) {}
}
@@ -110,7 +110,7 @@ private class CallableClsStubBuilder(
)
val kind = callableProto.annotatedCallableKind
val annotationIds = c.components.annotationLoader.loadCallableAnnotations(protoContainer, callableProto, c.nameResolver, kind)
val annotationIds = c.components.annotationLoader.loadCallableAnnotations(protoContainer, callableProto, kind)
createTargetedAnnotationStubs(annotationIds, modifierListStubImpl)
}
@@ -157,7 +157,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
val isVararg = valueParameterProto.hasVarargElementType()
val modifierList = if (isVararg) createModifierListStub(parameterStub, listOf(JetTokens.VARARG_KEYWORD)) else null
val parameterAnnotations = c.components.annotationLoader.loadValueParameterAnnotations(
container, callableProto, c.nameResolver, callableProto.annotatedCallableKind, index, valueParameterProto
container, callableProto, callableProto.annotatedCallableKind, index, valueParameterProto
)
if (parameterAnnotations.isNotEmpty()) {
createAnnotationStubs(parameterAnnotations, modifierList ?: createEmptyModifierList(parameterStub))