Merge branch 'ar/userdiff-java-update'

Userdiff regexp update for Java language.

* ar/userdiff-java-update:
  userdiff: support Java sealed classes
  userdiff: support Java record types
  userdiff: support Java type parameters
This commit is contained in:
Junio C Hamano 2023-02-15 17:11:52 -08:00
commit 4a6e6b0d5b
16 changed files with 95 additions and 2 deletions

View file

@ -0,0 +1,6 @@
class RIGHT
{
static int ONE;
static int TWO;
static int ChangeMe;
}

View file

@ -0,0 +1,6 @@
class RIGHT <TYPE, PARAMS, AFTER, SPACE> {
static int ONE;
static int TWO;
static int THREE;
private A ChangeMe;
}

View file

@ -0,0 +1,6 @@
class RIGHT<A, B> {
static int ONE;
static int TWO;
static int THREE;
private A ChangeMe;
}

View file

@ -0,0 +1,6 @@
class RIGHT<A, B> implements List<A> {
static int ONE;
static int TWO;
static int THREE;
private A ChangeMe;
}

View file

@ -0,0 +1,6 @@
interface RIGHT<A, B> {
static int ONE;
static int TWO;
static int THREE;
public B foo(A ChangeMe);
}

View file

@ -0,0 +1,6 @@
interface RIGHT<A, B> extends Function<A, B> {
static int ONE;
static int TWO;
static int THREE;
public B foo(A ChangeMe);
}

8
t/t4018/java-non-sealed Normal file
View file

@ -0,0 +1,8 @@
public abstract sealed class SealedClass {
public static non-sealed class RIGHT extends SealedClass {
static int ONE;
static int TWO;
static int THREE;
private int ChangeMe;
}
}

6
t/t4018/java-record Normal file
View file

@ -0,0 +1,6 @@
public record RIGHT(int comp1, double comp2, String comp3) {
static int ONE;
static int TWO;
static int THREE;
static int ChangeMe;
}

View file

@ -0,0 +1,6 @@
public record RIGHT (String components, String after, String space) {
static int ONE;
static int TWO;
static int THREE;
static int ChangeMe;
}

View file

@ -0,0 +1,6 @@
public record RIGHT<A, N extends Number>(A comp1, N comp2, int comp3) {
static int ONE;
static int TWO;
static int THREE;
static int ChangeMe;
}

7
t/t4018/java-sealed Normal file
View file

@ -0,0 +1,7 @@
public abstract sealed class Sealed { // RIGHT
static int ONE;
static int TWO;
static int THREE;
public final class ChangeMe extends Sealed {
}
}

View file

@ -0,0 +1,6 @@
public abstract sealed class RIGHT permits PermittedA, PermittedB {
static int ONE;
static int TWO;
static int THREE;
private int ChangeMe;
}

View file

@ -0,0 +1,6 @@
public abstract sealed class RIGHT<A, B> {
static int ONE;
static int TWO;
static int THREE;
private int ChangeMe;
}

View file

@ -0,0 +1,6 @@
public abstract sealed class RIGHT<A, B> implements List<A> permits PermittedA, PermittedB {
static int ONE;
static int TWO;
static int THREE;
private int ChangeMe;
}

View file

@ -0,0 +1,6 @@
public abstract sealed class RIGHT<A, B> permits PermittedA, PermittedB {
static int ONE;
static int TWO;
static int THREE;
private int ChangeMe;
}

View file

@ -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]+[A-Za-z][A-Za-z0-9_$]*[ \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]*\\([^;]*)$",