Skip to content

Commit 7132935

Browse files
zzzyxwvutchrisbra
authored andcommitted
runtime(java): Manage byte limits for variable-width lookbehind assertions
Raise the byte limits from 80 to 120 for "javaFuncDef" and "java*CommentTitle"; and support selecting other arbitrary values with ------------------------------------------------------------ let g:java_lookbehind_byte_counts = { \ 'javaMarkdownCommentTitle': 240, \ } ------------------------------------------------------------ for related groups of syntax definitions, referring to their names with dictionary keys. Over-80-Byte-Limit Lookbehind Examples: https://raw.githubusercontent.com/openjdk/jdk/refs/tags/jdk-24%2B36/src/java.base/share/classes/sun/security/x509/NamedX509Key.java [Lines 43 & 44] https://raw.githubusercontent.com/openjdk/jdk/refs/tags/jdk-24%2B36/src/jdk.compiler/share/classes/com/sun/tools/javac/util/GraphUtils.java [Line 154] closes: #17921 Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent adfea9b commit 7132935

10 files changed

Lines changed: 75 additions & 28 deletions

runtime/doc/syntax.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*syntax.txt* For Vim version 9.1. Last change: 2025 Aug 07
1+
*syntax.txt* For Vim version 9.1. Last change: 2025 Aug 08
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2231,6 +2231,15 @@ Certain modifiers are incompatible with each other, e.g. `abstract` and
22312231
and can be differently highlighted as a group than other modifiers with >
22322232
:hi link javaConceptKind NonText
22332233
2234+
All instances of variable-width lookbehind assertions (|/\@<!| and |/\@<=|),
2235+
resorted to in syntax item definitions, are confined to arbitrary byte counts.
2236+
Another arbitrary value can be selected for a related group of definitions.
2237+
For example: >
2238+
:let g:java_lookbehind_byte_counts = {'javaMarkdownCommentTitle': 240}
2239+
Where each key name of this dictionary is the name of a syntax item. The use
2240+
of these assertions in syntax items may vary among revisions, so no definitive
2241+
set of supported key names is committed to.
2242+
22342243
If you notice highlighting errors while scrolling backwards, which are fixed
22352244
when redrawing with CTRL-L, try setting the "g:java_minlines" variable to
22362245
a larger number: >

runtime/syntax/java.vim

Lines changed: 35 additions & 17 deletions
Large diffs are not rendered by default.

runtime/syntax/testdir/dumps/java_enfoldment_00.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
| +0#0000e05#a8a8a8255@1>/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l|o|c|a|l| |f|o|l|d|e|n|a|b|l|e| |f|o|l|d|c|o|l|u|m|n|=|2| |f|o|l|d|m|e|t|h|o|d|=|s|y|n|t|a|x| +0#0000000&@4
22
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|j|a|v|a|_|f|o|l|d|t|e|x|t|_|s|h|o|w|_|f|i|r|s|t|_|o|r|_|s|e|c|o|n|d|_|l|i|n|e| |=| |1| +0#0000000&@5
3+
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|j|a|v|a|_|l|o@1|k|b|e|h|i|n|d|_|b|y|t|e|_|c|o|u|n|t|s| |=| |{|'|j|a|v|a|B|l|o|c|k|'|:| |-|1|}| +0#0000000&@1
34
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i|g|h|l|i|g|h|t| |l|i|n|k| |j|a|v|a|B|l|o|c|k|O|t|h|e|r|S|t|a|r|t| |S|t|r|u|c|t|u|r|e| +0#0000000&@10
45
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i|g|h|l|i|g|h|t| |l|i|n|k| |j|a|v|a|B|l|o|c|k|S|t|a|r|t| |T|o|d|o| +0#0000000&@20
56
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
6-
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
77
|++0#0000e05#a8a8a8255| |+|-@1| |1|9| |l|i|n|e|s|:| |@|S|u|p@1|r|e|s@1|W|a|r|n|i|n|g|s|(|{|-@39
88
| @1|c+0#00e0003#ffffff0|l|a|s@1| +0#0000000&|F|o|l|d|i|n|g|T|e|s|t|s| |{+0#00e0003&| +0#0000000&@52
99
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|F|o|l|d|e|n|a|b|l|e| @48

