Skip to content
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

Fix issue #1819 incorrect enum value name generation with leading digits #1821

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TheMinefighter
Copy link

Currently any character complying with isJavaIdentifierPart but not isJavaIdentifierStart (e.g. digits) at the beginning of the name of an enum value will make buildCEnumConstants return null (as isJavaIdentifier fails) which causes the enums values to be named VALUE_x (method is called again but with needsToGenerateMemberName).

This PR fixes that by checking whether the first character of an enum value name complies with isJavaIdentifierStart, if not an underscore will be added to the StringBuilder that builds the name of the value. As that check is executed before the normal name generation loop that underscore is the first char of the StringBuilder and acts a prefix to the name. That behavior is consistent with the one found in other places of the java code generation, for example a package called 12 will be renamed to _12.

Note: There was a typo in an earlier version of this PR

… leading digits

The first character of an enum value name is checked whether it complies with isJavaIdentifierStart, if not an underscore prefix will be added to that name.
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