Skip to content

Commit a896086

Browse files
committed
Merge branch 'th/userdiff-more-java'
The userdiff pattern for "java" language has been updated. * th/userdiff-more-java: userdiff: improve java hunk header regex
2 parents fb0b14d + a8cbc89 commit a896086

File tree

6 files changed

+39
-1
lines changed

6 files changed

+39
-1
lines changed

t/t4018/java-class-member-function

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ public class Beer
33
int special;
44
public static void main(String RIGHT[])
55
{
6+
someMethodCall();
7+
someOtherMethod("17")
8+
.doThat();
9+
// Whatever
610
System.out.print("ChangeMe");
711
}
812
}

t/t4018/java-enum-constant

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
private enum RIGHT {
2+
ONE,
3+
TWO,
4+
THREE,
5+
ChangeMe
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class MyExample {
2+
public <T extends Bar & Foo<T>, R> Map<T, R[]> foo(String[] RIGHT) {
3+
someMethodCall();
4+
someOtherMethod()
5+
.doThat();
6+
// Whatever...
7+
return (List<T>) Arrays.asList("ChangeMe");
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class MyExample {
2+
public List<? extends Comparable> foo(String[] RIGHT) {
3+
someMethodCall();
4+
someOtherMethod()
5+
.doThat();
6+
// Whatever...
7+
return Arrays.asList("ChangeMe");
8+
}
9+
}

t/t4018/java-nested-field

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class MyExample {
2+
private static class RIGHT {
3+
// change an inner class field
4+
String inner = "ChangeMe";
5+
}
6+
}

userdiff.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ PATTERNS("html",
152152
"[^<>= \t]+"),
153153
PATTERNS("java",
154154
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
155-
"^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$",
155+
/* Class, enum, and interface declarations */
156+
"^[ \t]*(([a-z]+[ \t]+)*(class|enum|interface)[ \t]+[A-Za-z][A-Za-z0-9_$]*[ \t]+.*)$\n"
157+
/* Method definitions; note that constructor signatures are not */
158+
/* matched because they are indistinguishable from method calls. */
159+
"^[ \t]*(([A-Za-z_<>&][][?&<>.,A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$",
156160
/* -- */
157161
"[a-zA-Z_][a-zA-Z0-9_]*"
158162
"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"

0 commit comments

Comments
 (0)