Split ProtoBuf.Callable to three messages: constructor, function, property
Serialize both at the moment, will drop the old one after bootstrap
This commit is contained in:
+148
@@ -129,6 +129,10 @@ public class DescriptorSerializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ConstructorDescriptor descriptor : classDescriptor.getConstructors()) {
|
||||||
|
builder.addConstructor(constructorProto(descriptor));
|
||||||
|
}
|
||||||
|
|
||||||
for (ConstructorDescriptor constructorDescriptor : getSecondaryConstructors(classDescriptor)) {
|
for (ConstructorDescriptor constructorDescriptor : getSecondaryConstructors(classDescriptor)) {
|
||||||
builder.addSecondaryConstructor(callableProto(constructorDescriptor));
|
builder.addSecondaryConstructor(callableProto(constructorDescriptor));
|
||||||
}
|
}
|
||||||
@@ -138,6 +142,13 @@ public class DescriptorSerializer {
|
|||||||
CallableMemberDescriptor member = (CallableMemberDescriptor) descriptor;
|
CallableMemberDescriptor member = (CallableMemberDescriptor) descriptor;
|
||||||
if (member.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) continue;
|
if (member.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) continue;
|
||||||
builder.addMember(callableProto(member));
|
builder.addMember(callableProto(member));
|
||||||
|
|
||||||
|
if (descriptor instanceof PropertyDescriptor) {
|
||||||
|
builder.addProperty(propertyProto((PropertyDescriptor) descriptor));
|
||||||
|
}
|
||||||
|
else if (descriptor instanceof FunctionDescriptor) {
|
||||||
|
builder.addFunction(functionProto((FunctionDescriptor) descriptor));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +172,143 @@ public class DescriptorSerializer {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public ProtoBuf.Property.Builder propertyProto(@NotNull PropertyDescriptor descriptor) {
|
||||||
|
ProtoBuf.Property.Builder builder = ProtoBuf.Property.newBuilder();
|
||||||
|
|
||||||
|
DescriptorSerializer local = createChildSerializer();
|
||||||
|
|
||||||
|
boolean hasGetter = false;
|
||||||
|
boolean hasSetter = false;
|
||||||
|
boolean lateInit = descriptor.isLateInit();
|
||||||
|
boolean isConst = descriptor.isConst();
|
||||||
|
|
||||||
|
ConstantValue<?> compileTimeConstant = descriptor.getCompileTimeInitializer();
|
||||||
|
boolean hasConstant = !(compileTimeConstant == null || compileTimeConstant instanceof NullValue);
|
||||||
|
|
||||||
|
boolean hasAnnotations = !descriptor.getAnnotations().getAllAnnotations().isEmpty();
|
||||||
|
|
||||||
|
int propertyFlags = Flags.getAccessorFlags(
|
||||||
|
hasAnnotations,
|
||||||
|
descriptor.getVisibility(),
|
||||||
|
descriptor.getModality(),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
PropertyGetterDescriptor getter = descriptor.getGetter();
|
||||||
|
if (getter != null) {
|
||||||
|
hasGetter = true;
|
||||||
|
int accessorFlags = getAccessorFlags(getter);
|
||||||
|
if (accessorFlags != propertyFlags) {
|
||||||
|
builder.setGetterFlags(accessorFlags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertySetterDescriptor setter = descriptor.getSetter();
|
||||||
|
if (setter != null) {
|
||||||
|
hasSetter = true;
|
||||||
|
int accessorFlags = getAccessorFlags(setter);
|
||||||
|
if (accessorFlags != propertyFlags) {
|
||||||
|
builder.setSetterFlags(accessorFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!setter.isDefault()) {
|
||||||
|
for (ValueParameterDescriptor valueParameterDescriptor : setter.getValueParameters()) {
|
||||||
|
builder.setSetterValueParameter(local.valueParameter(valueParameterDescriptor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.setFlags(Flags.getPropertyFlags(
|
||||||
|
hasAnnotations,
|
||||||
|
descriptor.getVisibility(),
|
||||||
|
descriptor.getModality(),
|
||||||
|
descriptor.getKind(),
|
||||||
|
descriptor.isVar(),
|
||||||
|
hasGetter,
|
||||||
|
hasSetter,
|
||||||
|
hasConstant,
|
||||||
|
isConst,
|
||||||
|
lateInit
|
||||||
|
));
|
||||||
|
|
||||||
|
builder.setName(getSimpleNameIndex(descriptor.getName()));
|
||||||
|
|
||||||
|
builder.setReturnType(local.type(descriptor.getType()));
|
||||||
|
|
||||||
|
for (TypeParameterDescriptor typeParameterDescriptor : descriptor.getTypeParameters()) {
|
||||||
|
builder.addTypeParameter(local.typeParameter(typeParameterDescriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
||||||
|
if (receiverParameter != null) {
|
||||||
|
builder.setReceiverType(local.type(receiverParameter.getType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
extension.serializeProperty(descriptor, builder);
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public ProtoBuf.Function.Builder functionProto(@NotNull FunctionDescriptor descriptor) {
|
||||||
|
ProtoBuf.Function.Builder builder = ProtoBuf.Function.newBuilder();
|
||||||
|
|
||||||
|
DescriptorSerializer local = createChildSerializer();
|
||||||
|
|
||||||
|
builder.setFlags(Flags.getFunctionFlags(
|
||||||
|
hasAnnotations(descriptor),
|
||||||
|
descriptor.getVisibility(),
|
||||||
|
descriptor.getModality(),
|
||||||
|
descriptor.getKind(),
|
||||||
|
descriptor.isOperator(),
|
||||||
|
descriptor.isInfix()
|
||||||
|
));
|
||||||
|
|
||||||
|
builder.setName(getSimpleNameIndex(descriptor.getName()));
|
||||||
|
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
builder.setReturnType(local.type(descriptor.getReturnType()));
|
||||||
|
|
||||||
|
for (TypeParameterDescriptor typeParameterDescriptor : descriptor.getTypeParameters()) {
|
||||||
|
builder.addTypeParameter(local.typeParameter(typeParameterDescriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
||||||
|
if (receiverParameter != null) {
|
||||||
|
builder.setReceiverType(local.type(receiverParameter.getType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ValueParameterDescriptor valueParameterDescriptor : descriptor.getValueParameters()) {
|
||||||
|
builder.addValueParameter(local.valueParameter(valueParameterDescriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
extension.serializeFunction(descriptor, builder);
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public ProtoBuf.Constructor.Builder constructorProto(@NotNull ConstructorDescriptor descriptor) {
|
||||||
|
ProtoBuf.Constructor.Builder builder = ProtoBuf.Constructor.newBuilder();
|
||||||
|
|
||||||
|
DescriptorSerializer local = createChildSerializer();
|
||||||
|
|
||||||
|
builder.setFlags(Flags.getConstructorFlags(
|
||||||
|
hasAnnotations(descriptor),
|
||||||
|
descriptor.getVisibility(),
|
||||||
|
!descriptor.isPrimary()
|
||||||
|
));
|
||||||
|
|
||||||
|
for (ValueParameterDescriptor valueParameterDescriptor : descriptor.getValueParameters()) {
|
||||||
|
builder.addValueParameter(local.valueParameter(valueParameterDescriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
extension.serializeConstructor(descriptor, builder);
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ProtoBuf.Callable.Builder callableProto(@NotNull CallableMemberDescriptor descriptor) {
|
public ProtoBuf.Callable.Builder callableProto(@NotNull CallableMemberDescriptor descriptor) {
|
||||||
ProtoBuf.Callable.Builder builder = ProtoBuf.Callable.newBuilder();
|
ProtoBuf.Callable.Builder builder = ProtoBuf.Callable.newBuilder();
|
||||||
|
|||||||
+10
-4
@@ -17,10 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.serialization;
|
package org.jetbrains.kotlin.serialization;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
|
||||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor;
|
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
|
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -35,6 +32,15 @@ public abstract class SerializerExtension {
|
|||||||
public void serializePackage(@NotNull Collection<PackageFragmentDescriptor> packageFragments, @NotNull ProtoBuf.Package.Builder proto) {
|
public void serializePackage(@NotNull Collection<PackageFragmentDescriptor> packageFragments, @NotNull ProtoBuf.Package.Builder proto) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void serializeConstructor(@NotNull ConstructorDescriptor descriptor, @NotNull ProtoBuf.Constructor.Builder proto) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serializeFunction(@NotNull FunctionDescriptor descriptor, @NotNull ProtoBuf.Function.Builder proto) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serializeProperty(@NotNull PropertyDescriptor descriptor, @NotNull ProtoBuf.Property.Builder proto) {
|
||||||
|
}
|
||||||
|
|
||||||
public void serializeCallable(@NotNull CallableMemberDescriptor callable, @NotNull ProtoBuf.Callable.Builder proto) {
|
public void serializeCallable(@NotNull CallableMemberDescriptor callable, @NotNull ProtoBuf.Callable.Builder proto) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -173,6 +173,10 @@ message Class {
|
|||||||
|
|
||||||
repeated int32 nested_class_name = 7 [packed = true, (name_id_in_table) = true];
|
repeated int32 nested_class_name = 7 [packed = true, (name_id_in_table) = true];
|
||||||
|
|
||||||
|
repeated Constructor constructor = 8;
|
||||||
|
repeated Function function = 9;
|
||||||
|
repeated Property property = 10;
|
||||||
|
|
||||||
repeated Callable member = 11;
|
repeated Callable member = 11;
|
||||||
|
|
||||||
repeated int32 enum_entry = 12 [packed = true, (name_id_in_table) = true];
|
repeated int32 enum_entry = 12 [packed = true, (name_id_in_table) = true];
|
||||||
@@ -194,6 +198,84 @@ message Class {
|
|||||||
message Package {
|
message Package {
|
||||||
repeated Callable member = 1;
|
repeated Callable member = 1;
|
||||||
|
|
||||||
|
repeated Constructor constructor = 2;
|
||||||
|
repeated Function function = 3;
|
||||||
|
repeated Property property = 4;
|
||||||
|
|
||||||
|
extensions 100 to 199;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Constructor {
|
||||||
|
/*
|
||||||
|
hasAnnotations
|
||||||
|
Visibility
|
||||||
|
isSecondary
|
||||||
|
*/
|
||||||
|
optional int32 flags = 1;
|
||||||
|
|
||||||
|
repeated ValueParameter value_parameter = 2;
|
||||||
|
|
||||||
|
extensions 100 to 199;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Function {
|
||||||
|
/*
|
||||||
|
hasAnnotations
|
||||||
|
Visibility
|
||||||
|
Modality
|
||||||
|
MemberKind
|
||||||
|
isOperator
|
||||||
|
isInfix
|
||||||
|
*/
|
||||||
|
optional int32 flags = 1;
|
||||||
|
|
||||||
|
required int32 name = 2 [(name_id_in_table) = true];
|
||||||
|
|
||||||
|
required Type return_type = 3;
|
||||||
|
|
||||||
|
repeated TypeParameter type_parameter = 4;
|
||||||
|
|
||||||
|
optional Type receiver_type = 5;
|
||||||
|
|
||||||
|
repeated ValueParameter value_parameter = 6;
|
||||||
|
|
||||||
|
extensions 100 to 199;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Property {
|
||||||
|
/*
|
||||||
|
hasAnnotations
|
||||||
|
Visibility
|
||||||
|
Modality
|
||||||
|
MemberKind
|
||||||
|
isVar
|
||||||
|
hasGetter
|
||||||
|
hasSetter
|
||||||
|
isConst
|
||||||
|
lateinit
|
||||||
|
hasConstant
|
||||||
|
*/
|
||||||
|
optional int32 flags = 1;
|
||||||
|
|
||||||
|
required int32 name = 2 [(name_id_in_table) = true];
|
||||||
|
|
||||||
|
required Type return_type = 3;
|
||||||
|
|
||||||
|
repeated TypeParameter type_parameter = 4;
|
||||||
|
|
||||||
|
optional Type receiver_type = 5;
|
||||||
|
|
||||||
|
optional ValueParameter setter_value_parameter = 6;
|
||||||
|
|
||||||
|
/*
|
||||||
|
hasAnnotations
|
||||||
|
Visibility
|
||||||
|
Modality
|
||||||
|
isNotDefault
|
||||||
|
*/
|
||||||
|
optional int32 getter_flags = 7 /* absent => same as property */;
|
||||||
|
optional int32 setter_flags = 8 /* absent => same as property */;
|
||||||
|
|
||||||
extensions 100 to 199;
|
extensions 100 to 199;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,34 +26,47 @@ public class Flags {
|
|||||||
// Common
|
// Common
|
||||||
|
|
||||||
public static final FlagField<Boolean> HAS_ANNOTATIONS = FlagField.booleanFirst();
|
public static final FlagField<Boolean> HAS_ANNOTATIONS = FlagField.booleanFirst();
|
||||||
|
|
||||||
public static final FlagField<ProtoBuf.Visibility> VISIBILITY = FlagField.after(HAS_ANNOTATIONS, ProtoBuf.Visibility.values());
|
public static final FlagField<ProtoBuf.Visibility> VISIBILITY = FlagField.after(HAS_ANNOTATIONS, ProtoBuf.Visibility.values());
|
||||||
|
|
||||||
public static final FlagField<ProtoBuf.Modality> MODALITY = FlagField.after(VISIBILITY, ProtoBuf.Modality.values());
|
public static final FlagField<ProtoBuf.Modality> MODALITY = FlagField.after(VISIBILITY, ProtoBuf.Modality.values());
|
||||||
|
|
||||||
// Class
|
// Class
|
||||||
|
|
||||||
public static final FlagField<ProtoBuf.Class.Kind> CLASS_KIND = FlagField.after(MODALITY, ProtoBuf.Class.Kind.values());
|
public static final FlagField<ProtoBuf.Class.Kind> CLASS_KIND = FlagField.after(MODALITY, ProtoBuf.Class.Kind.values());
|
||||||
|
|
||||||
public static final FlagField<Boolean> INNER = FlagField.booleanAfter(CLASS_KIND);
|
public static final FlagField<Boolean> INNER = FlagField.booleanAfter(CLASS_KIND);
|
||||||
|
|
||||||
// Callables
|
// Callables
|
||||||
|
|
||||||
public static final FlagField<ProtoBuf.CallableKind> CALLABLE_KIND = FlagField.after(MODALITY, ProtoBuf.CallableKind.values());
|
public static final FlagField<ProtoBuf.CallableKind> CALLABLE_KIND = FlagField.after(MODALITY, ProtoBuf.CallableKind.values());
|
||||||
|
|
||||||
public static final FlagField<ProtoBuf.MemberKind> MEMBER_KIND = FlagField.after(CALLABLE_KIND, ProtoBuf.MemberKind.values());
|
public static final FlagField<ProtoBuf.MemberKind> MEMBER_KIND = FlagField.after(CALLABLE_KIND, ProtoBuf.MemberKind.values());
|
||||||
public static final FlagField<Boolean> HAS_GETTER = FlagField.booleanAfter(MEMBER_KIND);
|
|
||||||
public static final FlagField<Boolean> HAS_SETTER = FlagField.booleanAfter(HAS_GETTER);
|
|
||||||
public static final FlagField<Boolean> HAS_CONSTANT = FlagField.booleanAfter(HAS_SETTER);
|
|
||||||
|
|
||||||
public static final FlagField<Boolean> IS_CONST = FlagField.booleanAfter(HAS_CONSTANT);
|
// Constructors
|
||||||
|
|
||||||
public static final FlagField<Boolean> LATE_INIT = FlagField.booleanAfter(IS_CONST);
|
public static final FlagField<Boolean> IS_SECONDARY = FlagField.booleanAfter(VISIBILITY);
|
||||||
|
|
||||||
public static final FlagField<Boolean> IS_OPERATOR = FlagField.booleanAfter(LATE_INIT);
|
// Functions
|
||||||
|
|
||||||
|
public static final FlagField<Boolean> IS_OPERATOR = FlagField.booleanAfter(MEMBER_KIND);
|
||||||
public static final FlagField<Boolean> IS_INFIX = FlagField.booleanAfter(IS_OPERATOR);
|
public static final FlagField<Boolean> IS_INFIX = FlagField.booleanAfter(IS_OPERATOR);
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
|
||||||
|
public static final FlagField<Boolean> IS_VAR = FlagField.booleanAfter(MEMBER_KIND);
|
||||||
|
public static final FlagField<Boolean> HAS_GETTER = FlagField.booleanAfter(IS_VAR);
|
||||||
|
public static final FlagField<Boolean> HAS_SETTER = FlagField.booleanAfter(HAS_GETTER);
|
||||||
|
public static final FlagField<Boolean> IS_CONST = FlagField.booleanAfter(HAS_SETTER);
|
||||||
|
public static final FlagField<Boolean> LATE_INIT = FlagField.booleanAfter(IS_CONST);
|
||||||
|
public static final FlagField<Boolean> HAS_CONSTANT = FlagField.booleanAfter(LATE_INIT);
|
||||||
|
|
||||||
|
// Old callables. TODO: delete
|
||||||
|
|
||||||
|
public static final FlagField<Boolean> OLD_HAS_GETTER = FlagField.booleanAfter(MEMBER_KIND);
|
||||||
|
public static final FlagField<Boolean> OLD_HAS_SETTER = FlagField.booleanAfter(OLD_HAS_GETTER);
|
||||||
|
public static final FlagField<Boolean> OLD_HAS_CONSTANT = FlagField.booleanAfter(OLD_HAS_SETTER);
|
||||||
|
public static final FlagField<Boolean> OLD_IS_CONST = FlagField.booleanAfter(OLD_HAS_CONSTANT);
|
||||||
|
public static final FlagField<Boolean> OLD_LATE_INIT = FlagField.booleanAfter(OLD_IS_CONST);
|
||||||
|
public static final FlagField<Boolean> OLD_IS_OPERATOR = FlagField.booleanAfter(OLD_LATE_INIT);
|
||||||
|
public static final FlagField<Boolean> OLD_IS_INFIX = FlagField.booleanAfter(OLD_IS_OPERATOR);
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
|
|
||||||
public static final FlagField<Boolean> DECLARES_DEFAULT_VALUE = FlagField.booleanAfter(HAS_ANNOTATIONS);
|
public static final FlagField<Boolean> DECLARES_DEFAULT_VALUE = FlagField.booleanAfter(HAS_ANNOTATIONS);
|
||||||
@@ -129,14 +142,67 @@ public class Flags {
|
|||||||
| VISIBILITY.toFlags(visibility(visibility))
|
| VISIBILITY.toFlags(visibility(visibility))
|
||||||
| MEMBER_KIND.toFlags(memberKind(memberKind))
|
| MEMBER_KIND.toFlags(memberKind(memberKind))
|
||||||
| CALLABLE_KIND.toFlags(callableKind)
|
| CALLABLE_KIND.toFlags(callableKind)
|
||||||
| HAS_GETTER.toFlags(hasGetter)
|
| OLD_HAS_GETTER.toFlags(hasGetter)
|
||||||
| HAS_SETTER.toFlags(hasSetter)
|
| OLD_HAS_SETTER.toFlags(hasSetter)
|
||||||
| HAS_CONSTANT.toFlags(hasConstant)
|
| OLD_HAS_CONSTANT.toFlags(hasConstant)
|
||||||
| LATE_INIT.toFlags(lateInit)
|
| OLD_LATE_INIT.toFlags(lateInit)
|
||||||
| IS_CONST.toFlags(isConst)
|
| OLD_IS_CONST.toFlags(isConst)
|
||||||
|
| OLD_IS_OPERATOR.toFlags(isOperator)
|
||||||
|
| OLD_IS_INFIX.toFlags(isInfix)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getConstructorFlags(
|
||||||
|
boolean hasAnnotations,
|
||||||
|
@NotNull Visibility visibility,
|
||||||
|
boolean isSecondary
|
||||||
|
) {
|
||||||
|
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
|
||||||
|
| VISIBILITY.toFlags(visibility(visibility))
|
||||||
|
| IS_SECONDARY.toFlags(isSecondary)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getFunctionFlags(
|
||||||
|
boolean hasAnnotations,
|
||||||
|
@NotNull Visibility visibility,
|
||||||
|
@NotNull Modality modality,
|
||||||
|
@NotNull CallableMemberDescriptor.Kind memberKind,
|
||||||
|
boolean isOperator,
|
||||||
|
boolean isInfix
|
||||||
|
) {
|
||||||
|
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
|
||||||
|
| VISIBILITY.toFlags(visibility(visibility))
|
||||||
|
| MODALITY.toFlags(modality(modality))
|
||||||
|
| MEMBER_KIND.toFlags(memberKind(memberKind))
|
||||||
| IS_OPERATOR.toFlags(isOperator)
|
| IS_OPERATOR.toFlags(isOperator)
|
||||||
| IS_INFIX.toFlags(isInfix)
|
| IS_INFIX.toFlags(isInfix)
|
||||||
;
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPropertyFlags(
|
||||||
|
boolean hasAnnotations,
|
||||||
|
@NotNull Visibility visibility,
|
||||||
|
@NotNull Modality modality,
|
||||||
|
@NotNull CallableMemberDescriptor.Kind memberKind,
|
||||||
|
boolean isVar,
|
||||||
|
boolean hasGetter,
|
||||||
|
boolean hasSetter,
|
||||||
|
boolean hasConstant,
|
||||||
|
boolean isConst,
|
||||||
|
boolean lateInit
|
||||||
|
) {
|
||||||
|
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
|
||||||
|
| VISIBILITY.toFlags(visibility(visibility))
|
||||||
|
| MODALITY.toFlags(modality(modality))
|
||||||
|
| MEMBER_KIND.toFlags(memberKind(memberKind))
|
||||||
|
| IS_VAR.toFlags(isVar)
|
||||||
|
| HAS_GETTER.toFlags(hasGetter)
|
||||||
|
| HAS_SETTER.toFlags(hasSetter)
|
||||||
|
| IS_CONST.toFlags(isConst)
|
||||||
|
| LATE_INIT.toFlags(lateInit)
|
||||||
|
| HAS_CONSTANT.toFlags(hasConstant)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getAccessorFlags(
|
public static int getAccessorFlags(
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+7
-7
@@ -56,13 +56,13 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
Deserialization.memberKind(Flags.MEMBER_KIND.get(flags)),
|
Deserialization.memberKind(Flags.MEMBER_KIND.get(flags)),
|
||||||
proto,
|
proto,
|
||||||
c.nameResolver,
|
c.nameResolver,
|
||||||
Flags.LATE_INIT.get(flags),
|
Flags.OLD_LATE_INIT.get(flags),
|
||||||
Flags.IS_CONST.get(flags)
|
Flags.OLD_IS_CONST.get(flags)
|
||||||
)
|
)
|
||||||
|
|
||||||
val local = c.childContext(property, proto.getTypeParameterList())
|
val local = c.childContext(property, proto.getTypeParameterList())
|
||||||
|
|
||||||
val hasGetter = Flags.HAS_GETTER.get(flags)
|
val hasGetter = Flags.OLD_HAS_GETTER.get(flags)
|
||||||
val receiverAnnotations = if (hasGetter)
|
val receiverAnnotations = if (hasGetter)
|
||||||
getReceiverParameterAnnotations(proto, AnnotatedCallableKind.PROPERTY_GETTER)
|
getReceiverParameterAnnotations(proto, AnnotatedCallableKind.PROPERTY_GETTER)
|
||||||
else
|
else
|
||||||
@@ -99,7 +99,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
val setter = if (Flags.HAS_SETTER.get(flags)) {
|
val setter = if (Flags.OLD_HAS_SETTER.get(flags)) {
|
||||||
val setterFlags = proto.getSetterFlags()
|
val setterFlags = proto.getSetterFlags()
|
||||||
val isNotDefault = proto.hasSetterFlags() && Flags.IS_NOT_DEFAULT.get(setterFlags)
|
val isNotDefault = proto.hasSetterFlags() && Flags.IS_NOT_DEFAULT.get(setterFlags)
|
||||||
if (isNotDefault) {
|
if (isNotDefault) {
|
||||||
@@ -125,7 +125,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Flags.HAS_CONSTANT.get(flags)) {
|
if (Flags.OLD_HAS_CONSTANT.get(flags)) {
|
||||||
property.setCompileTimeInitializer(
|
property.setCompileTimeInitializer(
|
||||||
c.storageManager.createNullableLazyValue {
|
c.storageManager.createNullableLazyValue {
|
||||||
val container = c.containingDeclaration.asProtoContainer()!!
|
val container = c.containingDeclaration.asProtoContainer()!!
|
||||||
@@ -152,8 +152,8 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
local.typeDeserializer.type(proto.returnType),
|
local.typeDeserializer.type(proto.returnType),
|
||||||
Deserialization.modality(Flags.MODALITY.get(proto.flags)),
|
Deserialization.modality(Flags.MODALITY.get(proto.flags)),
|
||||||
Deserialization.visibility(Flags.VISIBILITY.get(proto.flags)),
|
Deserialization.visibility(Flags.VISIBILITY.get(proto.flags)),
|
||||||
Flags.IS_OPERATOR.get(proto.flags),
|
Flags.OLD_IS_OPERATOR.get(proto.flags),
|
||||||
Flags.IS_INFIX.get(proto.flags)
|
Flags.OLD_IS_INFIX.get(proto.flags)
|
||||||
)
|
)
|
||||||
return function
|
return function
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -188,25 +188,25 @@ enum class FlagsToModifiers {
|
|||||||
|
|
||||||
CONST {
|
CONST {
|
||||||
override fun getModifiers(flags: Int): JetModifierKeywordToken? {
|
override fun getModifiers(flags: Int): JetModifierKeywordToken? {
|
||||||
return if (Flags.IS_CONST.get(flags)) JetTokens.CONST_KEYWORD else null
|
return if (Flags.OLD_IS_CONST.get(flags)) JetTokens.CONST_KEYWORD else null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
LATEINIT {
|
LATEINIT {
|
||||||
override fun getModifiers(flags: Int): JetModifierKeywordToken? {
|
override fun getModifiers(flags: Int): JetModifierKeywordToken? {
|
||||||
return if (Flags.LATE_INIT.get(flags)) JetTokens.LATE_INIT_KEYWORD else null
|
return if (Flags.OLD_LATE_INIT.get(flags)) JetTokens.LATE_INIT_KEYWORD else null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
OPERATOR {
|
OPERATOR {
|
||||||
override fun getModifiers(flags: Int): JetModifierKeywordToken? {
|
override fun getModifiers(flags: Int): JetModifierKeywordToken? {
|
||||||
return if (Flags.IS_OPERATOR.get(flags)) JetTokens.OPERATOR_KEYWORD else null
|
return if (Flags.OLD_IS_OPERATOR.get(flags)) JetTokens.OPERATOR_KEYWORD else null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
INFIX {
|
INFIX {
|
||||||
override fun getModifiers(flags: Int): JetModifierKeywordToken? {
|
override fun getModifiers(flags: Int): JetModifierKeywordToken? {
|
||||||
return if (Flags.IS_INFIX.get(flags)) JetTokens.INFIX_KEYWORD else null
|
return if (Flags.OLD_IS_INFIX.get(flags)) JetTokens.INFIX_KEYWORD else null
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,19 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
open fun checkEquals(old: ProtoBuf.Package, new: ProtoBuf.Package): Boolean {
|
open fun checkEquals(old: ProtoBuf.Package, new: ProtoBuf.Package): Boolean {
|
||||||
if (!checkEqualsPackageMember(old, new)) return false
|
if (!checkEqualsPackageMember(old, new)) return false
|
||||||
|
|
||||||
|
if (!checkEqualsPackageConstructor(old, new)) return false
|
||||||
|
|
||||||
|
if (!checkEqualsPackageFunction(old, new)) return false
|
||||||
|
|
||||||
|
if (!checkEqualsPackageProperty(old, new)) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
public enum class ProtoBufPackageKind {
|
public enum class ProtoBufPackageKind {
|
||||||
MEMBER_LIST
|
MEMBER_LIST,
|
||||||
|
CONSTRUCTOR_LIST,
|
||||||
|
FUNCTION_LIST,
|
||||||
|
PROPERTY_LIST
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun difference(old: ProtoBuf.Package, new: ProtoBuf.Package): EnumSet<ProtoBufPackageKind> {
|
public fun difference(old: ProtoBuf.Package, new: ProtoBuf.Package): EnumSet<ProtoBufPackageKind> {
|
||||||
@@ -48,6 +57,12 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
|
|
||||||
if (!checkEqualsPackageMember(old, new)) result.add(ProtoBufPackageKind.MEMBER_LIST)
|
if (!checkEqualsPackageMember(old, new)) result.add(ProtoBufPackageKind.MEMBER_LIST)
|
||||||
|
|
||||||
|
if (!checkEqualsPackageConstructor(old, new)) result.add(ProtoBufPackageKind.CONSTRUCTOR_LIST)
|
||||||
|
|
||||||
|
if (!checkEqualsPackageFunction(old, new)) result.add(ProtoBufPackageKind.FUNCTION_LIST)
|
||||||
|
|
||||||
|
if (!checkEqualsPackageProperty(old, new)) result.add(ProtoBufPackageKind.PROPERTY_LIST)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +85,12 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
|
|
||||||
if (!checkEqualsClassNestedClassName(old, new)) return false
|
if (!checkEqualsClassNestedClassName(old, new)) return false
|
||||||
|
|
||||||
|
if (!checkEqualsClassConstructor(old, new)) return false
|
||||||
|
|
||||||
|
if (!checkEqualsClassFunction(old, new)) return false
|
||||||
|
|
||||||
|
if (!checkEqualsClassProperty(old, new)) return false
|
||||||
|
|
||||||
if (!checkEqualsClassMember(old, new)) return false
|
if (!checkEqualsClassMember(old, new)) return false
|
||||||
|
|
||||||
if (!checkEqualsClassEnumEntry(old, new)) return false
|
if (!checkEqualsClassEnumEntry(old, new)) return false
|
||||||
@@ -96,6 +117,9 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
TYPE_PARAMETER_LIST,
|
TYPE_PARAMETER_LIST,
|
||||||
SUPERTYPE_LIST,
|
SUPERTYPE_LIST,
|
||||||
NESTED_CLASS_NAME_LIST,
|
NESTED_CLASS_NAME_LIST,
|
||||||
|
CONSTRUCTOR_LIST,
|
||||||
|
FUNCTION_LIST,
|
||||||
|
PROPERTY_LIST,
|
||||||
MEMBER_LIST,
|
MEMBER_LIST,
|
||||||
ENUM_ENTRY_LIST,
|
ENUM_ENTRY_LIST,
|
||||||
PRIMARY_CONSTRUCTOR,
|
PRIMARY_CONSTRUCTOR,
|
||||||
@@ -124,6 +148,12 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
|
|
||||||
if (!checkEqualsClassNestedClassName(old, new)) result.add(ProtoBufClassKind.NESTED_CLASS_NAME_LIST)
|
if (!checkEqualsClassNestedClassName(old, new)) result.add(ProtoBufClassKind.NESTED_CLASS_NAME_LIST)
|
||||||
|
|
||||||
|
if (!checkEqualsClassConstructor(old, new)) result.add(ProtoBufClassKind.CONSTRUCTOR_LIST)
|
||||||
|
|
||||||
|
if (!checkEqualsClassFunction(old, new)) result.add(ProtoBufClassKind.FUNCTION_LIST)
|
||||||
|
|
||||||
|
if (!checkEqualsClassProperty(old, new)) result.add(ProtoBufClassKind.PROPERTY_LIST)
|
||||||
|
|
||||||
if (!checkEqualsClassMember(old, new)) result.add(ProtoBufClassKind.MEMBER_LIST)
|
if (!checkEqualsClassMember(old, new)) result.add(ProtoBufClassKind.MEMBER_LIST)
|
||||||
|
|
||||||
if (!checkEqualsClassEnumEntry(old, new)) result.add(ProtoBufClassKind.ENUM_ENTRY_LIST)
|
if (!checkEqualsClassEnumEntry(old, new)) result.add(ProtoBufClassKind.ENUM_ENTRY_LIST)
|
||||||
@@ -191,6 +221,74 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun checkEquals(old: ProtoBuf.Constructor, new: ProtoBuf.Constructor): Boolean {
|
||||||
|
if (old.hasFlags() != new.hasFlags()) return false
|
||||||
|
if (old.hasFlags()) {
|
||||||
|
if (old.flags != new.flags) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkEqualsConstructorValueParameter(old, new)) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun checkEquals(old: ProtoBuf.Function, new: ProtoBuf.Function): Boolean {
|
||||||
|
if (old.hasFlags() != new.hasFlags()) return false
|
||||||
|
if (old.hasFlags()) {
|
||||||
|
if (old.flags != new.flags) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkStringEquals(old.name, new.name)) return false
|
||||||
|
|
||||||
|
if (!checkEquals(old.returnType, new.returnType)) return false
|
||||||
|
|
||||||
|
if (!checkEqualsFunctionTypeParameter(old, new)) return false
|
||||||
|
|
||||||
|
if (old.hasReceiverType() != new.hasReceiverType()) return false
|
||||||
|
if (old.hasReceiverType()) {
|
||||||
|
if (!checkEquals(old.receiverType, new.receiverType)) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkEqualsFunctionValueParameter(old, new)) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun checkEquals(old: ProtoBuf.Property, new: ProtoBuf.Property): Boolean {
|
||||||
|
if (old.hasFlags() != new.hasFlags()) return false
|
||||||
|
if (old.hasFlags()) {
|
||||||
|
if (old.flags != new.flags) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkStringEquals(old.name, new.name)) return false
|
||||||
|
|
||||||
|
if (!checkEquals(old.returnType, new.returnType)) return false
|
||||||
|
|
||||||
|
if (!checkEqualsPropertyTypeParameter(old, new)) return false
|
||||||
|
|
||||||
|
if (old.hasReceiverType() != new.hasReceiverType()) return false
|
||||||
|
if (old.hasReceiverType()) {
|
||||||
|
if (!checkEquals(old.receiverType, new.receiverType)) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (old.hasSetterValueParameter() != new.hasSetterValueParameter()) return false
|
||||||
|
if (old.hasSetterValueParameter()) {
|
||||||
|
if (!checkEquals(old.setterValueParameter, new.setterValueParameter)) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (old.hasGetterFlags() != new.hasGetterFlags()) return false
|
||||||
|
if (old.hasGetterFlags()) {
|
||||||
|
if (old.getterFlags != new.getterFlags) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (old.hasSetterFlags() != new.hasSetterFlags()) return false
|
||||||
|
if (old.hasSetterFlags()) {
|
||||||
|
if (old.setterFlags != new.setterFlags) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
open fun checkEquals(old: ProtoBuf.TypeParameter, new: ProtoBuf.TypeParameter): Boolean {
|
open fun checkEquals(old: ProtoBuf.TypeParameter, new: ProtoBuf.TypeParameter): Boolean {
|
||||||
if (old.id != new.id) return false
|
if (old.id != new.id) return false
|
||||||
|
|
||||||
@@ -416,6 +514,36 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun checkEqualsPackageConstructor(old: ProtoBuf.Package, new: ProtoBuf.Package): Boolean {
|
||||||
|
if (old.constructorCount != new.constructorCount) return false
|
||||||
|
|
||||||
|
for(i in 0..old.constructorCount - 1) {
|
||||||
|
if (!checkEquals(old.getConstructor(i), new.getConstructor(i))) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun checkEqualsPackageFunction(old: ProtoBuf.Package, new: ProtoBuf.Package): Boolean {
|
||||||
|
if (old.functionCount != new.functionCount) return false
|
||||||
|
|
||||||
|
for(i in 0..old.functionCount - 1) {
|
||||||
|
if (!checkEquals(old.getFunction(i), new.getFunction(i))) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun checkEqualsPackageProperty(old: ProtoBuf.Package, new: ProtoBuf.Package): Boolean {
|
||||||
|
if (old.propertyCount != new.propertyCount) return false
|
||||||
|
|
||||||
|
for(i in 0..old.propertyCount - 1) {
|
||||||
|
if (!checkEquals(old.getProperty(i), new.getProperty(i))) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
open fun checkEqualsClassTypeParameter(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
open fun checkEqualsClassTypeParameter(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
||||||
if (old.typeParameterCount != new.typeParameterCount) return false
|
if (old.typeParameterCount != new.typeParameterCount) return false
|
||||||
|
|
||||||
@@ -446,6 +574,36 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun checkEqualsClassConstructor(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
||||||
|
if (old.constructorCount != new.constructorCount) return false
|
||||||
|
|
||||||
|
for(i in 0..old.constructorCount - 1) {
|
||||||
|
if (!checkEquals(old.getConstructor(i), new.getConstructor(i))) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun checkEqualsClassFunction(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
||||||
|
if (old.functionCount != new.functionCount) return false
|
||||||
|
|
||||||
|
for(i in 0..old.functionCount - 1) {
|
||||||
|
if (!checkEquals(old.getFunction(i), new.getFunction(i))) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun checkEqualsClassProperty(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
||||||
|
if (old.propertyCount != new.propertyCount) return false
|
||||||
|
|
||||||
|
for(i in 0..old.propertyCount - 1) {
|
||||||
|
if (!checkEquals(old.getProperty(i), new.getProperty(i))) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
open fun checkEqualsClassMember(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
open fun checkEqualsClassMember(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
||||||
if (old.memberCount != new.memberCount) return false
|
if (old.memberCount != new.memberCount) return false
|
||||||
|
|
||||||
@@ -496,6 +654,46 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun checkEqualsConstructorValueParameter(old: ProtoBuf.Constructor, new: ProtoBuf.Constructor): Boolean {
|
||||||
|
if (old.valueParameterCount != new.valueParameterCount) return false
|
||||||
|
|
||||||
|
for(i in 0..old.valueParameterCount - 1) {
|
||||||
|
if (!checkEquals(old.getValueParameter(i), new.getValueParameter(i))) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun checkEqualsFunctionTypeParameter(old: ProtoBuf.Function, new: ProtoBuf.Function): Boolean {
|
||||||
|
if (old.typeParameterCount != new.typeParameterCount) return false
|
||||||
|
|
||||||
|
for(i in 0..old.typeParameterCount - 1) {
|
||||||
|
if (!checkEquals(old.getTypeParameter(i), new.getTypeParameter(i))) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun checkEqualsFunctionValueParameter(old: ProtoBuf.Function, new: ProtoBuf.Function): Boolean {
|
||||||
|
if (old.valueParameterCount != new.valueParameterCount) return false
|
||||||
|
|
||||||
|
for(i in 0..old.valueParameterCount - 1) {
|
||||||
|
if (!checkEquals(old.getValueParameter(i), new.getValueParameter(i))) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun checkEqualsPropertyTypeParameter(old: ProtoBuf.Property, new: ProtoBuf.Property): Boolean {
|
||||||
|
if (old.typeParameterCount != new.typeParameterCount) return false
|
||||||
|
|
||||||
|
for(i in 0..old.typeParameterCount - 1) {
|
||||||
|
if (!checkEquals(old.getTypeParameter(i), new.getTypeParameter(i))) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
open fun checkEqualsTypeParameterUpperBound(old: ProtoBuf.TypeParameter, new: ProtoBuf.TypeParameter): Boolean {
|
open fun checkEqualsTypeParameterUpperBound(old: ProtoBuf.TypeParameter, new: ProtoBuf.TypeParameter): Boolean {
|
||||||
if (old.upperBoundCount != new.upperBoundCount) return false
|
if (old.upperBoundCount != new.upperBoundCount) return false
|
||||||
|
|
||||||
@@ -574,6 +772,18 @@ public fun ProtoBuf.Package.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes:
|
|||||||
hashCode = 31 * hashCode + getMember(i).hashCode(stringIndexes, fqNameIndexes)
|
hashCode = 31 * hashCode + getMember(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(i in 0..constructorCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getConstructor(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i in 0..functionCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getFunction(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i in 0..propertyCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getProperty(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
return hashCode
|
return hashCode
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,6 +812,18 @@ public fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (
|
|||||||
hashCode = 31 * hashCode + stringIndexes(getNestedClassName(i))
|
hashCode = 31 * hashCode + stringIndexes(getNestedClassName(i))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(i in 0..constructorCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getConstructor(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i in 0..functionCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getFunction(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i in 0..propertyCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getProperty(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
for(i in 0..memberCount - 1) {
|
for(i in 0..memberCount - 1) {
|
||||||
hashCode = 31 * hashCode + getMember(i).hashCode(stringIndexes, fqNameIndexes)
|
hashCode = 31 * hashCode + getMember(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
}
|
}
|
||||||
@@ -671,6 +893,80 @@ public fun ProtoBuf.Callable.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes
|
|||||||
return hashCode
|
return hashCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun ProtoBuf.Constructor.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||||
|
var hashCode = 1
|
||||||
|
|
||||||
|
if (hasFlags()) {
|
||||||
|
hashCode = 31 * hashCode + flags
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i in 0..valueParameterCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getValueParameter(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashCode
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun ProtoBuf.Function.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||||
|
var hashCode = 1
|
||||||
|
|
||||||
|
if (hasFlags()) {
|
||||||
|
hashCode = 31 * hashCode + flags
|
||||||
|
}
|
||||||
|
|
||||||
|
hashCode = 31 * hashCode + stringIndexes(name)
|
||||||
|
|
||||||
|
hashCode = 31 * hashCode + returnType.hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
|
||||||
|
for(i in 0..typeParameterCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getTypeParameter(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasReceiverType()) {
|
||||||
|
hashCode = 31 * hashCode + receiverType.hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i in 0..valueParameterCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getValueParameter(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashCode
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun ProtoBuf.Property.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||||
|
var hashCode = 1
|
||||||
|
|
||||||
|
if (hasFlags()) {
|
||||||
|
hashCode = 31 * hashCode + flags
|
||||||
|
}
|
||||||
|
|
||||||
|
hashCode = 31 * hashCode + stringIndexes(name)
|
||||||
|
|
||||||
|
hashCode = 31 * hashCode + returnType.hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
|
||||||
|
for(i in 0..typeParameterCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getTypeParameter(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasReceiverType()) {
|
||||||
|
hashCode = 31 * hashCode + receiverType.hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasSetterValueParameter()) {
|
||||||
|
hashCode = 31 * hashCode + setterValueParameter.hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasGetterFlags()) {
|
||||||
|
hashCode = 31 * hashCode + getterFlags
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasSetterFlags()) {
|
||||||
|
hashCode = 31 * hashCode + setterFlags
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashCode
|
||||||
|
}
|
||||||
|
|
||||||
public fun ProtoBuf.TypeParameter.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
public fun ProtoBuf.TypeParameter.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||||
var hashCode = 1
|
var hashCode = 1
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.jps.incremental
|
package org.jetbrains.kotlin.jps.incremental
|
||||||
|
|
||||||
|
import com.google.protobuf.MessageLite
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
|
import org.jetbrains.kotlin.jps.incremental.ProtoCompareGenerated.ProtoBufClassKind
|
||||||
|
import org.jetbrains.kotlin.jps.incremental.ProtoCompareGenerated.ProtoBufPackageKind
|
||||||
import org.jetbrains.kotlin.serialization.Flags
|
import org.jetbrains.kotlin.serialization.Flags
|
||||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.Deserialization
|
import org.jetbrains.kotlin.serialization.deserialization.Deserialization
|
||||||
@@ -52,17 +55,16 @@ private abstract class DifferenceCalculator() {
|
|||||||
|
|
||||||
protected fun membersOrNone(names: Collection<String>): DifferenceKind = if (names.isEmpty()) DifferenceKind.NONE else DifferenceKind.MEMBERS(names)
|
protected fun membersOrNone(names: Collection<String>): DifferenceKind = if (names.isEmpty()) DifferenceKind.NONE else DifferenceKind.MEMBERS(names)
|
||||||
|
|
||||||
protected fun calcDifferenceForMembers(
|
protected fun calcDifferenceForMembers(oldList: List<MessageLite>, newList: List<MessageLite>): Collection<String> {
|
||||||
oldList: List<ProtoBuf.Callable>,
|
|
||||||
newList: List<ProtoBuf.Callable>
|
|
||||||
): Collection<String> {
|
|
||||||
val result = hashSetOf<String>()
|
val result = hashSetOf<String>()
|
||||||
|
|
||||||
val oldMap = oldList.groupBy { it.hashCode({ compareObject.oldGetIndexOfString(it) }, { compareObject.oldGetIndexOfClassId(it) } )}
|
fun List<MessageLite>.names(nameResolver: NameResolver): List<String> =
|
||||||
val newMap = newList.groupBy { it.hashCode({ compareObject.newGetIndexOfString(it) }, { compareObject.newGetIndexOfClassId(it) } )}
|
map { it.name(nameResolver) }
|
||||||
|
|
||||||
fun List<ProtoBuf.Callable>.names(nameResolver: NameResolver): List<String> =
|
val oldMap =
|
||||||
map { nameResolver.getString(it.name) }
|
oldList.groupBy { it.getHashCode({ compareObject.oldGetIndexOfString(it) }, { compareObject.oldGetIndexOfClassId(it) }) }
|
||||||
|
val newMap =
|
||||||
|
newList.groupBy { it.getHashCode({ compareObject.newGetIndexOfString(it) }, { compareObject.newGetIndexOfClassId(it) }) }
|
||||||
|
|
||||||
val hashes = oldMap.keySet() + newMap.keySet()
|
val hashes = oldMap.keySet() + newMap.keySet()
|
||||||
for (hash in hashes) {
|
for (hash in hashes) {
|
||||||
@@ -81,8 +83,8 @@ private abstract class DifferenceCalculator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun calcDifferenceForEqualHashes(
|
private fun calcDifferenceForEqualHashes(
|
||||||
oldList: List<ProtoBuf.Callable>,
|
oldList: List<MessageLite>,
|
||||||
newList: List<ProtoBuf.Callable>
|
newList: List<MessageLite>
|
||||||
): Collection<String> {
|
): Collection<String> {
|
||||||
val result = hashSetOf<String>()
|
val result = hashSetOf<String>()
|
||||||
val newSet = HashSet(newList)
|
val newSet = HashSet(newList)
|
||||||
@@ -93,12 +95,12 @@ private abstract class DifferenceCalculator() {
|
|||||||
newSet.remove(newMember)
|
newSet.remove(newMember)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result.add(compareObject.oldNameResolver.getString(oldMember.name))
|
result.add(oldMember.name(compareObject.oldNameResolver))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newSet.forEach { newMember ->
|
newSet.forEach { newMember ->
|
||||||
result.add(compareObject.newNameResolver.getString(newMember.name))
|
result.add(newMember.name(compareObject.newNameResolver))
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@@ -113,8 +115,45 @@ private abstract class DifferenceCalculator() {
|
|||||||
return HashSetUtil.symmetricDifference(oldNames, newNames)
|
return HashSetUtil.symmetricDifference(oldNames, newNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected val ProtoBuf.Callable.isPrivate: Boolean
|
protected val MessageLite.isPrivate: Boolean
|
||||||
get() = Visibilities.isPrivate(Deserialization.visibility(Flags.VISIBILITY.get(flags)))
|
get() = Visibilities.isPrivate(Deserialization.visibility(
|
||||||
|
when (this) {
|
||||||
|
is ProtoBuf.Callable -> Flags.VISIBILITY.get(flags)
|
||||||
|
is ProtoBuf.Constructor -> Flags.VISIBILITY.get(flags)
|
||||||
|
is ProtoBuf.Function -> Flags.VISIBILITY.get(flags)
|
||||||
|
is ProtoBuf.Property -> Flags.VISIBILITY.get(flags)
|
||||||
|
else -> error("Unknown message: $this")
|
||||||
|
}))
|
||||||
|
|
||||||
|
private fun MessageLite.getHashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||||
|
return when (this) {
|
||||||
|
is ProtoBuf.Callable -> hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
is ProtoBuf.Constructor -> hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
is ProtoBuf.Function -> hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
is ProtoBuf.Property -> hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
else -> error("Unknown message: $this")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun MessageLite.name(nameResolver: NameResolver): String {
|
||||||
|
return when (this) {
|
||||||
|
is ProtoBuf.Callable -> nameResolver.getString(name)
|
||||||
|
is ProtoBuf.Constructor -> "<init>"
|
||||||
|
is ProtoBuf.Function -> nameResolver.getString(name)
|
||||||
|
is ProtoBuf.Property -> nameResolver.getString(name)
|
||||||
|
else -> error("Unknown message: $this")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ProtoCompareGenerated.checkEquals(old: MessageLite, new: MessageLite): Boolean {
|
||||||
|
return when {
|
||||||
|
old is ProtoBuf.Callable && new is ProtoBuf.Callable -> checkEquals(old, new)
|
||||||
|
old is ProtoBuf.Constructor && new is ProtoBuf.Constructor -> checkEquals(old, new)
|
||||||
|
old is ProtoBuf.Function && new is ProtoBuf.Function -> checkEquals(old, new)
|
||||||
|
old is ProtoBuf.Property && new is ProtoBuf.Property -> checkEquals(old, new)
|
||||||
|
else -> error("Unknown message: $this")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: ProtoMapValue) : DifferenceCalculator() {
|
private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: ProtoMapValue) : DifferenceCalculator() {
|
||||||
@@ -122,11 +161,11 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot
|
|||||||
private val CONSTRUCTOR = "<init>"
|
private val CONSTRUCTOR = "<init>"
|
||||||
|
|
||||||
private val CLASS_SIGNATURE_ENUMS = EnumSet.of(
|
private val CLASS_SIGNATURE_ENUMS = EnumSet.of(
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.FLAGS,
|
ProtoBufClassKind.FLAGS,
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.FQ_NAME,
|
ProtoBufClassKind.FQ_NAME,
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.TYPE_PARAMETER_LIST,
|
ProtoBufClassKind.TYPE_PARAMETER_LIST,
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.SUPERTYPE_LIST,
|
ProtoBufClassKind.SUPERTYPE_LIST,
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.CLASS_ANNOTATION_LIST
|
ProtoBufClassKind.CLASS_ANNOTATION_LIST
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,34 +194,43 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot
|
|||||||
fun Int.oldToNames() = names.add(oldNameResolver.getString(this))
|
fun Int.oldToNames() = names.add(oldNameResolver.getString(this))
|
||||||
fun Int.newToNames() = names.add(newNameResolver.getString(this))
|
fun Int.newToNames() = names.add(newNameResolver.getString(this))
|
||||||
|
|
||||||
|
fun calcDifferenceForNonPrivateMembers(members: (ProtoBuf.Class) -> List<MessageLite>): Collection<String> {
|
||||||
|
val oldMembers = members(oldProto).filterNot { it.isPrivate }
|
||||||
|
val newMembers = members(newProto).filterNot { it.isPrivate }
|
||||||
|
return calcDifferenceForMembers(oldMembers, newMembers)
|
||||||
|
}
|
||||||
|
|
||||||
for (kind in diff) {
|
for (kind in diff) {
|
||||||
when (kind!!) {
|
when (kind!!) {
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.COMPANION_OBJECT_NAME -> {
|
ProtoBufClassKind.COMPANION_OBJECT_NAME -> {
|
||||||
if (oldProto.hasCompanionObjectName()) oldProto.companionObjectName.oldToNames()
|
if (oldProto.hasCompanionObjectName()) oldProto.companionObjectName.oldToNames()
|
||||||
if (newProto.hasCompanionObjectName()) newProto.companionObjectName.newToNames()
|
if (newProto.hasCompanionObjectName()) newProto.companionObjectName.newToNames()
|
||||||
}
|
}
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.NESTED_CLASS_NAME_LIST ->
|
ProtoBufClassKind.NESTED_CLASS_NAME_LIST ->
|
||||||
names.addAll(calcDifferenceForNames(oldProto.nestedClassNameList, newProto.nestedClassNameList))
|
names.addAll(calcDifferenceForNames(oldProto.nestedClassNameList, newProto.nestedClassNameList))
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.MEMBER_LIST -> {
|
ProtoBufClassKind.CONSTRUCTOR_LIST ->
|
||||||
val oldMembers = oldProto.memberList.filter { !it.isPrivate }
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getConstructorList))
|
||||||
val newMembers = newProto.memberList.filter { !it.isPrivate }
|
ProtoBufClassKind.FUNCTION_LIST ->
|
||||||
names.addAll(calcDifferenceForMembers(oldMembers, newMembers))
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getFunctionList))
|
||||||
}
|
ProtoBufClassKind.PROPERTY_LIST ->
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.ENUM_ENTRY_LIST ->
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getPropertyList))
|
||||||
|
ProtoBufClassKind.MEMBER_LIST ->
|
||||||
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getMemberList))
|
||||||
|
ProtoBufClassKind.ENUM_ENTRY_LIST ->
|
||||||
names.addAll(calcDifferenceForNames(oldProto.enumEntryList, newProto.enumEntryList))
|
names.addAll(calcDifferenceForNames(oldProto.enumEntryList, newProto.enumEntryList))
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.PRIMARY_CONSTRUCTOR ->
|
ProtoBufClassKind.PRIMARY_CONSTRUCTOR ->
|
||||||
if (areNonPrivatePrimaryConstructorsDifferent()) {
|
if (areNonPrivatePrimaryConstructorsDifferent()) {
|
||||||
names.add(CONSTRUCTOR)
|
names.add(CONSTRUCTOR)
|
||||||
}
|
}
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.SECONDARY_CONSTRUCTOR_LIST ->
|
ProtoBufClassKind.SECONDARY_CONSTRUCTOR_LIST ->
|
||||||
if (areNonPrivateSecondaryConstructorsDifferent()) {
|
if (areNonPrivateSecondaryConstructorsDifferent()) {
|
||||||
names.add(CONSTRUCTOR)
|
names.add(CONSTRUCTOR)
|
||||||
}
|
}
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.FLAGS,
|
ProtoBufClassKind.FLAGS,
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.FQ_NAME,
|
ProtoBufClassKind.FQ_NAME,
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.TYPE_PARAMETER_LIST,
|
ProtoBufClassKind.TYPE_PARAMETER_LIST,
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.SUPERTYPE_LIST,
|
ProtoBufClassKind.SUPERTYPE_LIST,
|
||||||
ProtoCompareGenerated.ProtoBufClassKind.CLASS_ANNOTATION_LIST ->
|
ProtoBufClassKind.CLASS_ANNOTATION_LIST ->
|
||||||
throw IllegalArgumentException("Unexpected kind: $kind")
|
throw IllegalArgumentException("Unexpected kind: $kind")
|
||||||
else ->
|
else ->
|
||||||
throw IllegalArgumentException("Unsupported kind: $kind")
|
throw IllegalArgumentException("Unsupported kind: $kind")
|
||||||
@@ -237,14 +285,27 @@ private class DifferenceCalculatorForPackageFacade(oldData: ProtoMapValue, newDa
|
|||||||
private fun getChangedMembersNames(): Set<String> {
|
private fun getChangedMembersNames(): Set<String> {
|
||||||
val names = hashSetOf<String>()
|
val names = hashSetOf<String>()
|
||||||
|
|
||||||
|
fun calcDifferenceForNonPrivateMembers(members: (ProtoBuf.Package) -> List<MessageLite>): Collection<String> {
|
||||||
|
val oldMembers = members(oldProto).filterNot { it.isPrivate }
|
||||||
|
val newMembers = members(newProto).filterNot { it.isPrivate }
|
||||||
|
return calcDifferenceForMembers(oldMembers, newMembers)
|
||||||
|
}
|
||||||
|
|
||||||
for (kind in diff) {
|
for (kind in diff) {
|
||||||
when (kind!!) {
|
when (kind!!) {
|
||||||
ProtoCompareGenerated.ProtoBufPackageKind.MEMBER_LIST ->
|
ProtoBufPackageKind.CONSTRUCTOR_LIST ->
|
||||||
names.addAll(calcDifferenceForMembers(oldProto.memberList.filter { !it.isPrivate }, newProto.memberList.filter { !it.isPrivate }))
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Package::getConstructorList))
|
||||||
|
ProtoBufPackageKind.FUNCTION_LIST ->
|
||||||
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Package::getFunctionList))
|
||||||
|
ProtoBufPackageKind.PROPERTY_LIST ->
|
||||||
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Package::getPropertyList))
|
||||||
|
ProtoBufPackageKind.MEMBER_LIST ->
|
||||||
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Package::getMemberList))
|
||||||
else ->
|
else ->
|
||||||
throw IllegalArgumentException("Unsupported kind: $kind")
|
throw IllegalArgumentException("Unsupported kind: $kind")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user