Skip to content

Commit 198fa42

Browse files
cushongoogle-java-format Team
authored and
google-java-format Team
committed
Format long exception lists one-per-line
PiperOrigin-RevId: 486955708
1 parent dda4321 commit 198fa42

File tree

2 files changed

+91
-19
lines changed

2 files changed

+91
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2639,7 +2639,7 @@ private void visitThrowsClause(List<? extends ExpressionTree> thrownExceptionTyp
26392639
for (ExpressionTree thrownExceptionType : thrownExceptionTypes) {
26402640
if (!first) {
26412641
token(",");
2642-
builder.breakToFill(" ");
2642+
builder.breakOp(" ");
26432643
}
26442644
scan(thrownExceptionType, null);
26452645
first = false;

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

Lines changed: 90 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ class M {
3636

3737
/** JavaDoc. */
3838
void methodName3(int x)
39-
throws Exception0, Exception1, Exception2, Exception3, Exception4, Exception5, Exception6,
40-
Exception7, Exception8, Exception9 {}
39+
throws Exception0,
40+
Exception1,
41+
Exception2,
42+
Exception3,
43+
Exception4,
44+
Exception5,
45+
Exception6,
46+
Exception7,
47+
Exception8,
48+
Exception9 {}
4149

4250
/** JavaDoc. */
4351
void methodName4(
@@ -114,8 +122,16 @@ class M {
114122
int t,
115123
int u,
116124
int v)
117-
throws Exception0, Exception1, Exception2, Exception3, Exception4, Exception5, Exception6,
118-
Exception7, Exception8, Exception9 {}
125+
throws Exception0,
126+
Exception1,
127+
Exception2,
128+
Exception3,
129+
Exception4,
130+
Exception5,
131+
Exception6,
132+
Exception7,
133+
Exception8,
134+
Exception9 {}
119135

120136
Pair<
121137
Pair<Pair<Pair<T, T>, Pair<T, T>>, Pair<Pair<T, T>, Pair<T, T>>>,
@@ -135,8 +151,16 @@ class M {
135151
Pair<Pair<Pair<T, T>, Pair<T, T>>, Pair<Pair<T, T>, Pair<T, T>>>,
136152
Pair<Pair<Pair<T, T>, Pair<T, T>>, Pair<Pair<T, T>, Pair<T, T>>>>
137153
methodName11(int x)
138-
throws Exception0, Exception1, Exception2, Exception3, Exception4, Exception5, Exception6,
139-
Exception7, Exception8, Exception9 {
154+
throws Exception0,
155+
Exception1,
156+
Exception2,
157+
Exception3,
158+
Exception4,
159+
Exception5,
160+
Exception6,
161+
Exception7,
162+
Exception8,
163+
Exception9 {
140164
return null;
141165
}
142166

@@ -225,8 +249,16 @@ class M {
225249
int t,
226250
int u,
227251
int v)
228-
throws Exception0, Exception1, Exception2, Exception3, Exception4, Exception5, Exception6,
229-
Exception7, Exception8, Exception9 {
252+
throws Exception0,
253+
Exception1,
254+
Exception2,
255+
Exception3,
256+
Exception4,
257+
Exception5,
258+
Exception6,
259+
Exception7,
260+
Exception8,
261+
Exception9 {
230262
return null;
231263
}
232264

@@ -338,8 +370,16 @@ class M {
338370
T30,
339371
T31>
340372
T methodName22(int x)
341-
throws Exception0, Exception1, Exception2, Exception3, Exception4, Exception5, Exception6,
342-
Exception7, Exception8, Exception9 {
373+
throws Exception0,
374+
Exception1,
375+
Exception2,
376+
Exception3,
377+
Exception4,
378+
Exception5,
379+
Exception6,
380+
Exception7,
381+
Exception8,
382+
Exception9 {
343383
return null;
344384
}
345385

@@ -518,8 +558,16 @@ class M {
518558
int t,
519559
int u,
520560
int v)
521-
throws Exception0, Exception1, Exception2, Exception3, Exception4, Exception5, Exception6,
522-
Exception7, Exception8, Exception9 {
561+
throws Exception0,
562+
Exception1,
563+
Exception2,
564+
Exception3,
565+
Exception4,
566+
Exception5,
567+
Exception6,
568+
Exception7,
569+
Exception8,
570+
Exception9 {
523571
return null;
524572
}
525573

@@ -640,8 +688,16 @@ class M {
640688
Pair<Pair<Pair<T, T>, Pair<T, T>>, Pair<Pair<T, T>, Pair<T, T>>>,
641689
Pair<Pair<Pair<T, T>, Pair<T, T>>, Pair<Pair<T, T>, Pair<T, T>>>>
642690
methodName(int x)
643-
throws Exception0, Exception1, Exception2, Exception3, Exception4, Exception5,
644-
Exception6, Exception7, Exception8, Exception9 {
691+
throws Exception0,
692+
Exception1,
693+
Exception2,
694+
Exception3,
695+
Exception4,
696+
Exception5,
697+
Exception6,
698+
Exception7,
699+
Exception8,
700+
Exception9 {
645701
return null;
646702
}
647703

@@ -829,8 +885,16 @@ class M {
829885
int t,
830886
int u,
831887
int v)
832-
throws Exception0, Exception1, Exception2, Exception3, Exception4, Exception5,
833-
Exception6, Exception7, Exception8, Exception9 {
888+
throws Exception0,
889+
Exception1,
890+
Exception2,
891+
Exception3,
892+
Exception4,
893+
Exception5,
894+
Exception6,
895+
Exception7,
896+
Exception8,
897+
Exception9 {
834898
return null;
835899
}
836900

@@ -1011,6 +1075,14 @@ class M {
10111075
ZZZZZZZZZZ z,
10121076
ZZZZZZZZZZ z,
10131077
ZZZZZZZZZZ z)
1014-
throws EEEEEEEEEE, EEEEEEEEEE, EEEEEEEEEE, EEEEEEEEEE, EEEEEEEEEE, EEEEEEEEEE, EEEEEEEEEE,
1015-
EEEEEEEEEE, EEEEEEEEEE, EEEEEEEEEE {}
1078+
throws EEEEEEEEEE,
1079+
EEEEEEEEEE,
1080+
EEEEEEEEEE,
1081+
EEEEEEEEEE,
1082+
EEEEEEEEEE,
1083+
EEEEEEEEEE,
1084+
EEEEEEEEEE,
1085+
EEEEEEEEEE,
1086+
EEEEEEEEEE,
1087+
EEEEEEEEEE {}
10161088
}

0 commit comments

Comments
 (0)