Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9548 from harpocrates/alec/t12290
SI-12290: support JDK15 text blocks in Java parser
- Loading branch information
Showing
7 changed files
with
357 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
text-blocks/Invalid1.java:4: error: illegal text block open delimiter sequence, missing line terminator | ||
public static final String badOpeningDelimiter = """non-whitespace | ||
^ | ||
text-blocks/Invalid1.java:4: error: <identifier> expected | ||
public static final String badOpeningDelimiter = """non-whitespace | ||
^ | ||
text-blocks/Invalid1.java:6: error: illegal text block open delimiter sequence, missing line terminator | ||
"""; | ||
^ | ||
text-blocks/Invalid2.java:6: error: unclosed string literal | ||
foo""""; | ||
^ | ||
4 errors |
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,7 @@ | ||
// javaVersion: 15+ | ||
class Invalid1 { | ||
|
||
public static final String badOpeningDelimiter = """non-whitespace | ||
foo | ||
"""; | ||
} |
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,7 @@ | ||
// javaVersion: 15+ | ||
class Invalid2 { | ||
|
||
// Closing delimiter is first three eligible `"""`, not last | ||
public static final String closingDelimiterIsNotScalas = """ | ||
foo""""; | ||
} |
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,61 @@ | ||
==== | ||
A text | ||
|
||
==== | ||
<html> | ||
<body> | ||
<p>Hello, world</p> | ||
</body> | ||
</html> | ||
|
||
==== | ||
SELECT "EMP_ID", "LAST_NAME" FROM "EMPLOYEE_TB" | ||
WHERE "CITY" = 'INDIANAPOLIS' | ||
ORDER BY "EMP_ID", "LAST_NAME"; | ||
|
||
==== | ||
<html> | ||
<body> | ||
<p>Hello, world</p> | ||
</body> | ||
</html> | ||
|
||
==== | ||
<html> | ||
<body> | ||
<p>Hello, world</p> | ||
</body> | ||
</html> | ||
|
||
==== | ||
<html> | ||
<body> | ||
<p>Hello, world</p> | ||
</body> | ||
|
||
</html> | ||
|
||
==== | ||
<html> | ||
|
||
<body> <p>Hello , world</p> | ||
</body> | ||
</html> | ||
|
||
==== | ||
this line has 4 tabs before it | ||
this line has 5 spaces before it and space after it | ||
this line has 2 tabs and 3 spaces before it | ||
this line has 6 spaces before it | ||
|
||
==== | ||
String text = """ | ||
A text block inside a text block | ||
"""; | ||
|
||
==== | ||
foo bar | ||
baz | ||
==== | ||
|
||
==== |
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,30 @@ | ||
// javaVersion: 15+ | ||
/* Using `valueOf` is a way to check that the Java string literals were properly | ||
* parsed, since the parsed value is what the Scala compiler will use when | ||
* resolving the singleton types | ||
*/ | ||
object Test extends App { | ||
println("====") | ||
println(valueOf[TextBlocks.aText.type]) | ||
println("====") | ||
println(valueOf[TextBlocks.html1.type]) | ||
println("====") | ||
println(valueOf[TextBlocks.query.type]) | ||
println("====") | ||
println(valueOf[TextBlocks.html2.type]) | ||
println("====") | ||
println(valueOf[TextBlocks.html3.type]) | ||
println("====") | ||
println(valueOf[TextBlocks.html4.type]) | ||
println("====") | ||
println(valueOf[TextBlocks.html5.type]) | ||
println("====") | ||
println(valueOf[TextBlocks.mixedIndents.type]) | ||
println("====") | ||
println(valueOf[TextBlocks.code.type]) | ||
println("====") | ||
println(valueOf[TextBlocks.simpleString.type]) | ||
println("====") | ||
println(valueOf[TextBlocks.emptyString.type]) | ||
println("====") | ||
} |
Oops, something went wrong.