Conversation
allows enum constants to have comment annotations like // enum:alias=rw,read-write that enable parsing multiple string representations for the same enum value. - add parseAliasComment() to extract aliases from inline comments - add validateAliases() to check for conflicts and duplicates - update template to include aliases in parse map - make parsing always case-insensitive (fixes lowercase mode bug) - add comprehensive tests for alias feature - update README with alias documentation
There was a problem hiding this comment.
Pull request overview
This PR adds support for parsing aliases on enum constants, enabling multiple string representations to map to the same enum value. The implementation also fixes a bug where case-insensitive parsing wasn't working correctly in lowercase mode.
Key Changes:
- Added
parseAliasComment()function to extract aliases from inline comments usingenum:alias=directive - Added
validateAliases()to prevent duplicate aliases and conflicts with canonical names - Modified parsing to always be case-insensitive using
strings.ToLower(v)regardless of-lowerflag - Updated template to include aliases in parse map with duplicate key prevention logic
- Added comprehensive test coverage for alias functionality
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/generator/generator.go | Core implementation of alias parsing, validation, and storage in constValue/Value structs |
| internal/generator/enum.go.tmpl | Updated template to generate parse map with aliases and always use case-insensitive lookup |
| internal/generator/generator_test.go | Added comprehensive unit tests for alias parsing, validation, and generation |
| internal/generator/integration_test.go | Added integration test for alias functionality |
| internal/generator/testdata/integration/status_enum.go | Updated generated code to reflect new case-insensitive parsing behavior |
| internal/generator/testdata/integration/priority_enum.go | Fixed import ordering (standard library before third-party) |
| internal/generator/testdata/integration/permission.go | Added test enum with aliases for integration testing |
| README.md | Added comprehensive documentation for alias feature with examples and usage rules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Changes