Don't write unnecessary information to ValueParameter proto
Flags can have a default value and the index can be trivially computed almost all the time
This commit is contained in:
+4
-3
@@ -31,7 +31,7 @@ public class AnnotationLoaderForKotlinJavaScriptStubBuilder() : AnnotationAndCon
|
||||
override fun loadClassAnnotations(
|
||||
classProto: ProtoBuf.Class, nameResolver: NameResolver
|
||||
): List<ClassId> =
|
||||
classProto.getExtension(JsProtoBuf.classAnnotation).orEmpty().map { nameResolver.getClassId(it.getId()) }
|
||||
classProto.getExtension(JsProtoBuf.classAnnotation).orEmpty().map { nameResolver.getClassId(it.id) }
|
||||
|
||||
override fun loadCallableAnnotations(
|
||||
container: ProtoContainer,
|
||||
@@ -47,9 +47,10 @@ public class AnnotationLoaderForKotlinJavaScriptStubBuilder() : AnnotationAndCon
|
||||
callable: ProtoBuf.Callable,
|
||||
nameResolver: NameResolver,
|
||||
kind: AnnotatedCallableKind,
|
||||
parameterIndex: Int,
|
||||
proto: ProtoBuf.Callable.ValueParameter
|
||||
): List<ClassId> =
|
||||
proto.getExtension(JsProtoBuf.parameterAnnotation).orEmpty().map { nameResolver.getClassId(it.getId()) }
|
||||
proto.getExtension(JsProtoBuf.parameterAnnotation).orEmpty().map { nameResolver.getClassId(it.id) }
|
||||
|
||||
override fun loadExtensionReceiverParameterAnnotations(
|
||||
container: ProtoContainer,
|
||||
@@ -62,7 +63,7 @@ public class AnnotationLoaderForKotlinJavaScriptStubBuilder() : AnnotationAndCon
|
||||
proto: ProtoBuf.Type,
|
||||
nameResolver: NameResolver
|
||||
): List<ClassId> =
|
||||
proto.getExtension(JsProtoBuf.typeAnnotation).orEmpty().map { nameResolver.getClassId(it.getId()) }
|
||||
proto.getExtension(JsProtoBuf.typeAnnotation).orEmpty().map { nameResolver.getClassId(it.id) }
|
||||
|
||||
override fun loadPropertyConstant(
|
||||
container: ProtoContainer,
|
||||
|
||||
+5
-5
@@ -139,13 +139,13 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
||||
}
|
||||
|
||||
fun createValueParameterListStub(parent: StubElement<out PsiElement>, callableProto: ProtoBuf.Callable, container: ProtoContainer) {
|
||||
val callableKind = Flags.CALLABLE_KIND[callableProto.getFlags()]
|
||||
val callableKind = Flags.CALLABLE_KIND[callableProto.flags]
|
||||
if (callableKind == CallableKind.VAL || callableKind == CallableKind.VAR) {
|
||||
return
|
||||
}
|
||||
val parameterListStub = KotlinPlaceHolderStubImpl<JetParameterList>(parent, JetStubElementTypes.VALUE_PARAMETER_LIST)
|
||||
for (valueParameterProto in callableProto.getValueParameterList()) {
|
||||
val name = c.nameResolver.getName(valueParameterProto.getName())
|
||||
for ((index, valueParameterProto) in callableProto.valueParameterList.withIndex()) {
|
||||
val name = c.nameResolver.getName(valueParameterProto.name)
|
||||
val parameterStub = KotlinParameterStubImpl(
|
||||
parameterListStub,
|
||||
name = name.ref(),
|
||||
@@ -157,13 +157,13 @@ 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, valueParameterProto
|
||||
container, callableProto, c.nameResolver, callableProto.annotatedCallableKind, index, valueParameterProto
|
||||
)
|
||||
if (parameterAnnotations.isNotEmpty()) {
|
||||
createAnnotationStubs(parameterAnnotations, modifierList ?: createEmptyModifierList(parameterStub))
|
||||
}
|
||||
|
||||
val typeProto = if (isVararg) valueParameterProto.getVarargElementType() else valueParameterProto.getType()
|
||||
val typeProto = if (isVararg) valueParameterProto.varargElementType else valueParameterProto.type
|
||||
createTypeReferenceStub(parameterStub, typeProto)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user