Commit 331d683
committed
Use arrow switches where error-prone suggests them
error-prone's StatementSwitchToExpressionSwitch warned at 33 switch
statements in the formatter. They now use arrow cases: labels that
shared a body are one case, and the break statements go. Where every
case returned a value, the method returns a switch expression instead:
ImportOrderer.isJava, nextIsModifier, the sealed check in
ModifierOrderer, and TypeNameClassifier's three states, whose switches
cover all four JavaCaseFormat constants and so need no default; the
IllegalStateException after them goes.
This is error-prone's own fix, applied with
-PerrorProneApply=StatementSwitchToExpressionSwitch and formatted with
formatDiff. Nothing else changes: ./gradlew test passes, and so does
:open-java-format:test on JDK 25; the 15,747 files of the JDK 21
sources format exactly as before.1 parent a4cd6ae commit 331d683
13 files changed
Lines changed: 225 additions & 400 deletions
File tree
- open-java-format/src/main/java/com/palantir/javaformat
- doc
- java
- java14
- javadoc
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
80 | 81 | | |
81 | | - | |
82 | | - | |
| 82 | + | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
573 | | - | |
574 | | - | |
| 573 | + | |
575 | 574 | | |
576 | | - | |
| 575 | + | |
| 576 | + | |
577 | 577 | | |
578 | 578 | | |
579 | 579 | | |
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
586 | | - | |
| 586 | + | |
| 587 | + | |
587 | 588 | | |
588 | 589 | | |
589 | 590 | | |
590 | | - | |
| 591 | + | |
| 592 | + | |
591 | 593 | | |
592 | 594 | | |
593 | 595 | | |
| |||
Lines changed: 28 additions & 79 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 82 | + | |
| 83 | + | |
92 | 84 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 85 | + | |
98 | 86 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
113 | 90 | | |
114 | 91 | | |
115 | 92 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
151 | 103 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 104 | + | |
| 105 | + | |
159 | 106 | | |
160 | 107 | | |
161 | 108 | | |
| |||
196 | 143 | | |
197 | 144 | | |
198 | 145 | | |
199 | | - | |
| 146 | + | |
200 | 147 | | |
201 | 148 | | |
202 | | - | |
| 149 | + | |
| 150 | + | |
203 | 151 | | |
204 | 152 | | |
205 | 153 | | |
206 | | - | |
207 | | - | |
| 154 | + | |
| 155 | + | |
208 | 156 | | |
209 | 157 | | |
210 | 158 | | |
| |||
226 | 174 | | |
227 | 175 | | |
228 | 176 | | |
229 | | - | |
| 177 | + | |
230 | 178 | | |
231 | 179 | | |
232 | | - | |
| 180 | + | |
| 181 | + | |
233 | 182 | | |
234 | 183 | | |
235 | 184 | | |
236 | | - | |
237 | | - | |
| 185 | + | |
| 186 | + | |
238 | 187 | | |
239 | 188 | | |
240 | 189 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
116 | | - | |
| 117 | + | |
| 118 | + | |
117 | 119 | | |
| 120 | + | |
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
228 | | - | |
| 227 | + | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
Lines changed: 4 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
267 | 264 | | |
268 | 265 | | |
269 | 266 | | |
| |||
Lines changed: 6 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
546 | | - | |
547 | | - | |
548 | | - | |
| 546 | + | |
549 | 547 | | |
550 | | - | |
551 | | - | |
| 548 | + | |
| 549 | + | |
552 | 550 | | |
553 | 551 | | |
554 | 552 | | |
555 | 553 | | |
556 | | - | |
| 554 | + | |
557 | 555 | | |
558 | | - | |
559 | | - | |
| 556 | + | |
| 557 | + | |
560 | 558 | | |
561 | 559 | | |
562 | 560 | | |
| |||
0 commit comments