two optional fields have been added to Type.Constructor message in descriptors.proto in preparation to remove field which requires double interpetation

This commit is contained in:
Michael Nedzelsky
2015-07-21 01:19:32 +03:00
parent dbf6da89b7
commit ef8381f8af
4 changed files with 537 additions and 60 deletions
@@ -313,6 +313,7 @@ public class DescriptorSerializer {
ProtoBuf.Type.Builder builder = ProtoBuf.Type.newBuilder();
builder.setConstructor(typeConstructor(type.getConstructor()));
setTypeConstructorFields(builder, type.getConstructor());
for (TypeProjection projection : type.getArguments()) {
builder.addArgument(typeArgument(projection));
@@ -328,6 +329,21 @@ public class DescriptorSerializer {
return builder;
}
private void setTypeConstructorFields(@NotNull ProtoBuf.Type.Builder builder, @NotNull TypeConstructor typeConstructor) {
ClassifierDescriptor declarationDescriptor = typeConstructor.getDeclarationDescriptor();
assert declarationDescriptor instanceof TypeParameterDescriptor || declarationDescriptor instanceof ClassDescriptor
: "Unknown declaration descriptor: " + typeConstructor;
if (declarationDescriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
builder.setConstructorTypeParameter(getTypeParameterId(typeParameterDescriptor));
}
else {
ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor;
builder.setConstructorClassName(getClassId(classDescriptor));
}
}
private ProtoBuf.Type.Builder flexibleType(@NotNull JetType type) {
Flexibility flexibility = TypesPackage.flexibility(type);