Skip to main content

Module ast

Module ast 

Source
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§

WalkStats
What a walk actually covered.

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 ERROR or MISSING node 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 None if it is not valid UTF-8.
start_line
The 1-based line a node starts on, for Symbol and Relationship records.
walk
Visit root and all its descendants in pre-order, depth-first.