Deserialize annotations on class object properties
Class object properties' backing fields are generated into static fields of the containing class, not into fields of class object. For fields we now store the flag which, if set, tells that this field should be looked for in the containing class
This commit is contained in:
committed by
Pavel V. Talanov
parent
32c5624531
commit
19299daacd
@@ -51,6 +51,10 @@ message JavaMethodSignature {
|
||||
message JavaFieldSignature {
|
||||
required int32 name = 1;
|
||||
required JavaType type = 2;
|
||||
|
||||
// True iff this field is a backing field for a class object and is really present as a static
|
||||
// field in the outer class, not as an instance field here
|
||||
optional bool is_static_in_outer = 3 [default = false];
|
||||
}
|
||||
|
||||
message JavaPropertySignature {
|
||||
|
||||
+57
@@ -1016,6 +1016,10 @@ public final class JavaProtoBuf {
|
||||
// required .org.jetbrains.jet.descriptors.serialization.JavaType type = 2;
|
||||
boolean hasType();
|
||||
org.jetbrains.jet.descriptors.serialization.JavaProtoBuf.JavaType getType();
|
||||
|
||||
// optional bool is_static_in_outer = 3 [default = false];
|
||||
boolean hasIsStaticInOuter();
|
||||
boolean getIsStaticInOuter();
|
||||
}
|
||||
public static final class JavaFieldSignature extends
|
||||
com.google.protobuf.GeneratedMessageLite
|
||||
@@ -1056,9 +1060,20 @@ public final class JavaProtoBuf {
|
||||
return type_;
|
||||
}
|
||||
|
||||
// optional bool is_static_in_outer = 3 [default = false];
|
||||
public static final int IS_STATIC_IN_OUTER_FIELD_NUMBER = 3;
|
||||
private boolean isStaticInOuter_;
|
||||
public boolean hasIsStaticInOuter() {
|
||||
return ((bitField0_ & 0x00000004) == 0x00000004);
|
||||
}
|
||||
public boolean getIsStaticInOuter() {
|
||||
return isStaticInOuter_;
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
name_ = 0;
|
||||
type_ = org.jetbrains.jet.descriptors.serialization.JavaProtoBuf.JavaType.getDefaultInstance();
|
||||
isStaticInOuter_ = false;
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
@@ -1086,6 +1101,9 @@ public final class JavaProtoBuf {
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
output.writeMessage(2, type_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
output.writeBool(3, isStaticInOuter_);
|
||||
}
|
||||
}
|
||||
|
||||
private int memoizedSerializedSize = -1;
|
||||
@@ -1102,6 +1120,10 @@ public final class JavaProtoBuf {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(2, type_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeBoolSize(3, isStaticInOuter_);
|
||||
}
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
}
|
||||
@@ -1208,6 +1230,8 @@ public final class JavaProtoBuf {
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
type_ = org.jetbrains.jet.descriptors.serialization.JavaProtoBuf.JavaType.getDefaultInstance();
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
isStaticInOuter_ = false;
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1249,6 +1273,10 @@ public final class JavaProtoBuf {
|
||||
to_bitField0_ |= 0x00000002;
|
||||
}
|
||||
result.type_ = type_;
|
||||
if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
to_bitField0_ |= 0x00000004;
|
||||
}
|
||||
result.isStaticInOuter_ = isStaticInOuter_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
return result;
|
||||
}
|
||||
@@ -1261,6 +1289,9 @@ public final class JavaProtoBuf {
|
||||
if (other.hasType()) {
|
||||
mergeType(other.getType());
|
||||
}
|
||||
if (other.hasIsStaticInOuter()) {
|
||||
setIsStaticInOuter(other.getIsStaticInOuter());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1307,6 +1338,11 @@ public final class JavaProtoBuf {
|
||||
setType(subBuilder.buildPartial());
|
||||
break;
|
||||
}
|
||||
case 24: {
|
||||
bitField0_ |= 0x00000004;
|
||||
isStaticInOuter_ = input.readBool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1377,6 +1413,27 @@ public final class JavaProtoBuf {
|
||||
return this;
|
||||
}
|
||||
|
||||
// optional bool is_static_in_outer = 3 [default = false];
|
||||
private boolean isStaticInOuter_ ;
|
||||
public boolean hasIsStaticInOuter() {
|
||||
return ((bitField0_ & 0x00000004) == 0x00000004);
|
||||
}
|
||||
public boolean getIsStaticInOuter() {
|
||||
return isStaticInOuter_;
|
||||
}
|
||||
public Builder setIsStaticInOuter(boolean value) {
|
||||
bitField0_ |= 0x00000004;
|
||||
isStaticInOuter_ = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
public Builder clearIsStaticInOuter() {
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
isStaticInOuter_ = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.jet.descriptors.serialization.JavaFieldSignature)
|
||||
}
|
||||
|
||||
|
||||
+14
-3
@@ -113,6 +113,12 @@ public class JavaProtoBufUtil {
|
||||
return nameResolver.getName(proto.getExtension(JavaProtoBuf.srcClassName));
|
||||
}
|
||||
|
||||
public static boolean isStaticFieldInOuter(@NotNull ProtoBuf.Callable proto) {
|
||||
if (!proto.hasExtension(JavaProtoBuf.propertySignature)) return false;
|
||||
JavaProtoBuf.JavaPropertySignature propertySignature = proto.getExtension(JavaProtoBuf.propertySignature);
|
||||
return propertySignature.hasField() && propertySignature.getField().getIsStaticInOuter();
|
||||
}
|
||||
|
||||
public static void saveMethodSignature(@NotNull ProtoBuf.Callable.Builder proto, @NotNull Method method, @NotNull NameTable nameTable) {
|
||||
proto.setExtension(JavaProtoBuf.methodSignature, new Serializer(nameTable).methodSignature(method));
|
||||
}
|
||||
@@ -121,13 +127,14 @@ public class JavaProtoBufUtil {
|
||||
@NotNull ProtoBuf.Callable.Builder proto,
|
||||
@Nullable Type fieldType,
|
||||
@Nullable String fieldName,
|
||||
boolean isStaticInOuter,
|
||||
@Nullable String syntheticMethodName,
|
||||
@Nullable Method getter,
|
||||
@Nullable Method setter,
|
||||
@NotNull NameTable nameTable
|
||||
) {
|
||||
proto.setExtension(JavaProtoBuf.propertySignature,
|
||||
new Serializer(nameTable).propertySignature(fieldType, fieldName, syntheticMethodName, getter, setter));
|
||||
new Serializer(nameTable).propertySignature(fieldType, fieldName, isStaticInOuter, syntheticMethodName, getter, setter));
|
||||
}
|
||||
|
||||
public static void saveSrcClassName(
|
||||
@@ -164,6 +171,7 @@ public class JavaProtoBufUtil {
|
||||
public JavaProtoBuf.JavaPropertySignature propertySignature(
|
||||
@Nullable Type fieldType,
|
||||
@Nullable String fieldName,
|
||||
boolean isStaticInOuter,
|
||||
@Nullable String syntheticMethodName,
|
||||
@Nullable Method getter,
|
||||
@Nullable Method setter
|
||||
@@ -172,7 +180,7 @@ public class JavaProtoBufUtil {
|
||||
|
||||
if (fieldType != null) {
|
||||
assert fieldName != null : "Field name shouldn't be null when there's a field type: " + fieldType;
|
||||
signature.setField(fieldSignature(fieldType, fieldName));
|
||||
signature.setField(fieldSignature(fieldType, fieldName, isStaticInOuter));
|
||||
}
|
||||
|
||||
if (syntheticMethodName != null) {
|
||||
@@ -190,10 +198,13 @@ public class JavaProtoBufUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JavaProtoBuf.JavaFieldSignature fieldSignature(@NotNull Type type, @NotNull String name) {
|
||||
public JavaProtoBuf.JavaFieldSignature fieldSignature(@NotNull Type type, @NotNull String name, boolean isStaticInOuter) {
|
||||
JavaProtoBuf.JavaFieldSignature.Builder signature = JavaProtoBuf.JavaFieldSignature.newBuilder();
|
||||
signature.setName(nameTable.getSimpleNameIndex(Name.guess(name)));
|
||||
signature.setType(type(type));
|
||||
if (isStaticInOuter) {
|
||||
signature.setIsStaticInOuter(true);
|
||||
}
|
||||
return signature.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user