module

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:

  1. Path call Foo::bar(...) → "Foo::bar"
  2. Receiver chain obj.users.find(...) → "obj.users.find"
  3. Bare call foo(...) → "foo"
  4. 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

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's RESERVED set so callers see no behaviour change when swapping the implementation.

Instance methods

callees_for_body_text(body_text : String, file_path : String, start_line : Int32) : Array(Entry)

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.

Source
callees_in_body(body : LibTreeSitter::TSNode, source : String, file_path : String) : Array(Entry)

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.

Source