Expand description
Shared tree-sitter traversal primitives.
Behind the ast feature so that consumers who only read the graph — the
store, the query layer — do not pull a parser they never call.
Every adapter previously carried its own copy of a recursive walk_tree.
Recursion is the wrong shape here: node depth is attacker- and
generator-controlled (a machine-generated initializer nests one level per
element), adapters parse files on rayon workers whose stacks are smaller
than the main thread’s, and a stack overflow aborts the process rather than
unwinding, so one pathological file would take down an entire analyze run.
walk is iterative and depth-bounded instead, and reports what it skipped
so callers can turn truncation into a diagnostic rather than a silent gap.
Structs§
Constants§
- MAX_
TREE_ DEPTH - Maximum node depth visited by
walk.
Functions§
- end_
line - The 1-based line a node ends on.
- field_
text - The text of a named field of
node. - first_
error_ line - The first
ERRORorMISSINGnode in the subtree, for locating a parse diagnostic on a line. - first_
line_ of - The first line of a node’s text, for use as a symbol signature.
- has_
parse_ error - True if the subtree contains a node tree-sitter could not parse.
- node_
text - The source text a node spans, or
Noneif it is not valid UTF-8. - start_
line - The 1-based line a node starts on, for
SymbolandRelationshiprecords. - walk
- Visit
rootand all its descendants in pre-order, depth-first.