Skip to content

Commit

Permalink
Fix sanitizeSymbols for enum names
Browse files Browse the repository at this point in the history
  • Loading branch information
wilmveel committed Nov 9, 2023
1 parent 8f1feab commit be7de7e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class JavaEmitter(
|${SPACER}${SPACER}return label;
|${SPACER}}
""".trimMargin()
"public enum $name {\n${SPACER}${entries.joinToString(",\n${SPACER}") { enum -> "${enum.sanitize()}(\"${enum}\")" }};\n${body}\n${toString}\n}\n"
"public enum ${name.sanitizeSymbol()} {\n${SPACER}${entries.joinToString(",\n${SPACER}") { enum -> "${enum.sanitize()}(\"${enum}\")" }};\n${body}\n${toString}\n}\n"
}

override fun Refined.emit() = withLogging(logger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class KotlinEmitter(

override fun Enum.emit() = withLogging(logger) {
fun String.sanitize() = replace("-", "_").let { if (it.first().isDigit()) "_$it" else it }
"enum class ${name} (val label: String){\n${SPACER}${entries.joinToString(",\n${SPACER}") { "${it.sanitize().sanitizeKeywords()}(\"$it\")" }};\n\n${SPACER}override fun toString(): String {\n${SPACER}${SPACER}return label\n${SPACER}}\n}\n"
"enum class ${name.sanitizeSymbol()} (val label: String){\n${SPACER}${entries.joinToString(",\n${SPACER}") { "${it.sanitize().sanitizeKeywords()}(\"$it\")" }};\n\n${SPACER}override fun toString(): String {\n${SPACER}${SPACER}return label\n${SPACER}}\n}\n"
}

override fun Refined.emit() = withLogging(logger) {
Expand Down

0 comments on commit be7de7e

Please sign in to comment.