Visitor implementation details and constraints
mainWhen implementing a Visitor for visit():
- Node Replacement: You can replace the
nodeitself, but if you do not returnSKIP, the descendants of the original node will still be walked (this is a known behavior/limitation). - Sibling Manipulation:
- If you add or remove previous siblings of
node(or next siblings inreversemode), you must return a newIndexto specify which sibling to traverse afternodeis processed. - If you add or remove next siblings of
node(or previous siblings inreversemode), the traversal handles this automatically without needing a returnedIndex.
- If you add or remove previous siblings of
- Parent Manipulation: Removing the
childrenproperty of aparentdoes not prevent the children from being traversed.