Class ContextResolver

Constructor for ContextResolver instances.

Constructor

class ContextResolver(refnode, nodeindex, radius, threshold, matcher)
Arguments:
  • refnode – A tree.Node, typically the root node
  • nodeindex
    An index class capable of accessing nodes by offset to
    other nodes. Typically an instance of DocumentOrderIndex should be used for this purpose.
  • radius – The search radius for the fuzzy matching algorithm
  • threshold
    The threshold of the fuzzy matching algorithm. A value
    between 0.5 and 1. The authors of the xcc patching algorithm recommend 0.7.
  • matcher
    (optional) A matcher instance. Defaults to a
    WeightedContextMatcher with radius=4.

Methods

equalContent

ContextResolver#equalContent(docnode, patnode)
Arguments:
  • docnode – A candidate node from the document
  • patnode – A body-node from the pattern

Compare a document node against a content node from the patch. Return true if the docnode matches the patnode.

Override this method if you use something different than the value property of tree.Node.

equalContext

ContextResolver#equalContext(docnode, patnode)
Arguments:
  • docnode – A candidate node from the document
  • patnode – The value from a context node

Compare a document node against a context node value. Return true if the value of docnode matches the pattern value.

Override this method if you use something different than the value property of tree.Node.

find

ContextResolver#find(path, body, head, tail, type)
Arguments:
  • path
    An array of numbers. Each value represents an index
    into the childrens of a node in top-down order.
  • body
    An array containing the node sequence in question.
    When resolving the location of insert operations, the array is empty. For updates, the array will consist of exactly one node. Remove operations may consist of one or more nodes.
  • head
    Leading context: An array containing the values of
    leading nodes in the same generation.
  • tail
    Trailing context: An array containing the values of
    trailing nodes in the same generation.
  • type
    Operation type. This parameter is passed to the
    equalContent callback.
:returns :
A result object with two properties: node holds the resolved

tree.Node and tail the unresolved part of path. Returns undefined on failure.

Locate a node at the given path starting at refnode. Try to locate the target within a given radius using the fingerprint values if direct lookup failed.

getClosestNode

ContextResolver#getClosestNode(anchor, nodeindex)
Arguments:
  • anchor
  • nodeindex

Given an anchor and a nodeindex, this method identifies the node which matches the anchor as close as possible.

Table Of Contents

Previous topic

Resolver

Next topic

Class TopDownPathResolver