Class skelmatch.Diff

Create a new instance of the XCC diff implementation.

Constructor

class skelmatch.Diff(a, b)
Arguments:
  • a (tree.Node) – Root node of original tree
  • b (tree.Node) – Root node of changed tree

Methods

Diff#collectBones

skelmatch.Diff.Diff#collectBones(node)
Arguments:
  • node (tree.Node) – The internal node from where the search should start.

Return an array of the bottom-most structure-type nodes beneath the given node.

Diff#equalContent

skelmatch.Diff.Diff#equalContent(a, b)
Arguments:
  • a (tree.Node) – Candidate node from tree a
  • b (tree.Node) – Candidate node from tree b
Returns boolean:
 

Return true if the value of the two nodes is equal.

Default equality test for content nodes. Also test all descendants of a and b for equality. Override this method if you want to use tree hashing for this purpose.

Diff#equalStructure

skelmatch.Diff.Diff#equalStructure(a, b, b)
Arguments:
  • a (tree.Node) – Candidate node from tree a
  • b (tree.Node) – Candidate node from tree b
  • b (tree.Node) –
Returns boolean:
 

Return true if the value of the two nodes is equal.

Default equality test for structure nodes. Return true if ancestors either have the same node value or if they form a pair. Override this method if you want to use tree hashing for this purpose.

Diff#forEachUnmatchedSequenceOfSiblings

skelmatch.Diff.Diff#forEachUnmatchedSequenceOfSiblings(matching, a_sibs, b_sibs, callback, T)
Arguments:
  • matching (tree.Matching) – A partial matching
  • a_sibs (Array) – A sequence of siblings from tree a
  • b_sibs (Array) – A sequence of siblings from tree b
  • callback (function) – A function (a_nodes, b_nodes, a_parent, b_parent) called for every consecutive sequence of nodes from a_sibs and b_sibs seperated by one or more node pairs.
  • T (Object) – Context object bound to “this” when the callback is invoked.

Invoke the given callback with each sequence of unmatched nodes.

Diff#isContent

skelmatch.Diff.Diff#isContent(The)
Arguments:
  • The (tree.Node) – node which should be examined.
Returns boolean:
 

True if the node is a content-node, false otherwise.

Return true if the given node should be treated as a content node. Override this method in order to implement custom logic to decide whether a node should be examined during the initial LCS (content) or during the second pass. Default: Return true for leaf-nodes.

Diff#isStructure

skelmatch.Diff.Diff#isStructure(The)
Arguments:
  • The (tree.Node) – node which should be examined.
Returns boolean:
 

True if the node is a content-node, false otherwise.

Return true if the given node should be treated as a structure node. Default: Return true for internal nodes.

Diff#matchContent

skelmatch.Diff.Diff#matchContent(matching)
Arguments:
  • matching (tree.Matching) – A tree matching which will be populated by diffing tree a and b.

Identify unchanged leaves by comparing them using myers longest common subsequence algorithm.

Diff#matchingCheckAncestors

skelmatch.Diff.Diff#matchingCheckAncestors(matching, a, b)
Arguments:
  • matching (tree.Matching) – A tree matching which will be populated by diffing tree a and b.
  • a (tree.Node) – Candidate node from tree a
  • b (tree.Node) – Candidate node from tree b
Returns boolean:
 

Return true if a pair is found in the ancestor chain.

Return true if a pair is found in the ancestor chain of a and b.

Diff#matchingPutAncestors

skelmatch.Diff.Diff#matchingPutAncestors(matching, a, b)
Arguments:
  • matching (tree.Matching) – A tree matching which will be populated by diffing tree a and b.
  • a (tree.Node) – Candidate node from tree a
  • b (tree.Node) – Candidate node from tree b

Put a and b and all their unmatched ancestors into the matching.

Diff#matchStructure

skelmatch.Diff.Diff#matchStructure(matching)
Arguments:
  • matching (tree.Matching) – A partial matching

Traverse a partial matching and detect equal structure-type nodes between matched content nodes.