]> git.ipfire.org Git - thirdparty/vim.git/commit
runtime(java): Optionally highlight parameterised types
authorAliaksei Budavei <0x000c70@gmail.com>
Thu, 20 Jun 2024 19:00:53 +0000 (21:00 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 20 Jun 2024 19:00:53 +0000 (21:00 +0200)
commitbeb02ed674bc61f179c4ff71e93bdeeb44fe9c4e
tree0764a3031bda82f0b64e962332a21b5489339b57
parent49012cd8c2fb0452847e5d213b07aa8a978f4762
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>
12 files changed:
runtime/doc/syntax.txt
runtime/syntax/java.vim
runtime/syntax/testdir/dumps/java_generics_00.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/java_generics_01.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/java_generics_02.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/java_generics_03.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/java_generics_04.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/java_generics_05.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/java_generics_06.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/java_generics_07.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/java_generics_99.dump [new file with mode: 0644]
runtime/syntax/testdir/input/java_generics.java [new file with mode: 0644]