-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Handle new escapes for newlines and spaces * Handle `\"` escapes inside text blocks to prevent `\"""` being treated as a delimiter * Improve diagnostic positions for invalid escapes inside text blocks PiperOrigin-RevId: 575393801
- Loading branch information
Showing
7 changed files
with
269 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
=== T.java === | ||
public class T { | ||
public static final String a = | ||
""" | ||
a \ | ||
b \ | ||
"""; | ||
} |
92 changes: 92 additions & 0 deletions
92
javatests/com/google/turbine/lower/testdata/textblock2.test
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,92 @@ | ||
=== T.java === | ||
class T { | ||
static final String a = """ | ||
line 1 | ||
line 2 | ||
line 3 | ||
"""; | ||
|
||
static final String b = """ | ||
line 1 | ||
line 2 | ||
line 3"""; | ||
|
||
static final String c = """ | ||
"""; | ||
static final String g = | ||
""" | ||
<html>\r | ||
<body>\r | ||
<p>Hello, world</p>\r | ||
</body>\r | ||
</html>\r | ||
"""; | ||
static final String h = | ||
""" | ||
"When I use a word," Humpty Dumpty said, | ||
in rather a scornful tone, "it means just what I | ||
choose it to mean - neither more nor less." | ||
"The question is," said Alice, "whether you | ||
can make words mean so many different things." | ||
"The question is," said Humpty Dumpty, | ||
"which is to be master - that's all." | ||
"""; | ||
|
||
static final String i = """ | ||
String empty = ""; | ||
"""; | ||
|
||
static final String j = | ||
""" | ||
String text = \""" | ||
A text block inside a text block | ||
\"""; | ||
"""; | ||
|
||
static final String k = """ | ||
A common character | ||
in Java programs | ||
is \""""; | ||
|
||
static final String l = | ||
""" | ||
The empty string literal | ||
is formed from " characters | ||
as follows: \"\""""; | ||
|
||
static final String m = | ||
""" | ||
" | ||
"" | ||
""\" | ||
""\"" | ||
""\""" | ||
""\"""\" | ||
""\"""\"" | ||
""\"""\""" | ||
""\"""\"""\" | ||
""\"""\"""\"" | ||
""\"""\"""\""" | ||
""\"""\"""\"""\" | ||
"""; | ||
|
||
static final String n = | ||
""" | ||
Lorem ipsum dolor sit amet, consectetur adipiscing \ | ||
elit, sed do eiusmod tempor incididunt ut labore \ | ||
et dolore magna aliqua.\ | ||
"""; | ||
|
||
static final String o = """ | ||
red \s | ||
green\s | ||
blue \s | ||
"""; | ||
|
||
static final String p = | ||
"public void print(Object o) {" | ||
+ """ | ||
System.out.println(Objects.toString(o)); | ||
} | ||
"""; | ||
} |
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