New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SI-12290: support JDK15 text blocks in Java parser #9548
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of / before returning, maybe we try to advance reader to the end of the text block? Otherwise there are a lot of errors issued when continuing to parse.
Although javac is not any better :-) So I'm fine if you leave it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just not returning would do the trick? I'll try this out after work.