Skip to content

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

Open
krmahadevan wants to merge 1 commit intotirth8205:mainfrom
krmahadevan:bugfix/resolve_java_imports_to_file_paths
Open

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

Conversation

@krmahadevan
Copy link
Copy Markdown

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)
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.

1 participant