compareTo method
Implementation
List<ApiChange> compareTo(DocComponent newComponent) {
final changes = <ApiChange>[];
if (isNullSafe != newComponent.isNullSafe) {
changes.add(
ComponentApiChange(
component: this,
operation: newComponent.isNullSafe ? ApiChangeOperation.becameNullSafe : ApiChangeOperation.becameNullUnsafe,
),
);
}
if (aliasedType != newComponent.aliasedType) {
changes.add(
ComponentApiChange(
component: this,
operation: ApiChangeOperation.typeChanged,
),
);
}
for (final annotation in annotations) {
if (!newComponent.annotations.contains(annotation)) {
changes.add(ComponentApiChange(
component: this,
operation: ApiChangeOperation.annotationRemoved,
annotation: annotation,
));
}
}
for (final annotation in newComponent.annotations) {
if (!annotations.contains(annotation)) {
changes.add(ComponentApiChange(
component: this,
operation: ApiChangeOperation.annotationAdded,
annotation: annotation,
));
}
}
if (superClass != newComponent.superClass) {
changes.add(ComponentApiChange(
component: this,
operation: ApiChangeOperation.superClassChanged,
changedValue: '${superClass ?? 'null'} -> ${newComponent.superClass ?? 'null'}',
));
}
for (final interface in interfaces) {
if (!newComponent.interfaces.contains(interface)) {
changes.add(ComponentApiChange(
component: this,
operation: ApiChangeOperation.interfaceRemoved,
changedValue: interface,
));
}
}
for (final interface in newComponent.interfaces) {
if (!interfaces.contains(interface)) {
changes.add(ComponentApiChange(
component: this,
operation: ApiChangeOperation.interfaceAdded,
changedValue: interface,
));
}
}
for (final mixin in mixins) {
if (!newComponent.mixins.contains(mixin)) {
changes.add(ComponentApiChange(
component: this,
operation: ApiChangeOperation.mixinRemoved,
changedValue: mixin,
));
}
}
for (final mixin in newComponent.mixins) {
if (!mixins.contains(mixin)) {
changes.add(ComponentApiChange(
component: this,
operation: ApiChangeOperation.mixinAdded,
changedValue: mixin,
));
}
}
changes.addAll(
constructors.compareTo(newComponent.constructors, component: this),
);
changes.addAll(
properties.compareTo(newComponent.properties, component: this),
);
changes.addAll(
methods.compareTo(newComponent.methods, component: this),
);
return changes;
}