Interface WalkerVisitMethods

Methods used to visit document content from a Walker. The specific method determines which subset of the document's nodes will be visited. Visitation consists of traversing the selected document subset one node at a time, in order from the start of the document toward the end. For each node, the specified visitor function is called multiple times:

  1. When the node is first reached, the function is called with stage value "before".
  2. If the node has fields, each field will then be visited in order:
    1. Before each field visit begins, the function is again called, but with the stage value "beforeField" and a field value indicating the field number (0 for the first field).
    2. Each node in the field is then visited, recursively, in order.
    3. After the last node in the field is visited, the function is called with stage "afterField" and the field number.
  3. Once all of the fields have been visited, the function is called a final time for the node with stage "after".

Example: Visitation order for ½ x

before fraction
  beforeField 0 of fraction
     before digit 1
     after digit 1
  afterField 0 of fraction
  beforeField 1 of fraction
     before digit 2
     after digit 2
  afterField 1 of fraction
after fraction
before variable x
after variable x

Before each call to the visitor function, the walker position is updated to match the position of the visited node. Note that regardless of stage, the position is always the same: if the position were a caret position, the caret would be just before the node.

The order of node visits is determined by the document structure when the visit began. If a node is moved while visiting, it will be visited in its original order as if it had not moved. If a new node is inserted while visiting, it will be skipped by the visitor as if it were not present. If a node is removed while visiting, no further visits to that node will be made. Thus, if a node is removed at the "before" stage, then no "after" stage will occur, no fields will be visited, and none of node's children will be visited at all.

Hierarchy

  • WalkerVisitMethods

Index

Methods

document

  • Visits every node in the editor document. Note that the document root is not visited, since it does not have a position inside the document. The document root node would be the first and last node visited, so it can easily be handled as a special case if desired.

    see

    Node

    Parameters

    Returns void

position

  • Visits the node at the current walker position, if any. (As with all visits, all of the node's descendants are also visited.)

    Parameters

    Returns void

selection

  • Visits the nodes in the current editor selection, if any.

    Parameters

    Returns void

This API is still under development and is subject to change. Copyright © Math I Can Do Solutions Incorporated and/or its licensors.