Skip to content
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

Support JEP 378 Text Blocks in Java #1867

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/rouge/lexers/java.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Java < RegexLexer
rule %r/(?:true|false|null)\b/, Keyword::Constant
rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
rule %r/(?:import|package)\b/, Keyword::Namespace, :import
rule %r/"""\s*\n.*?(?<!\\)"""/m, Str::Heredoc
rule %r/"(\\\\|\\"|[^"])*"/, Str
rule %r/'(?:\\.|[^\\]|\\u[0-9a-f]{4})'/, Str::Char
rule %r/(\.)(#{id})/ do
Expand Down
41 changes: 41 additions & 0 deletions spec/visual/samples/java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,47 @@ public class PlatformManagerImpl implements PlatformManager
//T: PlatformManagerCapabilities
private final HashSet capabilitySet = new HashSet();

private static final String exampleTextBlock = """
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
<p>Hello, world</p>
</soap-env:Body>
</soap-env:Envelope>
""";

private static final String emptyTextBlock = """
""";

private static final String withoutFinalNewlineTextBlock = """
line 1
line 2""";

private static final String quotesEscapingTextBlock = """
String text = \"""
A text block inside a text block
\""";
""";

private static final String quotesEscaping2TextBlock = """
The empty string literal
is formed from " characters
as follows: \"\"""";

private static final String quotesEscaping3TextBlock = """
1 "
2 ""
3 ""\"
4 ""\""
5 ""\"""
6 ""\"""\"
7 ""\"""\""
8 ""\"""\"""
9 ""\"""\"""\"
10 ""\"""\"""\""
11 ""\"""\"""\"""
12 ""\"""\"""\"""\"
""";

/**
* Gets the platform manager singleton, which was already initialized
*/
Expand Down