Skip to content

feat(java): resolve Java imports to file paths#280

Merged
tirth8205 merged 1 commit intotirth8205:mainfrom
krmahadevan:bugfix/resolve_java_imports_to_file_paths
Apr 18, 2026
Merged

feat(java): resolve Java imports to file paths#280
tirth8205 merged 1 commit intotirth8205:mainfrom
krmahadevan:bugfix/resolve_java_imports_to_file_paths

Conversation

@krmahadevan
Copy link
Copy Markdown
Contributor

Java imports like import com.example.auth.User were stored as raw dot-notation strings because _do_resolve_module() had no Java branch. This caused importers_of queries to return 0 — the query looks for file path targets, but the stored edges had raw import strings.

Adds a Java branch that converts dot-notation to a relative path (com/example/auth/User.java) and walks up from the caller's directory to find the source root. This resolves same-source-root imports (the common case in Maven modules).

Also handles:

  • Static imports (import static pkg.Class.member) — strips the member name and resolves to the class file
  • Wildcard imports (import pkg.*) — skipped, can't resolve to one file
  • JDK/library imports (java.util.*) — remain unresolved (no local file)

Java imports like `import com.example.auth.User` were stored as raw
dot-notation strings because _do_resolve_module() had no Java branch.
This caused `importers_of` queries to return 0 — the query looks for
file path targets, but the stored edges had raw import strings.

Adds a Java branch that converts dot-notation to a relative path
(com/example/auth/User.java) and walks up from the caller's directory
to find the source root. This resolves same-source-root imports (the
common case in Maven modules).

Also handles:
- Static imports (import static pkg.Class.member) — strips the member
name and resolves to the class file
- Wildcard imports (import pkg.*) — skipped, can't resolve to one file
- JDK/library imports (java.util.*) — remain unresolved (no local file)
@tirth8205 tirth8205 merged commit 088c281 into tirth8205:main Apr 18, 2026
1 check passed
npkriami18 pushed a commit to npkriami18/code-review-graph that referenced this pull request Apr 21, 2026
Java imports like `import com.example.auth.User` were stored as raw
dot-notation strings because _do_resolve_module() had no Java branch.
This caused `importers_of` queries to return 0 — the query looks for
file path targets, but the stored edges had raw import strings.

Adds a Java branch that converts dot-notation to a relative path
(com/example/auth/User.java) and walks up from the caller's directory
to find the source root. This resolves same-source-root imports (the
common case in Maven modules).

Also handles:
- Static imports (import static pkg.Class.member) — strips the member
name and resolves to the class file
- Wildcard imports (import pkg.*) — skipped, can't resolve to one file
- JDK/library imports (java.util.*) — remain unresolved (no local file)

(cherry picked from commit 088c281)
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.

2 participants