Skip to content

Commit e322791

Browse files
java-team-github-botgoogle-java-format Team
authored andcommitted
Preserve ellipses when formatting parameter comments.
PiperOrigin-RevId: 488956140
1 parent 198fa42 commit e322791

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

core/src/main/java/com/google/googlejavaformat/CommentsHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ static Optional<String> reformatParameterComment(Tok tok) {
4646

4747
Pattern PARAMETER_COMMENT =
4848
Pattern.compile(
49-
"/\\*\\s*(\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*)(\\Q...\\E)?\\s*=\\s*\\*/");
49+
"/\\*\\s*(\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*(\\Q...\\E)?)\\s*=\\s*\\*/");
5050
}

core/src/test/resources/com/google/googlejavaformat/java/testdata/ParameterComment.input

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ class Q {
2323
/*k=*/ 1);
2424
g(/*a=*/ 1, /*b=*/ 1, /*c=*/ 1, /*d=*/ 1, /*e=*/ 1, /*f=*/ 1, /*g=*/ 1, /*h=*/ 1, /*i=*/ 1);
2525
}
26+
static void h(Object... xs) {
27+
h(/*xs...=*/ null);
28+
}
2629
}

core/src/test/resources/com/google/googlejavaformat/java/testdata/ParameterComment.output

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ class Q {
3131
/* h= */ 1,
3232
/* i= */ 1);
3333
}
34+
35+
static void h(Object... xs) {
36+
h(/* xs...= */ null);
37+
}
3438
}

0 commit comments

Comments
 (0)