Skip to content

Commit

Permalink
We can ship 1.0 without multiline for Groovy and Scala, delegate them…
Browse files Browse the repository at this point in the history
… out to #105 and #106.
  • Loading branch information
nedtwigg committed Jan 18, 2024
1 parent 282b7bf commit 71c59c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,20 @@ internal object LiteralString : LiteralFormat<String>() {
when (language) {
Language.SCALA, // scala only does $ substitution for s" and f" strings
Language.JAVA_PRE15,
Language.JAVA -> encodeSingleJava(value)
Language.GROOVY,
Language.JAVA -> encodeSingleJava(value)
Language.KOTLIN -> encodeSingleJavaWithDollars(value)
}
else
when (language) {
// TODO: support triple-quoted strings in scala
// https://github.com/diffplug/selfie/issues/106
Language.SCALA,
// TODO: support triple-quoted strings in groovy
// https://github.com/diffplug/selfie/issues/105
Language.GROOVY,
Language.JAVA_PRE15 -> encodeSingleJava(value)
Language.JAVA -> encodeMultiJava(value)
Language.GROOVY,
Language.KOTLIN -> encodeMultiKotlin(value)
}
override fun parse(str: String, language: Language): String =
Expand All @@ -133,10 +137,12 @@ internal object LiteralString : LiteralFormat<String>() {
when (language) {
Language.SCALA ->
throw UnsupportedOperationException(
"Selfie doesn't support triple-quoted strings in Scala")
"Selfie doesn't support triple-quoted strings in Scala, yet - help wanted: https://github.com/diffplug/selfie/issues/106")
Language.GROOVY ->
throw UnsupportedOperationException(
"Selfie doesn't support triple-quoted strings in Groovy, yet - help wanted: https://github.com/diffplug/selfie/issues/105")
Language.JAVA_PRE15,
Language.JAVA -> parseMultiJava(str)
Language.GROOVY,
Language.KOTLIN -> parseMultiKotlin(str)
}
fun encodeSingleJava(value: String): String = encodeSingleJavaish(value, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import kotlin.test.Test

class UT_InlineIntTest {
@Test fun singleInt() {
expectSelfie(7777).toBe(7_777)
expectSelfie(555).toBe_TODO(789)
}
}

0 comments on commit 71c59c7

Please sign in to comment.