feat(protogen): generate oneof case accessors and group clear - #365
Merged
Conversation
Teach the builder generator to handle protobuf `oneof` groups. For each real oneof (proto3 synthetic oneofs backing `optional` fields are excluded via getRealOneofs()), the generated optional interface and builder now expose: - `getXxxCase()` returning protobuf's generated `XxxCase` enum, so the selected member is inspectable through the fluent builder chain - `clearXxx()` that resets the whole group Member setters/hasXxx()/clearXxx() were already emitted since oneof members carry presence; this adds the group-level discriminator and clear. Refactors the field clear/declareClear helpers into name-based variants reused by the oneof methods. Adds a Payment oneof message to the proto3 test proto and integration tests covering case discrimination and group clear, and updates README/AGENTS docs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BNGeaXZiMQ98UUCBi1yKgi
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.
Teach the builder generator to handle protobuf
oneofgroups. For eachreal oneof (proto3 synthetic oneofs backing
optionalfields areexcluded via getRealOneofs()), the generated optional interface and
builder now expose:
getXxxCase()returning protobuf's generatedXxxCaseenum, so theselected member is inspectable through the fluent builder chain
clearXxx()that resets the whole groupMember setters/hasXxx()/clearXxx() were already emitted since oneof
members carry presence; this adds the group-level discriminator and
clear. Refactors the field clear/declareClear helpers into name-based
variants reused by the oneof methods.
Adds a Payment oneof message to the proto3 test proto and integration
tests covering case discrimination and group clear, and updates
README/AGENTS docs.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01BNGeaXZiMQ98UUCBi1yKgi