JS: do not require "id" in the File protobuf message
This commit is contained in:
@@ -722,11 +722,19 @@ public final class DebugJsProtoBuf {
|
||||
org.jetbrains.kotlin.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
boolean hasId();
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
int getId();
|
||||
|
||||
@@ -865,13 +873,21 @@ public final class DebugJsProtoBuf {
|
||||
public static final int ID_FIELD_NUMBER = 1;
|
||||
private int id_;
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasId() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
}
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public int getId() {
|
||||
return id_;
|
||||
@@ -922,10 +938,6 @@ public final class DebugJsProtoBuf {
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
if (!hasId()) {
|
||||
memoizedIsInitialized = 0;
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < getAnnotationCount(); i++) {
|
||||
if (!getAnnotation(i).isInitialized()) {
|
||||
memoizedIsInitialized = 0;
|
||||
@@ -1179,10 +1191,6 @@ public final class DebugJsProtoBuf {
|
||||
}
|
||||
|
||||
public final boolean isInitialized() {
|
||||
if (!hasId()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < getAnnotationCount(); i++) {
|
||||
if (!getAnnotation(i).isInitialized()) {
|
||||
|
||||
@@ -1213,19 +1221,31 @@ public final class DebugJsProtoBuf {
|
||||
|
||||
private int id_ ;
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasId() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
}
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public int getId() {
|
||||
return id_;
|
||||
}
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setId(int value) {
|
||||
bitField0_ |= 0x00000001;
|
||||
@@ -1234,7 +1254,11 @@ public final class DebugJsProtoBuf {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public Builder clearId() {
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
@@ -5456,7 +5480,7 @@ public final class DebugJsProtoBuf {
|
||||
"re/deserialization/src/descriptors.debug" +
|
||||
".proto\"P\n\006Header\022\r\n\005flags\030\001 \001(\005\022\036\n\026js_co" +
|
||||
"de_binary_version\030\002 \001(\005\022\027\n\017package_fq_na" +
|
||||
"me\030\003 \001(\t\"V\n\004File\022\n\n\002id\030\001 \002(\005\022B\n\nannotati" +
|
||||
"me\030\003 \001(\t\"V\n\004File\022\n\n\002id\030\001 \001(\005\022B\n\nannotati" +
|
||||
"on\030\002 \003(\0132..org.jetbrains.kotlin.serializ" +
|
||||
"ation.Annotation\"B\n\005Files\0229\n\004file\030\001 \003(\0132" +
|
||||
"+.org.jetbrains.kotlin.serialization.js." +
|
||||
|
||||
@@ -34,7 +34,9 @@ message Header {
|
||||
}
|
||||
|
||||
message File {
|
||||
required int32 id = 1;
|
||||
// If absent, id is the index of the file in the Files.file list
|
||||
optional int32 id = 1;
|
||||
|
||||
repeated Annotation annotation = 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -677,11 +677,19 @@ public final class JsProtoBuf {
|
||||
org.jetbrains.kotlin.protobuf.MessageLiteOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
boolean hasId();
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
int getId();
|
||||
|
||||
@@ -802,13 +810,21 @@ public final class JsProtoBuf {
|
||||
public static final int ID_FIELD_NUMBER = 1;
|
||||
private int id_;
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasId() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
}
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public int getId() {
|
||||
return id_;
|
||||
@@ -859,10 +875,6 @@ public final class JsProtoBuf {
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
if (!hasId()) {
|
||||
memoizedIsInitialized = 0;
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < getAnnotationCount(); i++) {
|
||||
if (!getAnnotation(i).isInitialized()) {
|
||||
memoizedIsInitialized = 0;
|
||||
@@ -1054,10 +1066,6 @@ public final class JsProtoBuf {
|
||||
}
|
||||
|
||||
public final boolean isInitialized() {
|
||||
if (!hasId()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < getAnnotationCount(); i++) {
|
||||
if (!getAnnotation(i).isInitialized()) {
|
||||
|
||||
@@ -1088,19 +1096,31 @@ public final class JsProtoBuf {
|
||||
|
||||
private int id_ ;
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasId() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
}
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public int getId() {
|
||||
return id_;
|
||||
}
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setId(int value) {
|
||||
bitField0_ |= 0x00000001;
|
||||
@@ -1109,7 +1129,11 @@ public final class JsProtoBuf {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>required int32 id = 1;</code>
|
||||
* <code>optional int32 id = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, id is the index of the file in the Files.file list
|
||||
* </pre>
|
||||
*/
|
||||
public Builder clearId() {
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
|
||||
+3
-1
@@ -42,7 +42,9 @@ class KotlinJavascriptPackageFragment(
|
||||
private val nameResolver: NameResolver
|
||||
) : DeserializedPackageFragment(fqName, storageManager, module) {
|
||||
private val fileMap: Map<Int, FileHolder> by storageManager.createLazyValue {
|
||||
proto.files.fileList.associate { file -> file.id to FileHolder(file.annotationList) }
|
||||
proto.files.fileList.withIndex().associate { (index, file) ->
|
||||
(if (file.hasId()) file.id else index) to FileHolder(file.annotationList)
|
||||
}
|
||||
}
|
||||
|
||||
private val annotationDeserializer: AnnotationDeserializer by storageManager.createLazyValue {
|
||||
|
||||
+4
-2
@@ -137,9 +137,11 @@ object KotlinJavascriptSerializationUtil {
|
||||
serializer: AnnotationSerializer
|
||||
): JsProtoBuf.Files {
|
||||
val filesProto = JsProtoBuf.Files.newBuilder()
|
||||
for ((file, id) in fileRegistry.fileIds) {
|
||||
for ((file, id) in fileRegistry.fileIds.entries.sortedBy { it.value }) {
|
||||
val fileProto = JsProtoBuf.File.newBuilder()
|
||||
fileProto.id = id
|
||||
if (id != filesProto.fileCount) {
|
||||
fileProto.id = id
|
||||
}
|
||||
for (annotationPsi in file.annotationEntries) {
|
||||
val annotation = bindingContext[BindingContext.ANNOTATION, annotationPsi]!!
|
||||
fileProto.addAnnotation(serializer.serializeAnnotation(annotation))
|
||||
|
||||
Reference in New Issue
Block a user