feat(gazelle): resolve class-level deps via external CrossResolvers#458
Open
shs96c wants to merge 1 commit into
Open
feat(gazelle): resolve class-level deps via external CrossResolvers#458shs96c wants to merge 1 commit into
shs96c wants to merge 1 commit into
Conversation
Class import specs are intentionally never registered in Gazelle's global index, so a class-level FindRulesByImportWithConfig lookup always falls through to registered CrossResolvers. Use this to let external extensions (e.g. wire/proto generators) provide class-level Java resolutions, including split packages where in-repo java/kotlin source coexists with externally generated classes in the same package. Precedence is unchanged: gazelle:resolve > in-repo class > CrossResolver. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
External Gazelle extensions (e.g. a Wire or third-party protobuf generator) can already provide package-level Java resolutions via
resolve.CrossResolver. They cannot provide class-level resolutions, so a split package, where some classes of a Java package come from an external extension's target and hand-written sources in the same package are built by ajava_library/kt_jvm_librarythis extension generates, can't be resolved correctly.The hand-written source registers the package in Gazelle's global index, so package resolution returns a single match. Gazelle only consults
CrossResolveon a zero-result index miss, so the external co-provider is never seen and the split goes undetected.Precedence is preserved:
# gazelle:resolvedirective > in-repo class >CrossResolver.External-plugin contract
An external extension contributes class-level resolutions by implementing
resolve.CrossResolverand answering dotted fully-qualified class names forlang == "java":🤖 Generated with Claude Code