runtime(java): Optionally highlight parameterised types

In the presence of parameterised types whose names begin
with a capital letter and end with a less-than sign "<" that
introduces a type argument or a list of comma-separated type
arguments, followed by a greater-than sign ">", a variable
"g:java_highlight_generics" can be defined to have some
components of such types uniformly coloured (by picking
highlight groups for javaGenericsC{1,2}, javaWildcardBound).

For example,
------------------------------------------------------------
java.io.InputStream stream = java.io.InputStream.nullInputStream();
java.util.function.Function<String,
    java.util.function.BiFunction<String, String, String>> updater =
	property -> (oldValue, newValue) -> oldValue;
java.util.logging.LogManager.getLogManager()
    .updateConfiguration(stream, updater);
------------------------------------------------------------

Note that the diamond form and explicit type arguments do
not qualify for this kind of recognition.

For example,
------------------------------------------------------------
new java.util.HashSet<>().<String>toArray(new String[0]);
------------------------------------------------------------

References:
https://docs.oracle.com/javase/specs/jls/se21/html/jls-4.html#jls-4.5
https://docs.oracle.com/javase/specs/jls/se21/html/jls-15.html#jls-15.9
https://docs.oracle.com/javase/specs/jls/se21/html/jls-15.html#jls-15.12.2.1

closes: #15050

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Aliaksei Budavei
2024-06-20 21:00:53 +02:00
committed by Christian Brabandt
parent 49012cd8c2
commit beb02ed674
12 changed files with 365 additions and 11 deletions

View File

