Skip to content

[gazelle] Handle proto libraries creating split packages#425

Open
shs96c wants to merge 2 commits into
bazel-contrib:mainfrom
shs96c:pr-h-proto-split-package
Open

[gazelle] Handle proto libraries creating split packages#425
shs96c wants to merge 2 commits into
bazel-contrib:mainfrom
shs96c:pr-h-proto-split-package

Conversation

@shs96c
Copy link
Copy Markdown
Collaborator

@shs96c shs96c commented Feb 12, 2026

Builds on #424

Parse .proto files from existing proto_library rules to extract java_package options and register proto-generated classes for resolution. This handles the case where proto_library rules create split packages with regular Java code, such as when a Java class imports types generated by a proto_library in a different Bazel package but the same Java package.

Track same-package type references and defined classes (including inner
classes) through the Java parser, protobuf interface, and Go-side
consumption. This improves dependency resolution when Java packages are
split across multiple Bazel packages.

Key changes:
- Java parser: track samePackageTypeReferences and definedClasses,
  handle class literals (Foo.class), static type imports, type
  parameters in scope, and private inner class filtering
- Protobuf: add same_package_type_references and defined_classes fields
- Go plumbing: map new proto fields, add DefinedClasses to Package,
  add BareInnermostClassName() for inner class resolution
- Resolution: use DefinedClasses for exported class tracking, improve
  non-local import filtering for split packages, index by innermost
  class name, add dedup helpers
Parse .proto files from existing proto_library rules to extract
java_package options and register proto-generated classes for
resolution. This handles the case where proto_library rules create
split packages with regular Java code — e.g., when a Java class
imports types generated by a proto_library in a different Bazel package
but the same Java package.
@shs96c shs96c force-pushed the pr-h-proto-split-package branch from 35c8200 to 839eb5b Compare February 12, 2026 17:43
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