module
Noir::JavaCalleeExtractor
Overview
Tree-sitter-backed Java 1-hop callee extractor. Parallels
Noir::PythonCalleeExtractor / Noir::GoCalleeExtractor for JVM
analyzers (Spring + framework-adapter siblings). Java's
method_invocation node carries the receiver in an object field
and the method name in a name field, so 1-hop extraction reduces
to:
- Find the (class_name, method_name)
method_declarationin the already-parsed root. - Walk its body for
method_invocation/method_referencenodes. - For each, reconstruct a textual callee:
foo()→fooservice.save(x)→service.savethis.foo()→this.fooFoo.bar()(static) →Foo.barMessage::body→Message.bodythis::toDto→this.toDtogetFoo().bar()→ "" (chained on a call — dropped as noise, mirroring the Python/Go chained-call filter)
Cross-file definition resolution (e.g. userService.save →
UserServiceImpl.save in another file) is intentionally out of
scope for this first cut. Callee#path therefore points at the
call site, matching the honest scope on every other analyzer.
Extended Modules
Defined in:
miniparsers/java_callee_extractor.crInstance Method Summary
-
#build_method_decl_index(root : LibTreeSitter::TSNode, source : String) : Hash(String, Int32 | Nil)
Build a same-file method-name -> start row map.
-
#callees_in_body(body : LibTreeSitter::TSNode, source : String, file_path : String) : Array(Tuple(String, String, Int32))
Generic body walker for analyzers/extractors that already have the handler method/lambda body node.
-
#callees_in_lambda(body : LibTreeSitter::TSNode, source : String, file_path : String) : Array(Tuple(String, String, Int32))
Lambda/handler entry point used by DSL analyzers (Javalin, Spark, …) where the handler body is a
lambda_expression's body — ablockor a single expression — not amethod_declaration. -
#callees_in_method(root : LibTreeSitter::TSNode, source : String, file_path : String, class_name : String, method_name : String, target_line : Int32 | Nil = nil, decl_index : Hash(String, Int32 | Nil) | Nil = nil) : Array(Tuple(String, String, Int32))
Find the matching method_declaration in
rootand return every 1-hop method_invocation callee inside its body as{name, file_path, file_line_1_based}.
Instance Method Detail
Build a same-file method-name -> start row map. nil value marks
an ambiguous name (multiple method_declarations share it), so the
caller knows to keep the call site location instead of guessing
which overload to point at. Conservative by design — overloads,
qualified non-this calls, and missing declarations all stay at
call site.
Generic body walker for analyzers/extractors that already have the
handler method/lambda body node. Returns every 1-hop
method_invocation callee inside that body.
Lambda/handler entry point used by DSL analyzers (Javalin, Spark,
…) where the handler body is a lambda_expression's body — a
block or a single expression — not a method_declaration.
Caller is responsible for locating the body (the JVM lambda DSL
extractor already does this for parameter scanning) and passing
it in. Walks the body and returns every 1-hop method_invocation
callee.
Find the matching method_declaration in root and return every
1-hop method_invocation callee inside its body as
{name, file_path, file_line_1_based}. Empty array when the
method can't be located or its body is missing.