Mercurial > vim
changeset 34514:728675946924
runtime(java): Recognise string templates (#14150)
Commit: https://github.com/vim/vim/commit/a2c65809dafe5c4f45f278fddf368c7c971d83e9
Author: Aliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com>
Date: Sat Mar 9 20:03:11 2024 +0300
runtime(java): Recognise string templates (https://github.com/vim/vim/issues/14150)
As this is encouraged in the referenced JEPs, "to visually
distinguish a string template from a string literal, and
a text block template from a text block", the default
colours for java\%[Debug]StrTempl are made distinct from
java\%[Debug]String.
According to ?3.2 Lexical Translations (JLS, c. 1996 or any
more recent version), line terminators, white space, and
comments are discarded before tokens are accepted. Since
a template expression comprises a template processor, a dot,
and a template, it may be visually appealing to break up
its head across a few lines whenever its tail already spans
multiple lines. Curiously, no allowance for it is made in
the distributed tests for OpenJDK 21; the proposed regexp
patterns take in consideration a line terminator and white
space after a dot.
References:
https://openjdk.org/jeps/430 (Preview)
https://openjdk.org/jeps/459 (Second Preview)
https://openjdk.org/jeps/465
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 09 Mar 2024 18:15:04 +0100 |
parents | 97fc56ee7ca7 |
children | 56c7b599d524 |
files | runtime/syntax/java.vim runtime/syntax/testdir/dumps/java_string_00.dump runtime/syntax/testdir/dumps/java_string_01.dump runtime/syntax/testdir/dumps/java_string_02.dump runtime/syntax/testdir/dumps/java_string_03.dump runtime/syntax/testdir/dumps/java_string_04.dump runtime/syntax/testdir/dumps/java_string_05.dump runtime/syntax/testdir/dumps/java_string_99.dump runtime/syntax/testdir/input/java_string.java |
diffstat | 9 files changed, 165 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/syntax/java.vim +++ b/runtime/syntax/java.vim @@ -2,7 +2,7 @@ " Language: Java " Maintainer: Claudio Fleiner <claudio@fleiner.com> " URL: https://github.com/fleiner/vim/blob/master/runtime/syntax/java.vim -" Last Change: 2024 Mar 02 +" Last Change: 2024 Mar 06 " Please check :help java.vim for comments on some of the options available. @@ -187,8 +187,8 @@ if exists("java_comment_strings") syn match javaCommentCharacter contained "'\\[^']\{1,6\}'" contains=javaSpecialChar syn match javaCommentCharacter contained "'\\''" contains=javaSpecialChar syn match javaCommentCharacter contained "'[^\\]'" - syn cluster javaCommentSpecial add=javaCommentString,javaCommentCharacter,javaNumber - syn cluster javaCommentSpecial2 add=javaComment2String,javaCommentCharacter,javaNumber + syn cluster javaCommentSpecial add=javaCommentString,javaCommentCharacter,javaNumber,javaStrTempl + syn cluster javaCommentSpecial2 add=javaComment2String,javaCommentCharacter,javaNumber,javaStrTempl endif syn region javaComment start="/\*" end="\*/" contains=@javaCommentSpecial,javaTodo,@Spell @@ -234,6 +234,9 @@ syn match javaSpecialChar contained " syn region javaString start=+"+ end=+"+ end=+$+ contains=javaSpecialChar,javaSpecialError,@Spell syn region javaString start=+"""[ \t\x0c\r]*$+hs=e+1 end=+"""+he=s-1 contains=javaSpecialChar,javaSpecialError,javaTextBlockError,@Spell syn match javaTextBlockError +"""\s*"""+ +syn region javaStrTemplEmbExp contained matchgroup=javaStrTempl start="\\{" end="}" contains=TOP +syn region javaStrTempl start=+\%(\.[[:space:]\n]*\)\@<="+ end=+"+ contains=javaStrTemplEmbExp,javaSpecialChar,javaSpecialError,@Spell +syn region javaStrTempl start=+\%(\.[[:space:]\n]*\)\@<="""[ \t\x0c\r]*$+hs=e+1 end=+"""+he=s-1 contains=javaStrTemplEmbExp,javaSpecialChar,javaSpecialError,javaTextBlockError,@Spell " The next line is commented out, it can cause a crash for a long line "syn match javaStringError +"\%([^"\\]\|\\.\)*$+ syn match javaCharacter "'[^']*'" contains=javaSpecialChar,javaSpecialCharError @@ -254,7 +257,7 @@ syn match javaNumber "\<0[xX]\%(\x\% " Unicode characters syn match javaSpecial "\\u\x\x\x\x" -syn cluster javaTop add=javaString,javaCharacter,javaNumber,javaSpecial,javaStringError,javaTextBlockError +syn cluster javaTop add=javaString,javaStrTempl,javaCharacter,javaNumber,javaSpecial,javaStringError,javaTextBlockError if exists("java_highlight_functions") if java_highlight_functions == "indent" @@ -280,7 +283,12 @@ if exists("java_highlight_debug") syn match javaDebugSpecial contained "\\\%(u\x\x\x\x\|[0-3]\o\o\|\o\o\=\|[bstnfr"'\\]\)" syn region javaDebugString contained start=+"+ end=+"+ contains=javaDebugSpecial syn region javaDebugString contained start=+"""[ \t\x0c\r]*$+hs=e+1 end=+"""+he=s-1 contains=javaDebugSpecial,javaDebugTextBlockError -" The next line is commented out, it can cause a crash for a long line + " The highlight groups of java{StrTempl,Debug{,Paren,StrTempl}}\, + " share one colour by default. Do not conflate unrelated parens. + syn region javaDebugStrTemplEmbExp contained matchgroup=javaDebugStrTempl start="\\{" end="}" contains=javaComment,javaLineComment,javaDebug\%(Paren\)\@!.* + syn region javaDebugStrTempl contained start=+\%(\.[[:space:]\n]*\)\@<="+ end=+"+ contains=javaDebugStrTemplEmbExp,javaDebugSpecial + syn region javaDebugStrTempl contained start=+\%(\.[[:space:]\n]*\)\@<="""[ \t\x0c\r]*$+hs=e+1 end=+"""+he=s-1 contains=javaDebugStrTemplEmbExp,javaDebugSpecial,javaDebugTextBlockError + " The next line is commented out, it can cause a crash for a long line " syn match javaDebugStringError contained +"\%([^"\\]\|\\.\)*$+ syn match javaDebugTextBlockError contained +"""\s*"""+ syn match javaDebugCharacter contained "'[^\\]'" @@ -307,6 +315,7 @@ if exists("java_highlight_debug") hi def link javaDebug Debug hi def link javaDebugString DebugString + hi def link javaDebugStrTempl Macro hi def link javaDebugStringError javaError hi def link javaDebugTextBlockError javaDebugStringError hi def link javaDebugType DebugType @@ -376,6 +385,7 @@ hi def link javaSpecial Special hi def link javaSpecialError Error hi def link javaSpecialCharError Error hi def link javaString String +hi def link javaStrTempl Macro hi def link javaCharacter Character hi def link javaSpecialChar SpecialChar hi def link javaNumber Number
--- a/runtime/syntax/testdir/dumps/java_string_00.dump +++ b/runtime/syntax/testdir/dumps/java_string_00.dump @@ -1,4 +1,4 @@ ->c+0#00e0003#ffffff0|l|a|s@1| +0#0000000&|S|t|r|i|n|g|T|e|s|t|s| @57 +>c+0#00e0003#ffffff0|l|a|s@1| +0#0000000&|S|t|r|i|n|g|T|e|s|t|s| @2|/+0#0000e05&@1| |J|D|K| |2|1|+| |(|-@1|e|n|a|b|l|e|-|p|r|e|v|i|e|w| |-@1|r|e|l|e|a|s|e| |2|1|)|.| +0#0000000&@11 |{| @73 @4|s+0#00e0003&|t|a|t|i|c| +0#0000000&|{| @62 @8|S|t|r|i|n|g| |s|1| |=| |"+0#e000002&|A| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e|r| |t|h|e| |l|a|z|y| |d|o|g|"|;+0#0000000&| @10
--- a/runtime/syntax/testdir/dumps/java_string_01.dump +++ b/runtime/syntax/testdir/dumps/java_string_01.dump @@ -17,4 +17,4 @@ @8|/+0#0000e05&@1| |T|h|e|r|e| |a|r|e| |S|P|A|C|E|,| |F@1|,| |H|T|,| |C|R|,| |a|n|d| |L|F| |a|f|t|e|r| |"@2|.| +0#0000000&@17 @8|S|t|r|i|n|g| |e|m|p|t|y| |=| |"@2| |^+0#0000e05&|L| +0#0000000&@2|^+0#0000e05&|M| +0#0000000&@40 | +0#e000002&@11|"+0#0000000&@2|;| @58 -@57|1|9|,|3|-|9| @7|5|2|%| +@57|1|9|,|3|-|9| @7|1|5|%|
--- a/runtime/syntax/testdir/dumps/java_string_02.dump +++ b/runtime/syntax/testdir/dumps/java_string_02.dump @@ -9,12 +9,12 @@ | +0#e000002&@7|"@1|\+0#e000e06&|"|"+0#e000002&@1|\+0#e000e06&|u|0@1|5|c|\|u|0@1|2@1| +0#0000000&@48 | +0#e000002&@7|"@1|\+0#e000e06&|"|"+0#e000002&@1|\+0#e000e06&|"|"+0#e000002&| +0#0000000&@57 | +0#e000002&@7|"@1|\+0#e000e06&|"|"+0#e000002&@1|\+0#e000e06&|"|"+0#e000002&|\+0#e000e06&|"|"+0#0000000&@2|)|;| @50 -@4|}| @69 -|}| @73 -|~+0#4040ff13&| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -| +0#0000000&@56|3|7|,|3|-|9| @7|B|o|t| +@75 +@8|S|y|s|t|e|m|.|o|u|t|.|p|r|i|n|t|l|n|(|S|T|R|.|"@2| @40 +| +0#e000e06&@7|"| +0#0000000&@65 +| +0#e000e06&@7|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&| +0#0000000&@57 +| +0#e000e06&@7|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|{|"+0#e000002&|\+0#e000e06&|u|0@1|5|c|\|u|0@1|2@1|"+0#e000002&|}+0#e000e06&| +0#0000000&@40 +| +0#e000e06&@7|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|{|"+0#e000002&|\+0#e000e06&|u|0@1|5|c|\|u|0@1|2@1|"+0#e000002&|}+0#e000e06&|"| +0#0000000&@39 +| +0#e000e06&@7|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|"|\|{|"+0#e000002&|\+0#e000e06&|u|0@1|5|c|\|u|0@1|2@1|\|u|0@1|5|c|\|u|0@1|2@1|"+0#e000002&|}+0#e000e06&| +0#0000000&@26 +| +0#e000e06&@7|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|"|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|{|"+0#e000002&|\+0#e000e06&|u|0@1|5|c|\|u|0@1|2@1|"+0#e000002&|}+0#e000e06&| +0#0000000&@29 +@57|3|7|,|3|-|9| @7|3|6|%|
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/dumps/java_string_03.dump @@ -0,0 +1,20 @@ +| +0#e000e06#ffffff0@7|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|"|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|{|"+0#e000002&|\+0#e000e06&|u|0@1|5|c|\|u|0@1|2@1|"+0#e000002&|}+0#e000e06&| +0#0000000&@29 +| +0#e000e06&@7|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|"|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|"@1| +0#0000000&@43 +| +0#e000e06&@7|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|"|\|{|"+0#e000002&|\+0#e000e06&|"|\|"|"+0#e000002&|}+0#e000e06&|\|"@1|\|"|"+0#0000000&@2|)|;| @5|/+0#0000e05&@1| |J|D|K| |2|1|+|.| +0#0000000&@19 +@75 +@8|S|t|r|i|n|g| |w|o@1|f| |=| |"+0#e000002&|W|o@1|f|"|,+0#0000000&| |d|o|g| |=| |"+0#e000002&|d|o|g|"|,+0#0000000&| |f|o|x| |=| |"+0#e000002&|f|o|x|"|;+0#0000000&| @19 +> @74 +@8|S|t|r|i|n|g| |s|6| |=| |S|T|R| @51 +@12|.|"+0#e000e06&|A| |q|u|i|c|k| |b|r|o|w|n| |\|{|f+0#0000000&|o|x|}+0#e000e06&| |j|u|m|p|s| |o|v|e|r| |t|h|e| |l|a|z|y| |\|{|d+0#0000000&|o|g|}+0#e000e06&|"|;+0#0000000&| @11 +@8|S|t|r|i|n|g| |s|7| |=| |S|T|R|.|p|r|o|c|e|s@1|(|S|t|r|i|n|g|T|e|m|p|l|a|t|e|.|R|A|W| @24 +@12|.|"+0#e000e06&|\|"|\|{|w+0#0000000&|o@1|f|}+0#e000e06&|\|s|!|\|"@1|)+0#0000000&|;| @43 +@8|S|t|r|i|n|g| |s|8| |=| |S|T|R|.|"@2| @47 +| +0#e000e06&@11|A|\|s|\| +0#0000000&@58 +| +0#e000e06&@11|q|u|i|c|k| |\| +0#0000000&@55 +| +0#e000e06&@11|b|r|o|w|n|\|s|\| +0#0000000&@54 +| +0#e000e06&@11|\|{|f+0#0000000&|o|x|}+0#e000e06&| |\| +0#0000000&@54 +| +0#e000e06&@11|j|u|m|p|s|\|s|\| +0#0000000&@54 +| +0#e000e06&@11|o|v|e|r| |\| +0#0000000&@56 +| +0#e000e06&@11|t|h|e|\|s|\| +0#0000000&@56 +| +0#e000e06&@11|l|a|z|y| |\| +0#0000000&@56 +@57|5@1|,|0|-|1| @7|5|7|%|
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/dumps/java_string_04.dump @@ -0,0 +1,20 @@ +| +0#e000e06#ffffff0@11|l|a|z|y| |\| +0#0000000&@56 +| +0#e000e06&@11|\|{|d+0#0000000&|o|g|}+0#e000e06&|"+0#0000000&@2|;| @52 +@8|S|t|r|i|n|g| |s|9| |=| |S|T|R|.|p|r|o|c|e|s@1|(|S|t|r|i|n|g|T|e|m|p|l|a|t|e|.|R|A|W| @24 +@12|.| @61 +@12|"@2| @59 +| +0#e000e06&@11>"|\|{|w+0#0000000&|o@1|f|}+0#e000e06&|\|s|!|\|"|"+0#0000000&@2|)|;| @44 +@8|S|t|r|i|n|g| |s|1|0| |=| |j|a|v|a|.|u|t|i|l|.|F|o|r|m|a|t|P|r|o|c|e|s@1|o|r|.|F|M|T| @24 +@12|.| |"+0#e000e06&|%|-|1|4|s|\|{|"+0#e000002&|A|\+0#e000e06&|s|"+0#e000002&| +0#0000000&|+| |S|T|R| |.| |"+0#e000e06&|q|u|i|c|k|"| +0#0000000&|+| |"+0#e000002&|b|r|o|w|n|"|}+0#e000e06&|%|s|\|{|f+0#0000000&|o|x|}+0#e000e06&| |"| +0#0000000&@10 +@12|+| |j|a|v|a|.|u|t|i|l|.|F|o|r|m|a|t|P|r|o|c|e|s@1|o|r|.|F|M|T| @31 +@12|.| |"+0#e000e06&|%|-|2|0|s|\|{|"+0#e000002&|j|u|m|p|s|\+0#e000e06&|s|o+0#e000002&|v|e|r| |t|h|e|\+0#e000e06&|s|"+0#e000002&| +0#0000000&@33 +@20|+| |S|T|R| |.| |"+0#e000e06&|l|a|z|y|"|}|%|s|\|{|d+0#0000000&|o|g|}+0#e000e06&|"|;+0#0000000&| @29 +@8|S|t|r|i|n|g| |s|1@1| |=| |S|T|R|.|"@2| @46 +| +0#e000e06&@11|\|"|\|{| +0#0000000&@11|/+0#0000e05&@1| |A| |n|e|s|t|e|d| |c|o|m@1|e|n|t|.| +0#0000000&@26 +@8|(|n+0#af5f00255&|e|w| +0#0000000&|j|a|v|a|.|u|t|i|l|.|f|u|n|c|t|i|o|n|.|F|u|n|c|t|i|o|n|<|S|t|r|i|n|g|,| |S|t|r|i|n|g|>|(|)| |{| @14 +@12|p+0#00e0003&|u|b|l|i|c| +0#0000000&|S|t|r|i|n|g| |a|p@1|l|y|(|S|t|r|i|n|g| |b|a|y|)| |{| |r+0#af5f00255&|e|t|u|r|n| +0#0000000&|b|a|y|;| |}|;| @14 +@8|}|)|.|a|p@1|l|y|(|w|o@1|f|)| @52 +@12|}+0#e000e06&|\|s|!|\|"|"+0#0000000&@2|;| @52 +@8|S|t|r|i|n|g| |s|1|2| |=| |j|a|v|a|.|u|t|i|l|.|F|o|r|m|a|t|P|r|o|c|e|s@1|o|r|.|F|M|T| @24 +@12|.|"@2| @58 +@57|7|3|,|4|-|1|3| @6|7|8|%|
new file mode 100644 --- /dev/null +++ b/runtime/syntax/testdir/dumps/java_string_05.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@11|.|"@2| @58 +| +0#e000e06&@11|%|-|1|4|s|\|{|S+0#0000000&|T|R|.|"@2| @48 +| +0#e000e06&@15|A|\|s|\| +0#0000000&@54 +| +0#e000e06&@15|\|{| +0#0000000&|"+0#e000002&|q|u|i|c|k|"| +0#0000000&|}+0#e000e06&| |\| +0#0000000&@44 +| +0#e000e06&@15|b|r|o|w|n|"+0#0000000&@2|}+0#e000e06&|\| +0#0000000&@48 +| +0#e000e06&@11>%|s|\|{| +0#0000000&|f|o|x| |}+0#e000e06&| |\| +0#0000000&@50 +| +0#e000e06&@11|%|-|2|0|s|\|{|S+0#0000000&|T|R|.|"@2| @48 +| +0#e000e06&@15|j|u|m|p|s|\|s|\| +0#0000000&@50 +| +0#e000e06&@15|o|v|e|r| |\| +0#0000000&@52 +| +0#e000e06&@15|t|h|e|\|s|\| +0#0000000&@52 +| +0#e000e06&@15|\|{| +0#0000000&|"+0#e000002&|l|a|z|y|"| +0#0000000&|}+0#e000e06&| |"+0#0000000&@2|}+0#e000e06&|\| +0#0000000&@41 +| +0#e000e06&@11|%|s|\|{| +0#0000000&|d|o|g| |}+0#e000e06&|"+0#0000000&@2|;| @48 +@8|S|t|r|i|n|g| |s|1|3| |=| |S|T|R| @50 +@12|.|"+0#e000e06&|\|"|\|{| +0#0000000&@9|/+0#0000e05&|*| |A| |n|e|s|t|e|d| |c|o|m@1|e|n|t|.| |*|/| +0#0000000&@23 +@8|(@1|j|a|v|a|.|u|t|i|l|.|f|u|n|c|t|i|o|n|.|F|u|n|c|t|i|o|n|<|S|t|r|i|n|g|,| |S|t|r|i|n|g|>|)| |b|a|y| |-|>| |b|a|y|)| @8 +@28|.|a|p@1|l|y|(|w|o@1|f|)| @34 +@12|}+0#e000e06&|\|s|!|\|"@1|;+0#0000000&| @54 +@4|}| @69 +|}| @73 +@57|9|1|,|4|-|1|3| @6|B|o|t|
--- a/runtime/syntax/testdir/dumps/java_string_99.dump +++ b/runtime/syntax/testdir/dumps/java_string_99.dump @@ -1,20 +1,20 @@ -| +0#e000002#ffffff0@11|t|h|e|\+0#e000e06&@1|s+0#e000002&|\+0#e000e06&@1| +0#0000000&@54 -| +0#e000002&@11|l|a|z|y| |\+0#e000e06&@1| +0#0000000&@55 -| +0#e000002&@11|d|o|g|\+0#e000e06&|"|"+0#e000002&@1|;|"+0#0000000&@2|;| @50 -@75 -@8|/+0#0000e05&@1| |T|h|e|r|e| |a|r|e| |S|P|A|C|E|,| |F@1|,| |H|T|,| |C|R|,| |a|n|d| |L|F| |a|f|t|e|r| |"@2|.| +0#0000000&@17 -@8|S|t|r|i|n|g| |e|m|p|t|y| |=| |"@2| |^+0#0000e05&|L| +0#0000000&@2|^+0#0000e05&|M| +0#0000000&@40 -| +0#e000002&@11|"+0#0000000&@2|;| @58 -@75 -@8|S|y|s|t|e|m|.|o|u|t|.|p|r|i|n|t|l|n|(|"@2| @44 -| +0#e000002&@7|"| +0#0000000&@65 -| +0#e000002&@7|"@1| +0#0000000&@64 -| +0#e000002&@7|"@1|\+0#e000e06&|u|0@1|5|c|"+0#e000002&| +0#0000000&@57 -| +0#e000002&@7|"@1|\+0#e000e06&|u|0@1|5|c|"+0#e000002&@1| +0#0000000&@56 -| +0#e000002&@7|"@1|\+0#e000e06&|"|\|u|0@1|2@1|\|u|0@1|2@1| +0#0000000&@50 -| +0#e000002&@7|"@1|\+0#e000e06&|"|"+0#e000002&@1|\+0#e000e06&|u|0@1|5|c|\|u|0@1|2@1| +0#0000000&@48 -| +0#e000002&@7|"@1|\+0#e000e06&|"|"+0#e000002&@1|\+0#e000e06&|"|"+0#e000002&| +0#0000000&@57 -| +0#e000002&@7|"@1|\+0#e000e06&|"|"+0#e000002&@1|\+0#e000e06&|"|"+0#e000002&|\+0#e000e06&|"|"+0#0000000&@2|)|;| @50 +| +0&#ffffff0@11|.|"@2| @58 +| +0#e000e06&@11|%|-|1|4|s|\|{|S+0#0000000&|T|R|.|"@2| @48 +| +0#e000e06&@15|A|\|s|\| +0#0000000&@54 +| +0#e000e06&@15|\|{| +0#0000000&|"+0#e000002&|q|u|i|c|k|"| +0#0000000&|}+0#e000e06&| |\| +0#0000000&@44 +| +0#e000e06&@15|b|r|o|w|n|"+0#0000000&@2|}+0#e000e06&|\| +0#0000000&@48 +| +0#e000e06&@11|%|s|\|{| +0#0000000&|f|o|x| |}+0#e000e06&| |\| +0#0000000&@50 +| +0#e000e06&@11|%|-|2|0|s|\|{|S+0#0000000&|T|R|.|"@2| @48 +| +0#e000e06&@15|j|u|m|p|s|\|s|\| +0#0000000&@50 +| +0#e000e06&@15|o|v|e|r| |\| +0#0000000&@52 +| +0#e000e06&@15|t|h|e|\|s|\| +0#0000000&@52 +| +0#e000e06&@15|\|{| +0#0000000&|"+0#e000002&|l|a|z|y|"| +0#0000000&|}+0#e000e06&| |"+0#0000000&@2|}+0#e000e06&|\| +0#0000000&@41 +| +0#e000e06&@11|%|s|\|{| +0#0000000&|d|o|g| |}+0#e000e06&|"+0#0000000&@2|;| @48 +@8|S|t|r|i|n|g| |s|1|3| |=| |S|T|R| @50 +@12|.|"+0#e000e06&|\|"|\|{| +0#0000000&@9|/+0#0000e05&|*| |A| |n|e|s|t|e|d| |c|o|m@1|e|n|t|.| |*|/| +0#0000000&@23 +@8|(@1|j|a|v|a|.|u|t|i|l|.|f|u|n|c|t|i|o|n|.|F|u|n|c|t|i|o|n|<|S|t|r|i|n|g|,| |S|t|r|i|n|g|>|)| |b|a|y| |-|>| |b|a|y|)| @8 +@28|.|a|p@1|l|y|(|w|o@1|f|)| @34 +@12|}+0#e000e06&|\|s|!|\|"@1|;+0#0000000&| @54 @4|}| @69 >}| @73 -@57|4@1|,|1| @9|B|o|t| +@57|1|0|4|,|1| @8|B|o|t|
--- a/runtime/syntax/testdir/input/java_string.java +++ b/runtime/syntax/testdir/input/java_string.java @@ -1,4 +1,4 @@ -class StringTests +class StringTests // JDK 21+ (--enable-preview --release 21). { static { String s1 = "A quick brown fox jumps over the lazy dog"; @@ -40,5 +40,65 @@ class StringTests ""\"""\u005c\u0022 ""\"""\"" ""\"""\""\""""); + + System.out.println(STR.""" + " + \{"\"\""} + \{"\"\""}\{"\u005c\u0022"} + \{"\"\""}\{"\u005c\u0022"}" + \{"\"\""}\"\{"\u005c\u0022\u005c\u0022"} + \{"\"\""}\"\{"\"\""}\{"\u005c\u0022"} + \{"\"\""}\"\{"\"\""}\"" + \{"\"\""}\"\{"\"\""}\""\""""); // JDK 21+. + + String woof = "Woof", dog = "dog", fox = "fox"; + + String s6 = STR + ."A quick brown \{fox} jumps over the lazy \{dog}"; + String s7 = STR.process(StringTemplate.RAW + ."\"\{woof}\s!\""); + String s8 = STR.""" + A\s\ + quick \ + brown\s\ + \{fox} \ + jumps\s\ + over \ + the\s\ + lazy \ + \{dog}"""; + String s9 = STR.process(StringTemplate.RAW + . + """ + "\{woof}\s!\""""); + String s10 = java.util.FormatProcessor.FMT + . "%-14s\{"A\s" + STR . "quick" + "brown"}%s\{fox} " + + java.util.FormatProcessor.FMT + . "%-20s\{"jumps\sover the\s" + + STR . "lazy"}%s\{dog}"; + String s11 = STR.""" + \"\{ // A nested comment. + (new java.util.function.Function<String, String>() { + public String apply(String bay) { return bay; }; + }).apply(woof) + }\s!\""""; + String s12 = java.util.FormatProcessor.FMT + .""" + %-14s\{STR.""" + A\s\ + \{ "quick" } \ + brown"""}\ + %s\{ fox } \ + %-20s\{STR.""" + jumps\s\ + over \ + the\s\ + \{ "lazy" } """}\ + %s\{ dog }"""; + String s13 = STR + ."\"\{ /* A nested comment. */ + ((java.util.function.Function<String, String>) bay -> bay) + .apply(woof) + }\s!\""; } }