JS: write/read module annotation FQ names to/from metadata
#KT-22759 In Progress
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -31,6 +31,13 @@ message Header {
|
||||
optional int32 js_code_binary_version = 2 [default = 1];
|
||||
|
||||
optional string package_fq_name = 3;
|
||||
|
||||
optional StringTable strings = 4;
|
||||
|
||||
optional QualifiedNameTable qualified_names = 5;
|
||||
|
||||
// Annotations on the whole module
|
||||
repeated Annotation annotation = 6;
|
||||
}
|
||||
|
||||
message File {
|
||||
|
||||
@@ -73,6 +73,50 @@ public final class JsProtoBuf {
|
||||
*/
|
||||
org.jetbrains.kotlin.protobuf.ByteString
|
||||
getPackageFqNameBytes();
|
||||
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.StringTable strings = 4;</code>
|
||||
*/
|
||||
boolean hasStrings();
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.StringTable strings = 4;</code>
|
||||
*/
|
||||
org.jetbrains.kotlin.serialization.ProtoBuf.StringTable getStrings();
|
||||
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.QualifiedNameTable qualified_names = 5;</code>
|
||||
*/
|
||||
boolean hasQualifiedNames();
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.QualifiedNameTable qualified_names = 5;</code>
|
||||
*/
|
||||
org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable getQualifiedNames();
|
||||
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation>
|
||||
getAnnotationList();
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
org.jetbrains.kotlin.serialization.ProtoBuf.Annotation getAnnotation(int index);
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
int getAnnotationCount();
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.serialization.js.Header}
|
||||
@@ -140,6 +184,40 @@ public final class JsProtoBuf {
|
||||
packageFqName_ = bs;
|
||||
break;
|
||||
}
|
||||
case 34: {
|
||||
org.jetbrains.kotlin.serialization.ProtoBuf.StringTable.Builder subBuilder = null;
|
||||
if (((bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
subBuilder = strings_.toBuilder();
|
||||
}
|
||||
strings_ = input.readMessage(org.jetbrains.kotlin.serialization.ProtoBuf.StringTable.PARSER, extensionRegistry);
|
||||
if (subBuilder != null) {
|
||||
subBuilder.mergeFrom(strings_);
|
||||
strings_ = subBuilder.buildPartial();
|
||||
}
|
||||
bitField0_ |= 0x00000008;
|
||||
break;
|
||||
}
|
||||
case 42: {
|
||||
org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.Builder subBuilder = null;
|
||||
if (((bitField0_ & 0x00000010) == 0x00000010)) {
|
||||
subBuilder = qualifiedNames_.toBuilder();
|
||||
}
|
||||
qualifiedNames_ = input.readMessage(org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.PARSER, extensionRegistry);
|
||||
if (subBuilder != null) {
|
||||
subBuilder.mergeFrom(qualifiedNames_);
|
||||
qualifiedNames_ = subBuilder.buildPartial();
|
||||
}
|
||||
bitField0_ |= 0x00000010;
|
||||
break;
|
||||
}
|
||||
case 50: {
|
||||
if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
annotation_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation>();
|
||||
mutable_bitField0_ |= 0x00000020;
|
||||
}
|
||||
annotation_.add(input.readMessage(org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.PARSER, extensionRegistry));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
@@ -148,6 +226,9 @@ public final class JsProtoBuf {
|
||||
throw new org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException(
|
||||
e.getMessage()).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
annotation_ = java.util.Collections.unmodifiableList(annotation_);
|
||||
}
|
||||
try {
|
||||
unknownFieldsCodedOutput.flush();
|
||||
} catch (java.io.IOException e) {
|
||||
@@ -262,10 +343,98 @@ public final class JsProtoBuf {
|
||||
}
|
||||
}
|
||||
|
||||
public static final int STRINGS_FIELD_NUMBER = 4;
|
||||
private org.jetbrains.kotlin.serialization.ProtoBuf.StringTable strings_;
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.StringTable strings = 4;</code>
|
||||
*/
|
||||
public boolean hasStrings() {
|
||||
return ((bitField0_ & 0x00000008) == 0x00000008);
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.StringTable strings = 4;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.ProtoBuf.StringTable getStrings() {
|
||||
return strings_;
|
||||
}
|
||||
|
||||
public static final int QUALIFIED_NAMES_FIELD_NUMBER = 5;
|
||||
private org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable qualifiedNames_;
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.QualifiedNameTable qualified_names = 5;</code>
|
||||
*/
|
||||
public boolean hasQualifiedNames() {
|
||||
return ((bitField0_ & 0x00000010) == 0x00000010);
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.QualifiedNameTable qualified_names = 5;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable getQualifiedNames() {
|
||||
return qualifiedNames_;
|
||||
}
|
||||
|
||||
public static final int ANNOTATION_FIELD_NUMBER = 6;
|
||||
private java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation> annotation_;
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation> getAnnotationList() {
|
||||
return annotation_;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<? extends org.jetbrains.kotlin.serialization.ProtoBuf.AnnotationOrBuilder>
|
||||
getAnnotationOrBuilderList() {
|
||||
return annotation_;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public int getAnnotationCount() {
|
||||
return annotation_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.ProtoBuf.Annotation getAnnotation(int index) {
|
||||
return annotation_.get(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.ProtoBuf.AnnotationOrBuilder getAnnotationOrBuilder(
|
||||
int index) {
|
||||
return annotation_.get(index);
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
flags_ = 0;
|
||||
jsCodeBinaryVersion_ = 1;
|
||||
packageFqName_ = "";
|
||||
strings_ = org.jetbrains.kotlin.serialization.ProtoBuf.StringTable.getDefaultInstance();
|
||||
qualifiedNames_ = org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.getDefaultInstance();
|
||||
annotation_ = java.util.Collections.emptyList();
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
@@ -273,6 +442,18 @@ public final class JsProtoBuf {
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
if (hasQualifiedNames()) {
|
||||
if (!getQualifiedNames().isInitialized()) {
|
||||
memoizedIsInitialized = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < getAnnotationCount(); i++) {
|
||||
if (!getAnnotation(i).isInitialized()) {
|
||||
memoizedIsInitialized = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
@@ -289,6 +470,15 @@ public final class JsProtoBuf {
|
||||
if (((bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
output.writeBytes(3, getPackageFqNameBytes());
|
||||
}
|
||||
if (((bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
output.writeMessage(4, strings_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000010) == 0x00000010)) {
|
||||
output.writeMessage(5, qualifiedNames_);
|
||||
}
|
||||
for (int i = 0; i < annotation_.size(); i++) {
|
||||
output.writeMessage(6, annotation_.get(i));
|
||||
}
|
||||
output.writeRawBytes(unknownFields);
|
||||
}
|
||||
|
||||
@@ -310,6 +500,18 @@ public final class JsProtoBuf {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeBytesSize(3, getPackageFqNameBytes());
|
||||
}
|
||||
if (((bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeMessageSize(4, strings_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000010) == 0x00000010)) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeMessageSize(5, qualifiedNames_);
|
||||
}
|
||||
for (int i = 0; i < annotation_.size(); i++) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeMessageSize(6, annotation_.get(i));
|
||||
}
|
||||
size += unknownFields.size();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
@@ -410,6 +612,12 @@ public final class JsProtoBuf {
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
packageFqName_ = "";
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
strings_ = org.jetbrains.kotlin.serialization.ProtoBuf.StringTable.getDefaultInstance();
|
||||
bitField0_ = (bitField0_ & ~0x00000008);
|
||||
qualifiedNames_ = org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.getDefaultInstance();
|
||||
bitField0_ = (bitField0_ & ~0x00000010);
|
||||
annotation_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -445,6 +653,19 @@ public final class JsProtoBuf {
|
||||
to_bitField0_ |= 0x00000004;
|
||||
}
|
||||
result.packageFqName_ = packageFqName_;
|
||||
if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
to_bitField0_ |= 0x00000008;
|
||||
}
|
||||
result.strings_ = strings_;
|
||||
if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
|
||||
to_bitField0_ |= 0x00000010;
|
||||
}
|
||||
result.qualifiedNames_ = qualifiedNames_;
|
||||
if (((bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
annotation_ = java.util.Collections.unmodifiableList(annotation_);
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
}
|
||||
result.annotation_ = annotation_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
return result;
|
||||
}
|
||||
@@ -461,6 +682,22 @@ public final class JsProtoBuf {
|
||||
bitField0_ |= 0x00000004;
|
||||
packageFqName_ = other.packageFqName_;
|
||||
|
||||
}
|
||||
if (other.hasStrings()) {
|
||||
mergeStrings(other.getStrings());
|
||||
}
|
||||
if (other.hasQualifiedNames()) {
|
||||
mergeQualifiedNames(other.getQualifiedNames());
|
||||
}
|
||||
if (!other.annotation_.isEmpty()) {
|
||||
if (annotation_.isEmpty()) {
|
||||
annotation_ = other.annotation_;
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
} else {
|
||||
ensureAnnotationIsMutable();
|
||||
annotation_.addAll(other.annotation_);
|
||||
}
|
||||
|
||||
}
|
||||
setUnknownFields(
|
||||
getUnknownFields().concat(other.unknownFields));
|
||||
@@ -468,6 +705,18 @@ public final class JsProtoBuf {
|
||||
}
|
||||
|
||||
public final boolean isInitialized() {
|
||||
if (hasQualifiedNames()) {
|
||||
if (!getQualifiedNames().isInitialized()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < getAnnotationCount(); i++) {
|
||||
if (!getAnnotation(i).isInitialized()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -662,6 +911,299 @@ public final class JsProtoBuf {
|
||||
return this;
|
||||
}
|
||||
|
||||
private org.jetbrains.kotlin.serialization.ProtoBuf.StringTable strings_ = org.jetbrains.kotlin.serialization.ProtoBuf.StringTable.getDefaultInstance();
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.StringTable strings = 4;</code>
|
||||
*/
|
||||
public boolean hasStrings() {
|
||||
return ((bitField0_ & 0x00000008) == 0x00000008);
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.StringTable strings = 4;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.ProtoBuf.StringTable getStrings() {
|
||||
return strings_;
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.StringTable strings = 4;</code>
|
||||
*/
|
||||
public Builder setStrings(org.jetbrains.kotlin.serialization.ProtoBuf.StringTable value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
strings_ = value;
|
||||
|
||||
bitField0_ |= 0x00000008;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.StringTable strings = 4;</code>
|
||||
*/
|
||||
public Builder setStrings(
|
||||
org.jetbrains.kotlin.serialization.ProtoBuf.StringTable.Builder builderForValue) {
|
||||
strings_ = builderForValue.build();
|
||||
|
||||
bitField0_ |= 0x00000008;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.StringTable strings = 4;</code>
|
||||
*/
|
||||
public Builder mergeStrings(org.jetbrains.kotlin.serialization.ProtoBuf.StringTable value) {
|
||||
if (((bitField0_ & 0x00000008) == 0x00000008) &&
|
||||
strings_ != org.jetbrains.kotlin.serialization.ProtoBuf.StringTable.getDefaultInstance()) {
|
||||
strings_ =
|
||||
org.jetbrains.kotlin.serialization.ProtoBuf.StringTable.newBuilder(strings_).mergeFrom(value).buildPartial();
|
||||
} else {
|
||||
strings_ = value;
|
||||
}
|
||||
|
||||
bitField0_ |= 0x00000008;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.StringTable strings = 4;</code>
|
||||
*/
|
||||
public Builder clearStrings() {
|
||||
strings_ = org.jetbrains.kotlin.serialization.ProtoBuf.StringTable.getDefaultInstance();
|
||||
|
||||
bitField0_ = (bitField0_ & ~0x00000008);
|
||||
return this;
|
||||
}
|
||||
|
||||
private org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable qualifiedNames_ = org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.getDefaultInstance();
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.QualifiedNameTable qualified_names = 5;</code>
|
||||
*/
|
||||
public boolean hasQualifiedNames() {
|
||||
return ((bitField0_ & 0x00000010) == 0x00000010);
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.QualifiedNameTable qualified_names = 5;</code>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable getQualifiedNames() {
|
||||
return qualifiedNames_;
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.QualifiedNameTable qualified_names = 5;</code>
|
||||
*/
|
||||
public Builder setQualifiedNames(org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
qualifiedNames_ = value;
|
||||
|
||||
bitField0_ |= 0x00000010;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.QualifiedNameTable qualified_names = 5;</code>
|
||||
*/
|
||||
public Builder setQualifiedNames(
|
||||
org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.Builder builderForValue) {
|
||||
qualifiedNames_ = builderForValue.build();
|
||||
|
||||
bitField0_ |= 0x00000010;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.QualifiedNameTable qualified_names = 5;</code>
|
||||
*/
|
||||
public Builder mergeQualifiedNames(org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable value) {
|
||||
if (((bitField0_ & 0x00000010) == 0x00000010) &&
|
||||
qualifiedNames_ != org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.getDefaultInstance()) {
|
||||
qualifiedNames_ =
|
||||
org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.newBuilder(qualifiedNames_).mergeFrom(value).buildPartial();
|
||||
} else {
|
||||
qualifiedNames_ = value;
|
||||
}
|
||||
|
||||
bitField0_ |= 0x00000010;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional .org.jetbrains.kotlin.serialization.QualifiedNameTable qualified_names = 5;</code>
|
||||
*/
|
||||
public Builder clearQualifiedNames() {
|
||||
qualifiedNames_ = org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.getDefaultInstance();
|
||||
|
||||
bitField0_ = (bitField0_ & ~0x00000010);
|
||||
return this;
|
||||
}
|
||||
|
||||
private java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation> annotation_ =
|
||||
java.util.Collections.emptyList();
|
||||
private void ensureAnnotationIsMutable() {
|
||||
if (!((bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
annotation_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation>(annotation_);
|
||||
bitField0_ |= 0x00000020;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation> getAnnotationList() {
|
||||
return java.util.Collections.unmodifiableList(annotation_);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public int getAnnotationCount() {
|
||||
return annotation_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.serialization.ProtoBuf.Annotation getAnnotation(int index) {
|
||||
return annotation_.get(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setAnnotation(
|
||||
int index, org.jetbrains.kotlin.serialization.ProtoBuf.Annotation value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureAnnotationIsMutable();
|
||||
annotation_.set(index, value);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setAnnotation(
|
||||
int index, org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Builder builderForValue) {
|
||||
ensureAnnotationIsMutable();
|
||||
annotation_.set(index, builderForValue.build());
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addAnnotation(org.jetbrains.kotlin.serialization.ProtoBuf.Annotation value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureAnnotationIsMutable();
|
||||
annotation_.add(value);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addAnnotation(
|
||||
int index, org.jetbrains.kotlin.serialization.ProtoBuf.Annotation value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureAnnotationIsMutable();
|
||||
annotation_.add(index, value);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addAnnotation(
|
||||
org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Builder builderForValue) {
|
||||
ensureAnnotationIsMutable();
|
||||
annotation_.add(builderForValue.build());
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addAnnotation(
|
||||
int index, org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Builder builderForValue) {
|
||||
ensureAnnotationIsMutable();
|
||||
annotation_.add(index, builderForValue.build());
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addAllAnnotation(
|
||||
java.lang.Iterable<? extends org.jetbrains.kotlin.serialization.ProtoBuf.Annotation> values) {
|
||||
ensureAnnotationIsMutable();
|
||||
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
|
||||
values, annotation_);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public Builder clearAnnotation() {
|
||||
annotation_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .org.jetbrains.kotlin.serialization.Annotation annotation = 6;</code>
|
||||
*
|
||||
* <pre>
|
||||
* Annotations on the whole module
|
||||
* </pre>
|
||||
*/
|
||||
public Builder removeAnnotation(int index) {
|
||||
ensureAnnotationIsMutable();
|
||||
annotation_.remove(index);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.js.Header)
|
||||
}
|
||||
|
||||
|
||||
+10
-5
@@ -21,13 +21,11 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SourceFile
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.AnnotationDeserializer
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
@@ -65,11 +63,18 @@ class KotlinJavascriptPackageFragment(
|
||||
}
|
||||
}
|
||||
|
||||
private class JsContainerSource(
|
||||
class JsContainerSource(
|
||||
private val fqName: FqName,
|
||||
header: JsProtoBuf.Header,
|
||||
configuration: DeserializationConfiguration
|
||||
) : DeserializedContainerSource {
|
||||
val annotations: List<ClassId> =
|
||||
if (header.annotationCount == 0) emptyList()
|
||||
else NameResolverImpl(header.strings, header.qualifiedNames).let { nameResolver ->
|
||||
// TODO: read arguments of module annotations
|
||||
header.annotationList.map { annotation -> nameResolver.getClassId(annotation.id) }
|
||||
}
|
||||
|
||||
// TODO
|
||||
override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE
|
||||
|
||||
|
||||
+22
-3
@@ -16,10 +16,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.js
|
||||
|
||||
import org.jetbrains.kotlin.config.AnalysisFlag
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.isPreRelease
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.protobuf.CodedInputStream
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -29,6 +31,7 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.serialization.AnnotationSerializer
|
||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.StringTableImpl
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor
|
||||
@@ -224,7 +227,7 @@ object KotlinJavascriptSerializationUtil {
|
||||
version.forEach(this::writeInt)
|
||||
}
|
||||
|
||||
serializeHeader(fqName, languageVersionSettings).writeDelimitedTo(stream)
|
||||
serializeHeader(module, fqName, languageVersionSettings).writeDelimitedTo(stream)
|
||||
part.writeTo(stream)
|
||||
|
||||
contentMap[JsSerializerProtocol.getKjsmFilePath(fqName)] = stream.toByteArray()
|
||||
@@ -236,7 +239,9 @@ object KotlinJavascriptSerializationUtil {
|
||||
private fun ProtoBuf.PackageFragment.isEmpty(): Boolean =
|
||||
class_Count == 0 && `package`.let { it.functionCount == 0 && it.propertyCount == 0 && it.typeAliasCount == 0 }
|
||||
|
||||
fun serializeHeader(packageFqName: FqName?, languageVersionSettings: LanguageVersionSettings): JsProtoBuf.Header {
|
||||
fun serializeHeader(
|
||||
module: ModuleDescriptor, packageFqName: FqName?, languageVersionSettings: LanguageVersionSettings
|
||||
): JsProtoBuf.Header {
|
||||
val header = JsProtoBuf.Header.newBuilder()
|
||||
|
||||
if (packageFqName != null) {
|
||||
@@ -247,6 +252,20 @@ object KotlinJavascriptSerializationUtil {
|
||||
header.flags = 1
|
||||
}
|
||||
|
||||
val experimentalAnnotationFqNames = languageVersionSettings.getFlag(AnalysisFlag.experimental)
|
||||
if (experimentalAnnotationFqNames.isNotEmpty()) {
|
||||
val stringTable = StringTableImpl()
|
||||
for (fqName in experimentalAnnotationFqNames) {
|
||||
val descriptor = module.resolveClassByFqName(FqName(fqName), NoLookupLocation.FOR_ALREADY_TRACKED) ?: continue
|
||||
header.addAnnotation(ProtoBuf.Annotation.newBuilder().apply {
|
||||
id = stringTable.getFqNameIndex(descriptor)
|
||||
})
|
||||
}
|
||||
val (strings, qualifiedNames) = stringTable.buildProto()
|
||||
header.strings = strings
|
||||
header.qualifiedNames = qualifiedNames
|
||||
}
|
||||
|
||||
// TODO: write JS code binary version
|
||||
|
||||
return header.build()
|
||||
@@ -278,7 +297,7 @@ object KotlinJavascriptSerializationUtil {
|
||||
): ByteArray {
|
||||
return ByteArrayOutputStream().apply {
|
||||
GZIPOutputStream(this).use { stream ->
|
||||
serializeHeader(null, languageVersionSettings).writeDelimitedTo(stream)
|
||||
serializeHeader(data, null, languageVersionSettings).writeDelimitedTo(stream)
|
||||
serializeMetadata(bindingContext, data, kind, imported).writeTo(stream)
|
||||
}
|
||||
}.toByteArray()
|
||||
|
||||
@@ -184,7 +184,7 @@ public final class K2JSTranslator {
|
||||
}
|
||||
|
||||
LanguageVersionSettings settings = CommonConfigurationKeysKt.getLanguageVersionSettings(config.getConfiguration());
|
||||
incrementalResults.processHeader(serializationUtil.serializeHeader(null, settings).toByteArray());
|
||||
incrementalResults.processHeader(serializationUtil.serializeHeader(moduleDescriptor, null, settings).toByteArray());
|
||||
}
|
||||
|
||||
RemoveDuplicateImportsKt.removeDuplicateImports(translationResult.getProgram());
|
||||
|
||||
Reference in New Issue
Block a user