Serialize/deserialize annotations on enum entries
#KT-10338 Fixed
Original commit: 3e2eb8c1a0
This commit is contained in:
@@ -249,7 +249,7 @@ public class IncrementalCacheImpl(
|
||||
ProtoBuf.Class::getFunctionList,
|
||||
ProtoBuf.Class::getPropertyList
|
||||
) +
|
||||
classData.classProto.enumEntryList.map { classData.nameResolver.getString(it) }.toSet()
|
||||
classData.classProto.enumEntryNameList.map { classData.nameResolver.getString(it) }.toSet()
|
||||
|
||||
ChangeInfo.Removed(className.fqNameForClassNameWithoutDollars, memberNames)
|
||||
}
|
||||
|
||||
@@ -94,6 +94,8 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
||||
|
||||
if (!checkEqualsClassProperty(old, new)) return false
|
||||
|
||||
if (!checkEqualsClassEnumEntryName(old, new)) return false
|
||||
|
||||
if (!checkEqualsClassEnumEntry(old, new)) return false
|
||||
|
||||
if (old.hasTypeTable() != new.hasTypeTable()) return false
|
||||
@@ -120,6 +122,7 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
||||
CONSTRUCTOR_LIST,
|
||||
FUNCTION_LIST,
|
||||
PROPERTY_LIST,
|
||||
ENUM_ENTRY_NAME_LIST,
|
||||
ENUM_ENTRY_LIST,
|
||||
TYPE_TABLE,
|
||||
CLASS_ANNOTATION_LIST
|
||||
@@ -154,6 +157,8 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
||||
|
||||
if (!checkEqualsClassProperty(old, new)) result.add(ProtoBufClassKind.PROPERTY_LIST)
|
||||
|
||||
if (!checkEqualsClassEnumEntryName(old, new)) result.add(ProtoBufClassKind.ENUM_ENTRY_NAME_LIST)
|
||||
|
||||
if (!checkEqualsClassEnumEntry(old, new)) result.add(ProtoBufClassKind.ENUM_ENTRY_LIST)
|
||||
|
||||
if (old.hasTypeTable() != new.hasTypeTable()) result.add(ProtoBufClassKind.TYPE_TABLE)
|
||||
@@ -395,6 +400,15 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
||||
return true
|
||||
}
|
||||
|
||||
open fun checkEquals(old: ProtoBuf.EnumEntry, new: ProtoBuf.EnumEntry): Boolean {
|
||||
if (old.hasName() != new.hasName()) return false
|
||||
if (old.hasName()) {
|
||||
if (old.name != new.name) return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
open fun checkEquals(old: ProtoBuf.Annotation, new: ProtoBuf.Annotation): Boolean {
|
||||
if (!checkClassIdEquals(old.id, new.id)) return false
|
||||
|
||||
@@ -659,11 +673,21 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
||||
return true
|
||||
}
|
||||
|
||||
open fun checkEqualsClassEnumEntryName(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
||||
if (old.enumEntryNameCount != new.enumEntryNameCount) return false
|
||||
|
||||
for(i in 0..old.enumEntryNameCount - 1) {
|
||||
if (!checkStringEquals(old.getEnumEntryName(i), new.getEnumEntryName(i))) return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
open fun checkEqualsClassEnumEntry(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
||||
if (old.enumEntryCount != new.enumEntryCount) return false
|
||||
|
||||
for(i in 0..old.enumEntryCount - 1) {
|
||||
if (!checkStringEquals(old.getEnumEntry(i), new.getEnumEntry(i))) return false
|
||||
if (!checkEquals(old.getEnumEntry(i), new.getEnumEntry(i))) return false
|
||||
}
|
||||
|
||||
return true
|
||||
@@ -859,8 +883,12 @@ public fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (
|
||||
hashCode = 31 * hashCode + getProperty(i).hashCode(stringIndexes, fqNameIndexes)
|
||||
}
|
||||
|
||||
for(i in 0..enumEntryNameCount - 1) {
|
||||
hashCode = 31 * hashCode + stringIndexes(getEnumEntryName(i))
|
||||
}
|
||||
|
||||
for(i in 0..enumEntryCount - 1) {
|
||||
hashCode = 31 * hashCode + stringIndexes(getEnumEntry(i))
|
||||
hashCode = 31 * hashCode + getEnumEntry(i).hashCode(stringIndexes, fqNameIndexes)
|
||||
}
|
||||
|
||||
if (hasTypeTable()) {
|
||||
@@ -1090,6 +1118,16 @@ public fun ProtoBuf.Constructor.hashCode(stringIndexes: (Int) -> Int, fqNameInde
|
||||
return hashCode
|
||||
}
|
||||
|
||||
public fun ProtoBuf.EnumEntry.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||
var hashCode = 1
|
||||
|
||||
if (hasName()) {
|
||||
hashCode = 31 * hashCode + name
|
||||
}
|
||||
|
||||
return hashCode
|
||||
}
|
||||
|
||||
public fun ProtoBuf.Annotation.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||
var hashCode = 1
|
||||
|
||||
|
||||
@@ -206,8 +206,10 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot
|
||||
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getFunctionList))
|
||||
ProtoBufClassKind.PROPERTY_LIST ->
|
||||
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getPropertyList))
|
||||
ProtoBufClassKind.ENUM_ENTRY_NAME_LIST ->
|
||||
names.addAll(calcDifferenceForNames(oldProto.enumEntryNameList, newProto.enumEntryNameList))
|
||||
ProtoBufClassKind.ENUM_ENTRY_LIST ->
|
||||
names.addAll(calcDifferenceForNames(oldProto.enumEntryList, newProto.enumEntryList))
|
||||
names.addAll(calcDifferenceForNames(oldProto.enumEntryList.map { it.name }, newProto.enumEntryList.map { it.name }))
|
||||
ProtoBufClassKind.TYPE_TABLE -> {
|
||||
// TODO
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user