-
-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for complex type names #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for complex type names #3
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds support for multi-word named types, allowing enum generators to process types such as "jobStatus" rather than treating them as errors.
- Added support for complex (camel case) type names in the generator
- Introduced helper functions (splitCamelCase, getFileNameForType) to handle name conversions
- Updated tests and examples to cover the new behavior
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/generator/testdata/job_status.go | Added test data for multi-word type "jobStatus" |
| internal/generator/generator_test.go | Extended tests to cover generation with complex names |
| internal/generator/generator.go | Modified title casing and output naming functions; added helper functions for name conversion |
| _examples/status/status.go | Updated go:generate comments and added multi-word type definition |
| _examples/status/job_status_test.go | Added tests for the new multi-word enum type |
| _examples/status/job_status_enum.go | Generated enum code for "jobStatus" with new parsing logic |
| README.md | Updated generator option description for type naming |
Comments suppressed due to low confidence (1)
internal/generator/generator.go:243
- [nitpick] The comment for getFileNameForType uses an example 'JobStatus', but the generator expects a private (lowercase) type name. Consider updating the comment to clarify the expected input case.
// getFileNameForType returns the file name for the generated enum code based on the type name.
4381757 to
1bca6b0
Compare
1bca6b0 to
0b753d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds support for multi-word named types, enabling the generator to correctly process types like "jobStatus" that were previously treated as errors. Key changes include:
- Adding a new testdata file and examples for the multi-word type "jobStatus".
- Updating the generator logic to derive snake_case file names from camel-cased type names.
- Extending tests and documentation to support and ensure proper functionality for complex type names.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/generator/testdata/job_status.go | Added a sample multi-word named type for testing. |
| internal/generator/generator_test.go | Updated tests to verify generation with complex type names. |
| internal/generator/generator.go | Modified type name validation and file name generation using splitCamelCase. |
| _examples/status/status.go | Added a new go:generate directive and jobStatus type example. |
| _examples/status/job_status_test.go | Introduced tests covering enum behavior for the jobStatus type. |
| _examples/status/job_status_enum.go | Generated enum code for the jobStatus type. |
| README.md | Updated generator options description regarding type privacy. |
Comments suppressed due to low confidence (3)
internal/generator/generator.go:48
- The check for lowercase only inspects the first character of the type name. If multi-word type names are expected to include uppercase letters internally, consider clarifying in the error message or inline documentation that only the initial character is validated.
if !unicode.IsLower(rune(typeName[0])) {
internal/generator/generator.go:24
- [nitpick] Consider adding a comment to explain the use of 'cases.NoLower', so future maintainers understand how it affects the title casing of complex type names.
var titleCaser = cases.Title(language.English, cases.NoLower)
README.md:89
- [nitpick] The README mentions that the type must be private but does not specify that only the first character's case is enforced. Consider clarifying that the enforcement only requires the first letter to be lowercase for supporting multi-word type names.
- `-type` (required): the name of the type to generate enum for (must be private)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx!
This pull request adds support for multi-word named types (for example,
jobStatus). Although these types remain private, the previous version treated them as errors.