pub trait Visitor {
// Provided methods
fn enter_node(&mut self, _node: &SyntaxNode) -> ControlFlow<()> { ... }
fn leave_node(&mut self, _node: &SyntaxNode) -> ControlFlow<()> { ... }
fn visit_token(&mut self, _token: &SyntaxToken) -> ControlFlow<()> { ... }
}Expand description
Trait for visiting a sipha syntax tree.
Override only the methods you need; default implementations do nothing and
return WalkResult::Continue(()). Use node.kind() or
node.kind_as::<YourKind>() to dispatch on node type.
§Order of calls
For each node, enter_node is called first (pre-order), then children are
visited, then leave_node (post-order). This supports scoping: push scope
in enter_node for block/function nodes, pop in leave_node.
§Early termination
Return WalkResult::Break(()) from any callback to stop the walk; the
break propagates to the caller of walk.
§Collecting results
Store any result in your visitor struct and read it after walk returns.
Provided Methods§
Sourcefn enter_node(&mut self, _node: &SyntaxNode) -> ControlFlow<()>
fn enter_node(&mut self, _node: &SyntaxNode) -> ControlFlow<()>
Called before visiting this node’s children (pre-order).
Sourcefn leave_node(&mut self, _node: &SyntaxNode) -> ControlFlow<()>
fn leave_node(&mut self, _node: &SyntaxNode) -> ControlFlow<()>
Called after visiting this node’s children (post-order).
Sourcefn visit_token(&mut self, _token: &SyntaxToken) -> ControlFlow<()>
fn visit_token(&mut self, _token: &SyntaxToken) -> ControlFlow<()>
Called for each token when WalkOptions::visit_tokens is true.
Trivia is included only when WalkOptions::visit_trivia is true.