Skip to main content

ast_node_count

Function ast_node_count 

Source
pub fn ast_node_count(tree: &Tree) -> usize
Expand description

Count total tree-sitter nodes (named + anonymous) in a parse tree.

Walks the tree once, same O(n) pass as error_ratio but without the error-tracking overhead. Useful as a proxy for computational surface area in deployment metrics.

Iterates with a single reusable cursor instead of allocating a fresh TreeCursor per node, which the recursive node.children(&mut node.walk()) form does for every node in the tree.