-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime(java): Recognise string templates (vim#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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
- Loading branch information
Showing
9 changed files
with
165 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
" Language: Java | ||
" Maintainer: Claudio Fleiner <[email protected]> | ||
" 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 "\\\%(u\x\x\x\x\|[0-3]\o\o\|\o\o\=\|[bstn | |
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\%(_*\x\)*\.\=\|\%(\x\%(_*\x\)*\)\=\.\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 | ||
|
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,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|%| |
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,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|%| |
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,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| |
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 |
---|---|---|
@@ -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| |
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