Skip to main content

traverse_node

Function traverse_node 

Source
pub fn traverse_node<F>(
    node: Node<'_>,
    source: &str,
    facts: &mut Vec<RawNode>,
    parent_idx: Option<usize>,
    language: Language,
    classifier: &F,
) -> Option<usize>
where F: Fn(&Node<'_>, &str) -> Option<(NodeKind, Option<String>, bool)>,
Expand description

Generic recursive traversal of a tree-sitter sub‑tree.

For every node the classifier closure is called. If it returns Some((node_kind, name, is_container)) a RawNode is recorded and – when is_container is true – its children are traversed with the node itself becoming the new parent. If classifier returns None the children are still visited, but the current parent remains unchanged.