runtime/syntax/testdir/dumps/java_enfoldment_02.dump

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |{| +0#0000000&@68
1616
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |}| +0#0000000&@68
1717
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
18-
|++0#0000e05#a8a8a8255| |+|-@1| @1|2| |l|i|n|e|s|:| |1|2@1|||.@54
19-
|~+0#4040ff13#ffffff0| @73
20-
| +0#0000000&@56|9|7|,|2|-|1| @7|B|o|t|
18+
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0|*| |1|2@1|||.@65
19+
| +0&#a8a8a8255@1|.+0&#ffffff0@23|*|/| +0#0000000&|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|F|o|l|d|e|n|a|b|l|e| |{+0#00e0003&| +0#0000000&@23
20+
@57|9|7|,|2|-|1| @7|9|8|%|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0|*| |1|2@1|||.@65
2+
| +0&#a8a8a8255@1|.+0&#ffffff0@23|*|/| +0#0000000&|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|F|o|l|d|e|n|a|b|l|e| |{+0#00e0003&| +0#0000000&@23
3+
| +0#0000e05#a8a8a8255@1>}+0#00e0003#ffffff0| +0#0000000&@71
4+
|~+0#4040ff13&| @73
5+
|~| @73
6+
|~| @73
7+
|~| @73
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|~| @73
15+
|~| @73
16+
|~| @73
17+
|~| @73
18+
|~| @73
19+
|~| @73
20+
| +0#0000000&@56|1|2@1|,|1| @8|B|o|t|

runtime/syntax/testdir/dumps/java_unfoldment_00.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
>/+0#0000e05#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l|o|c|a|l| |n|o|f|o|l|d|e|n|a|b|l|e| +0#0000000&@35
22
|/+0#0000e05&@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|j|a|v|a|_|m|a|r|k|_|b|r|a|c|e|s|_|i|n|_|p|a|r|e|n|s|_|a|s|_|e|r@1|o|r|s| |=| |1| +0#0000000&@10
3+
|/+0#0000e05&@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|j|a|v|a|_|l|o@1|k|b|e|h|i|n|d|_|b|y|t|e|_|c|o|u|n|t|s| |=| |{|'|j|a|v|a|B|l|o|c|k|'|:| |-|1|}| +0#0000000&@3
34
|/+0#0000e05&@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i|g|h|l|i|g|h|t| |l|i|n|k| |j|a|v|a|B|l|o|c|k|O|t|h|e|r|S|t|a|r|t| |S|t|r|u|c|t|u|r|e| +0#0000000&@12
45
|/+0#0000e05&@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i|g|h|l|i|g|h|t| |l|i|n|k| |j|a|v|a|B|l|o|c|k|S|t|a|r|t| |T|o|d|o| +0#0000000&@22
56
@75
6-
@75
77
@4|@+0#e000e06&|S|u|p@1|r|e|s@1|W|a|r|n|i|n|g|s|(|{+0#0000001#ffff4012| +0#0000000#ffffff0@51
88
@4|"@2| @67
99
| +0#e000002&@3|b|e|s|p|o|k|e| +0#0000000&@63

runtime/syntax/testdir/dumps/java_unfoldment_06.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
|/+0#0000e05&@1| |}| +0#0000000&@70
1717
@75
1818
|/+0#0000e05&|*| |1|2@1|||.@67
19-
@20|*|/| +0#0000000&|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|U|n|f|o|l|d|e|n|a|b|l|e| |{+0#0000001#ffff4012| +0#0000000#ffffff0@27
19+
@20|*|/| +0#0000000&|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|U|n|f|o|l|d|e|n|a|b|l|e| |{+0#00e0003&| +0#0000000&@27
2020
@57|1|0|9|,|1| @8|9@1|%|

runtime/syntax/testdir/dumps/java_unfoldment_07.dump

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
|/+0#0000e05#ffffff0|*| |1|2@1|||.@67
2-
@20|*|/| +0#0000000&|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|U|n|f|o|l|d|e|n|a|b|l|e| |{+0#0000001#ffff4012| +0#0000000#ffffff0@27
3-
>}+0#0000001#ffff4012| +0#0000000#ffffff0@73
2+
@20|*|/| +0#0000000&|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|U|n|f|o|l|d|e|n|a|b|l|e| |{+0#00e0003&| +0#0000000&@27
3+
>}+0#00e0003&| +0#0000000&@73
44
|~+0#4040ff13&| @73
55
|~| @73
66
|~| @73

runtime/syntax/testdir/input/java_enfoldment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// VIM_TEST_SETUP setlocal foldenable foldcolumn=2 foldmethod=syntax
22
// VIM_TEST_SETUP let g:java_foldtext_show_first_or_second_line = 1
3+
// VIM_TEST_SETUP let g:java_lookbehind_byte_counts = {'javaBlock': -1}
34
// VIM_TEST_SETUP highlight link javaBlockOtherStart Structure
45
// VIM_TEST_SETUP highlight link javaBlockStart Todo
56

6-
77
@SuppressWarnings({
88
"""
99
bespoke

runtime/syntax/testdir/input/java_unfoldment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// VIM_TEST_SETUP setlocal nofoldenable
22
// VIM_TEST_SETUP let g:java_mark_braces_in_parens_as_errors = 1
3+
// VIM_TEST_SETUP let g:java_lookbehind_byte_counts = {'javaBlock': -1}
34
// VIM_TEST_SETUP highlight link javaBlockOtherStart Structure
45
// VIM_TEST_SETUP highlight link javaBlockStart Todo
56

6-
77
@SuppressWarnings({
88
"""
99
bespoke

0 commit comments

Comments
 (0)