Extract interface out of StringTable
Rework SerializerExtension interface: don't pass StringTable to each method every time, create it in each extension's constructor instead and expose to DescriptorSerializer with an interface method
This commit is contained in:
@@ -26,11 +26,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.RawTypeCapabilities;
|
||||
import org.jetbrains.kotlin.load.kotlin.SignatureDeserializer;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.serialization.AnnotationSerializer;
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf;
|
||||
import org.jetbrains.kotlin.serialization.SerializerExtension;
|
||||
import org.jetbrains.kotlin.serialization.StringTable;
|
||||
import org.jetbrains.kotlin.serialization.*;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor;
|
||||
@@ -47,36 +43,38 @@ import static org.jetbrains.kotlin.codegen.JvmSerializationBindings.*;
|
||||
public class JvmSerializerExtension extends SerializerExtension {
|
||||
private final JvmSerializationBindings bindings;
|
||||
private final JetTypeMapper typeMapper;
|
||||
private final AnnotationSerializer annotationSerializer = new AnnotationSerializer();
|
||||
private final StringTableImpl stringTable = new StringTableImpl(this);
|
||||
private final AnnotationSerializer annotationSerializer = new AnnotationSerializer(stringTable);
|
||||
|
||||
public JvmSerializerExtension(@NotNull JvmSerializationBindings bindings, @NotNull JetTypeMapper typeMapper) {
|
||||
this.bindings = bindings;
|
||||
this.typeMapper = typeMapper;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void serializeClass(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class.Builder proto, @NotNull StringTable stringTable) {
|
||||
public StringTable getStringTable() {
|
||||
return stringTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeClass(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class.Builder proto) {
|
||||
AnnotationDescriptor annotation = descriptor.getAnnotations().findAnnotation(KotlinBuiltIns.FQ_NAMES.annotation);
|
||||
if (annotation != null) {
|
||||
proto.addExtension(JvmProtoBuf.classAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable));
|
||||
proto.addExtension(JvmProtoBuf.classAnnotation, annotationSerializer.serializeAnnotation(annotation));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeCallable(
|
||||
@NotNull CallableMemberDescriptor callable,
|
||||
@NotNull ProtoBuf.Callable.Builder proto,
|
||||
@NotNull StringTable stringTable
|
||||
) {
|
||||
saveSignature(callable, proto, stringTable);
|
||||
saveImplClassName(callable, proto, stringTable);
|
||||
public void serializeCallable(@NotNull CallableMemberDescriptor callable, @NotNull ProtoBuf.Callable.Builder proto) {
|
||||
saveSignature(callable, proto);
|
||||
saveImplClassName(callable, proto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeValueParameter(
|
||||
@NotNull ValueParameterDescriptor descriptor,
|
||||
@NotNull ProtoBuf.Callable.ValueParameter.Builder proto,
|
||||
@NotNull StringTable stringTable
|
||||
@NotNull ProtoBuf.Callable.ValueParameter.Builder proto
|
||||
) {
|
||||
Integer index = bindings.get(INDEX_FOR_VALUE_PARAMETER, descriptor);
|
||||
if (index != null) {
|
||||
@@ -85,10 +83,10 @@ public class JvmSerializerExtension extends SerializerExtension {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeType(@NotNull JetType type, @NotNull ProtoBuf.Type.Builder proto, @NotNull StringTable stringTable) {
|
||||
public void serializeType(@NotNull JetType type, @NotNull ProtoBuf.Type.Builder proto) {
|
||||
// TODO: don't store type annotations in our binary metadata on Java 8, use *TypeAnnotations attributes instead
|
||||
for (AnnotationDescriptor annotation : type.getAnnotations()) {
|
||||
proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable));
|
||||
proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation));
|
||||
}
|
||||
|
||||
if (type.getCapabilities() instanceof RawTypeCapabilities) {
|
||||
@@ -102,12 +100,8 @@ public class JvmSerializerExtension extends SerializerExtension {
|
||||
return shortNameByAsmType(typeMapper.mapClass(descriptor));
|
||||
}
|
||||
|
||||
private void saveSignature(
|
||||
@NotNull CallableMemberDescriptor callable,
|
||||
@NotNull ProtoBuf.Callable.Builder proto,
|
||||
@NotNull StringTable stringTable
|
||||
) {
|
||||
SignatureSerializer signatureSerializer = new SignatureSerializer(stringTable);
|
||||
private void saveSignature(@NotNull CallableMemberDescriptor callable, @NotNull ProtoBuf.Callable.Builder proto) {
|
||||
SignatureSerializer signatureSerializer = new SignatureSerializer();
|
||||
if (callable instanceof FunctionDescriptor) {
|
||||
JvmProtoBuf.JvmMethodSignature signature;
|
||||
if (callable instanceof DeserializedSimpleFunctionDescriptor) {
|
||||
@@ -165,24 +159,14 @@ public class JvmSerializerExtension extends SerializerExtension {
|
||||
}
|
||||
}
|
||||
|
||||
private void saveImplClassName(
|
||||
@NotNull CallableMemberDescriptor callable,
|
||||
@NotNull ProtoBuf.Callable.Builder proto,
|
||||
@NotNull StringTable stringTable
|
||||
) {
|
||||
private void saveImplClassName(@NotNull CallableMemberDescriptor callable, @NotNull ProtoBuf.Callable.Builder proto) {
|
||||
String name = bindings.get(IMPL_CLASS_NAME_FOR_CALLABLE, callable);
|
||||
if (name != null) {
|
||||
proto.setExtension(JvmProtoBuf.implClassName, stringTable.getSimpleNameIndex(Name.identifier(name)));
|
||||
proto.setExtension(JvmProtoBuf.implClassName, stringTable.getStringIndex(name));
|
||||
}
|
||||
}
|
||||
|
||||
private static class SignatureSerializer {
|
||||
private final StringTable stringTable;
|
||||
|
||||
public SignatureSerializer(@NotNull StringTable stringTable) {
|
||||
this.stringTable = stringTable;
|
||||
}
|
||||
|
||||
private class SignatureSerializer {
|
||||
@NotNull
|
||||
public JvmProtoBuf.JvmMethodSignature copyMethodSignature(
|
||||
@NotNull JvmProtoBuf.JvmMethodSignature signature,
|
||||
@@ -301,7 +285,7 @@ public class JvmSerializerExtension extends SerializerExtension {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static FqName internalNameToFqName(@NotNull String internalName) {
|
||||
private FqName internalNameToFqName(@NotNull String internalName) {
|
||||
return FqName.fromSegments(Arrays.asList(internalName.split("/")));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ public class BuiltInsSerializer(private val dependOnOldBuiltIns: Boolean) {
|
||||
BuiltInsSerializedResourcePaths.fallbackPaths.getPackageFilePath(fqName))
|
||||
|
||||
val nameStream = ByteArrayOutputStream()
|
||||
serializer.serializeStringTable(nameStream)
|
||||
serializer.stringTable.serializeTo(nameStream)
|
||||
write(destDir, BuiltInsSerializedResourcePaths.getStringTableFilePath(fqName), nameStream,
|
||||
BuiltInsSerializedResourcePaths.fallbackPaths.getStringTableFilePath(fqName))
|
||||
}
|
||||
|
||||
+12
-21
@@ -22,19 +22,18 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.serialization.*
|
||||
|
||||
public class BuiltInsSerializerExtension : SerializerExtension() {
|
||||
private val annotationSerializer = AnnotationSerializer()
|
||||
private val stringTable = StringTableImpl(this)
|
||||
private val annotationSerializer = AnnotationSerializer(stringTable)
|
||||
|
||||
override fun serializeClass(descriptor: ClassDescriptor, proto: ProtoBuf.Class.Builder, stringTable: StringTable) {
|
||||
override fun getStringTable(): StringTable = stringTable
|
||||
|
||||
override fun serializeClass(descriptor: ClassDescriptor, proto: ProtoBuf.Class.Builder) {
|
||||
for (annotation in descriptor.annotations) {
|
||||
proto.addExtension(BuiltInsProtoBuf.classAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable))
|
||||
proto.addExtension(BuiltInsProtoBuf.classAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
}
|
||||
|
||||
override fun serializePackage(
|
||||
packageFragments: Collection<PackageFragmentDescriptor>,
|
||||
proto: ProtoBuf.Package.Builder,
|
||||
stringTable: StringTable
|
||||
) {
|
||||
override fun serializePackage(packageFragments: Collection<PackageFragmentDescriptor>, proto: ProtoBuf.Package.Builder) {
|
||||
val classes = packageFragments.flatMap {
|
||||
it.getMemberScope().getDescriptors(DescriptorKindFilter.CLASSIFIERS).filterIsInstance<ClassDescriptor>()
|
||||
}
|
||||
@@ -44,29 +43,21 @@ public class BuiltInsSerializerExtension : SerializerExtension() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun serializeCallable(
|
||||
callable: CallableMemberDescriptor,
|
||||
proto: ProtoBuf.Callable.Builder,
|
||||
stringTable: StringTable
|
||||
) {
|
||||
override fun serializeCallable(callable: CallableMemberDescriptor, proto: ProtoBuf.Callable.Builder) {
|
||||
for (annotation in callable.annotations) {
|
||||
proto.addExtension(BuiltInsProtoBuf.callableAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable))
|
||||
proto.addExtension(BuiltInsProtoBuf.callableAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
val propertyDescriptor = callable as? PropertyDescriptor ?: return
|
||||
val compileTimeConstant = propertyDescriptor.compileTimeInitializer
|
||||
if (compileTimeConstant != null && compileTimeConstant !is NullValue) {
|
||||
val valueProto = annotationSerializer.valueProto(compileTimeConstant, compileTimeConstant.type, stringTable)
|
||||
val valueProto = annotationSerializer.valueProto(compileTimeConstant)
|
||||
proto.setExtension(BuiltInsProtoBuf.compileTimeValue, valueProto.build())
|
||||
}
|
||||
}
|
||||
|
||||
override fun serializeValueParameter(
|
||||
descriptor: ValueParameterDescriptor,
|
||||
proto: ProtoBuf.Callable.ValueParameter.Builder,
|
||||
stringTable: StringTable
|
||||
) {
|
||||
override fun serializeValueParameter(descriptor: ValueParameterDescriptor, proto: ProtoBuf.Callable.ValueParameter.Builder) {
|
||||
for (annotation in descriptor.annotations) {
|
||||
proto.addExtension(BuiltInsProtoBuf.parameterAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable))
|
||||
proto.addExtension(BuiltInsProtoBuf.parameterAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-16
@@ -23,24 +23,22 @@ import org.jetbrains.kotlin.resolve.constants.*
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value.Type
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
|
||||
public class AnnotationSerializer() {
|
||||
|
||||
public fun serializeAnnotation(annotation: AnnotationDescriptor, stringTable: StringTable): ProtoBuf.Annotation {
|
||||
public class AnnotationSerializer(private val stringTable: StringTable) {
|
||||
public fun serializeAnnotation(annotation: AnnotationDescriptor): ProtoBuf.Annotation {
|
||||
return with(ProtoBuf.Annotation.newBuilder()) {
|
||||
val annotationClass = annotation.getType().getConstructor().getDeclarationDescriptor() as? ClassDescriptor
|
||||
?: error("Annotation type is not a class: ${annotation.getType()}")
|
||||
val annotationClass = annotation.type.constructor.declarationDescriptor as? ClassDescriptor
|
||||
?: error("Annotation type is not a class: ${annotation.type}")
|
||||
if (ErrorUtils.isError(annotationClass)) {
|
||||
error("Unresolved annotation type: ${annotation.getType()}")
|
||||
error("Unresolved annotation type: ${annotation.type}")
|
||||
}
|
||||
|
||||
setId(stringTable.getFqNameIndex(annotationClass))
|
||||
|
||||
for ((parameter, value) in annotation.getAllValueArguments()) {
|
||||
for ((parameter, value) in annotation.allValueArguments) {
|
||||
val argument = ProtoBuf.Annotation.Argument.newBuilder()
|
||||
argument.setNameId(stringTable.getSimpleNameIndex(parameter.getName()))
|
||||
argument.setValue(valueProto(value, parameter.getType(), stringTable))
|
||||
argument.setNameId(stringTable.getStringIndex(parameter.name.asString()))
|
||||
argument.setValue(valueProto(value))
|
||||
addArgument(argument)
|
||||
}
|
||||
|
||||
@@ -48,17 +46,17 @@ public class AnnotationSerializer() {
|
||||
}
|
||||
}
|
||||
|
||||
fun valueProto(constant: ConstantValue<*>, type: JetType, nameTable: StringTable): Value.Builder = with(Value.newBuilder()) {
|
||||
fun valueProto(constant: ConstantValue<*>): Value.Builder = with(Value.newBuilder()) {
|
||||
constant.accept(object : AnnotationArgumentVisitor<Unit, Unit> {
|
||||
override fun visitAnnotationValue(value: AnnotationValue, data: Unit) {
|
||||
setType(Type.ANNOTATION)
|
||||
setAnnotation(serializeAnnotation(value.value, nameTable))
|
||||
setAnnotation(serializeAnnotation(value.value))
|
||||
}
|
||||
|
||||
override fun visitArrayValue(value: ArrayValue, data: Unit) {
|
||||
setType(Type.ARRAY)
|
||||
for (element in value.value) {
|
||||
addArrayElement(valueProto(element, value.elementType, nameTable).build())
|
||||
addArrayElement(valueProto(element).build())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,8 +83,8 @@ public class AnnotationSerializer() {
|
||||
override fun visitEnumValue(value: EnumValue, data: Unit) {
|
||||
setType(Type.ENUM)
|
||||
val enumEntry = value.value
|
||||
setClassId(nameTable.getFqNameIndex(enumEntry.getContainingDeclaration() as ClassDescriptor))
|
||||
setEnumValueId(nameTable.getSimpleNameIndex(enumEntry.getName()))
|
||||
setClassId(stringTable.getFqNameIndex(enumEntry.containingDeclaration as ClassDescriptor))
|
||||
setEnumValueId(stringTable.getStringIndex(enumEntry.name.asString()))
|
||||
}
|
||||
|
||||
override fun visitErrorValue(value: ErrorValue, data: Unit) {
|
||||
@@ -124,7 +122,7 @@ public class AnnotationSerializer() {
|
||||
|
||||
override fun visitStringValue(value: StringValue, data: Unit) {
|
||||
setType(Type.STRING)
|
||||
setStringValue(nameTable.getStringIndex(value.value))
|
||||
setStringValue(stringTable.getStringIndex(value.value))
|
||||
}
|
||||
}, Unit)
|
||||
|
||||
|
||||
+24
-26
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory;
|
||||
import org.jetbrains.kotlin.resolve.MemberComparator;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
@@ -33,7 +34,6 @@ import org.jetbrains.kotlin.utils.UtilsPackage;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -44,12 +44,10 @@ import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.
|
||||
|
||||
public class DescriptorSerializer {
|
||||
|
||||
private final StringTable stringTable;
|
||||
private final Interner<TypeParameterDescriptor> typeParameters;
|
||||
private final SerializerExtension extension;
|
||||
|
||||
private DescriptorSerializer(StringTable stringTable, Interner<TypeParameterDescriptor> typeParameters, SerializerExtension extension) {
|
||||
this.stringTable = stringTable;
|
||||
private DescriptorSerializer(Interner<TypeParameterDescriptor> typeParameters, SerializerExtension extension) {
|
||||
this.typeParameters = typeParameters;
|
||||
this.extension = extension;
|
||||
}
|
||||
@@ -58,7 +56,7 @@ public class DescriptorSerializer {
|
||||
public byte[] serialize(@NotNull MessageLite message) {
|
||||
try {
|
||||
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||
serializeStringTable(result);
|
||||
getStringTable().serializeTo(result);
|
||||
message.writeTo(result);
|
||||
return result.toByteArray();
|
||||
}
|
||||
@@ -67,14 +65,9 @@ public class DescriptorSerializer {
|
||||
}
|
||||
}
|
||||
|
||||
public void serializeStringTable(@NotNull OutputStream out) throws IOException {
|
||||
stringTable.serializeSimpleNames().writeDelimitedTo(out);
|
||||
stringTable.serializeQualifiedNames().writeDelimitedTo(out);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static DescriptorSerializer createTopLevel(@NotNull SerializerExtension extension) {
|
||||
return new DescriptorSerializer(new StringTable(extension), new Interner<TypeParameterDescriptor>(), extension);
|
||||
return new DescriptorSerializer(new Interner<TypeParameterDescriptor>(), extension);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -95,13 +88,14 @@ public class DescriptorSerializer {
|
||||
return serializer;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DescriptorSerializer createChildSerializer() {
|
||||
return new DescriptorSerializer(stringTable, new Interner<TypeParameterDescriptor>(typeParameters), extension);
|
||||
return new DescriptorSerializer(new Interner<TypeParameterDescriptor>(typeParameters), extension);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public StringTable getStringTable() {
|
||||
return stringTable;
|
||||
return extension.getStringTable();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -150,7 +144,7 @@ public class DescriptorSerializer {
|
||||
}
|
||||
|
||||
for (DeclarationDescriptor descriptor : sort(classDescriptor.getUnsubstitutedInnerClassesScope().getAllDescriptors())) {
|
||||
int name = stringTable.getSimpleNameIndex(descriptor.getName());
|
||||
int name = getSimpleNameIndex(descriptor.getName());
|
||||
if (isEnumEntry(descriptor)) {
|
||||
builder.addEnumEntry(name);
|
||||
}
|
||||
@@ -161,10 +155,10 @@ public class DescriptorSerializer {
|
||||
|
||||
ClassDescriptor companionObjectDescriptor = classDescriptor.getCompanionObjectDescriptor();
|
||||
if (companionObjectDescriptor != null) {
|
||||
builder.setCompanionObjectName(stringTable.getSimpleNameIndex(companionObjectDescriptor.getName()));
|
||||
builder.setCompanionObjectName(getSimpleNameIndex(companionObjectDescriptor.getName()));
|
||||
}
|
||||
|
||||
extension.serializeClass(classDescriptor, builder, stringTable);
|
||||
extension.serializeClass(classDescriptor, builder);
|
||||
|
||||
return builder;
|
||||
}
|
||||
@@ -253,7 +247,7 @@ public class DescriptorSerializer {
|
||||
builder.setReceiverType(local.type(receiverParameter.getType()));
|
||||
}
|
||||
|
||||
builder.setName(stringTable.getSimpleNameIndex(descriptor.getName()));
|
||||
builder.setName(getSimpleNameIndex(descriptor.getName()));
|
||||
|
||||
for (ValueParameterDescriptor valueParameterDescriptor : descriptor.getValueParameters()) {
|
||||
builder.addValueParameter(local.valueParameter(valueParameterDescriptor));
|
||||
@@ -262,7 +256,7 @@ public class DescriptorSerializer {
|
||||
//noinspection ConstantConditions
|
||||
builder.setReturnType(local.type(descriptor.getReturnType()));
|
||||
|
||||
extension.serializeCallable(descriptor, builder, stringTable);
|
||||
extension.serializeCallable(descriptor, builder);
|
||||
|
||||
return builder;
|
||||
}
|
||||
@@ -294,7 +288,7 @@ public class DescriptorSerializer {
|
||||
|
||||
builder.setFlags(Flags.getValueParameterFlags(hasAnnotations(descriptor), descriptor.declaresDefaultValue()));
|
||||
|
||||
builder.setName(stringTable.getSimpleNameIndex(descriptor.getName()));
|
||||
builder.setName(getSimpleNameIndex(descriptor.getName()));
|
||||
|
||||
builder.setType(type(descriptor.getType()));
|
||||
|
||||
@@ -303,7 +297,7 @@ public class DescriptorSerializer {
|
||||
builder.setVarargElementType(type(varargElementType));
|
||||
}
|
||||
|
||||
extension.serializeValueParameter(descriptor, builder, stringTable);
|
||||
extension.serializeValueParameter(descriptor, builder);
|
||||
|
||||
return builder;
|
||||
}
|
||||
@@ -313,7 +307,7 @@ public class DescriptorSerializer {
|
||||
|
||||
builder.setId(getTypeParameterId(typeParameter));
|
||||
|
||||
builder.setName(stringTable.getSimpleNameIndex(typeParameter.getName()));
|
||||
builder.setName(getSimpleNameIndex(typeParameter.getName()));
|
||||
|
||||
// to avoid storing a default
|
||||
if (typeParameter.isReified()) {
|
||||
@@ -353,7 +347,7 @@ public class DescriptorSerializer {
|
||||
Flexibility flexibility = TypesPackage.flexibility(type);
|
||||
|
||||
return type(flexibility.getLowerBound())
|
||||
.setFlexibleTypeCapabilitiesId(stringTable.getStringIndex(flexibility.getExtraCapabilities().getId()))
|
||||
.setFlexibleTypeCapabilitiesId(getStringTable().getStringIndex(flexibility.getExtraCapabilities().getId()))
|
||||
.setFlexibleUpperBound(type(flexibility.getUpperBound()));
|
||||
}
|
||||
|
||||
@@ -376,7 +370,7 @@ public class DescriptorSerializer {
|
||||
builder.setNullable(true);
|
||||
}
|
||||
|
||||
extension.serializeType(type, builder, stringTable);
|
||||
extension.serializeType(type, builder);
|
||||
|
||||
return builder;
|
||||
}
|
||||
@@ -410,7 +404,7 @@ public class DescriptorSerializer {
|
||||
public ProtoBuf.Package.Builder packageProtoWithoutDescriptors() {
|
||||
ProtoBuf.Package.Builder builder = ProtoBuf.Package.newBuilder();
|
||||
|
||||
extension.serializePackage(Collections.<PackageFragmentDescriptor>emptyList(), builder, stringTable);
|
||||
extension.serializePackage(Collections.<PackageFragmentDescriptor>emptyList(), builder);
|
||||
|
||||
return builder;
|
||||
}
|
||||
@@ -432,7 +426,7 @@ public class DescriptorSerializer {
|
||||
}
|
||||
}
|
||||
|
||||
extension.serializePackage(fragments, builder, stringTable);
|
||||
extension.serializePackage(fragments, builder);
|
||||
|
||||
return builder;
|
||||
}
|
||||
@@ -464,7 +458,11 @@ public class DescriptorSerializer {
|
||||
}
|
||||
|
||||
private int getClassId(@NotNull ClassDescriptor descriptor) {
|
||||
return stringTable.getFqNameIndex(descriptor);
|
||||
return getStringTable().getFqNameIndex(descriptor);
|
||||
}
|
||||
|
||||
private int getSimpleNameIndex(@NotNull Name name) {
|
||||
return getStringTable().getStringIndex(name.asString());
|
||||
}
|
||||
|
||||
private int getTypeParameterId(@NotNull TypeParameterDescriptor descriptor) {
|
||||
|
||||
+8
-22
@@ -26,39 +26,25 @@ import org.jetbrains.kotlin.types.JetType;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class SerializerExtension {
|
||||
public void serializeClass(
|
||||
@NotNull ClassDescriptor descriptor,
|
||||
@NotNull ProtoBuf.Class.Builder proto,
|
||||
@NotNull StringTable stringTable
|
||||
) {
|
||||
@NotNull
|
||||
public abstract StringTable getStringTable();
|
||||
|
||||
public void serializeClass(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class.Builder proto) {
|
||||
}
|
||||
|
||||
public void serializePackage(
|
||||
@NotNull Collection<PackageFragmentDescriptor> packageFragments,
|
||||
@NotNull ProtoBuf.Package.Builder proto,
|
||||
@NotNull StringTable stringTable
|
||||
) {
|
||||
public void serializePackage(@NotNull Collection<PackageFragmentDescriptor> packageFragments, @NotNull ProtoBuf.Package.Builder proto) {
|
||||
}
|
||||
|
||||
public void serializeCallable(
|
||||
@NotNull CallableMemberDescriptor callable,
|
||||
@NotNull ProtoBuf.Callable.Builder proto,
|
||||
@NotNull StringTable stringTable
|
||||
) {
|
||||
public void serializeCallable(@NotNull CallableMemberDescriptor callable, @NotNull ProtoBuf.Callable.Builder proto) {
|
||||
}
|
||||
|
||||
public void serializeValueParameter(
|
||||
@NotNull ValueParameterDescriptor descriptor,
|
||||
@NotNull ProtoBuf.Callable.ValueParameter.Builder proto,
|
||||
@NotNull StringTable stringTable
|
||||
@NotNull ProtoBuf.Callable.ValueParameter.Builder proto
|
||||
) {
|
||||
}
|
||||
|
||||
public void serializeType(
|
||||
@NotNull JetType type,
|
||||
@NotNull ProtoBuf.Type.Builder proto,
|
||||
@NotNull StringTable stringTable
|
||||
) {
|
||||
public void serializeType(@NotNull JetType type, @NotNull ProtoBuf.Type.Builder proto) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -17,128 +17,17 @@
|
||||
package org.jetbrains.kotlin.serialization;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ClassOrPackageFragmentDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.utils.Interner;
|
||||
|
||||
import static org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.QualifiedName;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class StringTable {
|
||||
private static final class FqNameProto {
|
||||
public final QualifiedName.Builder fqName;
|
||||
public interface StringTable {
|
||||
int getStringIndex(@NotNull String string);
|
||||
|
||||
public FqNameProto(@NotNull QualifiedName.Builder fqName) {
|
||||
this.fqName = fqName;
|
||||
}
|
||||
int getFqNameIndex(@NotNull ClassOrPackageFragmentDescriptor descriptor);
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 13;
|
||||
result = 31 * result + fqName.getParentQualifiedName();
|
||||
result = 31 * result + fqName.getShortName();
|
||||
result = 31 * result + fqName.getKind().hashCode();
|
||||
return result;
|
||||
}
|
||||
int getFqNameIndex(@NotNull FqName fqName);
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
|
||||
QualifiedName.Builder other = ((FqNameProto) obj).fqName;
|
||||
return fqName.getParentQualifiedName() == other.getParentQualifiedName()
|
||||
&& fqName.getShortName() == other.getShortName()
|
||||
&& fqName.getKind() == other.getKind();
|
||||
}
|
||||
}
|
||||
|
||||
private final Interner<String> strings = new Interner<String>();
|
||||
private final Interner<FqNameProto> qualifiedNames = new Interner<FqNameProto>();
|
||||
private final SerializerExtension extension;
|
||||
|
||||
public StringTable(@NotNull SerializerExtension extension) {
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
public int getSimpleNameIndex(@NotNull Name name) {
|
||||
return getStringIndex(name.asString());
|
||||
}
|
||||
|
||||
public int getStringIndex(@NotNull String string) {
|
||||
return strings.intern(string);
|
||||
}
|
||||
|
||||
public int getFqNameIndex(@NotNull ClassOrPackageFragmentDescriptor descriptor) {
|
||||
if (ErrorUtils.isError(descriptor)) {
|
||||
throw new IllegalStateException("Cannot get FQ name of error class: " + descriptor);
|
||||
}
|
||||
|
||||
QualifiedName.Builder builder = QualifiedName.newBuilder();
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
builder.setKind(QualifiedName.Kind.CLASS);
|
||||
}
|
||||
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
int shortName;
|
||||
if (containingDeclaration instanceof PackageFragmentDescriptor) {
|
||||
shortName = getSimpleNameIndex(descriptor.getName());
|
||||
PackageFragmentDescriptor fragment = (PackageFragmentDescriptor) containingDeclaration;
|
||||
if (!fragment.getFqName().isRoot()) {
|
||||
builder.setParentQualifiedName(getFqNameIndex(fragment.getFqName()));
|
||||
}
|
||||
}
|
||||
else if (containingDeclaration instanceof ClassDescriptor) {
|
||||
shortName = getSimpleNameIndex(descriptor.getName());
|
||||
ClassDescriptor outerClass = (ClassDescriptor) containingDeclaration;
|
||||
builder.setParentQualifiedName(getFqNameIndex(outerClass));
|
||||
}
|
||||
else {
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
builder.setKind(QualifiedName.Kind.LOCAL);
|
||||
shortName = getStringIndex(extension.getLocalClassName((ClassDescriptor) descriptor));
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Package container should be a package: " + descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
builder.setShortName(shortName);
|
||||
|
||||
return qualifiedNames.intern(new FqNameProto(builder));
|
||||
}
|
||||
|
||||
public int getFqNameIndex(@NotNull FqName fqName) {
|
||||
int result = -1;
|
||||
for (Name segment : fqName.pathSegments()) {
|
||||
QualifiedName.Builder builder = QualifiedName.newBuilder();
|
||||
builder.setShortName(getSimpleNameIndex(segment));
|
||||
if (result != -1) {
|
||||
builder.setParentQualifiedName(result);
|
||||
}
|
||||
result = qualifiedNames.intern(new FqNameProto(builder));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ProtoBuf.StringTable serializeSimpleNames() {
|
||||
ProtoBuf.StringTable.Builder builder = ProtoBuf.StringTable.newBuilder();
|
||||
for (String simpleName : strings.getAllInternedObjects()) {
|
||||
builder.addString(simpleName);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ProtoBuf.QualifiedNameTable serializeQualifiedNames() {
|
||||
ProtoBuf.QualifiedNameTable.Builder builder = ProtoBuf.QualifiedNameTable.newBuilder();
|
||||
for (FqNameProto fqName : qualifiedNames.getAllInternedObjects()) {
|
||||
builder.addQualifiedName(fqName.fqName);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
void serializeTo(@NotNull OutputStream output);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright 2010-2015 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.kotlin.serialization;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ClassOrPackageFragmentDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.utils.Interner;
|
||||
import org.jetbrains.kotlin.utils.UtilsPackage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import static org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.QualifiedName;
|
||||
|
||||
public class StringTableImpl implements StringTable {
|
||||
private static final class FqNameProto {
|
||||
public final QualifiedName.Builder fqName;
|
||||
|
||||
public FqNameProto(@NotNull QualifiedName.Builder fqName) {
|
||||
this.fqName = fqName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 13;
|
||||
result = 31 * result + fqName.getParentQualifiedName();
|
||||
result = 31 * result + fqName.getShortName();
|
||||
result = 31 * result + fqName.getKind().hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
|
||||
QualifiedName.Builder other = ((FqNameProto) obj).fqName;
|
||||
return fqName.getParentQualifiedName() == other.getParentQualifiedName()
|
||||
&& fqName.getShortName() == other.getShortName()
|
||||
&& fqName.getKind() == other.getKind();
|
||||
}
|
||||
}
|
||||
|
||||
private final Interner<String> strings = new Interner<String>();
|
||||
private final Interner<FqNameProto> qualifiedNames = new Interner<FqNameProto>();
|
||||
private final SerializerExtension extension;
|
||||
|
||||
public StringTableImpl(@NotNull SerializerExtension extension) {
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
public int getSimpleNameIndex(@NotNull Name name) {
|
||||
return getStringIndex(name.asString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStringIndex(@NotNull String string) {
|
||||
return strings.intern(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFqNameIndex(@NotNull ClassOrPackageFragmentDescriptor descriptor) {
|
||||
if (ErrorUtils.isError(descriptor)) {
|
||||
throw new IllegalStateException("Cannot get FQ name of error class: " + descriptor);
|
||||
}
|
||||
|
||||
QualifiedName.Builder builder = QualifiedName.newBuilder();
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
builder.setKind(QualifiedName.Kind.CLASS);
|
||||
}
|
||||
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
int shortName;
|
||||
if (containingDeclaration instanceof PackageFragmentDescriptor) {
|
||||
shortName = getSimpleNameIndex(descriptor.getName());
|
||||
PackageFragmentDescriptor fragment = (PackageFragmentDescriptor) containingDeclaration;
|
||||
if (!fragment.getFqName().isRoot()) {
|
||||
builder.setParentQualifiedName(getFqNameIndex(fragment.getFqName()));
|
||||
}
|
||||
}
|
||||
else if (containingDeclaration instanceof ClassDescriptor) {
|
||||
shortName = getSimpleNameIndex(descriptor.getName());
|
||||
ClassDescriptor outerClass = (ClassDescriptor) containingDeclaration;
|
||||
builder.setParentQualifiedName(getFqNameIndex(outerClass));
|
||||
}
|
||||
else {
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
builder.setKind(QualifiedName.Kind.LOCAL);
|
||||
shortName = getStringIndex(extension.getLocalClassName((ClassDescriptor) descriptor));
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Package container should be a package: " + descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
builder.setShortName(shortName);
|
||||
|
||||
return qualifiedNames.intern(new FqNameProto(builder));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFqNameIndex(@NotNull FqName fqName) {
|
||||
int result = -1;
|
||||
for (Name segment : fqName.pathSegments()) {
|
||||
QualifiedName.Builder builder = QualifiedName.newBuilder();
|
||||
builder.setShortName(getSimpleNameIndex(segment));
|
||||
if (result != -1) {
|
||||
builder.setParentQualifiedName(result);
|
||||
}
|
||||
result = qualifiedNames.intern(new FqNameProto(builder));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeTo(@NotNull OutputStream output) {
|
||||
try {
|
||||
ProtoBuf.StringTable.Builder stringTable = ProtoBuf.StringTable.newBuilder();
|
||||
for (String simpleName : strings.getAllInternedObjects()) {
|
||||
stringTable.addString(simpleName);
|
||||
}
|
||||
stringTable.build().writeDelimitedTo(output);
|
||||
|
||||
ProtoBuf.QualifiedNameTable.Builder qualifiedNameTable = ProtoBuf.QualifiedNameTable.newBuilder();
|
||||
for (FqNameProto fqName : qualifiedNames.getAllInternedObjects()) {
|
||||
qualifiedNameTable.addQualifiedName(fqName.fqName);
|
||||
}
|
||||
qualifiedNameTable.build().writeDelimitedTo(output);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.StringTable
|
||||
import org.jetbrains.kotlin.serialization.StringTableImpl
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadata
|
||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils
|
||||
@@ -49,9 +49,9 @@ public object KotlinJavascriptSerializationUtil {
|
||||
}
|
||||
|
||||
private val STRING_TABLE_DEFAULT_BYTES = run {
|
||||
val serializer = DescriptorSerializer.createTopLevel(KotlinJavascriptSerializerExtension)
|
||||
val serializer = DescriptorSerializer.createTopLevel(KotlinJavascriptSerializerExtension())
|
||||
val stream = ByteArrayOutputStream()
|
||||
serializer.serializeStringTable(stream)
|
||||
serializer.stringTable.serializeTo(stream)
|
||||
stream.toByteArray()
|
||||
}
|
||||
|
||||
@@ -103,7 +103,8 @@ public object KotlinJavascriptSerializationUtil {
|
||||
|
||||
val skip: (DeclarationDescriptor) -> Boolean = { DescriptorUtils.getContainingModule(it) != module }
|
||||
|
||||
val serializer = DescriptorSerializer.createTopLevel(KotlinJavascriptSerializerExtension)
|
||||
val serializerExtension = KotlinJavascriptSerializerExtension()
|
||||
val serializer = DescriptorSerializer.createTopLevel(serializerExtension)
|
||||
|
||||
val classifierDescriptors = DescriptorSerializer.sort(packageView.memberScope.getDescriptors(DescriptorKindFilter.CLASSIFIERS))
|
||||
|
||||
@@ -123,11 +124,11 @@ public object KotlinJavascriptSerializationUtil {
|
||||
writeFun(KotlinJavascriptSerializedResourcePaths.getPackageFilePath(fqName), packageStream.toByteArray())
|
||||
}
|
||||
|
||||
val strings = serializer.stringTable
|
||||
val strings = serializerExtension.stringTable
|
||||
serializeClassNamesInPackage(fqName, fragments, strings, skip, writeFun)
|
||||
|
||||
val nameStream = ByteArrayOutputStream()
|
||||
serializer.serializeStringTable(nameStream)
|
||||
strings.serializeTo(nameStream)
|
||||
val stringBytes = nameStream.toByteArray()
|
||||
|
||||
if (!stringBytes.isEmpty()) {
|
||||
@@ -138,7 +139,7 @@ public object KotlinJavascriptSerializationUtil {
|
||||
private fun serializeClassNamesInPackage(
|
||||
fqName: FqName,
|
||||
packageFragments: Collection<PackageFragmentDescriptor>,
|
||||
stringTable: StringTable,
|
||||
stringTable: StringTableImpl,
|
||||
skip: (DeclarationDescriptor) -> Boolean,
|
||||
writeFun: (String, ByteArray) -> Unit
|
||||
) {
|
||||
|
||||
+19
-26
@@ -24,48 +24,41 @@ import org.jetbrains.kotlin.resolve.constants.NullValue
|
||||
import org.jetbrains.kotlin.serialization.AnnotationSerializer
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.SerializerExtension
|
||||
import org.jetbrains.kotlin.serialization.StringTable
|
||||
import org.jetbrains.kotlin.serialization.StringTableImpl
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
|
||||
public object KotlinJavascriptSerializerExtension : SerializerExtension() {
|
||||
public class KotlinJavascriptSerializerExtension : SerializerExtension() {
|
||||
private val stringTable = StringTableImpl(this)
|
||||
private val annotationSerializer = AnnotationSerializer(stringTable)
|
||||
|
||||
private val annotationSerializer = AnnotationSerializer()
|
||||
override fun getStringTable() = stringTable
|
||||
|
||||
override fun serializeClass(descriptor: ClassDescriptor, proto: ProtoBuf.Class.Builder, stringTable: StringTable) {
|
||||
for (annotation in descriptor.getAnnotations()) {
|
||||
proto.addExtension(JsProtoBuf.classAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable))
|
||||
override fun serializeClass(descriptor: ClassDescriptor, proto: ProtoBuf.Class.Builder) {
|
||||
for (annotation in descriptor.annotations) {
|
||||
proto.addExtension(JsProtoBuf.classAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
}
|
||||
|
||||
override fun serializeCallable(
|
||||
callable: CallableMemberDescriptor,
|
||||
proto: ProtoBuf.Callable.Builder,
|
||||
stringTable: StringTable
|
||||
) {
|
||||
for (annotation in callable.getAnnotations()) {
|
||||
proto.addExtension(JsProtoBuf.callableAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable))
|
||||
override fun serializeCallable(callable: CallableMemberDescriptor, proto: ProtoBuf.Callable.Builder) {
|
||||
for (annotation in callable.annotations) {
|
||||
proto.addExtension(JsProtoBuf.callableAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
val propertyDescriptor = callable as? PropertyDescriptor ?: return
|
||||
val constantInitializer = propertyDescriptor.getCompileTimeInitializer()
|
||||
val constantInitializer = propertyDescriptor.compileTimeInitializer
|
||||
if (constantInitializer != null && constantInitializer !is NullValue) {
|
||||
val type = constantInitializer.type
|
||||
proto.setExtension(JsProtoBuf.compileTimeValue, annotationSerializer.valueProto(constantInitializer, type, stringTable).build())
|
||||
proto.setExtension(JsProtoBuf.compileTimeValue, annotationSerializer.valueProto(constantInitializer).build())
|
||||
}
|
||||
}
|
||||
|
||||
override fun serializeValueParameter(
|
||||
descriptor: ValueParameterDescriptor,
|
||||
proto: ProtoBuf.Callable.ValueParameter.Builder,
|
||||
stringTable: StringTable
|
||||
) {
|
||||
for (annotation in descriptor.getAnnotations()) {
|
||||
proto.addExtension(JsProtoBuf.parameterAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable))
|
||||
override fun serializeValueParameter(descriptor: ValueParameterDescriptor, proto: ProtoBuf.Callable.ValueParameter.Builder) {
|
||||
for (annotation in descriptor.annotations) {
|
||||
proto.addExtension(JsProtoBuf.parameterAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
}
|
||||
|
||||
override fun serializeType(type: JetType, proto: ProtoBuf.Type.Builder, stringTable: StringTable) {
|
||||
for (annotation in type.getAnnotations()) {
|
||||
proto.addExtension(JsProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable))
|
||||
override fun serializeType(type: JetType, proto: ProtoBuf.Type.Builder) {
|
||||
for (annotation in type.annotations) {
|
||||
proto.addExtension(JsProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user