Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static String computeDefaultValue(Shape shape) {
}

public static String computeVariableName(String memberName) {
return memberName.substring(0, 1).toLowerCase() + memberName.substring(1);
return lowercasesFirstChar(memberName).replace("-", "_");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of underscores/string manipulation should we just copy what we do for upper camel case, but make it for lower camel case? since its only variable names shouldn't be publicly impacting, but it could make a nasty delta.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, the issue with CaseFormat is that we need to know the source case convention, but we don't know it.

Copy link
Copy Markdown
Collaborator

@sbiscigl sbiscigl Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it always be lower camelcase with variables?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't control it, it comes from the model file.

}

public static String convertToUpperCamel(String lowerCamel) {
Expand Down Expand Up @@ -506,6 +506,15 @@ public static String computeCoreErrorConstName(String errorName) {
return CoreErrors.VARIANTS.get(errorName);
}

public static String lowercasesFirstChar(final String str) {
if (str.length() > 1) {
return str.substring(0,1).toLowerCase() + str.substring(1);
}
else {
return str.toLowerCase();
}
}

public static String capitalizeFirstChar(final String str) {
if (str.length() > 1) {
return str.substring(0,1).toUpperCase() + str.substring(1);
Expand Down