Serialize/deserialize annotations on enum entries

#KT-10338 Fixed
This commit is contained in:
Alexander Udalov
2015-12-10 15:26:00 +03:00
parent 5e421b4024
commit 3e2eb8c1a0
29 changed files with 1845 additions and 260 deletions
@@ -174,7 +174,8 @@ public class DescriptorSerializer {
for (DeclarationDescriptor descriptor : sort(DescriptorUtils.getAllDescriptors(classDescriptor.getUnsubstitutedInnerClassesScope()))) { for (DeclarationDescriptor descriptor : sort(DescriptorUtils.getAllDescriptors(classDescriptor.getUnsubstitutedInnerClassesScope()))) {
int name = getSimpleNameIndex(descriptor.getName()); int name = getSimpleNameIndex(descriptor.getName());
if (isEnumEntry(descriptor)) { if (isEnumEntry(descriptor)) {
builder.addEnumEntry(name); builder.addEnumEntryName(name);
builder.addEnumEntry(enumEntryProto((ClassDescriptor) descriptor));
} }
else { else {
builder.addNestedClassName(name); builder.addNestedClassName(name);
@@ -357,6 +358,14 @@ public class DescriptorSerializer {
return builder; return builder;
} }
@NotNull
public ProtoBuf.EnumEntry.Builder enumEntryProto(@NotNull ClassDescriptor descriptor) {
ProtoBuf.EnumEntry.Builder builder = ProtoBuf.EnumEntry.newBuilder();
builder.setName(getSimpleNameIndex(descriptor.getName()));
extension.serializeEnumEntry(descriptor, builder);
return builder;
}
private static int getAccessorFlags(@NotNull PropertyAccessorDescriptor accessor) { private static int getAccessorFlags(@NotNull PropertyAccessorDescriptor accessor) {
return Flags.getAccessorFlags( return Flags.getAccessorFlags(
hasAnnotations(accessor), hasAnnotations(accessor),
@@ -45,6 +45,9 @@ public abstract class SerializerExtension {
public void serializeProperty(@NotNull PropertyDescriptor descriptor, @NotNull ProtoBuf.Property.Builder proto) { public void serializeProperty(@NotNull PropertyDescriptor descriptor, @NotNull ProtoBuf.Property.Builder proto) {
} }
public void serializeEnumEntry(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.EnumEntry.Builder proto) {
}
public void serializeValueParameter(@NotNull ValueParameterDescriptor descriptor, @NotNull ProtoBuf.ValueParameter.Builder proto) { public void serializeValueParameter(@NotNull ValueParameterDescriptor descriptor, @NotNull ProtoBuf.ValueParameter.Builder proto) {
} }
@@ -54,6 +54,12 @@ public open class KotlinSerializerExtensionBase(private val protocol: Serializer
} }
} }
override fun serializeEnumEntry(descriptor: ClassDescriptor, proto: ProtoBuf.EnumEntry.Builder) {
for (annotation in descriptor.annotations) {
proto.addExtension(protocol.enumEntryAnnotation, annotationSerializer.serializeAnnotation(annotation))
}
}
override fun serializeValueParameter(descriptor: ValueParameterDescriptor, proto: ProtoBuf.ValueParameter.Builder) { override fun serializeValueParameter(descriptor: ValueParameterDescriptor, proto: ProtoBuf.ValueParameter.Builder) {
for (annotation in descriptor.annotations) { for (annotation in descriptor.annotations) {
proto.addExtension(protocol.parameterAnnotation, annotationSerializer.serializeAnnotation(annotation)) proto.addExtension(protocol.parameterAnnotation, annotationSerializer.serializeAnnotation(annotation))
@@ -0,0 +1,14 @@
package test
annotation class Anno(val value: String = "0", val x: Int = 0)
annotation class Bnno
enum class Eee {
@Anno()
Entry1,
Entry2,
@Anno("3") @Bnno
Entry3,
@Anno("4", 4)
Entry4,
}
@@ -0,0 +1,32 @@
package test
public final annotation class Anno : kotlin.Annotation {
public constructor Anno(/*0*/ value: kotlin.String = ..., /*1*/ x: kotlin.Int = ...)
public final val value: kotlin.String
public final val x: kotlin.Int
}
public final annotation class Bnno : kotlin.Annotation {
public constructor Bnno()
}
public final enum class Eee : kotlin.Enum<test.Eee> {
@test.Anno() enum entry Entry1
enum entry Entry2
@test.Anno(value = "3") @test.Bnno() enum entry Entry3
@test.Anno(value = "4", x = 4) enum entry Entry4
private constructor Eee()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.Eee): kotlin.Int
// Static members
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use 'values()' function instead", replaceWith = kotlin.ReplaceWith(expression = "this.values()", imports = {})) public final /*synthesized*/ val values: kotlin.Array<test.Eee>
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): test.Eee
public final /*synthesized*/ fun values(): kotlin.Array<test.Eee>
}
File diff suppressed because it is too large Load Diff
@@ -74,6 +74,10 @@ public class BuiltInsSerializerTest : TestCaseWithTmpdir() {
doTest("annotationTargets.kt") doTest("annotationTargets.kt")
} }
fun testAnnotatedEnumEntry() {
doTest("annotatedEnumEntry.kt")
}
fun testPrimitives() { fun testPrimitives() {
doTest("annotationArguments/primitives.kt") doTest("annotationArguments/primitives.kt")
} }
@@ -14,6 +14,7 @@ public final class DebugBuiltInsProtoBuf {
registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.functionAnnotation); registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.functionAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.propertyAnnotation); registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.propertyAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.compileTimeValue); registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.compileTimeValue);
registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.enumEntryAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.parameterAnnotation); registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.parameterAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.typeAnnotation); registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.typeAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.typeParameterAnnotation); registry.add(org.jetbrains.kotlin.serialization.builtins.DebugBuiltInsProtoBuf.typeParameterAnnotation);
@@ -95,6 +96,17 @@ public final class DebugBuiltInsProtoBuf {
.newFileScopedGeneratedExtension( .newFileScopedGeneratedExtension(
org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.Argument.Value.class, org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.Argument.Value.class,
org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.Argument.Value.getDefaultInstance()); org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.Argument.Value.getDefaultInstance());
public static final int ENUM_ENTRY_ANNOTATION_FIELD_NUMBER = 150;
/**
* <code>extend .org.jetbrains.kotlin.serialization.EnumEntry { ... }</code>
*/
public static final
com.google.protobuf.GeneratedMessage.GeneratedExtension<
org.jetbrains.kotlin.serialization.DebugProtoBuf.EnumEntry,
java.util.List<org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation>> enumEntryAnnotation = com.google.protobuf.GeneratedMessage
.newFileScopedGeneratedExtension(
org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.class,
org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.getDefaultInstance());
public static final int PARAMETER_ANNOTATION_FIELD_NUMBER = 150; public static final int PARAMETER_ANNOTATION_FIELD_NUMBER = 150;
/** /**
* <code>extend .org.jetbrains.kotlin.serialization.ValueParameter { ... }</code> * <code>extend .org.jetbrains.kotlin.serialization.ValueParameter { ... }</code>
@@ -160,17 +172,20 @@ public final class DebugBuiltInsProtoBuf {
"lue\022,.org.jetbrains.kotlin.serialization" + "lue\022,.org.jetbrains.kotlin.serialization" +
".Property\030\227\001 \001(\0132=.org.jetbrains.kotlin." + ".Property\030\227\001 \001(\0132=.org.jetbrains.kotlin." +
"serialization.Annotation.Argument.Value:" + "serialization.Annotation.Argument.Value:" +
"\201\001\n\024parameter_annotation\0222.org.jetbrains" + "}\n\025enum_entry_annotation\022-.org.jetbrains" +
".kotlin.serialization.ValueParameter\030\226\001 " + ".kotlin.serialization.EnumEntry\030\226\001 \003(\0132." +
"\003(\0132..org.jetbrains.kotlin.serialization" + ".org.jetbrains.kotlin.serialization.Anno" +
".Annotation:r\n\017type_annotation\022(.org.jet" + "tation:\201\001\n\024parameter_annotation\0222.org.je" +
"brains.kotlin.serialization.Type\030\226\001 \003(\0132" + "tbrains.kotlin.serialization.ValueParame" +
"..org.jetbrains.kotlin.serialization.Ann" + "ter\030\226\001 \003(\0132..org.jetbrains.kotlin.serial" +
"otation:\205\001\n\031type_parameter_annotation\0221.", "ization.Annotation:r\n\017type_annotation\022(.",
"org.jetbrains.kotlin.serialization.TypeP" + "org.jetbrains.kotlin.serialization.Type\030" +
"arameter\030\226\001 \003(\0132..org.jetbrains.kotlin.s" + "\226\001 \003(\0132..org.jetbrains.kotlin.serializat" +
"erialization.AnnotationB\027B\025DebugBuiltIns" + "ion.Annotation:\205\001\n\031type_parameter_annota" +
"ProtoBuf" "tion\0221.org.jetbrains.kotlin.serializatio" +
"n.TypeParameter\030\226\001 \003(\0132..org.jetbrains.k" +
"otlin.serialization.AnnotationB\027B\025DebugB" +
"uiltInsProtoBuf"
}; };
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -184,9 +199,10 @@ public final class DebugBuiltInsProtoBuf {
functionAnnotation.internalInit(descriptor.getExtensions().get(4)); functionAnnotation.internalInit(descriptor.getExtensions().get(4));
propertyAnnotation.internalInit(descriptor.getExtensions().get(5)); propertyAnnotation.internalInit(descriptor.getExtensions().get(5));
compileTimeValue.internalInit(descriptor.getExtensions().get(6)); compileTimeValue.internalInit(descriptor.getExtensions().get(6));
parameterAnnotation.internalInit(descriptor.getExtensions().get(7)); enumEntryAnnotation.internalInit(descriptor.getExtensions().get(7));
typeAnnotation.internalInit(descriptor.getExtensions().get(8)); parameterAnnotation.internalInit(descriptor.getExtensions().get(8));
typeParameterAnnotation.internalInit(descriptor.getExtensions().get(9)); typeAnnotation.internalInit(descriptor.getExtensions().get(9));
typeParameterAnnotation.internalInit(descriptor.getExtensions().get(10));
return null; return null;
} }
}; };
@@ -12,6 +12,7 @@ public final class DebugJsProtoBuf {
registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.functionAnnotation); registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.functionAnnotation);
registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.propertyAnnotation); registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.propertyAnnotation);
registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.compileTimeValue); registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.compileTimeValue);
registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.enumEntryAnnotation);
registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.parameterAnnotation); registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.parameterAnnotation);
registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.typeAnnotation); registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.typeAnnotation);
registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.typeParameterAnnotation); registry.add(org.jetbrains.kotlin.serialization.js.DebugJsProtoBuf.typeParameterAnnotation);
@@ -1859,6 +1860,17 @@ public final class DebugJsProtoBuf {
.newFileScopedGeneratedExtension( .newFileScopedGeneratedExtension(
org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.Argument.Value.class, org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.Argument.Value.class,
org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.Argument.Value.getDefaultInstance()); org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.Argument.Value.getDefaultInstance());
public static final int ENUM_ENTRY_ANNOTATION_FIELD_NUMBER = 130;
/**
* <code>extend .org.jetbrains.kotlin.serialization.EnumEntry { ... }</code>
*/
public static final
com.google.protobuf.GeneratedMessage.GeneratedExtension<
org.jetbrains.kotlin.serialization.DebugProtoBuf.EnumEntry,
java.util.List<org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation>> enumEntryAnnotation = com.google.protobuf.GeneratedMessage
.newFileScopedGeneratedExtension(
org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.class,
org.jetbrains.kotlin.serialization.DebugProtoBuf.Annotation.getDefaultInstance());
public static final int PARAMETER_ANNOTATION_FIELD_NUMBER = 130; public static final int PARAMETER_ANNOTATION_FIELD_NUMBER = 130;
/** /**
* <code>extend .org.jetbrains.kotlin.serialization.ValueParameter { ... }</code> * <code>extend .org.jetbrains.kotlin.serialization.ValueParameter { ... }</code>
@@ -1939,17 +1951,20 @@ public final class DebugJsProtoBuf {
"ime_value\022,.org.jetbrains.kotlin.seriali" + "ime_value\022,.org.jetbrains.kotlin.seriali" +
"zation.Property\030\203\001 \001(\0132=.org.jetbrains.k" + "zation.Property\030\203\001 \001(\0132=.org.jetbrains.k" +
"otlin.serialization.Annotation.Argument." + "otlin.serialization.Annotation.Argument." +
"Value:\201\001\n\024parameter_annotation\0222.org.jet" + "Value:}\n\025enum_entry_annotation\022-.org.jet" +
"brains.kotlin.serialization.ValueParamet" + "brains.kotlin.serialization.EnumEntry\030\202\001" +
"er\030\202\001 \003(\0132..org.jetbrains.kotlin.seriali" + " \003(\0132..org.jetbrains.kotlin.serializatio" +
"zation.Annotation:r\n\017type_annotation\022(.o" + "n.Annotation:\201\001\n\024parameter_annotation\0222." +
"rg.jetbrains.kotlin.serialization.Type\030\202" + "org.jetbrains.kotlin.serialization.Value" +
"\001 \003(\0132..org.jetbrains.kotlin.serializati" + "Parameter\030\202\001 \003(\0132..org.jetbrains.kotlin." +
"on.Annotation:\205\001\n\031type_parameter_annotat", "serialization.Annotation:r\n\017type_annotat",
"ion\0221.org.jetbrains.kotlin.serialization" + "ion\022(.org.jetbrains.kotlin.serialization" +
".TypeParameter\030\202\001 \003(\0132..org.jetbrains.ko" + ".Type\030\202\001 \003(\0132..org.jetbrains.kotlin.seri" +
"tlin.serialization.AnnotationB\021B\017DebugJs" + "alization.Annotation:\205\001\n\031type_parameter_" +
"ProtoBuf" "annotation\0221.org.jetbrains.kotlin.serial" +
"ization.TypeParameter\030\202\001 \003(\0132..org.jetbr" +
"ains.kotlin.serialization.AnnotationB\021B\017" +
"DebugJsProtoBuf"
}; };
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -1979,9 +1994,10 @@ public final class DebugJsProtoBuf {
functionAnnotation.internalInit(descriptor.getExtensions().get(2)); functionAnnotation.internalInit(descriptor.getExtensions().get(2));
propertyAnnotation.internalInit(descriptor.getExtensions().get(3)); propertyAnnotation.internalInit(descriptor.getExtensions().get(3));
compileTimeValue.internalInit(descriptor.getExtensions().get(4)); compileTimeValue.internalInit(descriptor.getExtensions().get(4));
parameterAnnotation.internalInit(descriptor.getExtensions().get(5)); enumEntryAnnotation.internalInit(descriptor.getExtensions().get(5));
typeAnnotation.internalInit(descriptor.getExtensions().get(6)); parameterAnnotation.internalInit(descriptor.getExtensions().get(6));
typeParameterAnnotation.internalInit(descriptor.getExtensions().get(7)); typeAnnotation.internalInit(descriptor.getExtensions().get(7));
typeParameterAnnotation.internalInit(descriptor.getExtensions().get(8));
return null; return null;
} }
}; };
@@ -111,6 +111,10 @@ public class KotlinJavascriptSerializerTest : TestCaseWithTmpdir() {
doTest("builtinsSerializer/annotationTargets.kt") doTest("builtinsSerializer/annotationTargets.kt")
} }
fun testAnnotatedEnumEntry() {
doTest("builtinsSerializer/annotatedEnumEntry.kt")
}
fun testPrimitives() { fun testPrimitives() {
doTest("builtinsSerializer/annotationArguments/primitives.kt") doTest("builtinsSerializer/annotationArguments/primitives.kt")
} }
@@ -35,7 +35,7 @@ public final class JvmAbi {
* - Patch version can be increased freely and is only supposed to be used for debugging. Increase the patch version when you * - Patch version can be increased freely and is only supposed to be used for debugging. Increase the patch version when you
* make a change to the metadata format or the bytecode which is both forward- and backward compatible. * make a change to the metadata format or the bytecode which is both forward- and backward compatible.
*/ */
public static final BinaryVersion VERSION = BinaryVersion.create(1, 0, 0); public static final BinaryVersion VERSION = BinaryVersion.create(1, 0, 1);
public static final String DEFAULT_IMPLS_CLASS_NAME = "DefaultImpls"; public static final String DEFAULT_IMPLS_CLASS_NAME = "DefaultImpls";
public static final String DEFAULT_IMPLS_SUFFIX = "$" + DEFAULT_IMPLS_CLASS_NAME; public static final String DEFAULT_IMPLS_SUFFIX = "$" + DEFAULT_IMPLS_CLASS_NAME;
@@ -26,10 +26,7 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.* import org.jetbrains.kotlin.serialization.deserialization.*
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.index import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.*
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.methodImplClassName
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.propertyImplClassName
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.propertySignature
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.KotlinType
@@ -112,6 +109,14 @@ public abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C
return transformAnnotations(findClassAndLoadMemberAnnotations(container, proto, signature)) return transformAnnotations(findClassAndLoadMemberAnnotations(container, proto, signature))
} }
override fun loadEnumEntryAnnotations(
container: ProtoContainer,
proto: ProtoBuf.EnumEntry
): List<A> {
// TODO
return listOf()
}
protected abstract fun loadPropertyAnnotations(propertyAnnotations: List<A>, fieldAnnotations: List<A>): List<T> protected abstract fun loadPropertyAnnotations(propertyAnnotations: List<A>, fieldAnnotations: List<A>): List<T>
protected abstract fun transformAnnotations(annotations: List<A>): List<T> protected abstract fun transformAnnotations(annotations: List<A>): List<T>
@@ -21,6 +21,6 @@ import org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf
object BuiltInSerializerProtocol : SerializerExtensionProtocol( object BuiltInSerializerProtocol : SerializerExtensionProtocol(
BuiltInsProtoBuf.constructorAnnotation, BuiltInsProtoBuf.classAnnotation, BuiltInsProtoBuf.functionAnnotation, BuiltInsProtoBuf.constructorAnnotation, BuiltInsProtoBuf.classAnnotation, BuiltInsProtoBuf.functionAnnotation,
BuiltInsProtoBuf.propertyAnnotation, BuiltInsProtoBuf.compileTimeValue, BuiltInsProtoBuf.parameterAnnotation, BuiltInsProtoBuf.propertyAnnotation, BuiltInsProtoBuf.enumEntryAnnotation, BuiltInsProtoBuf.compileTimeValue,
BuiltInsProtoBuf.typeAnnotation, BuiltInsProtoBuf.typeParameterAnnotation BuiltInsProtoBuf.parameterAnnotation, BuiltInsProtoBuf.typeAnnotation, BuiltInsProtoBuf.typeParameterAnnotation
) )
+4
View File
@@ -44,6 +44,10 @@ extend Property {
optional Annotation.Argument.Value compile_time_value = 151; optional Annotation.Argument.Value compile_time_value = 151;
} }
extend EnumEntry {
repeated Annotation enum_entry_annotation = 150;
}
extend ValueParameter { extend ValueParameter {
repeated Annotation parameter_annotation = 150; repeated Annotation parameter_annotation = 150;
} }
+9 -1
View File
@@ -192,7 +192,9 @@ message Class {
repeated Function function = 9; repeated Function function = 9;
repeated Property property = 10; repeated Property property = 10;
repeated int32 enum_entry = 12 [packed = true, (name_id_in_table) = true]; repeated int32 enum_entry_name = 12 [packed = true, (name_id_in_table) = true];
repeated EnumEntry enum_entry = 13;
optional TypeTable type_table = 30; optional TypeTable type_table = 30;
@@ -320,6 +322,12 @@ message ValueParameter {
extensions 100 to 199; extensions 100 to 199;
} }
message EnumEntry {
optional int32 name = 1;
extensions 100 to 199;
}
enum Modality { enum Modality {
// 2 bits // 2 bits
FINAL = 0; FINAL = 0;
@@ -7538,19 +7538,34 @@ public final class ProtoBuf {
*/ */
int getPropertyCount(); int getPropertyCount();
// repeated int32 enum_entry = 12 [packed = true]; // repeated int32 enum_entry_name = 12 [packed = true];
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/ */
java.util.List<java.lang.Integer> getEnumEntryList(); java.util.List<java.lang.Integer> getEnumEntryNameList();
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/
int getEnumEntryNameCount();
/**
* <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/
int getEnumEntryName(int index);
// repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry>
getEnumEntryList();
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry getEnumEntry(int index);
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/ */
int getEnumEntryCount(); int getEnumEntryCount();
/**
* <code>repeated int32 enum_entry = 12 [packed = true];</code>
*/
int getEnumEntry(int index);
// optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30; // optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;
/** /**
@@ -7704,25 +7719,33 @@ public final class ProtoBuf {
} }
case 96: { case 96: {
if (!((mutable_bitField0_ & 0x00000400) == 0x00000400)) { if (!((mutable_bitField0_ & 0x00000400) == 0x00000400)) {
enumEntry_ = new java.util.ArrayList<java.lang.Integer>(); enumEntryName_ = new java.util.ArrayList<java.lang.Integer>();
mutable_bitField0_ |= 0x00000400; mutable_bitField0_ |= 0x00000400;
} }
enumEntry_.add(input.readInt32()); enumEntryName_.add(input.readInt32());
break; break;
} }
case 98: { case 98: {
int length = input.readRawVarint32(); int length = input.readRawVarint32();
int limit = input.pushLimit(length); int limit = input.pushLimit(length);
if (!((mutable_bitField0_ & 0x00000400) == 0x00000400) && input.getBytesUntilLimit() > 0) { if (!((mutable_bitField0_ & 0x00000400) == 0x00000400) && input.getBytesUntilLimit() > 0) {
enumEntry_ = new java.util.ArrayList<java.lang.Integer>(); enumEntryName_ = new java.util.ArrayList<java.lang.Integer>();
mutable_bitField0_ |= 0x00000400; mutable_bitField0_ |= 0x00000400;
} }
while (input.getBytesUntilLimit() > 0) { while (input.getBytesUntilLimit() > 0) {
enumEntry_.add(input.readInt32()); enumEntryName_.add(input.readInt32());
} }
input.popLimit(limit); input.popLimit(limit);
break; break;
} }
case 106: {
if (!((mutable_bitField0_ & 0x00000800) == 0x00000800)) {
enumEntry_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry>();
mutable_bitField0_ |= 0x00000800;
}
enumEntry_.add(input.readMessage(org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry.PARSER, extensionRegistry));
break;
}
case 242: { case 242: {
org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.Builder subBuilder = null; org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.Builder subBuilder = null;
if (((bitField0_ & 0x00000008) == 0x00000008)) { if (((bitField0_ & 0x00000008) == 0x00000008)) {
@@ -7766,6 +7789,9 @@ public final class ProtoBuf {
property_ = java.util.Collections.unmodifiableList(property_); property_ = java.util.Collections.unmodifiableList(property_);
} }
if (((mutable_bitField0_ & 0x00000400) == 0x00000400)) { if (((mutable_bitField0_ & 0x00000400) == 0x00000400)) {
enumEntryName_ = java.util.Collections.unmodifiableList(enumEntryName_);
}
if (((mutable_bitField0_ & 0x00000800) == 0x00000800)) {
enumEntry_ = java.util.Collections.unmodifiableList(enumEntry_); enumEntry_ = java.util.Collections.unmodifiableList(enumEntry_);
} }
makeExtensionsImmutable(); makeExtensionsImmutable();
@@ -8192,29 +8218,65 @@ public final class ProtoBuf {
return property_.get(index); return property_.get(index);
} }
// repeated int32 enum_entry = 12 [packed = true]; // repeated int32 enum_entry_name = 12 [packed = true];
public static final int ENUM_ENTRY_FIELD_NUMBER = 12; public static final int ENUM_ENTRY_NAME_FIELD_NUMBER = 12;
private java.util.List<java.lang.Integer> enumEntry_; private java.util.List<java.lang.Integer> enumEntryName_;
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/ */
public java.util.List<java.lang.Integer> public java.util.List<java.lang.Integer>
getEnumEntryList() { getEnumEntryNameList() {
return enumEntryName_;
}
/**
* <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/
public int getEnumEntryNameCount() {
return enumEntryName_.size();
}
/**
* <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/
public int getEnumEntryName(int index) {
return enumEntryName_.get(index);
}
private int enumEntryNameMemoizedSerializedSize = -1;
// repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;
public static final int ENUM_ENTRY_FIELD_NUMBER = 13;
private java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry> enumEntry_;
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
public java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry> getEnumEntryList() {
return enumEntry_; return enumEntry_;
} }
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
public java.util.List<? extends org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntryOrBuilder>
getEnumEntryOrBuilderList() {
return enumEntry_;
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/ */
public int getEnumEntryCount() { public int getEnumEntryCount() {
return enumEntry_.size(); return enumEntry_.size();
} }
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/ */
public int getEnumEntry(int index) { public org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry getEnumEntry(int index) {
return enumEntry_.get(index);
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
public org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntryOrBuilder getEnumEntryOrBuilder(
int index) {
return enumEntry_.get(index); return enumEntry_.get(index);
} }
private int enumEntryMemoizedSerializedSize = -1;
// optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30; // optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;
public static final int TYPE_TABLE_FIELD_NUMBER = 30; public static final int TYPE_TABLE_FIELD_NUMBER = 30;
@@ -8243,6 +8305,7 @@ public final class ProtoBuf {
constructor_ = java.util.Collections.emptyList(); constructor_ = java.util.Collections.emptyList();
function_ = java.util.Collections.emptyList(); function_ = java.util.Collections.emptyList();
property_ = java.util.Collections.emptyList(); property_ = java.util.Collections.emptyList();
enumEntryName_ = java.util.Collections.emptyList();
enumEntry_ = java.util.Collections.emptyList(); enumEntry_ = java.util.Collections.emptyList();
typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance(); typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance();
} }
@@ -8285,6 +8348,12 @@ public final class ProtoBuf {
return false; return false;
} }
} }
for (int i = 0; i < getEnumEntryCount(); i++) {
if (!getEnumEntry(i).isInitialized()) {
memoizedIsInitialized = 0;
return false;
}
}
if (hasTypeTable()) { if (hasTypeTable()) {
if (!getTypeTable().isInitialized()) { if (!getTypeTable().isInitialized()) {
memoizedIsInitialized = 0; memoizedIsInitialized = 0;
@@ -8343,12 +8412,15 @@ public final class ProtoBuf {
for (int i = 0; i < property_.size(); i++) { for (int i = 0; i < property_.size(); i++) {
output.writeMessage(10, property_.get(i)); output.writeMessage(10, property_.get(i));
} }
if (getEnumEntryList().size() > 0) { if (getEnumEntryNameList().size() > 0) {
output.writeRawVarint32(98); output.writeRawVarint32(98);
output.writeRawVarint32(enumEntryMemoizedSerializedSize); output.writeRawVarint32(enumEntryNameMemoizedSerializedSize);
}
for (int i = 0; i < enumEntryName_.size(); i++) {
output.writeInt32NoTag(enumEntryName_.get(i));
} }
for (int i = 0; i < enumEntry_.size(); i++) { for (int i = 0; i < enumEntry_.size(); i++) {
output.writeInt32NoTag(enumEntry_.get(i)); output.writeMessage(13, enumEntry_.get(i));
} }
if (((bitField0_ & 0x00000008) == 0x00000008)) { if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeMessage(30, typeTable_); output.writeMessage(30, typeTable_);
@@ -8424,17 +8496,21 @@ public final class ProtoBuf {
} }
{ {
int dataSize = 0; int dataSize = 0;
for (int i = 0; i < enumEntry_.size(); i++) { for (int i = 0; i < enumEntryName_.size(); i++) {
dataSize += com.google.protobuf.CodedOutputStream dataSize += com.google.protobuf.CodedOutputStream
.computeInt32SizeNoTag(enumEntry_.get(i)); .computeInt32SizeNoTag(enumEntryName_.get(i));
} }
size += dataSize; size += dataSize;
if (!getEnumEntryList().isEmpty()) { if (!getEnumEntryNameList().isEmpty()) {
size += 1; size += 1;
size += com.google.protobuf.CodedOutputStream size += com.google.protobuf.CodedOutputStream
.computeInt32SizeNoTag(dataSize); .computeInt32SizeNoTag(dataSize);
} }
enumEntryMemoizedSerializedSize = dataSize; enumEntryNameMemoizedSerializedSize = dataSize;
}
for (int i = 0; i < enumEntry_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(13, enumEntry_.get(i));
} }
if (((bitField0_ & 0x00000008) == 0x00000008)) { if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += com.google.protobuf.CodedOutputStream size += com.google.protobuf.CodedOutputStream
@@ -8551,10 +8627,12 @@ public final class ProtoBuf {
bitField0_ = (bitField0_ & ~0x00000100); bitField0_ = (bitField0_ & ~0x00000100);
property_ = java.util.Collections.emptyList(); property_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000200); bitField0_ = (bitField0_ & ~0x00000200);
enumEntry_ = java.util.Collections.emptyList(); enumEntryName_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000400); bitField0_ = (bitField0_ & ~0x00000400);
typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance(); enumEntry_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000800); bitField0_ = (bitField0_ & ~0x00000800);
typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00001000);
return this; return this;
} }
@@ -8626,11 +8704,16 @@ public final class ProtoBuf {
} }
result.property_ = property_; result.property_ = property_;
if (((bitField0_ & 0x00000400) == 0x00000400)) { if (((bitField0_ & 0x00000400) == 0x00000400)) {
enumEntry_ = java.util.Collections.unmodifiableList(enumEntry_); enumEntryName_ = java.util.Collections.unmodifiableList(enumEntryName_);
bitField0_ = (bitField0_ & ~0x00000400); bitField0_ = (bitField0_ & ~0x00000400);
} }
result.enumEntryName_ = enumEntryName_;
if (((bitField0_ & 0x00000800) == 0x00000800)) {
enumEntry_ = java.util.Collections.unmodifiableList(enumEntry_);
bitField0_ = (bitField0_ & ~0x00000800);
}
result.enumEntry_ = enumEntry_; result.enumEntry_ = enumEntry_;
if (((from_bitField0_ & 0x00000800) == 0x00000800)) { if (((from_bitField0_ & 0x00001000) == 0x00001000)) {
to_bitField0_ |= 0x00000008; to_bitField0_ |= 0x00000008;
} }
result.typeTable_ = typeTable_; result.typeTable_ = typeTable_;
@@ -8718,11 +8801,21 @@ public final class ProtoBuf {
property_.addAll(other.property_); property_.addAll(other.property_);
} }
}
if (!other.enumEntryName_.isEmpty()) {
if (enumEntryName_.isEmpty()) {
enumEntryName_ = other.enumEntryName_;
bitField0_ = (bitField0_ & ~0x00000400);
} else {
ensureEnumEntryNameIsMutable();
enumEntryName_.addAll(other.enumEntryName_);
}
} }
if (!other.enumEntry_.isEmpty()) { if (!other.enumEntry_.isEmpty()) {
if (enumEntry_.isEmpty()) { if (enumEntry_.isEmpty()) {
enumEntry_ = other.enumEntry_; enumEntry_ = other.enumEntry_;
bitField0_ = (bitField0_ & ~0x00000400); bitField0_ = (bitField0_ & ~0x00000800);
} else { } else {
ensureEnumEntryIsMutable(); ensureEnumEntryIsMutable();
enumEntry_.addAll(other.enumEntry_); enumEntry_.addAll(other.enumEntry_);
@@ -8771,6 +8864,12 @@ public final class ProtoBuf {
return false; return false;
} }
} }
for (int i = 0; i < getEnumEntryCount(); i++) {
if (!getEnumEntry(i).isInitialized()) {
return false;
}
}
if (hasTypeTable()) { if (hasTypeTable()) {
if (!getTypeTable().isInitialized()) { if (!getTypeTable().isInitialized()) {
@@ -9699,69 +9798,194 @@ public final class ProtoBuf {
return this; return this;
} }
// repeated int32 enum_entry = 12 [packed = true]; // repeated int32 enum_entry_name = 12 [packed = true];
private java.util.List<java.lang.Integer> enumEntry_ = java.util.Collections.emptyList(); private java.util.List<java.lang.Integer> enumEntryName_ = java.util.Collections.emptyList();
private void ensureEnumEntryIsMutable() { private void ensureEnumEntryNameIsMutable() {
if (!((bitField0_ & 0x00000400) == 0x00000400)) { if (!((bitField0_ & 0x00000400) == 0x00000400)) {
enumEntry_ = new java.util.ArrayList<java.lang.Integer>(enumEntry_); enumEntryName_ = new java.util.ArrayList<java.lang.Integer>(enumEntryName_);
bitField0_ |= 0x00000400; bitField0_ |= 0x00000400;
} }
} }
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/ */
public java.util.List<java.lang.Integer> public java.util.List<java.lang.Integer>
getEnumEntryList() { getEnumEntryNameList() {
return java.util.Collections.unmodifiableList(enumEntryName_);
}
/**
* <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/
public int getEnumEntryNameCount() {
return enumEntryName_.size();
}
/**
* <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/
public int getEnumEntryName(int index) {
return enumEntryName_.get(index);
}
/**
* <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/
public Builder setEnumEntryName(
int index, int value) {
ensureEnumEntryNameIsMutable();
enumEntryName_.set(index, value);
return this;
}
/**
* <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/
public Builder addEnumEntryName(int value) {
ensureEnumEntryNameIsMutable();
enumEntryName_.add(value);
return this;
}
/**
* <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/
public Builder addAllEnumEntryName(
java.lang.Iterable<? extends java.lang.Integer> values) {
ensureEnumEntryNameIsMutable();
super.addAll(values, enumEntryName_);
return this;
}
/**
* <code>repeated int32 enum_entry_name = 12 [packed = true];</code>
*/
public Builder clearEnumEntryName() {
enumEntryName_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000400);
return this;
}
// repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;
private java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry> enumEntry_ =
java.util.Collections.emptyList();
private void ensureEnumEntryIsMutable() {
if (!((bitField0_ & 0x00000800) == 0x00000800)) {
enumEntry_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry>(enumEntry_);
bitField0_ |= 0x00000800;
}
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
public java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry> getEnumEntryList() {
return java.util.Collections.unmodifiableList(enumEntry_); return java.util.Collections.unmodifiableList(enumEntry_);
} }
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/ */
public int getEnumEntryCount() { public int getEnumEntryCount() {
return enumEntry_.size(); return enumEntry_.size();
} }
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/ */
public int getEnumEntry(int index) { public org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry getEnumEntry(int index) {
return enumEntry_.get(index); return enumEntry_.get(index);
} }
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/ */
public Builder setEnumEntry( public Builder setEnumEntry(
int index, int value) { int index, org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry value) {
if (value == null) {
throw new NullPointerException();
}
ensureEnumEntryIsMutable(); ensureEnumEntryIsMutable();
enumEntry_.set(index, value); enumEntry_.set(index, value);
return this; return this;
} }
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/ */
public Builder addEnumEntry(int value) { public Builder setEnumEntry(
int index, org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry.Builder builderForValue) {
ensureEnumEntryIsMutable();
enumEntry_.set(index, builderForValue.build());
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
public Builder addEnumEntry(org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry value) {
if (value == null) {
throw new NullPointerException();
}
ensureEnumEntryIsMutable(); ensureEnumEntryIsMutable();
enumEntry_.add(value); enumEntry_.add(value);
return this; return this;
} }
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
public Builder addEnumEntry(
int index, org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry value) {
if (value == null) {
throw new NullPointerException();
}
ensureEnumEntryIsMutable();
enumEntry_.add(index, value);
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
public Builder addEnumEntry(
org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry.Builder builderForValue) {
ensureEnumEntryIsMutable();
enumEntry_.add(builderForValue.build());
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
public Builder addEnumEntry(
int index, org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry.Builder builderForValue) {
ensureEnumEntryIsMutable();
enumEntry_.add(index, builderForValue.build());
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/ */
public Builder addAllEnumEntry( public Builder addAllEnumEntry(
java.lang.Iterable<? extends java.lang.Integer> values) { java.lang.Iterable<? extends org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry> values) {
ensureEnumEntryIsMutable(); ensureEnumEntryIsMutable();
super.addAll(values, enumEntry_); super.addAll(values, enumEntry_);
return this; return this;
} }
/** /**
* <code>repeated int32 enum_entry = 12 [packed = true];</code> * <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/ */
public Builder clearEnumEntry() { public Builder clearEnumEntry() {
enumEntry_ = java.util.Collections.emptyList(); enumEntry_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000400); bitField0_ = (bitField0_ & ~0x00000800);
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.EnumEntry enum_entry = 13;</code>
*/
public Builder removeEnumEntry(int index) {
ensureEnumEntryIsMutable();
enumEntry_.remove(index);
return this; return this;
} }
@@ -9771,7 +9995,7 @@ public final class ProtoBuf {
* <code>optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;</code> * <code>optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;</code>
*/ */
public boolean hasTypeTable() { public boolean hasTypeTable() {
return ((bitField0_ & 0x00000800) == 0x00000800); return ((bitField0_ & 0x00001000) == 0x00001000);
} }
/** /**
* <code>optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;</code> * <code>optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;</code>
@@ -9788,7 +10012,7 @@ public final class ProtoBuf {
} }
typeTable_ = value; typeTable_ = value;
bitField0_ |= 0x00000800; bitField0_ |= 0x00001000;
return this; return this;
} }
/** /**
@@ -9798,14 +10022,14 @@ public final class ProtoBuf {
org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.Builder builderForValue) { org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.Builder builderForValue) {
typeTable_ = builderForValue.build(); typeTable_ = builderForValue.build();
bitField0_ |= 0x00000800; bitField0_ |= 0x00001000;
return this; return this;
} }
/** /**
* <code>optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;</code> * <code>optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;</code>
*/ */
public Builder mergeTypeTable(org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable value) { public Builder mergeTypeTable(org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable value) {
if (((bitField0_ & 0x00000800) == 0x00000800) && if (((bitField0_ & 0x00001000) == 0x00001000) &&
typeTable_ != org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance()) { typeTable_ != org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance()) {
typeTable_ = typeTable_ =
org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.newBuilder(typeTable_).mergeFrom(value).buildPartial(); org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.newBuilder(typeTable_).mergeFrom(value).buildPartial();
@@ -9813,7 +10037,7 @@ public final class ProtoBuf {
typeTable_ = value; typeTable_ = value;
} }
bitField0_ |= 0x00000800; bitField0_ |= 0x00001000;
return this; return this;
} }
/** /**
@@ -9822,7 +10046,7 @@ public final class ProtoBuf {
public Builder clearTypeTable() { public Builder clearTypeTable() {
typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance(); typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00000800); bitField0_ = (bitField0_ & ~0x00001000);
return this; return this;
} }
@@ -15916,6 +16140,353 @@ public final class ProtoBuf {
// @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.serialization.ValueParameter) // @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.serialization.ValueParameter)
} }
public interface EnumEntryOrBuilder extends
com.google.protobuf.GeneratedMessageLite.
ExtendableMessageOrBuilder<EnumEntry> {
// optional int32 name = 1;
/**
* <code>optional int32 name = 1;</code>
*/
boolean hasName();
/**
* <code>optional int32 name = 1;</code>
*/
int getName();
}
/**
* Protobuf type {@code org.jetbrains.kotlin.serialization.EnumEntry}
*/
public static final class EnumEntry extends
com.google.protobuf.GeneratedMessageLite.ExtendableMessage<
EnumEntry> implements EnumEntryOrBuilder {
// Use EnumEntry.newBuilder() to construct.
private EnumEntry(com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry, ?> builder) {
super(builder);
}
private EnumEntry(boolean noInit) {}
private static final EnumEntry defaultInstance;
public static EnumEntry getDefaultInstance() {
return defaultInstance;
}
public EnumEntry getDefaultInstanceForType() {
return defaultInstance;
}
private EnumEntry(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
initFields();
int mutable_bitField0_ = 0;
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!parseUnknownField(input,
extensionRegistry, tag)) {
done = true;
}
break;
}
case 8: {
bitField0_ |= 0x00000001;
name_ = input.readInt32();
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this);
} finally {
makeExtensionsImmutable();
}
}
public static com.google.protobuf.Parser<EnumEntry> PARSER =
new com.google.protobuf.AbstractParser<EnumEntry>() {
public EnumEntry parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new EnumEntry(input, extensionRegistry);
}
};
@java.lang.Override
public com.google.protobuf.Parser<EnumEntry> getParserForType() {
return PARSER;
}
private int bitField0_;
// optional int32 name = 1;
public static final int NAME_FIELD_NUMBER = 1;
private int name_;
/**
* <code>optional int32 name = 1;</code>
*/
public boolean hasName() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>optional int32 name = 1;</code>
*/
public int getName() {
return name_;
}
private void initFields() {
name_ = 0;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized != -1) return isInitialized == 1;
if (!extensionsAreInitialized()) {
memoizedIsInitialized = 0;
return false;
}
memoizedIsInitialized = 1;
return true;
}
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
getSerializedSize();
com.google.protobuf.GeneratedMessageLite
.ExtendableMessage<org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry>.ExtensionWriter extensionWriter =
newExtensionWriter();
if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeInt32(1, name_);
}
extensionWriter.writeUntil(200, output);
}
private int memoizedSerializedSize = -1;
public int getSerializedSize() {
int size = memoizedSerializedSize;
if (size != -1) return size;
size = 0;
if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(1, name_);
}
size += extensionsSerializedSize();
memoizedSerializedSize = size;
return size;
}
private static final long serialVersionUID = 0L;
@java.lang.Override
protected java.lang.Object writeReplace()
throws java.io.ObjectStreamException {
return super.writeReplace();
}
public static org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parseFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
public static org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
public static org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
public static org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
public static Builder newBuilder() { return Builder.create(); }
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder(org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry prototype) {
return newBuilder().mergeFrom(prototype);
}
public Builder toBuilder() { return newBuilder(this); }
/**
* Protobuf type {@code org.jetbrains.kotlin.serialization.EnumEntry}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<
org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry, Builder> implements org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntryOrBuilder {
// Construct using org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
}
private static Builder create() {
return new Builder();
}
public Builder clear() {
super.clear();
name_ = 0;
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
public Builder clone() {
return create().mergeFrom(buildPartial());
}
public org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry getDefaultInstanceForType() {
return org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry.getDefaultInstance();
}
public org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry build() {
org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
public org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry buildPartial() {
org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry result = new org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
to_bitField0_ |= 0x00000001;
}
result.name_ = name_;
result.bitField0_ = to_bitField0_;
return result;
}
public Builder mergeFrom(org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry other) {
if (other == org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry.getDefaultInstance()) return this;
if (other.hasName()) {
setName(other.getName());
}
this.mergeExtensionFields(other);
return this;
}
public final boolean isInitialized() {
if (!extensionsAreInitialized()) {
return false;
}
return true;
}
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private int bitField0_;
// optional int32 name = 1;
private int name_ ;
/**
* <code>optional int32 name = 1;</code>
*/
public boolean hasName() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>optional int32 name = 1;</code>
*/
public int getName() {
return name_;
}
/**
* <code>optional int32 name = 1;</code>
*/
public Builder setName(int value) {
bitField0_ |= 0x00000001;
name_ = value;
return this;
}
/**
* <code>optional int32 name = 1;</code>
*/
public Builder clearName() {
bitField0_ = (bitField0_ & ~0x00000001);
name_ = 0;
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.EnumEntry)
}
static {
defaultInstance = new EnumEntry(true);
defaultInstance.initFields();
}
// @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.serialization.EnumEntry)
}
static { static {
} }
@@ -23,6 +23,7 @@ open class SerializerExtensionProtocol(
val classAnnotation: GeneratedExtension<ProtoBuf.Class, List<ProtoBuf.Annotation>>, val classAnnotation: GeneratedExtension<ProtoBuf.Class, List<ProtoBuf.Annotation>>,
val functionAnnotation: GeneratedExtension<ProtoBuf.Function, List<ProtoBuf.Annotation>>, val functionAnnotation: GeneratedExtension<ProtoBuf.Function, List<ProtoBuf.Annotation>>,
val propertyAnnotation: GeneratedExtension<ProtoBuf.Property, List<ProtoBuf.Annotation>>, val propertyAnnotation: GeneratedExtension<ProtoBuf.Property, List<ProtoBuf.Annotation>>,
val enumEntryAnnotation: GeneratedExtension<ProtoBuf.EnumEntry, List<ProtoBuf.Annotation>>,
val compileTimeValue: GeneratedExtension<ProtoBuf.Property, ProtoBuf.Annotation.Argument.Value>, val compileTimeValue: GeneratedExtension<ProtoBuf.Property, ProtoBuf.Annotation.Argument.Value>,
val parameterAnnotation: GeneratedExtension<ProtoBuf.ValueParameter, List<ProtoBuf.Annotation>>, val parameterAnnotation: GeneratedExtension<ProtoBuf.ValueParameter, List<ProtoBuf.Annotation>>,
val typeAnnotation: GeneratedExtension<ProtoBuf.Type, List<ProtoBuf.Annotation>>, val typeAnnotation: GeneratedExtension<ProtoBuf.Type, List<ProtoBuf.Annotation>>,
@@ -14,6 +14,7 @@ public final class BuiltInsProtoBuf {
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.functionAnnotation); registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.functionAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.propertyAnnotation); registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.propertyAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.compileTimeValue); registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.compileTimeValue);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.enumEntryAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.parameterAnnotation); registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.parameterAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.typeAnnotation); registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.typeAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.typeParameterAnnotation); registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.typeParameterAnnotation);
@@ -123,6 +124,21 @@ public final class BuiltInsProtoBuf {
null, null,
151, 151,
com.google.protobuf.WireFormat.FieldType.MESSAGE); com.google.protobuf.WireFormat.FieldType.MESSAGE);
public static final int ENUM_ENTRY_ANNOTATION_FIELD_NUMBER = 150;
/**
* <code>extend .org.jetbrains.kotlin.serialization.EnumEntry { ... }</code>
*/
public static final
com.google.protobuf.GeneratedMessageLite.GeneratedExtension<
org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry,
java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation>> enumEntryAnnotation = com.google.protobuf.GeneratedMessageLite
.newRepeatedGeneratedExtension(
org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry.getDefaultInstance(),
org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.getDefaultInstance(),
null,
150,
com.google.protobuf.WireFormat.FieldType.MESSAGE,
false);
public static final int PARAMETER_ANNOTATION_FIELD_NUMBER = 150; public static final int PARAMETER_ANNOTATION_FIELD_NUMBER = 150;
/** /**
* <code>extend .org.jetbrains.kotlin.serialization.ValueParameter { ... }</code> * <code>extend .org.jetbrains.kotlin.serialization.ValueParameter { ... }</code>
@@ -40,6 +40,12 @@ public interface AnnotationAndConstantLoader<A, C, T> {
@NotNull AnnotatedCallableKind kind @NotNull AnnotatedCallableKind kind
); );
@NotNull
List<A> loadEnumEntryAnnotations(
@NotNull ProtoContainer container,
@NotNull ProtoBuf.EnumEntry proto
);
@NotNull @NotNull
List<A> loadValueParameterAnnotations( List<A> loadValueParameterAnnotations(
@NotNull ProtoContainer container, @NotNull ProtoContainer container,
@@ -53,6 +53,14 @@ class AnnotationAndConstantLoaderImpl(
return annotations.map { proto -> AnnotationWithTarget(deserializer.deserializeAnnotation(proto, container.nameResolver), null) } return annotations.map { proto -> AnnotationWithTarget(deserializer.deserializeAnnotation(proto, container.nameResolver), null) }
} }
override fun loadEnumEntryAnnotations(
container: ProtoContainer,
proto: ProtoBuf.EnumEntry
): List<AnnotationDescriptor> {
val annotations = proto.getExtension(protocol.enumEntryAnnotation).orEmpty()
return annotations.map { proto -> deserializer.deserializeAnnotation(proto, container.nameResolver) }
}
override fun loadValueParameterAnnotations( override fun loadValueParameterAnnotations(
container: ProtoContainer, container: ProtoContainer,
message: MessageLite, message: MessageLite,
@@ -65,7 +65,7 @@ public class DeserializedClassDescriptor(
private val typeConstructor = DeserializedClassTypeConstructor() private val typeConstructor = DeserializedClassTypeConstructor()
private val memberScope = DeserializedClassMemberScope() private val memberScope = DeserializedClassMemberScope()
private val nestedClasses = NestedClassDescriptors() private val nestedClasses = NestedClassDescriptors()
private val enumEntries = EnumEntryClassDescriptors() private val enumEntries = if (kind == ClassKind.ENUM_CLASS) EnumEntryClassDescriptors() else null
private val containingDeclaration = outerContext.containingDeclaration private val containingDeclaration = outerContext.containingDeclaration
private val primaryConstructor = c.storageManager.createNullableLazyValue { computePrimaryConstructor() } private val primaryConstructor = c.storageManager.createNullableLazyValue { computePrimaryConstructor() }
@@ -248,14 +248,14 @@ public class DeserializedClassDescriptor(
} }
override fun getClassDescriptor(name: Name): ClassifierDescriptor? = override fun getClassDescriptor(name: Name): ClassifierDescriptor? =
classDescriptor.enumEntries.findEnumEntry(name) ?: classDescriptor.nestedClasses.findNestedClass(name) classDescriptor.enumEntries?.findEnumEntry(name) ?: classDescriptor.nestedClasses.findNestedClass(name)
override fun addClassDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) { override fun addClassDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) {
result.addAll(classDescriptor.nestedClasses.all()) result.addAll(classDescriptor.nestedClasses.all())
} }
override fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) { override fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) {
result.addAll(classDescriptor.enumEntries.all()) result.addAll(classDescriptor.enumEntries?.all().orEmpty())
} }
} }
@@ -287,54 +287,51 @@ public class DeserializedClassDescriptor(
} }
private inner class EnumEntryClassDescriptors { private inner class EnumEntryClassDescriptors {
private val enumEntryNames = enumEntryNames() private val oldEnumEntryNames = classProto.enumEntryNameList.mapTo(LinkedHashSet()) { c.nameResolver.getName(it) }
private val enumEntryProtos = classProto.enumEntryList.toMapBy { c.nameResolver.getName(it.name) }
private fun enumEntryNames(): Set<Name> { val enumEntryByName = c.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
if (getKind() != ClassKind.ENUM_CLASS) return setOf()
val result = LinkedHashSet<Name>()
val nameResolver = c.nameResolver
for (index in classProto.getEnumEntryList()) {
result.add(nameResolver.getName(index!!))
}
return result
}
val findEnumEntry = c.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
name -> name ->
if (name in enumEntryNames) {
val annotations = enumEntryProtos[name]?.let { proto ->
DeserializedAnnotations(c.storageManager) {
c.components.annotationAndConstantLoader.loadEnumEntryAnnotations(
ProtoContainer(classProto, null, c.nameResolver, c.typeTable), proto
)
}
} ?: if (name in oldEnumEntryNames) Annotations.EMPTY
else null
annotations?.let { annotations ->
EnumEntrySyntheticClassDescriptor.create( EnumEntrySyntheticClassDescriptor.create(
//TODO: load annotations from class file c.storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, annotations, SourceElement.NO_SOURCE
c.storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, Annotations.EMPTY, SourceElement.NO_SOURCE
) )
} }
else null
} }
private val enumMemberNames = c.storageManager.createLazyValue { computeEnumMemberNames() } private val enumMemberNames = c.storageManager.createLazyValue { computeEnumMemberNames() }
fun findEnumEntry(name: Name): ClassDescriptor? = enumEntryByName(name)
private fun computeEnumMemberNames(): Collection<Name> { private fun computeEnumMemberNames(): Collection<Name> {
// NOTE: order of enum entry members should be irrelevant // NOTE: order of enum entry members should be irrelevant
// because enum entries are effectively invisible to user (as classes) // because enum entries are effectively invisible to user (as classes)
val result = HashSet<Name>() val result = HashSet<Name>()
for (supertype in getTypeConstructor().getSupertypes()) { for (supertype in getTypeConstructor().supertypes) {
for (descriptor in supertype.getMemberScope().getContributedDescriptors()) { for (descriptor in supertype.memberScope.getContributedDescriptors()) {
if (descriptor is SimpleFunctionDescriptor || descriptor is PropertyDescriptor) { if (descriptor is SimpleFunctionDescriptor || descriptor is PropertyDescriptor) {
result.add(descriptor.getName()) result.add(descriptor.name)
} }
} }
} }
val nameResolver = c.nameResolver return classProto.functionList.mapTo(result) { c.nameResolver.getName(it.name) } +
return classProto.functionList.mapTo(result) { nameResolver.getName(it.name) } + classProto.propertyList.mapTo(result) { c.nameResolver.getName(it.name) }
classProto.propertyList.mapTo(result) { nameResolver.getName(it.name) }
} }
fun all(): Collection<ClassDescriptor> { fun all(): Collection<ClassDescriptor> =
val result = ArrayList<ClassDescriptor>(enumEntryNames.size()) (if (oldEnumEntryNames.isEmpty()) enumEntryProtos.keys else oldEnumEntryNames)
enumEntryNames.forEach { name -> result.addIfNotNull(findEnumEntry(name)) } .mapNotNull { name -> findEnumEntry(name) }
return result
}
} }
} }
@@ -52,6 +52,11 @@ public class AnnotationLoaderForStubBuilderImpl(
} }
} }
override fun loadEnumEntryAnnotations(container: ProtoContainer, proto: ProtoBuf.EnumEntry): List<ClassId> {
// TODO
return listOf()
}
override fun loadValueParameterAnnotations( override fun loadValueParameterAnnotations(
container: ProtoContainer, container: ProtoContainer,
message: MessageLite, message: MessageLite,
@@ -172,7 +172,7 @@ private class ClassClsStubBuilder(
} }
private fun createEnumEntryStubs(classBody: KotlinPlaceHolderStubImpl<KtClassBody>) { private fun createEnumEntryStubs(classBody: KotlinPlaceHolderStubImpl<KtClassBody>) {
classProto.getEnumEntryList().forEach { id -> classProto.getEnumEntryNameList().forEach { id ->
val name = c.nameResolver.getName(id) val name = c.nameResolver.getName(id)
KotlinClassStubImpl( KotlinClassStubImpl(
KtStubElementTypes.ENUM_ENTRY, KtStubElementTypes.ENUM_ENTRY,
@@ -249,7 +249,7 @@ public class IncrementalCacheImpl(
ProtoBuf.Class::getFunctionList, ProtoBuf.Class::getFunctionList,
ProtoBuf.Class::getPropertyList ProtoBuf.Class::getPropertyList
) + ) +
classData.classProto.enumEntryList.map { classData.nameResolver.getString(it) }.toSet() classData.classProto.enumEntryNameList.map { classData.nameResolver.getString(it) }.toSet()
ChangeInfo.Removed(className.fqNameForClassNameWithoutDollars, memberNames) ChangeInfo.Removed(className.fqNameForClassNameWithoutDollars, memberNames)
} }
@@ -94,6 +94,8 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
if (!checkEqualsClassProperty(old, new)) return false if (!checkEqualsClassProperty(old, new)) return false
if (!checkEqualsClassEnumEntryName(old, new)) return false
if (!checkEqualsClassEnumEntry(old, new)) return false if (!checkEqualsClassEnumEntry(old, new)) return false
if (old.hasTypeTable() != new.hasTypeTable()) return false if (old.hasTypeTable() != new.hasTypeTable()) return false
@@ -120,6 +122,7 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
CONSTRUCTOR_LIST, CONSTRUCTOR_LIST,
FUNCTION_LIST, FUNCTION_LIST,
PROPERTY_LIST, PROPERTY_LIST,
ENUM_ENTRY_NAME_LIST,
ENUM_ENTRY_LIST, ENUM_ENTRY_LIST,
TYPE_TABLE, TYPE_TABLE,
CLASS_ANNOTATION_LIST CLASS_ANNOTATION_LIST
@@ -154,6 +157,8 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
if (!checkEqualsClassProperty(old, new)) result.add(ProtoBufClassKind.PROPERTY_LIST) if (!checkEqualsClassProperty(old, new)) result.add(ProtoBufClassKind.PROPERTY_LIST)
if (!checkEqualsClassEnumEntryName(old, new)) result.add(ProtoBufClassKind.ENUM_ENTRY_NAME_LIST)
if (!checkEqualsClassEnumEntry(old, new)) result.add(ProtoBufClassKind.ENUM_ENTRY_LIST) if (!checkEqualsClassEnumEntry(old, new)) result.add(ProtoBufClassKind.ENUM_ENTRY_LIST)
if (old.hasTypeTable() != new.hasTypeTable()) result.add(ProtoBufClassKind.TYPE_TABLE) if (old.hasTypeTable() != new.hasTypeTable()) result.add(ProtoBufClassKind.TYPE_TABLE)
@@ -395,6 +400,15 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
return true return true
} }
open fun checkEquals(old: ProtoBuf.EnumEntry, new: ProtoBuf.EnumEntry): Boolean {
if (old.hasName() != new.hasName()) return false
if (old.hasName()) {
if (old.name != new.name) return false
}
return true
}
open fun checkEquals(old: ProtoBuf.Annotation, new: ProtoBuf.Annotation): Boolean { open fun checkEquals(old: ProtoBuf.Annotation, new: ProtoBuf.Annotation): Boolean {
if (!checkClassIdEquals(old.id, new.id)) return false if (!checkClassIdEquals(old.id, new.id)) return false
@@ -659,11 +673,21 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
return true return true
} }
open fun checkEqualsClassEnumEntryName(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
if (old.enumEntryNameCount != new.enumEntryNameCount) return false
for(i in 0..old.enumEntryNameCount - 1) {
if (!checkStringEquals(old.getEnumEntryName(i), new.getEnumEntryName(i))) return false
}
return true
}
open fun checkEqualsClassEnumEntry(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean { open fun checkEqualsClassEnumEntry(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
if (old.enumEntryCount != new.enumEntryCount) return false if (old.enumEntryCount != new.enumEntryCount) return false
for(i in 0..old.enumEntryCount - 1) { for(i in 0..old.enumEntryCount - 1) {
if (!checkStringEquals(old.getEnumEntry(i), new.getEnumEntry(i))) return false if (!checkEquals(old.getEnumEntry(i), new.getEnumEntry(i))) return false
} }
return true return true
@@ -859,8 +883,12 @@ public fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (
hashCode = 31 * hashCode + getProperty(i).hashCode(stringIndexes, fqNameIndexes) hashCode = 31 * hashCode + getProperty(i).hashCode(stringIndexes, fqNameIndexes)
} }
for(i in 0..enumEntryNameCount - 1) {
hashCode = 31 * hashCode + stringIndexes(getEnumEntryName(i))
}
for(i in 0..enumEntryCount - 1) { for(i in 0..enumEntryCount - 1) {
hashCode = 31 * hashCode + stringIndexes(getEnumEntry(i)) hashCode = 31 * hashCode + getEnumEntry(i).hashCode(stringIndexes, fqNameIndexes)
} }
if (hasTypeTable()) { if (hasTypeTable()) {
@@ -1090,6 +1118,16 @@ public fun ProtoBuf.Constructor.hashCode(stringIndexes: (Int) -> Int, fqNameInde
return hashCode return hashCode
} }
public fun ProtoBuf.EnumEntry.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1
if (hasName()) {
hashCode = 31 * hashCode + name
}
return hashCode
}
public fun ProtoBuf.Annotation.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { public fun ProtoBuf.Annotation.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
@@ -206,8 +206,10 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getFunctionList)) names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getFunctionList))
ProtoBufClassKind.PROPERTY_LIST -> ProtoBufClassKind.PROPERTY_LIST ->
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getPropertyList)) names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getPropertyList))
ProtoBufClassKind.ENUM_ENTRY_NAME_LIST ->
names.addAll(calcDifferenceForNames(oldProto.enumEntryNameList, newProto.enumEntryNameList))
ProtoBufClassKind.ENUM_ENTRY_LIST -> ProtoBufClassKind.ENUM_ENTRY_LIST ->
names.addAll(calcDifferenceForNames(oldProto.enumEntryList, newProto.enumEntryList)) names.addAll(calcDifferenceForNames(oldProto.enumEntryList.map { it.name }, newProto.enumEntryList.map { it.name }))
ProtoBufClassKind.TYPE_TABLE -> { ProtoBufClassKind.TYPE_TABLE -> {
// TODO // TODO
} }
+4
View File
@@ -38,6 +38,10 @@ extend Property {
optional Annotation.Argument.Value compile_time_value = 131; optional Annotation.Argument.Value compile_time_value = 131;
} }
extend EnumEntry {
repeated Annotation enum_entry_annotation = 130;
}
extend ValueParameter { extend ValueParameter {
repeated Annotation parameter_annotation = 130; repeated Annotation parameter_annotation = 130;
} }
@@ -12,6 +12,7 @@ public final class JsProtoBuf {
registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.functionAnnotation); registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.functionAnnotation);
registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.propertyAnnotation); registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.propertyAnnotation);
registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.compileTimeValue); registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.compileTimeValue);
registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.enumEntryAnnotation);
registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.parameterAnnotation); registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.parameterAnnotation);
registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.typeAnnotation); registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.typeAnnotation);
registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.typeParameterAnnotation); registry.add(org.jetbrains.kotlin.serialization.js.JsProtoBuf.typeParameterAnnotation);
@@ -1540,6 +1541,21 @@ public final class JsProtoBuf {
null, null,
131, 131,
com.google.protobuf.WireFormat.FieldType.MESSAGE); com.google.protobuf.WireFormat.FieldType.MESSAGE);
public static final int ENUM_ENTRY_ANNOTATION_FIELD_NUMBER = 130;
/**
* <code>extend .org.jetbrains.kotlin.serialization.EnumEntry { ... }</code>
*/
public static final
com.google.protobuf.GeneratedMessageLite.GeneratedExtension<
org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry,
java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation>> enumEntryAnnotation = com.google.protobuf.GeneratedMessageLite
.newRepeatedGeneratedExtension(
org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry.getDefaultInstance(),
org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.getDefaultInstance(),
null,
130,
com.google.protobuf.WireFormat.FieldType.MESSAGE,
false);
public static final int PARAMETER_ANNOTATION_FIELD_NUMBER = 130; public static final int PARAMETER_ANNOTATION_FIELD_NUMBER = 130;
/** /**
* <code>extend .org.jetbrains.kotlin.serialization.ValueParameter { ... }</code> * <code>extend .org.jetbrains.kotlin.serialization.ValueParameter { ... }</code>
@@ -23,5 +23,6 @@ public class KotlinJavascriptSerializerExtension : KotlinSerializerExtensionBase
object JsSerializerProtocol : SerializerExtensionProtocol( object JsSerializerProtocol : SerializerExtensionProtocol(
JsProtoBuf.constructorAnnotation, JsProtoBuf.classAnnotation, JsProtoBuf.functionAnnotation, JsProtoBuf.propertyAnnotation, JsProtoBuf.constructorAnnotation, JsProtoBuf.classAnnotation, JsProtoBuf.functionAnnotation, JsProtoBuf.propertyAnnotation,
JsProtoBuf.compileTimeValue, JsProtoBuf.parameterAnnotation, JsProtoBuf.typeAnnotation, JsProtoBuf.typeParameterAnnotation JsProtoBuf.enumEntryAnnotation, JsProtoBuf.compileTimeValue, JsProtoBuf.parameterAnnotation, JsProtoBuf.typeAnnotation,
) JsProtoBuf.typeParameterAnnotation
)