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:

  1. Find the (class_name, method_name) method_declaration in the already-parsed root.
  2. Walk its body for method_invocation nodes.
  3. For each, reconstruct a textual callee:
    • foo()foo
    • service.save(x)service.save
    • this.foo()this.foo
    • Foo.bar() (static) → Foo.bar
    • getFoo().bar() → "" (chained on a call — dropped as noise, mirroring the Python/Go chained-call filter)

Cross-file definition resolution (e.g. userService.saveUserServiceImpl.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.cr

Instance Method Summary

Instance Method Detail

def 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. Returns every 1-hop method_invocation callee inside that body.


[View source]
def 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 — 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.


[View source]
def callees_in_method(root : LibTreeSitter::TSNode, source : String, file_path : String, class_name : String, method_name : String) : Array(Tuple(String, String, Int32)) #

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.


[View source]