Drop Callable and primary/secondary constructor proto messages
Original commit: e4efa27b76
This commit is contained in:
@@ -35,10 +35,6 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
private val classIds = Interner<ClassId>()
|
private val classIds = Interner<ClassId>()
|
||||||
|
|
||||||
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 (!checkEqualsPackageConstructor(old, new)) return false
|
|
||||||
|
|
||||||
if (!checkEqualsPackageFunction(old, new)) return false
|
if (!checkEqualsPackageFunction(old, new)) return false
|
||||||
|
|
||||||
if (!checkEqualsPackageProperty(old, new)) return false
|
if (!checkEqualsPackageProperty(old, new)) return false
|
||||||
@@ -46,8 +42,6 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
public enum class ProtoBufPackageKind {
|
public enum class ProtoBufPackageKind {
|
||||||
MEMBER_LIST,
|
|
||||||
CONSTRUCTOR_LIST,
|
|
||||||
FUNCTION_LIST,
|
FUNCTION_LIST,
|
||||||
PROPERTY_LIST
|
PROPERTY_LIST
|
||||||
}
|
}
|
||||||
@@ -55,10 +49,6 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
public fun difference(old: ProtoBuf.Package, new: ProtoBuf.Package): EnumSet<ProtoBufPackageKind> {
|
public fun difference(old: ProtoBuf.Package, new: ProtoBuf.Package): EnumSet<ProtoBufPackageKind> {
|
||||||
val result = EnumSet.noneOf(ProtoBufPackageKind::class.java)
|
val result = EnumSet.noneOf(ProtoBufPackageKind::class.java)
|
||||||
|
|
||||||
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 (!checkEqualsPackageFunction(old, new)) result.add(ProtoBufPackageKind.FUNCTION_LIST)
|
||||||
|
|
||||||
if (!checkEqualsPackageProperty(old, new)) result.add(ProtoBufPackageKind.PROPERTY_LIST)
|
if (!checkEqualsPackageProperty(old, new)) result.add(ProtoBufPackageKind.PROPERTY_LIST)
|
||||||
@@ -91,17 +81,8 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
|
|
||||||
if (!checkEqualsClassProperty(old, new)) return false
|
if (!checkEqualsClassProperty(old, new)) return false
|
||||||
|
|
||||||
if (!checkEqualsClassMember(old, new)) return false
|
|
||||||
|
|
||||||
if (!checkEqualsClassEnumEntry(old, new)) return false
|
if (!checkEqualsClassEnumEntry(old, new)) return false
|
||||||
|
|
||||||
if (old.hasPrimaryConstructor() != new.hasPrimaryConstructor()) return false
|
|
||||||
if (old.hasPrimaryConstructor()) {
|
|
||||||
if (!checkEquals(old.primaryConstructor, new.primaryConstructor)) return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkEqualsClassSecondaryConstructor(old, new)) return false
|
|
||||||
|
|
||||||
if (old.getExtensionCount(JvmProtoBuf.classAnnotation) != new.getExtensionCount(JvmProtoBuf.classAnnotation)) return false
|
if (old.getExtensionCount(JvmProtoBuf.classAnnotation) != new.getExtensionCount(JvmProtoBuf.classAnnotation)) return false
|
||||||
|
|
||||||
for(i in 0..old.getExtensionCount(JvmProtoBuf.classAnnotation) - 1) {
|
for(i in 0..old.getExtensionCount(JvmProtoBuf.classAnnotation) - 1) {
|
||||||
@@ -120,10 +101,7 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
CONSTRUCTOR_LIST,
|
CONSTRUCTOR_LIST,
|
||||||
FUNCTION_LIST,
|
FUNCTION_LIST,
|
||||||
PROPERTY_LIST,
|
PROPERTY_LIST,
|
||||||
MEMBER_LIST,
|
|
||||||
ENUM_ENTRY_LIST,
|
ENUM_ENTRY_LIST,
|
||||||
PRIMARY_CONSTRUCTOR,
|
|
||||||
SECONDARY_CONSTRUCTOR_LIST,
|
|
||||||
CLASS_ANNOTATION_LIST
|
CLASS_ANNOTATION_LIST
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,17 +132,8 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
|
|
||||||
if (!checkEqualsClassProperty(old, new)) result.add(ProtoBufClassKind.PROPERTY_LIST)
|
if (!checkEqualsClassProperty(old, new)) result.add(ProtoBufClassKind.PROPERTY_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)
|
||||||
|
|
||||||
if (old.hasPrimaryConstructor() != new.hasPrimaryConstructor()) result.add(ProtoBufClassKind.PRIMARY_CONSTRUCTOR)
|
|
||||||
if (old.hasPrimaryConstructor()) {
|
|
||||||
if (!checkEquals(old.primaryConstructor, new.primaryConstructor)) result.add(ProtoBufClassKind.PRIMARY_CONSTRUCTOR)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkEqualsClassSecondaryConstructor(old, new)) result.add(ProtoBufClassKind.SECONDARY_CONSTRUCTOR_LIST)
|
|
||||||
|
|
||||||
if (old.getExtensionCount(JvmProtoBuf.classAnnotation) != new.getExtensionCount(JvmProtoBuf.classAnnotation)) result.add(ProtoBufClassKind.CLASS_ANNOTATION_LIST)
|
if (old.getExtensionCount(JvmProtoBuf.classAnnotation) != new.getExtensionCount(JvmProtoBuf.classAnnotation)) result.add(ProtoBufClassKind.CLASS_ANNOTATION_LIST)
|
||||||
|
|
||||||
for(i in 0..old.getExtensionCount(JvmProtoBuf.classAnnotation) - 1) {
|
for(i in 0..old.getExtensionCount(JvmProtoBuf.classAnnotation) - 1) {
|
||||||
@@ -174,69 +143,6 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun checkEquals(old: ProtoBuf.Callable, new: ProtoBuf.Callable): Boolean {
|
|
||||||
if (old.hasFlags() != new.hasFlags()) return false
|
|
||||||
if (old.hasFlags()) {
|
|
||||||
if (old.flags != new.flags) 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
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkEqualsCallableTypeParameter(old, new)) return false
|
|
||||||
|
|
||||||
if (old.hasReceiverType() != new.hasReceiverType()) return false
|
|
||||||
if (old.hasReceiverType()) {
|
|
||||||
if (!checkEquals(old.receiverType, new.receiverType)) return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkStringEquals(old.name, new.name)) return false
|
|
||||||
|
|
||||||
if (!checkEqualsCallableValueParameter(old, new)) return false
|
|
||||||
|
|
||||||
if (!checkEquals(old.returnType, new.returnType)) return false
|
|
||||||
|
|
||||||
if (old.hasExtension(JvmProtoBuf.oldMethodSignature) != new.hasExtension(JvmProtoBuf.oldMethodSignature)) return false
|
|
||||||
if (old.hasExtension(JvmProtoBuf.oldMethodSignature)) {
|
|
||||||
if (!checkEquals(old.getExtension(JvmProtoBuf.oldMethodSignature), new.getExtension(JvmProtoBuf.oldMethodSignature))) return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (old.hasExtension(JvmProtoBuf.oldPropertySignature) != new.hasExtension(JvmProtoBuf.oldPropertySignature)) return false
|
|
||||||
if (old.hasExtension(JvmProtoBuf.oldPropertySignature)) {
|
|
||||||
if (!checkEquals(old.getExtension(JvmProtoBuf.oldPropertySignature), new.getExtension(JvmProtoBuf.oldPropertySignature))) return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (old.hasExtension(JvmProtoBuf.oldImplClassName) != new.hasExtension(JvmProtoBuf.oldImplClassName)) return false
|
|
||||||
if (old.hasExtension(JvmProtoBuf.oldImplClassName)) {
|
|
||||||
if (!checkStringEquals(old.getExtension(JvmProtoBuf.oldImplClassName), new.getExtension(JvmProtoBuf.oldImplClassName))) return false
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
if (old.hasExtension(JvmProtoBuf.constructorSignature) != new.hasExtension(JvmProtoBuf.constructorSignature)) return false
|
|
||||||
if (old.hasExtension(JvmProtoBuf.constructorSignature)) {
|
|
||||||
if (!checkEquals(old.getExtension(JvmProtoBuf.constructorSignature), new.getExtension(JvmProtoBuf.constructorSignature))) return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun checkEquals(old: ProtoBuf.Function, new: ProtoBuf.Function): Boolean {
|
open fun checkEquals(old: ProtoBuf.Function, new: ProtoBuf.Function): Boolean {
|
||||||
if (old.hasFlags() != new.hasFlags()) return false
|
if (old.hasFlags() != new.hasFlags()) return false
|
||||||
if (old.hasFlags()) {
|
if (old.hasFlags()) {
|
||||||
@@ -376,10 +282,17 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun checkEquals(old: ProtoBuf.Class.PrimaryConstructor, new: ProtoBuf.Class.PrimaryConstructor): Boolean {
|
open fun checkEquals(old: ProtoBuf.Constructor, new: ProtoBuf.Constructor): Boolean {
|
||||||
if (old.hasData() != new.hasData()) return false
|
if (old.hasFlags() != new.hasFlags()) return false
|
||||||
if (old.hasData()) {
|
if (old.hasFlags()) {
|
||||||
if (!checkEquals(old.data, new.data)) return false
|
if (old.flags != new.flags) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkEqualsConstructorValueParameter(old, new)) return false
|
||||||
|
|
||||||
|
if (old.hasExtension(JvmProtoBuf.constructorSignature) != new.hasExtension(JvmProtoBuf.constructorSignature)) return false
|
||||||
|
if (old.hasExtension(JvmProtoBuf.constructorSignature)) {
|
||||||
|
if (!checkEquals(old.getExtension(JvmProtoBuf.constructorSignature), new.getExtension(JvmProtoBuf.constructorSignature))) return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@@ -529,26 +442,6 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun checkEqualsPackageMember(old: ProtoBuf.Package, new: ProtoBuf.Package): Boolean {
|
|
||||||
if (old.memberCount != new.memberCount) return false
|
|
||||||
|
|
||||||
for(i in 0..old.memberCount - 1) {
|
|
||||||
if (!checkEquals(old.getMember(i), new.getMember(i))) return false
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
open fun checkEqualsPackageFunction(old: ProtoBuf.Package, new: ProtoBuf.Package): Boolean {
|
||||||
if (old.functionCount != new.functionCount) return false
|
if (old.functionCount != new.functionCount) return false
|
||||||
|
|
||||||
@@ -629,16 +522,6 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun checkEqualsClassMember(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
|
||||||
if (old.memberCount != new.memberCount) return false
|
|
||||||
|
|
||||||
for(i in 0..old.memberCount - 1) {
|
|
||||||
if (!checkEquals(old.getMember(i), new.getMember(i))) return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun checkEqualsClassEnumEntry(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
open fun checkEqualsClassEnumEntry(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
||||||
if (old.enumEntryCount != new.enumEntryCount) return false
|
if (old.enumEntryCount != new.enumEntryCount) return false
|
||||||
|
|
||||||
@@ -649,46 +532,6 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun checkEqualsClassSecondaryConstructor(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
|
|
||||||
if (old.secondaryConstructorCount != new.secondaryConstructorCount) return false
|
|
||||||
|
|
||||||
for(i in 0..old.secondaryConstructorCount - 1) {
|
|
||||||
if (!checkEquals(old.getSecondaryConstructor(i), new.getSecondaryConstructor(i))) return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun checkEqualsCallableTypeParameter(old: ProtoBuf.Callable, new: ProtoBuf.Callable): 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 checkEqualsCallableValueParameter(old: ProtoBuf.Callable, new: ProtoBuf.Callable): 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 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 {
|
open fun checkEqualsFunctionTypeParameter(old: ProtoBuf.Function, new: ProtoBuf.Function): Boolean {
|
||||||
if (old.typeParameterCount != new.typeParameterCount) return false
|
if (old.typeParameterCount != new.typeParameterCount) return false
|
||||||
|
|
||||||
@@ -739,6 +582,16 @@ 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 checkEqualsAnnotationArgument(old: ProtoBuf.Annotation, new: ProtoBuf.Annotation): Boolean {
|
open fun checkEqualsAnnotationArgument(old: ProtoBuf.Annotation, new: ProtoBuf.Annotation): Boolean {
|
||||||
if (old.argumentCount != new.argumentCount) return false
|
if (old.argumentCount != new.argumentCount) return false
|
||||||
|
|
||||||
@@ -793,14 +646,6 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
|
|||||||
public fun ProtoBuf.Package.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
public fun ProtoBuf.Package.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||||
var hashCode = 1
|
var hashCode = 1
|
||||||
|
|
||||||
for(i in 0..memberCount - 1) {
|
|
||||||
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) {
|
for(i in 0..functionCount - 1) {
|
||||||
hashCode = 31 * hashCode + getFunction(i).hashCode(stringIndexes, fqNameIndexes)
|
hashCode = 31 * hashCode + getFunction(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
}
|
}
|
||||||
@@ -849,22 +694,10 @@ public fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (
|
|||||||
hashCode = 31 * hashCode + getProperty(i).hashCode(stringIndexes, fqNameIndexes)
|
hashCode = 31 * hashCode + getProperty(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i in 0..memberCount - 1) {
|
|
||||||
hashCode = 31 * hashCode + getMember(i).hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i in 0..enumEntryCount - 1) {
|
for(i in 0..enumEntryCount - 1) {
|
||||||
hashCode = 31 * hashCode + stringIndexes(getEnumEntry(i))
|
hashCode = 31 * hashCode + stringIndexes(getEnumEntry(i))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasPrimaryConstructor()) {
|
|
||||||
hashCode = 31 * hashCode + primaryConstructor.hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i in 0..secondaryConstructorCount - 1) {
|
|
||||||
hashCode = 31 * hashCode + getSecondaryConstructor(i).hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i in 0..getExtensionCount(JvmProtoBuf.classAnnotation) - 1) {
|
for(i in 0..getExtensionCount(JvmProtoBuf.classAnnotation) - 1) {
|
||||||
hashCode = 31 * hashCode + getExtension(JvmProtoBuf.classAnnotation, i).hashCode(stringIndexes, fqNameIndexes)
|
hashCode = 31 * hashCode + getExtension(JvmProtoBuf.classAnnotation, i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
}
|
}
|
||||||
@@ -872,70 +705,6 @@ public fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (
|
|||||||
return hashCode
|
return hashCode
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun ProtoBuf.Callable.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
|
||||||
var hashCode = 1
|
|
||||||
|
|
||||||
if (hasFlags()) {
|
|
||||||
hashCode = 31 * hashCode + flags
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasGetterFlags()) {
|
|
||||||
hashCode = 31 * hashCode + getterFlags
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasSetterFlags()) {
|
|
||||||
hashCode = 31 * hashCode + setterFlags
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i in 0..typeParameterCount - 1) {
|
|
||||||
hashCode = 31 * hashCode + getTypeParameter(i).hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasReceiverType()) {
|
|
||||||
hashCode = 31 * hashCode + receiverType.hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
}
|
|
||||||
|
|
||||||
hashCode = 31 * hashCode + stringIndexes(name)
|
|
||||||
|
|
||||||
for(i in 0..valueParameterCount - 1) {
|
|
||||||
hashCode = 31 * hashCode + getValueParameter(i).hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
}
|
|
||||||
|
|
||||||
hashCode = 31 * hashCode + returnType.hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
|
|
||||||
if (hasExtension(JvmProtoBuf.oldMethodSignature)) {
|
|
||||||
hashCode = 31 * hashCode + getExtension(JvmProtoBuf.oldMethodSignature).hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasExtension(JvmProtoBuf.oldPropertySignature)) {
|
|
||||||
hashCode = 31 * hashCode + getExtension(JvmProtoBuf.oldPropertySignature).hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasExtension(JvmProtoBuf.oldImplClassName)) {
|
|
||||||
hashCode = 31 * hashCode + stringIndexes(getExtension(JvmProtoBuf.oldImplClassName))
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasExtension(JvmProtoBuf.constructorSignature)) {
|
|
||||||
hashCode = 31 * hashCode + getExtension(JvmProtoBuf.constructorSignature).hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
}
|
|
||||||
|
|
||||||
return hashCode
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun ProtoBuf.Function.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
public fun ProtoBuf.Function.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||||
var hashCode = 1
|
var hashCode = 1
|
||||||
|
|
||||||
@@ -1072,11 +841,19 @@ public fun ProtoBuf.Type.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (I
|
|||||||
return hashCode
|
return hashCode
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun ProtoBuf.Class.PrimaryConstructor.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
public fun ProtoBuf.Constructor.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||||
var hashCode = 1
|
var hashCode = 1
|
||||||
|
|
||||||
if (hasData()) {
|
if (hasFlags()) {
|
||||||
hashCode = 31 * hashCode + data.hashCode(stringIndexes, fqNameIndexes)
|
hashCode = 31 * hashCode + flags
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i in 0..valueParameterCount - 1) {
|
||||||
|
hashCode = 31 * hashCode + getValueParameter(i).hashCode(stringIndexes, fqNameIndexes)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasExtension(JvmProtoBuf.constructorSignature)) {
|
||||||
|
hashCode = 31 * hashCode + getExtension(JvmProtoBuf.constructorSignature).hashCode(stringIndexes, fqNameIndexes)
|
||||||
}
|
}
|
||||||
|
|
||||||
return hashCode
|
return hashCode
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ private abstract class DifferenceCalculator() {
|
|||||||
protected val MessageLite.isPrivate: Boolean
|
protected val MessageLite.isPrivate: Boolean
|
||||||
get() = Visibilities.isPrivate(Deserialization.visibility(
|
get() = Visibilities.isPrivate(Deserialization.visibility(
|
||||||
when (this) {
|
when (this) {
|
||||||
is ProtoBuf.Callable -> Flags.VISIBILITY.get(flags)
|
|
||||||
is ProtoBuf.Constructor -> Flags.VISIBILITY.get(flags)
|
is ProtoBuf.Constructor -> Flags.VISIBILITY.get(flags)
|
||||||
is ProtoBuf.Function -> Flags.VISIBILITY.get(flags)
|
is ProtoBuf.Function -> Flags.VISIBILITY.get(flags)
|
||||||
is ProtoBuf.Property -> Flags.VISIBILITY.get(flags)
|
is ProtoBuf.Property -> Flags.VISIBILITY.get(flags)
|
||||||
@@ -127,7 +126,6 @@ private abstract class DifferenceCalculator() {
|
|||||||
|
|
||||||
private fun MessageLite.getHashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
private fun MessageLite.getHashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is ProtoBuf.Callable -> hashCode(stringIndexes, fqNameIndexes)
|
|
||||||
is ProtoBuf.Constructor -> hashCode(stringIndexes, fqNameIndexes)
|
is ProtoBuf.Constructor -> hashCode(stringIndexes, fqNameIndexes)
|
||||||
is ProtoBuf.Function -> hashCode(stringIndexes, fqNameIndexes)
|
is ProtoBuf.Function -> hashCode(stringIndexes, fqNameIndexes)
|
||||||
is ProtoBuf.Property -> hashCode(stringIndexes, fqNameIndexes)
|
is ProtoBuf.Property -> hashCode(stringIndexes, fqNameIndexes)
|
||||||
@@ -137,7 +135,6 @@ private abstract class DifferenceCalculator() {
|
|||||||
|
|
||||||
private fun MessageLite.name(nameResolver: NameResolver): String {
|
private fun MessageLite.name(nameResolver: NameResolver): String {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is ProtoBuf.Callable -> nameResolver.getString(name)
|
|
||||||
is ProtoBuf.Constructor -> "<init>"
|
is ProtoBuf.Constructor -> "<init>"
|
||||||
is ProtoBuf.Function -> nameResolver.getString(name)
|
is ProtoBuf.Function -> nameResolver.getString(name)
|
||||||
is ProtoBuf.Property -> nameResolver.getString(name)
|
is ProtoBuf.Property -> nameResolver.getString(name)
|
||||||
@@ -147,7 +144,6 @@ private abstract class DifferenceCalculator() {
|
|||||||
|
|
||||||
private fun ProtoCompareGenerated.checkEquals(old: MessageLite, new: MessageLite): Boolean {
|
private fun ProtoCompareGenerated.checkEquals(old: MessageLite, new: MessageLite): Boolean {
|
||||||
return when {
|
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.Constructor && new is ProtoBuf.Constructor -> checkEquals(old, new)
|
||||||
old is ProtoBuf.Function && new is ProtoBuf.Function -> 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)
|
old is ProtoBuf.Property && new is ProtoBuf.Property -> checkEquals(old, new)
|
||||||
@@ -158,8 +154,6 @@ private abstract class DifferenceCalculator() {
|
|||||||
|
|
||||||
private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: ProtoMapValue) : DifferenceCalculator() {
|
private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: ProtoMapValue) : DifferenceCalculator() {
|
||||||
companion object {
|
companion object {
|
||||||
private val CONSTRUCTOR = "<init>"
|
|
||||||
|
|
||||||
private val CLASS_SIGNATURE_ENUMS = EnumSet.of(
|
private val CLASS_SIGNATURE_ENUMS = EnumSet.of(
|
||||||
ProtoBufClassKind.FLAGS,
|
ProtoBufClassKind.FLAGS,
|
||||||
ProtoBufClassKind.FQ_NAME,
|
ProtoBufClassKind.FQ_NAME,
|
||||||
@@ -214,18 +208,8 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot
|
|||||||
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getFunctionList))
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getFunctionList))
|
||||||
ProtoBufClassKind.PROPERTY_LIST ->
|
ProtoBufClassKind.PROPERTY_LIST ->
|
||||||
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getPropertyList))
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getPropertyList))
|
||||||
ProtoBufClassKind.MEMBER_LIST ->
|
|
||||||
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getMemberList))
|
|
||||||
ProtoBufClassKind.ENUM_ENTRY_LIST ->
|
ProtoBufClassKind.ENUM_ENTRY_LIST ->
|
||||||
names.addAll(calcDifferenceForNames(oldProto.enumEntryList, newProto.enumEntryList))
|
names.addAll(calcDifferenceForNames(oldProto.enumEntryList, newProto.enumEntryList))
|
||||||
ProtoBufClassKind.PRIMARY_CONSTRUCTOR ->
|
|
||||||
if (areNonPrivatePrimaryConstructorsDifferent()) {
|
|
||||||
names.add(CONSTRUCTOR)
|
|
||||||
}
|
|
||||||
ProtoBufClassKind.SECONDARY_CONSTRUCTOR_LIST ->
|
|
||||||
if (areNonPrivateSecondaryConstructorsDifferent()) {
|
|
||||||
names.add(CONSTRUCTOR)
|
|
||||||
}
|
|
||||||
ProtoBufClassKind.FLAGS,
|
ProtoBufClassKind.FLAGS,
|
||||||
ProtoBufClassKind.FQ_NAME,
|
ProtoBufClassKind.FQ_NAME,
|
||||||
ProtoBufClassKind.TYPE_PARAMETER_LIST,
|
ProtoBufClassKind.TYPE_PARAMETER_LIST,
|
||||||
@@ -238,30 +222,6 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot
|
|||||||
}
|
}
|
||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun areNonPrivatePrimaryConstructorsDifferent(): Boolean {
|
|
||||||
val oldPrimaryConstructor = oldProto.getNonPrivatePrimaryConstructor
|
|
||||||
val newPrimaryConstructor = newProto.getNonPrivatePrimaryConstructor
|
|
||||||
if (oldPrimaryConstructor == null && newPrimaryConstructor == null) return false
|
|
||||||
|
|
||||||
if (oldPrimaryConstructor == null || newPrimaryConstructor == null) return true
|
|
||||||
|
|
||||||
return !compareObject.checkEquals(oldPrimaryConstructor, newPrimaryConstructor)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun areNonPrivateSecondaryConstructorsDifferent(): Boolean {
|
|
||||||
val oldSecondaryConstructors = oldProto.secondaryConstructorList.filter { !it.isPrivate }
|
|
||||||
val newSecondaryConstructors = newProto.secondaryConstructorList.filter { !it.isPrivate }
|
|
||||||
return (oldSecondaryConstructors.size() != newSecondaryConstructors.size() ||
|
|
||||||
oldSecondaryConstructors.indices.any { !compareObject.checkEquals(oldSecondaryConstructors[it], newSecondaryConstructors[it]) })
|
|
||||||
}
|
|
||||||
|
|
||||||
private val ProtoBuf.Class.getNonPrivatePrimaryConstructor: ProtoBuf.Class.PrimaryConstructor?
|
|
||||||
get() {
|
|
||||||
if (!hasPrimaryConstructor()) return null
|
|
||||||
|
|
||||||
return if (primaryConstructor?.data?.isPrivate ?: false) null else primaryConstructor
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DifferenceCalculatorForPackageFacade(oldData: ProtoMapValue, newData: ProtoMapValue) : DifferenceCalculator() {
|
private class DifferenceCalculatorForPackageFacade(oldData: ProtoMapValue, newData: ProtoMapValue) : DifferenceCalculator() {
|
||||||
@@ -293,14 +253,10 @@ private class DifferenceCalculatorForPackageFacade(oldData: ProtoMapValue, newDa
|
|||||||
|
|
||||||
for (kind in diff) {
|
for (kind in diff) {
|
||||||
when (kind!!) {
|
when (kind!!) {
|
||||||
ProtoBufPackageKind.CONSTRUCTOR_LIST ->
|
|
||||||
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Package::getConstructorList))
|
|
||||||
ProtoBufPackageKind.FUNCTION_LIST ->
|
ProtoBufPackageKind.FUNCTION_LIST ->
|
||||||
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Package::getFunctionList))
|
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Package::getFunctionList))
|
||||||
ProtoBufPackageKind.PROPERTY_LIST ->
|
ProtoBufPackageKind.PROPERTY_LIST ->
|
||||||
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Package::getPropertyList))
|
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")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user