module
Noir::RustCalleeExtractorTS
Overview
Tree-sitter-backed Rust callee extractor. Replaces the regex
line-scanner in Noir::RustCalleeExtractor with an AST walker over
the vendored tree-sitter-rust grammar. Catches calls that span
lines, sees through string/comment context for free (the parser
already does that), and exposes a parse-once entry point so analyzers
can share a single parsed tree per file.
Three call shapes are recognised, mirroring the legacy extractor:
- Path call
Foo::bar(...)→ "Foo::bar" - Receiver chain
obj.users.find(...)→ "obj.users.find" - Bare call
foo(...)→ "foo" - Macro invocation
println!(...)→ "println!"std::format!(...)→ "std::format!"
Receivers rooted on another call result (foo().bar()) are dropped
as noise — same convention used by Noir::JavaCalleeExtractor and
Noir::GoCalleeExtractor.
Extended Modules
Defined in:
miniparsers/rust_callee_extractor_ts.crConstant Summary
-
RESERVED =
Set {"as", "async", "await", "break", "const", "continue", "crate", "dyn", "else", "enum", "extern", "false", "fn", "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref", "return", "self", "Self", "static", "struct", "super", "trait", "true", "type", "unsafe", "use", "where", "while", "Ok", "Err", "Some", "None", "format", "format!", "vec", "vec!", "println", "println!"} -
Rust keywords + commonly-aliased control-flow constructors that surface as
call_expressions but carry no useful callee signal. Kept in sync with the legacy regex extractor'sRESERVEDset so callers see no behaviour change when swapping the implementation.
Instance Method Summary
-
#callees_for_body_text(body_text : String, file_path : String, start_line : Int32) : Array(Entry)
Drop-in replacement for
Noir::RustCalleeExtractor.callees_for_body. -
#callees_in_body(body : LibTreeSitter::TSNode, source : String, file_path : String) : Array(Entry)
Walk
body(typically ablockfrom afunction_item'sbodyfield, but any subtree works) and return every callee inside.
Instance Method Detail
Drop-in replacement for Noir::RustCalleeExtractor.callees_for_body.
Wraps body_text in a synthetic fn _() { ... } so the grammar
has a complete top-level item to parse, then translates wrapper-
relative rows back to file-relative ones (start_line is the
1-based file line of the body's first line).
This shim exists for back-compat with the existing engine that
extracts function bodies as raw text. New code should parse the
file once and call #callees_in_body with the body node directly.
Walk body (typically a block from a function_item's body
field, but any subtree works) and return every callee inside.
Line numbers are taken straight from the tree-sitter node row, so
source must be the full file text that was parsed — callers
using a wrapper or sub-extract should use #callees_for_body_text
instead.