@ -0,0 +1,20 @@
>/+0#0000e05#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|j|a|v|a|_|h|i|g|h|l|i|g|h|t|_|f|u|n|c|t|i|o|n|s| |=| |'|s|t|y|l|e|'| +0#0000000&@16
|/+0#0000e05&@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|j|a|v|a|_|h|i|g|h|l|i|g|h|t|_|g|e|n|e|r|i|c|s| |=| |1| +0#0000000&@23
|/+0#0000e05&@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i| |l|i|n|k| |j|a|v|a|G|e|n|e|r|i|c|s|C|1| |T|o|d|o| +0#0000000&@29
|/+0#0000e05&@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i| |l|i|n|k| |j|a|v|a|G|e|n|e|r|i|c|s|C|2| |E|r@1|o|r| +0#0000000&@28
@75
|i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|a|v|a|.|m|a|t|h|.|B|i|g|I|n|t|e|g|e|r|;| @46
|i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|a|v|a|.|u|t|i|l|.|f|u|n|c|t|i|o|n|.|C|o|n|s|u|m|e|r|;| @39
|i+0#e000e06&|m|p|o|r|t| +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|;| @39
|i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|a|v|a|.|u|t|i|l|.|f|u|n|c|t|i|o|n|.|L|o|n|g|F|u|n|c|t|i|o|n|;| @35
|i+0#e000e06&|m|p|o|r|t| +0#0000000&|j|a|v|a|.|u|t|i|l|.|f|u|n|c|t|i|o|n|.|P|r|e|d|i|c|a|t|e|;| @38
@75
|c+0#00e0003&|l|a|s@1| +0#0000000&|G+0#0000001#ffff4012|e|n|e|r|i|c|s|T|e|s|t|s|<|T+0#0000000#ffffff0| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|N|u|m|b|e|r| |&| |C+0#ffffff16#ff404010|o|m|p|a|r|a|b|l|e|<|?+0#0000000#ffffff0| |s+0#00e0003&|u|p|e|r| +0#0000000&|T|>+0#ffffff16#ff404010|,+0#0000000#ffffff0| |U|>+0#0000001#ffff4012| +0#0000000#ffffff0@10
|{| @2|/+0#0000e05&@1| |J|D|K| |2|1|+|.| +0#0000000&@59
@4|s+0#00e0003&|t|a|t|i|c| +0#0000000&|f+0#4040ff13&|i|n|a|l| +0#0000000&|F+0#0000001#ffff4012|u|n|c|t|i|o|n|<|F+0#ffffff16#ff404010|u|n|c|t|i|o|n|<|O+0#0000000#ffffff0|b|j|e|c|t|,| |O|b|j|e|c|t|>+0#ffffff16#ff404010|,+0#0000000#ffffff0| |O|b|j|e|c|t|>+0#0000001#ffff4012| +0#0000000#ffffff0|P|A|R|T|I|A|L| |=| @5
@24|G|e|n|e|r|i|c|s|T|e|s|t|s|.|y|0|(|)|;| @31
@4|s+0#00e0003&|t|a|t|i|c| +0#0000000&|f+0#4040ff13&|i|n|a|l| +0#0000000&|F+0#0000001#ffff4012|u|n|c|t|i|o|n|<|B+0#0000000#ffffff0|i|g|I|n|t|e|g|e|r|,| |B|i|g|I|n|t|e|g|e|r|>+0#0000001#ffff4012| +0#0000000#ffffff0|F|A|C|T|O|R|I|A|L|_|2|0@2| |=| @8
@16|G|e|n|e|r|i|c|s|T|e|s|t|s|.|<|B|i|g|I|n|t|e|g|e|r|,| |B|i|g|I|n|t|e|g|e|r|>|y|1|(|)| @16
@8|.|a|p@1|l|y|(|f+0#00e0e07&| |-|>| +0#0000000&|x+0#00e0e07&| |-|>| +0#0000000&|(|x|.|c|o|m|p|a|r|e|T|o|(|B|i|g|I|n|t|e|g|e|r|.|O|N|E|)| |<| |1+0#e000002&|)+0#0000000&| @16
@12|?| |B|i|g|I|n|t|e|g|e|r|.|O|N|E| @46
@57|1|,|1| @10|T|o|p|

View File

@ -0,0 +1,20 @@
| +0&#ffffff0@3|s+0#00e0003&|t|a|t|i|c| +0#0000000&|f+0#4040ff13&|i|n|a|l| +0#0000000&|F+0#0000001#ffff4012|u|n|c|t|i|o|n|<|F+0#ffffff16#ff404010|u|n|c|t|i|o|n|<|O+0#0000000#ffffff0|b|j|e|c|t|,| |O|b|j|e|c|t|>+0#ffffff16#ff404010|,+0#0000000#ffffff0| |O|b|j|e|c|t|>+0#0000001#ffff4012| +0#0000000#ffffff0|P|A|R|T|I|A|L| |=| @5
@24|G|e|n|e|r|i|c|s|T|e|s|t|s|.|y|0|(|)|;| @31
@4|s+0#00e0003&|t|a|t|i|c| +0#0000000&|f+0#4040ff13&|i|n|a|l| +0#0000000&|F+0#0000001#ffff4012|u|n|c|t|i|o|n|<|B+0#0000000#ffffff0|i|g|I|n|t|e|g|e|r|,| |B|i|g|I|n|t|e|g|e|r|>+0#0000001#ffff4012| +0#0000000#ffffff0|F|A|C|T|O|R|I|A|L|_|2|0@2| |=| @8
@16|G|e|n|e|r|i|c|s|T|e|s|t|s|.|<|B|i|g|I|n|t|e|g|e|r|,| |B|i|g|I|n|t|e|g|e|r|>|y|1|(|)| @16
@8|.|a|p@1|l|y|(|f+0#00e0e07&| |-|>| +0#0000000&|x+0#00e0e07&| |-|>| +0#0000000&|(|x|.|c|o|m|p|a|r|e|T|o|(|B|i|g|I|n|t|e|g|e|r|.|O|N|E|)| |<| |1+0#e000002&|)+0#0000000&| @16
@12>?| |B|i|g|I|n|t|e|g|e|r|.|O|N|E| @46
@12|:| |x|.|m|u|l|t|i|p|l|y|(|f|.|a|p@1|l|y|(|x|.|s|u|b|t|r|a|c|t|(|B|i|g|I|n|t|e|g|e|r|.|O|N|E|)@3|;| @11
@75
| +0#00e0e07&@3|s+0#00e0003&|t|a|t|i|c| +0#00e0e07&|<|T|1|>| |Y+0#0000001#ffff4012|0|<|T+0#0000000#ffffff0|1|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|y|0|(|)| +0#0000000&@47
@4|{| @69
@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|(+0#00e0e07&|F+0#0000001#ffff4012|u|n|c|t|i|o|n|<|T+0#0000000#ffffff0|1|,+0#00e0e07&| |T+0#0000000&|1|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|f|)| |-|>| +0#0000000&|f|.|a|p@1|l|y|(| @27
@20|G|e|n|e|r|i|c|s|T|e|s|t|s|.|<|T|1|>|y|0|(|)| @32
@24|.|a|p@1|l|y|(|f|)@1|;| @39
@4|}| @69
@75
| +0#00e0e07&@3|s+0#00e0003&|t|a|t|i|c| +0#00e0e07&|<|T|1|,| |T|2|>| |Y+0#0000001#ffff4012|1|<|T+0#0000000#ffffff0|1|,+0#00e0e07&| |T+0#0000000&|2|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|y|1|(|)| +0#0000000&@39
@4|{| @69
@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|(+0#00e0e07&|F+0#0000001#ffff4012|u|n|c|t|i|o|n|<|F+0#ffffff16#ff404010|u|n|c|t|i|o|n|<|T+0#0000000#ffffff0|1|,+0#00e0e07&| |T+0#0000000&|2|>+0#ffffff16#ff404010|,+0#00e0e07#ffffff0| |F+0#ffffff16#ff404010|u|n|c|t|i|o|n|<|T+0#0000000#ffffff0|1|,+0#00e0e07&| |T+0#0000000&|2|>+0#ffffff16#ff404010|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|f|)| |-|>| +0#0000000&@8
@12|(+0#00e0e07&|T|1| |x|)| |-|>| +0#0000000&|f|.|a|p@1|l|y|(|G|e|n|e|r|i|c|s|T|e|s|t|s|.|<|T|1|,| |T|2|>|y|1|(|)| @18
@57|1|9|,|4|-|1|3| @6|1|0|%|

View File

@ -0,0 +1,20 @@
| +0&#ffffff0@11|(+0#00e0e07&|T|1| |x|)| |-|>| +0#0000000&|f|.|a|p@1|l|y|(|G|e|n|e|r|i|c|s|T|e|s|t|s|.|<|T|1|,| |T|2|>|y|1|(|)| @18
@24|.|a|p@1|l|y|(|f|)@1| @40
@16|.|a|p@1|l|y|(|x|)|;| @48
@4|}| @69
@75
@4>s+0#00e0003&|t|a|t|i|c|<+0#0000000&|T|>| |v+0#00e0003&|o|i|d| +0#0000000&|n|o|O|p|(|T| |d|u|m@1|y|)| |{| |}| @38
@75
@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|a|l|p|h|a|<|T|>| |{| |}| @48
@75
@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|Y+0#0000001#ffff4012|0|<|T+0#0000000#ffffff0|1|>+0#0000001#ffff4012| +0#0000000#ffffff0|e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|F+0#0000001#ffff4012|u|n|c|t|i|o|n|<|F+0#ffffff16#ff404010|u|n|c|t|i|o|n|<|T+0#0000000#ffffff0|1|,| |T|1|>+0#ffffff16#ff404010|,+0#0000000#ffffff0| |T|1|>+0#0000001#ffff4012| +0#0000000#ffffff0|{| |}| @11
@75
@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|Y+0#0000001#ffff4012|1|<|T+0#0000000#ffffff0|1|,| |T|2|>+0#0000001#ffff4012| +0#0000000#ffffff0|e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|F+0#0000001#ffff4012|u|n|c|t|i|o|n|<|F+0#ffffff16#ff404010|u|n|c|t|i|o|n|<|F+0#0000001#ffff4012|u|n|c|t|i|o|n|<|T+0#0000000#ffffff0|1|,| |T|2|>+0#0000001#ffff4012|,+0#0000000#ffffff0| @6
@20|F+0#0000001#ffff4012|u|n|c|t|i|o|n|<|T+0#0000000#ffffff0|1|,| |T|2|>+0#0000001#ffff4012|>+0#ffffff16#ff404010|,+0#0000000#ffffff0| @36
@20|F+0#ffffff16#ff404010|u|n|c|t|i|o|n|<|T+0#0000000#ffffff0|1|,| |T|2|>+0#ffffff16#ff404010|>+0#0000001#ffff4012| +0#0000000#ffffff0|{| |}| @33
@75
@4|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|S+0#0000001#ffff4012|t|a|c|k|a|b|l|e|<|E+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0|e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|I+0#0000001#ffff4012|t|e|r|a|b|l|e|<|E+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0@28
@4|{| @69
| +0#00e0e07&@7|b+0#00e0003&|o@1|l|e|a|n| +0#00e0e07&|i|s|E|m|p|t|y|(|)|;+0#0000000&| @48
| +0#00e0e07&@7|E| |p|e@1|k|(|)|;+0#0000000&| @57
@57|3|7|,|2|-|5| @7|2|5|%|

View File

@ -0,0 +1,20 @@
| +0#00e0e07#ffffff0@7|E| |p|e@1|k|(|)|;+0#0000000&| @57
| +0#00e0e07&@7|E| |p|o|p|(|)|;+0#0000000&| @58
| +0#00e0e07&@7|S+0#0000001#ffff4012|t|a|c|k|a|b|l|e|<|E+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|p|o|p|A|l@1|(|S+0#0000001#ffff4012|t|a|c|k|a|b|l|e|<|?+0#0000000#ffffff0| +0#00e0e07&|s+0#00e0003&|u|p|e|r| +0#00e0e07&|E+0#0000000&|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|e|l|e|m|e|n|t|s|)|;+0#0000000&| @15
| +0#00e0e07&@7|S+0#0000001#ffff4012|t|a|c|k|a|b|l|e|<|E+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|p|o|p|S|o|m|e|(|S+0#0000001#ffff4012|t|a|c|k|a|b|l|e|<|?+0#0000000#ffffff0| +0#00e0e07&|s+0#00e0003&|u|p|e|r| +0#00e0e07&|E+0#0000000&|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|e|l|e|m|e|n|t|s|,| +0#0000000&@15
| +0#00e0e07&@19|P+0#0000001#ffff4012|r|e|d|i|c|a|t|e|<|?+0#0000000#ffffff0| +0#00e0e07&|s+0#00e0003&|u|p|e|r| +0#00e0e07&|E+0#0000000&|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|f|i|l|t|e|r|)|;+0#0000000&| @25
| +0#00e0e07&@7>S+0#0000001#ffff4012|t|a|c|k|a|b|l|e|<|E+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|p|u|s|h|(|E| |e|l|e|m|e|n|t|)|;+0#0000000&| @37
| +0#00e0e07&@7|S+0#0000001#ffff4012|t|a|c|k|a|b|l|e|<|E+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|p|u|s|h|A|l@1|(|I+0#0000001#ffff4012|t|e|r|a|b|l|e|<|?+0#0000000#ffffff0| +0#00e0e07&|e+0#00e0003&|x|t|e|n|d|s| +0#00e0e07&|E+0#0000000&|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|e|l|e|m|e|n|t|s|)|;+0#0000000&| @13
| +0#00e0e07&@7|S+0#0000001#ffff4012|t|a|c|k|a|b|l|e|<|E+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|p|u|s|h|S|o|m|e|(|I+0#0000001#ffff4012|t|e|r|a|b|l|e|<|?+0#0000000#ffffff0| +0#00e0e07&|e+0#00e0003&|x|t|e|n|d|s| +0#00e0e07&|E+0#0000000&|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|e|l|e|m|e|n|t|s|,| +0#0000000&@13
| +0#00e0e07&@19|P+0#0000001#ffff4012|r|e|d|i|c|a|t|e|<|?+0#0000000#ffffff0| +0#00e0e07&|s+0#00e0003&|u|p|e|r| +0#00e0e07&|E+0#0000000&|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|f|i|l|t|e|r|)|;+0#0000000&| @25
| +0#00e0e07&@7|S+0#0000001#ffff4012|t|a|c|k|a|b|l|e|<|E+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|w|i|n|d|(|C+0#0000001#ffff4012|o|n|s|u|m|e|r|<|?+0#0000000#ffffff0| +0#00e0e07&|s+0#00e0003&|u|p|e|r| +0#00e0e07&|S+0#ffffff16#ff404010|t|a|c|k|a|b|l|e|<|E+0#0000000#ffffff0|>+0#ffffff16#ff404010|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|a|c|t|i|o|n|)|;+0#0000000&| @9
@4|}| @69
@75
@4|s+0#4040ff13&|e|a|l|e|d| +0#0000000&|i+0#00e0003&|n|t|e|r|f|a|c|e| +0#0000000&|N+0#0000001#ffff4012|u|m|<|N+0#0000000#ffffff0| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|N|u|m|b|e|r|>+0#0000001#ffff4012| +0#0000000#ffffff0@32
@4|{| @69
| +0#00e0e07&@7|i+0#00e0003&|n|t| +0#00e0e07&|r|a|d|i|x|(|)|;+0#0000000&| @54
| +0#00e0e07&@7|N| |v|a|l|u|e|(|)|;+0#0000000&| @56
@4|}| @69
@75
@4|r+0#00e0003&|e|c|o|r|d| +0#0000000&|B+0#0000001#ffff4012|i|n|<|N+0#0000000#ffffff0| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|N|u|m|b|e|r|>+0#0000001#ffff4012|(+0#0000000#ffffff0|N| |v|a|l|u|e|)| |i+0#00e0003&|m|p|l|e|m|e|n|t|s| +0#0000000&|N+0#0000001#ffff4012|u|m|<|N+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0@15
@57|5@1|,|3|-|9| @7|4|0|%|

View File

@ -0,0 +1,20 @@
| +0&#ffffff0@3|r+0#00e0003&|e|c|o|r|d| +0#0000000&|B+0#0000001#ffff4012|i|n|<|N+0#0000000#ffffff0| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|N|u|m|b|e|r|>+0#0000001#ffff4012|(+0#0000000#ffffff0|N| |v|a|l|u|e|)| |i+0#00e0003&|m|p|l|e|m|e|n|t|s| +0#0000000&|N+0#0000001#ffff4012|u|m|<|N+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0@15
@4|{| @69
| +0#00e0e07&@7|p+0#00e0003&|u|b|l|i|c| +0#00e0e07&|i+0#00e0003&|n|t| +0#00e0e07&|r|a|d|i|x|(|)| +0#0000000&|{| |r+0#af5f00255&|e|t|u|r|n| +0#0000000&|2+0#e000002&|;+0#0000000&| |}| @34
@4|}| @69
@75
@4>r+0#00e0003&|e|c|o|r|d| +0#0000000&|D+0#0000001#ffff4012|e|c|<|N+0#0000000#ffffff0| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|N|u|m|b|e|r|>+0#0000001#ffff4012|(+0#0000000#ffffff0|N| |v|a|l|u|e|)| |i+0#00e0003&|m|p|l|e|m|e|n|t|s| +0#0000000&|N+0#0000001#ffff4012|u|m|<|N+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0@15
@4|{| @69
| +0#00e0e07&@7|p+0#00e0003&|u|b|l|i|c| +0#00e0e07&|i+0#00e0003&|n|t| +0#00e0e07&|r|a|d|i|x|(|)| +0#0000000&|{| |r+0#af5f00255&|e|t|u|r|n| +0#0000000&|1+0#e000002&|0|;+0#0000000&| |}| @33
@4|}| @69
@75
@4|r+0#00e0003&|e|c|o|r|d| +0#0000000&|H+0#0000001#ffff4012|e|x|<|N+0#0000000#ffffff0| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|N|u|m|b|e|r|>+0#0000001#ffff4012|(+0#0000000#ffffff0|N| |v|a|l|u|e|)| |i+0#00e0003&|m|p|l|e|m|e|n|t|s| +0#0000000&|N+0#0000001#ffff4012|u|m|<|N+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0@15
@4|{| @69
| +0#00e0e07&@7|p+0#00e0003&|u|b|l|i|c| +0#00e0e07&|i+0#00e0003&|n|t| +0#00e0e07&|r|a|d|i|x|(|)| +0#0000000&|{| |r+0#af5f00255&|e|t|u|r|n| +0#0000000&|1+0#e000002&|6|;+0#0000000&| |}| @33
@4|}| @69
@75
@4|r+0#00e0003&|e|c|o|r|d| +0#0000000&|O+0#0000001#ffff4012|c|t|<|N+0#0000000#ffffff0| |e+0#00e0003&|x|t|e|n|d|s| +0#0000000&|N|u|m|b|e|r|>+0#0000001#ffff4012|(+0#0000000#ffffff0|N| |v|a|l|u|e|)| |i+0#00e0003&|m|p|l|e|m|e|n|t|s| +0#0000000&|N+0#0000001#ffff4012|u|m|<|N+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0@15
@4|{| @69
| +0#00e0e07&@7|p+0#00e0003&|u|b|l|i|c| +0#00e0e07&|i+0#00e0003&|n|t| +0#00e0e07&|r|a|d|i|x|(|)| +0#0000000&|{| |r+0#af5f00255&|e|t|u|r|n| +0#0000000&|8+0#e000002&|;+0#0000000&| |}| @34
@4|}| @69
@57|7|3|,|2|-|5| @7|5@1|%|

View File

@ -0,0 +1,20 @@
| +0&#ffffff0@3|}| @69
@75
| +0#00e0e07&@3|s+0#00e0003&|t|a|t|i|c| +0#00e0e07&|N+0#0000001#ffff4012|u|m|<|L+0#0000000#ffffff0|o|n|g|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|f|r|o|m|D|e|c|i|m|a|l|(|l+0#00e0003&|o|n|g| +0#00e0e07&|x|,| |i+0#00e0003&|n|t| +0#00e0e07&|r|a|d|i|x|)| +0#0000000&@23
@4|{| @69
@8|r+0#00e0003&|e|c|o|r|d| +0#0000000&|P|a|i|r|(|L+0#0000001#ffff4012|o|n|g|F|u|n|c|t|i|o|n|<|N+0#ffffff16#ff404010|u|m|<|L+0#0000000#ffffff0|o|n|g|>+0#ffffff16#ff404010|>+0#0000001#ffff4012| +0#0000000#ffffff0|a|,| @28
@20>L+0#0000001#ffff4012|o|n|g|F|u|n|c|t|i|o|n|<|S+0#0000000#ffffff0|t|r|i|n|g|>+0#0000001#ffff4012| +0#0000000#ffffff0|b|)| |{| |}| @27
@8|f+0#4040ff13&|i|n|a|l| +0#0000000&|P|a|i|r| |p| |=| |s+0#af5f00255&|w|i|t|c|h| +0#0000000&|(|r|a|d|i|x|)| |{| @35
@12|c+0#af5f00255&|a|s|e| +0#0000000&|2+0#e000002&| +0#0000000&|-|>| |n+0#af5f00255&|e|w| +0#0000000&|P|a|i|r|(|B|i|n|:@1|n+0#af5f00255&|e|w|,+0#0000000&| |L|o|n|g|:@1|t|o|B|i|n|a|r|y|S|t|r|i|n|g|)|;| @11
@12|c+0#af5f00255&|a|s|e| +0#0000000&|8+0#e000002&| +0#0000000&|-|>| |n+0#af5f00255&|e|w| +0#0000000&|P|a|i|r|(|O|c|t|:@1|n+0#af5f00255&|e|w|,+0#0000000&| |L|o|n|g|:@1|t|o|O|c|t|a|l|S|t|r|i|n|g|)|;| @12
@12|c+0#af5f00255&|a|s|e| +0#0000000&|1+0#e000002&|6| +0#0000000&|-|>| |n+0#af5f00255&|e|w| +0#0000000&|P|a|i|r|(|H|e|x|:@1|n+0#af5f00255&|e|w|,+0#0000000&| |L|o|n|g|:@1|t|o|H|e|x|S|t|r|i|n|g|)|;| @13
@12|d+0#af5f00255&|e|f|a|u|l|t| +0#0000000&|-|>| |n+0#af5f00255&|e|w| +0#0000000&|P|a|i|r|(|D|e|c|:@1|n+0#af5f00255&|e|w|,+0#0000000&| @33
@24|y+0#00e0e07&| |-|>| +0#0000000&|L|o|n|g|.|t|o|S|t|r|i|n|g|(|y|)@1|;| @27
@8|}|;| @64
@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|p|.|a|(|)|.|a|p@1|l|y|(|L|o|n|g|.|p|a|r|s|e|L|o|n|g|(|p|.|b|(|)|.|a|p@1|l|y|(|x|)|,| |r|a|d|i|x|)@1|;| @8
@4|}| @69
@75
| +0#00e0e07&@3|s+0#00e0003&|t|a|t|i|c| +0#00e0e07&|l+0#00e0003&|o|n|g| +0#00e0e07&|t|o|D|e|c|i|m|a|l|(|N+0#0000001#ffff4012|u|m|<|L+0#0000000#ffffff0|o|n|g|>+0#0000001#ffff4012| +0#00e0e07#ffffff0|x|)| +0#0000000&@36
@4|{| @69
@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|L|o|n|g|.|p|a|r|s|e|L|o|n|g|(|s+0#af5f00255&|w|i|t|c|h| +0#0000000&|(|x|)| |{| @32
@57|9|1|,|6|-|2|1| @6|7|0|%|

View File

@ -0,0 +1,20 @@
| +0&#ffffff0@7|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|L|o|n|g|.|p|a|r|s|e|L|o|n|g|(|s+0#af5f00255&|w|i|t|c|h| +0#0000000&|(|x|)| |{| @32
@12|c+0#af5f00255&|a|s|e| +0#0000000&|B+0#0000001#ffff4012|i|n|<|?+0#0000000#ffffff0|>+0#0000001#ffff4012|(+0#0000000#ffffff0|L|o|n|g| |b|)| |-|>| |L|o|n|g|.|t|o|B|i|n|a|r|y|S|t|r|i|n|g|(|b|)|;| @16
@12|c+0#af5f00255&|a|s|e| +0#0000000&|O+0#0000001#ffff4012|c|t|<|?+0#0000000#ffffff0|>+0#0000001#ffff4012|(+0#0000000#ffffff0|L|o|n|g| |o|)| |-|>| |L|o|n|g|.|t|o|O|c|t|a|l|S|t|r|i|n|g|(|o|)|;| @17
@12|c+0#af5f00255&|a|s|e| +0#0000000&|H+0#0000001#ffff4012|e|x|<|?+0#0000000#ffffff0|>+0#0000001#ffff4012|(+0#0000000#ffffff0|L|o|n|g| |h|)| |-|>| |L|o|n|g|.|t|o|H|e|x|S|t|r|i|n|g|(|h|)|;| @19
@12|d+0#af5f00255&|e|f|a|u|l|t| +0#0000000&|-|>| |L|o|n|g|.|t|o|S|t|r|i|n|g|(|x|.|v|a|l|u|e|(|)@1|;| @26
@8>}|,| |x|.|r|a|d|i|x|(|)@1|;| @52
@4|}| @69
@75
@4|@+0#e000e06&|j|a|v|a|.|l|a|n|g|.|a|n@1|o|t|a|t|i|o|n|.|T|a|r|g|e|t|(| +0#0000000&@41
@16|j|a|v|a|.|l|a|n|g|.|a|n@1|o|t|a|t|i|o|n|.|E|l|e|m|e|n|t|T|y|p|e|.|T|Y|P|E|_|U|S|E|)+0#e000e06&| +0#0000000&@16
@4|@+0#00e0003&|i|n|t|e|r|f|a|c|e| +0#0000000&|T|a|g@1|a|b|l|e| @51
@4|{| @69
| +0#00e0e07&@7|S|t|r|i|n|g| |v|a|l|u|e|(|)| +0#0000000&|d+0#4040ff13&|e|f|a|u|l|t| +0#0000000&|"+0#e000002&@1|;+0#0000000&| @40
@4|}| @69
@75
@4|{| @69
@8|i+0#00e0003&|n|t| +0#0000000&|N| |=| |0+0#e000002&|,+0#0000000&| |X| |=| |1+0#e000002&|,+0#0000000&| |Y| |=| |2+0#e000002&|;+0#0000000&| @42
@8|P+0#0000001#ffff4012|r|e|d|i|c|a|t|e|<|T+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0|f| |=| |y+0#00e0e07&|-|>|N+0#0000000&|<|y|.|i|n|t|V|a|l|u|e|(|)|;| @31
@8|P+0#0000001#ffff4012|r|e|d|i|c|a|t|e|<|T+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0|g| |=| |y+0#00e0e07&|-|>|X+0#0000001#ffff4012|<|N+0#0000000#ffffff0|&@1|(|I|n|t|e|g|e|r|)|y|>+0#0000001#ffff4012|N+0#0000000#ffffff0|;| @28
@57|1|0|9|,|3|-|9| @6|8|5|%|

View File

@ -0,0 +1,20 @@
| +0&#ffffff0@7|P+0#0000001#ffff4012|r|e|d|i|c|a|t|e|<|T+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0|g| |=| |y+0#00e0e07&|-|>|X+0#0000001#ffff4012|<|N+0#0000000#ffffff0|&@1|(|I|n|t|e|g|e|r|)|y|>+0#0000001#ffff4012|N+0#0000000#ffffff0|;| @28
@8|b+0#00e0003&|o@1|l|e|a|n|[+0#0000000&|]| |b@1| |=| |{| @50
@12|X+0#0000001#ffff4012|<|N+0#0000000#ffffff0||@1|N|>+0#0000001#ffff4012|Y+0#0000000#ffffff0|,| |X| |<| |Y|,| |X| |<|Y|,| |X| |<|(|Y|)|,| |X|<|(|Y|)|,| |(|X|)|<|Y|,| @18
@12|D|o|u|b|l|e|.|i|s|F|i|n|i|t|e|(|X|<@1|Y|)|,| @40
@12|X|<|=|Y|,| |X|<|(|i+0#00e0003&|n|t|)+0#0000000&|(|b+0#00e0003&|y|t|e|)+0#0000000&|Y|,| |X|<|~|Y|,| |X|<|-|Y|,| |X|<|+|Y|,| @23
@8>}|;| @64
@8|C+0#0000001#ffff4012|l|a|s@1|<|?+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0|k|l|a|s@1| |=| |G|e|n|e|r|i|c|s|T|e|s|t|s|.|c+0#00e0003&|l|a|s@1|;+0#0000000&| @29
@8|C+0#0000001#ffff4012|l|a|s@1|<| +0#0000000#ffffff0|j+0#ffffff16#ff404010|a|v|a|.|l|a|n|g|.|C|l|a|s@1|<|@+0#e000e06#ffffff0|T|a|g@1|a|b|l|e|(|"+0#e000002&|<|>|"|)+0#e000e06&|i+0#00e0003&|n|t|[+0#0000000&|]|[|]|>+0#ffffff16#ff404010| +0#0000000#ffffff0|[+0#ffffff16#ff404010|]| +0#0000000#ffffff0|[+0#ffffff16#ff404010|]| +0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0@12
@8|[+0#0000001#ffff4012| +0#0000000#ffffff0|]+0#0000001#ffff4012| +0#0000000#ffffff0|[+0#0000001#ffff4012| +0#0000000#ffffff0|]+0#0000001#ffff4012| +0#0000000#ffffff0|$| |[| |]| |[| |]|;| @48
@8|i+0#af5f00255&|f| +0#0000000&|(|f+0#e000002&|a|l|s|e|)+0#0000000&| |{| |n+0#af5f00255&|e|w| +0#0000000&|G|e|n|e|r|i|c|s|T|e|s|t|s|<|>|(|)|;| |}| @29
@8|a|l|p|h|a|<|?|>| |a|o|;| @54
@8|a|l|p|h|a|<|U|>| |a|u|;| @54
@8|a|l|p|h|a|<|a|l|p|h|a|<|U|>@1| |a@1|u|;| @46
@8|a|l|p|h|a|<|Y+0#0000001#ffff4012|0|<|?+0#0000000#ffffff0|>+0#0000001#ffff4012|>+0#0000000#ffffff0| |a|y|0|o|;| @48
@8|a|l|p|h|a|<|Y+0#0000001#ffff4012|0|<|U+0#0000000#ffffff0|>+0#0000001#ffff4012|>+0#0000000#ffffff0| |a|y|0|u|;| @48
@8|Y|0|<|a|l|p|h|a|<|?|>@1| |y|0|a|o|;| @48
@8|Y|0|<|a|l|p|h|a|<|U|>@1| |y|0|a|u|;| @48
@4|}| @69
|}| @73
@57|1|2|7|,|3|-|9| @6|B|o|t|

View File

@ -0,0 +1,20 @@
| +0&#ffffff0@7|P+0#0000001#ffff4012|r|e|d|i|c|a|t|e|<|T+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0|g| |=| |y+0#00e0e07&|-|>|X+0#0000001#ffff4012|<|N+0#0000000#ffffff0|&@1|(|I|n|t|e|g|e|r|)|y|>+0#0000001#ffff4012|N+0#0000000#ffffff0|;| @28
@8|b+0#00e0003&|o@1|l|e|a|n|[+0#0000000&|]| |b@1| |=| |{| @50
@12|X+0#0000001#ffff4012|<|N+0#0000000#ffffff0||@1|N|>+0#0000001#ffff4012|Y+0#0000000#ffffff0|,| |X| |<| |Y|,| |X| |<|Y|,| |X| |<|(|Y|)|,| |X|<|(|Y|)|,| |(|X|)|<|Y|,| @18
@12|D|o|u|b|l|e|.|i|s|F|i|n|i|t|e|(|X|<@1|Y|)|,| @40
@12|X|<|=|Y|,| |X|<|(|i+0#00e0003&|n|t|)+0#0000000&|(|b+0#00e0003&|y|t|e|)+0#0000000&|Y|,| |X|<|~|Y|,| |X|<|-|Y|,| |X|<|+|Y|,| @23
@8|}|;| @64
@8|C+0#0000001#ffff4012|l|a|s@1|<|?+0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0|k|l|a|s@1| |=| |G|e|n|e|r|i|c|s|T|e|s|t|s|.|c+0#00e0003&|l|a|s@1|;+0#0000000&| @29
@8|C+0#0000001#ffff4012|l|a|s@1|<| +0#0000000#ffffff0|j+0#ffffff16#ff404010|a|v|a|.|l|a|n|g|.|C|l|a|s@1|<|@+0#e000e06#ffffff0|T|a|g@1|a|b|l|e|(|"+0#e000002&|<|>|"|)+0#e000e06&|i+0#00e0003&|n|t|[+0#0000000&|]|[|]|>+0#ffffff16#ff404010| +0#0000000#ffffff0|[+0#ffffff16#ff404010|]| +0#0000000#ffffff0|[+0#ffffff16#ff404010|]| +0#0000000#ffffff0|>+0#0000001#ffff4012| +0#0000000#ffffff0@12
@8|[+0#0000001#ffff4012| +0#0000000#ffffff0|]+0#0000001#ffff4012| +0#0000000#ffffff0|[+0#0000001#ffff4012| +0#0000000#ffffff0|]+0#0000001#ffff4012| +0#0000000#ffffff0|$| |[| |]| |[| |]|;| @48
@8|i+0#af5f00255&|f| +0#0000000&|(|f+0#e000002&|a|l|s|e|)+0#0000000&| |{| |n+0#af5f00255&|e|w| +0#0000000&|G|e|n|e|r|i|c|s|T|e|s|t|s|<|>|(|)|;| |}| @29
@8|a|l|p|h|a|<|?|>| |a|o|;| @54
@8|a|l|p|h|a|<|U|>| |a|u|;| @54
@8|a|l|p|h|a|<|a|l|p|h|a|<|U|>@1| |a@1|u|;| @46
@8|a|l|p|h|a|<|Y+0#0000001#ffff4012|0|<|?+0#0000000#ffffff0|>+0#0000001#ffff4012|>+0#0000000#ffffff0| |a|y|0|o|;| @48
@8|a|l|p|h|a|<|Y+0#0000001#ffff4012|0|<|U+0#0000000#ffffff0|>+0#0000001#ffff4012|>+0#0000000#ffffff0| |a|y|0|u|;| @48
@8|Y|0|<|a|l|p|h|a|<|?|>@1| |y|0|a|o|;| @48
@8|Y|0|<|a|l|p|h|a|<|U|>@1| |y|0|a|u|;| @48
@4|}| @69
>}| @73
@57|1|4|0|,|1| @8|B|o|t|

View File

@ -0,0 +1,140 @@
// VIM_TEST_SETUP let g:java_highlight_functions = 'style'
// VIM_TEST_SETUP let g:java_highlight_generics = 1
// VIM_TEST_SETUP hi link javaGenericsC1 Todo
// VIM_TEST_SETUP hi link javaGenericsC2 Error
import java.math.BigInteger;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.LongFunction;
import java.util.function.Predicate;
class GenericsTests<T extends Number & Comparable<? super T>, U>
{ // JDK 21+.
static final Function<Function<Object, Object>, Object> PARTIAL =
GenericsTests.y0();
static final Function<BigInteger, BigInteger> FACTORIAL_2000 =
GenericsTests.<BigInteger, BigInteger>y1()
.apply(f -> x -> (x.compareTo(BigInteger.ONE) < 1)
? BigInteger.ONE
: x.multiply(f.apply(x.subtract(BigInteger.ONE))));
static <T1> Y0<T1> y0()
{
return (Function<T1, T1> f) -> f.apply(
GenericsTests.<T1>y0()
.apply(f));
}
static <T1, T2> Y1<T1, T2> y1()
{
return (Function<Function<T1, T2>, Function<T1, T2>> f) ->
(T1 x) -> f.apply(GenericsTests.<T1, T2>y1()
.apply(f))
.apply(x);
}
static<T> void noOp(T dummy) { }
interface alpha<T> { }
interface Y0<T1> extends Function<Function<T1, T1>, T1> { }
interface Y1<T1, T2> extends Function<Function<Function<T1, T2>,
Function<T1, T2>>,
Function<T1, T2>> { }
interface Stackable<E> extends Iterable<E>
{
boolean isEmpty();
E peek();
E pop();
Stackable<E> popAll(Stackable<? super E> elements);
Stackable<E> popSome(Stackable<? super E> elements,
Predicate<? super E> filter);
Stackable<E> push(E element);
Stackable<E> pushAll(Iterable<? extends E> elements);
Stackable<E> pushSome(Iterable<? extends E> elements,
Predicate<? super E> filter);
Stackable<E> wind(Consumer<? super Stackable<E>> action);
}
sealed interface Num<N extends Number>
{
int radix();
N value();
}
record Bin<N extends Number>(N value) implements Num<N>
{
public int radix() { return 2; }
}
record Dec<N extends Number>(N value) implements Num<N>
{
public int radix() { return 10; }
}
record Hex<N extends Number>(N value) implements Num<N>
{
public int radix() { return 16; }
}
record Oct<N extends Number>(N value) implements Num<N>
{
public int radix() { return 8; }
}
static Num<Long> fromDecimal(long x, int radix)
{
record Pair(LongFunction<Num<Long>> a,
LongFunction<String> b) { }
final Pair p = switch (radix) {
case 2 -> new Pair(Bin::new, Long::toBinaryString);
case 8 -> new Pair(Oct::new, Long::toOctalString);
case 16 -> new Pair(Hex::new, Long::toHexString);
default -> new Pair(Dec::new,
y -> Long.toString(y));
};
return p.a().apply(Long.parseLong(p.b().apply(x), radix));
}
static long toDecimal(Num<Long> x)
{
return Long.parseLong(switch (x) {
case Bin<?>(Long b) -> Long.toBinaryString(b);
case Oct<?>(Long o) -> Long.toOctalString(o);
case Hex<?>(Long h) -> Long.toHexString(h);
default -> Long.toString(x.value());
}, x.radix());
}
@java.lang.annotation.Target(
java.lang.annotation.ElementType.TYPE_USE)
@interface Taggable
{
String value() default "";
}
{
int N = 0, X = 1, Y = 2;
Predicate<T> f = y->N<y.intValue();
Predicate<T> g = y->X<N&&(Integer)y>N;
boolean[] bb = {
X<N||N>Y, X < Y, X <Y, X <(Y), X<(Y), (X)<Y,
Double.isFinite(X<<Y),
X<=Y, X<(int)(byte)Y, X<~Y, X<-Y, X<+Y,
};
Class<?> klass = GenericsTests.class;
Class< java.lang.Class<@Taggable("<>")int[][]> [] [] >
[ ] [ ] $ [ ] [ ];
if (false) { new GenericsTests<>(); }
alpha<?> ao;
alpha<U> au;
alpha<alpha<U>> aau;
alpha<Y0<?>> ay0o;
alpha<Y0<U>> ay0u;
Y0<alpha<?>> y0ao;
Y0<alpha<U>> y0au;
}
}