Skip to content

fix: resolve same-file call targets to qualified names#38

Closed
n24q02m wants to merge 1 commit intotirth8205:mainfrom
n24q02m:fix/resolve-call-targets
Closed

fix: resolve same-file call targets to qualified names#38
n24q02m wants to merge 1 commit intotirth8205:mainfrom
n24q02m:fix/resolve-call-targets

Conversation

@n24q02m
Copy link
Contributor

@n24q02m n24q02m commented Mar 20, 2026

Summary

Fixes #20.

callers_of and callees_of queries return empty results because the parser stores CALLS edges with bare target names (e.g. FirebaseAuth) while graph queries look up qualified names (e.g. main.go::FirebaseAuth).

This PR adds a post-parse resolution step that builds a symbol table from parsed nodes and qualifies bare call targets that match local definitions.

Before: callers_of("main.go::FirebaseAuth") returns 0 results, even though setupRoutes() calls FirebaseAuth() in the same file.

After: The CALLS edge target is resolved from FirebaseAuth to main.go::FirebaseAuth, so callers_of correctly returns setupRoutes.

External calls (names not defined in the file) remain bare -- this is correct since they reference symbols in other files or libraries.

Changes

  • code_review_graph/parser.py:
    • Added _resolve_call_targets() method that builds a symbol table and qualifies bare targets
    • Called at the end of parse_bytes() after tree extraction

Test plan

  • Go file with func FirebaseAuth() and func setupRoutes() { FirebaseAuth() } produces a CALLS edge with qualified target main.go::FirebaseAuth
  • Python file with local function calls produces qualified CALLS targets
  • External library calls (e.g. json.loads()) remain bare (no :: in target)
  • Existing tests pass

After parsing all nodes in a file, build a symbol table of local
definitions (functions, classes, types). For each CALLS edge with a
bare target name, check if it matches a local definition and replace
it with the qualified name (file_path::name).

External calls (names not defined in the file) remain bare.

This fixes callers_of/callees_of returning empty results for
functions called by bare name, which is the common case in Go
(middleware chaining), Python (helper functions), and most other
languages.

Closes tirth8205#20

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tirth8205 added a commit that referenced this pull request Mar 20, 2026
- Multi-word AND search logic for search_nodes (#37 by n24q02m)
- Resolve same-file bare call targets to qualified names (#38 by n24q02m)
- Output pagination with truncation flag for impact radius (#39 by n24q02m)
- Update tests to handle qualified call targets from _resolve_call_targets

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tirth8205
Copy link
Owner

Integrated into main via a344eaf. Thanks for the contribution! Same-file call target resolution is now live.

@tirth8205 tirth8205 closed this Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

query_graph callers_of/callees_of returns empty — edge targets stored as bare names

2 participants