UNPKG

@ui5/task-adaptation

Version:

Custom task for ui5-builder which allows building UI5 Flexibility Adaptation Projects for SAP BTP, Cloud Foundry environment

48 lines (47 loc) 1.76 kB
export interface IDiffProperty { object: any; property: string | number; } export declare class Diff { __old: string; __new: string; constructor(__old: string, __new: string); toString(): string; } export interface DiffJson { json: any; properties: Set<IDiffProperty>; } export default class Comparator { private diffs; private xml_a; private xml_b; constructor(xml_a: string, xml_b: string); compare(): DiffJson; private traverseCompare; /** * If one language annotation has one property it is an object, if other * language same annotation consists of multiple properties, we need to * equal them, so they are both arrays (see test 01-04). */ private arrayIfNeeded; /** * If some node (Annotations, Annotation, PropertyValue, LabeledElement) has * an id, we can compare by id, so the items order doesn't matter anymore. * @param a array of nodes with id of one language * @param b array of nodes with id of the other language * @param idProperty property which value is an id (e.g. Target="<unique-id>") * @param property node name (Annotations, Annotation, PropertyValue, ...) */ private traverseById; /** * Some nodes, like Annotations, Annotation, PropertyValue have unique id * among other same nodes. We can use it to know what to compare with what * even if the order is different. IdProperty is a property name of that id, * e.g. for Annotations it will be Target (like in * Target="<some-unique-id>"). * @param property node which might have an id: Annotations, PropertyValue * @return the property name which represents id: Target, Property */ private getIdProperty; }