-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rosetta): correctly emit multi-line string literals (#2419)
This fixes hox multi-line string literals and template expressions are rendered in all supported languages, leveraging idiomatic multi-line literals where possible (i.e: everywhere but Java). --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
- Loading branch information
1 parent
aeb624d
commit a30a996
Showing
14 changed files
with
126 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
packages/jsii-rosetta/test/translations/expressions/string_interpolation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
string x = "world"; | ||
string y = "well"; | ||
Console.WriteLine($"Hello, {x}, it works {y}!"); | ||
Console.WriteLine($"Hello, {x}, it works {y}!"); | ||
|
||
// And now a multi-line expression | ||
Console.WriteLine($@" | ||
Hello, {x}. | ||
It works {y}! | ||
"); |
3 changes: 3 additions & 0 deletions
3
packages/jsii-rosetta/test/translations/expressions/string_interpolation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
String x = "world"; | ||
String y = "well"; | ||
System.out.println(String.format("Hello, %s, it works %s!", x, y)); | ||
|
||
// And now a multi-line expression | ||
System.out.println(String.format("%nHello, %s.%n%nIt works %s!%n", x, y)); |
9 changes: 8 additions & 1 deletion
9
packages/jsii-rosetta/test/translations/expressions/string_interpolation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
x = "world" | ||
y = "well" | ||
print(f"Hello, {x}, it works {y}!") | ||
print(f"Hello, {x}, it works {y}!") | ||
|
||
# And now a multi-line expression | ||
print(f""" | ||
Hello, {x}. | ||
It works {y}! | ||
""") |
13 changes: 10 additions & 3 deletions
13
packages/jsii-rosetta/test/translations/expressions/string_interpolation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
const x = "world"; | ||
const y = "well"; | ||
console.log(`Hello, ${x}, it works ${y}!`); | ||
const x = 'world'; | ||
const y = 'well'; | ||
console.log(`Hello, ${x}, it works ${y}!`); | ||
|
||
// And now a multi-line expression | ||
console.log(` | ||
Hello, ${x}. | ||
It works ${y}! | ||
`); |
9 changes: 9 additions & 0 deletions
9
packages/jsii-rosetta/test/translations/expressions/string_literal.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
string literal = @" | ||
This si a multiline string literal. | ||
""It's cool!"". | ||
YEAH BABY!! | ||
Litteral \n right here (not a newline!) | ||
"; |
1 change: 1 addition & 0 deletions
1
packages/jsii-rosetta/test/translations/expressions/string_literal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
String literal = "\nThis si a multiline string literal.\n\n\"It's cool!\".\n\nYEAH BABY!!\n\nLitteral \\n right here (not a newline!)\n"; |
9 changes: 9 additions & 0 deletions
9
packages/jsii-rosetta/test/translations/expressions/string_literal.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
literal = """ | ||
This si a multiline string literal. | ||
"It's cool!". | ||
YEAH BABY!! | ||
Litteral \\n right here (not a newline!) | ||
""" |
9 changes: 9 additions & 0 deletions
9
packages/jsii-rosetta/test/translations/expressions/string_literal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const literal = ` | ||
This si a multiline string literal. | ||
"It's cool!". | ||
YEAH BABY!! | ||
Litteral \\n right here (not a newline!) | ||
`; |