Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Rybak <rybak.a.v@gmail.com>2023-02-08 02:42:58 +0300
committerJunio C Hamano <gitster@pobox.com>2023-02-08 23:57:11 +0300
commit575e6fcfcc961a64a222e0241cdc117d24f9ec87 (patch)
treeaf9609ef5892403e845884923dcac8d2e05f3379 /userdiff.c
parent39226a8dacc866417be19b0a95b45e82d5975a84 (diff)
userdiff: support Java record types
A new kind of class was added in Java 16 -- records.[1] The syntax of records is similar to regular classes with one important distinction: the name of the record class is followed by a mandatory list of components. The list is enclosed in parentheses, it may be empty, and it may immediately follow the name of the class or type parameters, if any, with or without separating whitespace. For example: public record Example(int i, String s) { } public record WithTypeParameters<A, B>(A a, B b, String s) { } record SpaceBeforeComponents (String comp1, int comp2) { } Support records in the builtin userdiff pattern for Java. Add "record" to the alternatives of keywords for kinds of class. Allowing matching various possibilities for the type parameters and/or list of the components of a record has already been covered by the preceding patch. [1] detailed description is available in "JEP 395: Records" https://openjdk.org/jeps/395 Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com> Reviewed-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'userdiff.c')
-rw-r--r--userdiff.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/userdiff.c b/userdiff.c
index bc5f3ed4c3..37ac98e177 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -170,8 +170,8 @@ PATTERNS("html",
"[^<>= \t]+"),
PATTERNS("java",
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
- /* Class, enum, and interface declarations */
- "^[ \t]*(([a-z]+[ \t]+)*(class|enum|interface)[ \t]+.*)$\n"
+ /* Class, enum, interface, and record declarations */
+ "^[ \t]*(([a-z]+[ \t]+)*(class|enum|interface|record)[ \t]+.*)$\n"
/* Method definitions; note that constructor signatures are not */
/* matched because they are indistinguishable from method calls. */
"^[ \t]*(([A-Za-z_<>&][][?&<>.,A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$",