Noir::RustCalleeExtractorTS
Inherits Noir::CalleeExtractorBase
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.
Constants
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's RESERVED set so
callers see no behaviour change when swapping the implementation.
Instance methods
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.