Walk a CST the way @babel/traverse walks a Babel AST: every node -- named,
unnamed, ignored, and leaves alike -- is visited pre-order, and the visitor
steers the walk through the CSTPath it is handed (skip a subtree, stop
the walk, replace or remove nodes).
The walk is non-mutating. It returns the tree with every replacement applied:
a subtree nothing replaced in is returned as the very same objects, while a
node with a changed descendant is rebuilt -- same span, type, and flags, new
children, and neither value nor a cached hash carried over, since both may
have depended on the old children. Replacements made before a
CSTPath.stop still apply; the rest of the tree is returned as it
was.
Walk a CST the way @babel/traverse walks a Babel AST: every node -- named, unnamed, ignored, and leaves alike -- is visited pre-order, and the visitor steers the walk through the CSTPath it is handed (skip a subtree, stop the walk, replace or remove nodes).
The walk is non-mutating. It returns the tree with every replacement applied: a subtree nothing replaced in is returned as the very same objects, while a node with a changed descendant is rebuilt -- same span, type, and flags, new children, and neither
valuenor a cached hash carried over, since both may have depended on the old children. Replacements made before a CSTPath.stop still apply; the rest of the tree is returned as it was.