-
Notifications
You must be signed in to change notification settings - Fork 747
Add stringer-alike String methods to non-string LSP enums #2148
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
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 PR adds String() methods to non-string LSP enumerations in the generated protocol code, making them compatible with Go's Stringer interface. The implementation uses a stringer-style approach with string concatenation and index arrays for memory efficiency.
Key changes:
- Generator now creates
String()methods for all non-string enums - Bitflag enums (currently only
WatchKind) get special handling to display combined flags as "Flag1|Flag2" - Regular enums use an index-based lookup for efficient string conversion
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/lsp/lsproto/_generate/generate.mts | Added logic to generate String() methods for non-string enums, with separate handling for bitflag vs. regular enums |
| internal/lsp/lsproto/lsp_generated.go | Generated String() methods for 24 different enum types using the stringer-style pattern |
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
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
No description provided.