NEWCKEditor AI is here! Learn how to supercharge your editor with AI on our webinar.
Sign up (with export icon)

Differ

Api-class iconclass

Calculates the difference between two model states.

Receives operations that are to be applied on the model document. Marks parts of the model document tree which are changed and saves the state of these elements before the change. Then, it compares saved elements with the changed elements, after all changes are applied on the model document. Calculates the diff between saved elements and new ones and returns a change set.

Properties

  • Chevron-right icon

    isEmpty : boolean
    readonly

    Informs whether there are any changes buffered in Differ.

  • Chevron-right icon

    _cachedChanges : Array<DifferItem> | null
    Lock iconprivate

    For efficiency purposes, Differ stores the change set returned by the differ after getChanges call. Cache is reset each time a new operation is buffered. If the cache has not been reset, getChanges will return the cached value instead of calculating it again.

    This property stores those changes that did not take place in graveyard root.

  • Chevron-right icon

    _cachedChangesWithGraveyard : Array<DifferItem> | null
    Lock iconprivate

    For efficiency purposes, Differ stores the change set returned by the differ after the getChanges call. The cache is reset each time a new operation is buffered. If the cache has not been reset, getChanges will return the cached value instead of calculating it again.

    This property stores all changes evaluated by Differ, including those that took place in the graveyard.

  • Chevron-right icon

    _changeCount : number
    Lock iconprivate

    Stores the number of changes that were processed. Used to order the changes chronologically. It is important when changes are sorted.

  • Chevron-right icon

    _changedMarkers : Map<string, object>
    Lock iconprivatereadonly

    A map that stores all changed markers.

    The keys of the map are marker names.

    The values of the map are objects with the following properties:

    • oldMarkerData,
    • newMarkerData.
  • Chevron-right icon

    _changedRoots : Map<string, DifferItemRoot>
    Lock iconprivatereadonly

    A map that stores all roots that have been changed.

    The keys are the names of the roots while value represents the changes.

  • Chevron-right icon

    _changesInElement : Map<ModelElement | ModelDocumentFragment, Array<ChangeItem>>
    Lock iconprivatereadonly

    A map that stores changes that happened in a given element.

    The keys of the map are references to the model elements. The values of the map are arrays with changes that were done on this element.

  • Chevron-right icon

    For each element or document fragment inside which there was a change, it stores a snapshot of the child nodes list (an array of children snapshots that represent the state in the element / fragment before any change has happened).

    This complements _elementsSnapshots.

    See also DifferSnapshot.

  • Chevron-right icon

    _elementState : Map<ModelElement, 'rename' | 'move' | 'refresh'>
    Lock iconprivatereadonly

    Keeps the state for a given element, describing how the element was changed so far. It is used to evaluate the action property of diff items returned by getChanges.

    Possible values, in the order from the lowest priority to the highest priority:

    • 'refresh' - element was refreshed,
    • 'rename' - element was renamed,
    • 'move' - element was moved (or, usually, removed, that is moved to the graveyard).

    Element that was refreshed, may change its state to 'rename' if it was later renamed, or to 'move' if it was removed. But the element cannot change its state from 'move' to 'rename', or from 'rename' to 'refresh'.

    Only already existing elements are registered in _elementState. If a new element was inserted as a result of a buffered operation, it is not be registered in _elementState.

  • Chevron-right icon

    _elementsSnapshots : Map<ModelNode, DifferSnapshot>
    Lock iconprivatereadonly

    Stores a snapshot for these model nodes that might have changed.

    This complements _elementChildrenSnapshots.

    See also DifferSnapshot.

  • Chevron-right icon

    _markerCollection : MarkerCollection
    Lock iconprivatereadonly

    Reference to the model's marker collection.

  • Chevron-right icon

    _refreshedItems : Set<ModelItem>
    Lock iconprivate

    Set of model items that were marked to get refreshed in _refreshItem.

Static properties

Methods