Summary
For Java methods that return domain objects (non-primitive types), the
Tree-sitter parser incorrectly extracts the return type identifier as
the function node name instead of the actual method name. This makes
query_graph("callers_of", ...) and all function-level queries
unreliable for Java codebases.
Reproduction
# Create a Java class with domain object return types
cat > /tmp/test-repo/src/InvoiceService.java << 'EOF'
public class InvoiceService {
public MyDomainObject processBusinessLogic(String param) {
return new MyDomainObject();
}
public void simpleMethod(String param) {
// void method — works correctly
}
}
EOF
cd /tmp/test-repo
code-review-graph build
# Query by actual method name — returns 0 results
code-review-graph query_graph callers_of processBusinessLogic
Returns "summary": "Found 0 result(s)" despite the method
existing in the codebase.
Root cause
Raw node data in SQLite shows:
Function node name: MyDomainObject ← return type (WRONG)
Expected node name: processBusinessLogic ← method name (CORRECT)
The Tree-sitter Java grammar traversal is picking up the first
identifier in the method_declaration node (which is the return
type) instead of the identifier inside method_declarator.
Java AST structure:
method_declaration
modifiers
type_identifier ← "MyDomainObject" (being picked up incorrectly)
method_declarator
identifier ← "processBusinessLogic" (should be picked up)
formal_parameters
Affected queries
callers_of — always returns empty for methods with domain object return types
callees_of — same issue
query_graph function lookups — method nodes not found by actual name
semantic_search_nodes — indexes wrong names
Not affected
- Methods returning primitives (
void, int, String, boolean)
- File-level features (
get_architecture_overview, get_review_context)
get_impact_radius — uses file-level traversal, unaffected
Expected behavior
The function node name should always be the method name
(processBusinessLogic), not the return type (MyDomainObject).
The fix should target method_declarator → identifier in the
Java Tree-sitter grammar traversal inside parser.py.
Environment
- code-review-graph v2.3.2
- Java Spring Boot microservice codebase (500+ files)
- macOS
- Python 3.x
Summary
For Java methods that return domain objects (non-primitive types), the
Tree-sitter parser incorrectly extracts the return type identifier as
the function node name instead of the actual method name. This makes
query_graph("callers_of", ...)and all function-level queriesunreliable for Java codebases.
Reproduction
Returns
"summary": "Found 0 result(s)"despite the methodexisting in the codebase.
Root cause
Raw node data in SQLite shows:
Function node name: MyDomainObject ← return type (WRONG)
Expected node name: processBusinessLogic ← method name (CORRECT)
The Tree-sitter Java grammar traversal is picking up the first
identifierin themethod_declarationnode (which is the returntype) instead of the
identifierinsidemethod_declarator.Java AST structure:
method_declaration
modifiers
type_identifier ← "MyDomainObject" (being picked up incorrectly)
method_declarator
identifier ← "processBusinessLogic" (should be picked up)
formal_parameters
Affected queries
callers_of— always returns empty for methods with domain object return typescallees_of— same issuequery_graphfunction lookups — method nodes not found by actual namesemantic_search_nodes— indexes wrong namesNot affected
void,int,String,boolean)get_architecture_overview,get_review_context)get_impact_radius— uses file-level traversal, unaffectedExpected behavior
The function node name should always be the method name
(
processBusinessLogic), not the return type (MyDomainObject).The fix should target
method_declarator → identifierin theJava Tree-sitter grammar traversal inside
parser.py.Environment