Expand description
Structural (AST) search.
Two input dialects are accepted:
- A native tree-sitter query S-expression (anything starting with
(), with captures (@name) and#eq?/#match?predicates. This is the full power of the tree-sitter query language. - A friendlier code pattern with
$NAMEmeta-variables, e.g.fn $NAME($PARAMS) -> Result<$T>, which is compiled into a tree-sitter query: concrete tokens become structure +#eq?constraints, and each meta-variable becomes a wildcard capture. A variadic$$$(optionally$$$NAME) matches any sequence of sibling nodes, sofunction $NAME($$$) { $$$ }matches a function with any parameters and any body. Variadic meta-variables only relax structure; they do not bind a capture.
Matching runs the compiled query over candidate documents. Literal tokens in the pattern double as trigram anchors so the index prunes candidates before parsing.
Structs§
- Compiled
- A compiled structural pattern ready to run against documents.
- Struct
Capture - A capture bound by a structural match.
- Struct
Match - A single structural match within one document.