Commit 2af2bbc
committed
Language version all of the formatting changes since Dart 3.7.
The new formatter launch was pretty rocky, but one thing I think helped mitigate that was that the formatting style was gated on language version. Users could install the new SDK and their code wouldn't be spontaneously reformatted under them until they deliberately updated their SDK constraint to opt in to the new language version.
This PR applies that same logic to the changes we've made since Dart 3.7.
Any source file at language version 3.7 is formatted (almost, see below) identically to how it would be formatted with the SDK as it shipped in 3.7. Source files at language version 3.8 or higher get all of the new style changes I've landed since then.
This increases the complexity of the formatter codebase a decent amount, but it's mostly just a lot of "if 3.7 do X else do Y". Tedious but not intractable.
I expect to continue to language version changes like this going forward. So after Dart 3.8 ships, whatever formatter style is in that version will be locked down and style changes after that will have to support 3.7 and 3.8 fallback behavior. I expect there to be much less style churn going forward, so it's probably manageable.
In cases where there are *bugs* (i.e. the formatter produces invalid syntax or rearranges code), those won't be language versioned. But most other style changes will be.
It's important to make sure we don't regress and accidentally affect the formatting of older language versioned files when making changes to the formatter. To avoid that, this also expands testing to be multi-versioned. Every test is now run on multiple versions and for cases where the style differs between versions, there are different expectations for each. Fortunately, the tests run very fast, so it doesn't slow down things more than a couple of seconds.
In addition to running through the formatter's own test suite and regression tests, I also tested this on a giant corpus of pub packages. I formatted them all using the shipped Dart 3.7 formatter, then using this PR with `--language-version=3.7`. Of the 89,468 files, 7 had differences. They all relate to a single weird corner case around giant multiline strings containing multiline string interpolation expressions where the formatting is slightly different. #1706 helps that somewhat -- there were about dozen diffs before -- but doesn't totally eliminate it. I think it's close enough to be tolerable.1 parent c7f6131 commit 2af2bbc
File tree
126 files changed
+3661
-559
lines changed- example
- lib/src
- back_end
- front_end
- piece
- testing
- test
- cli
- short/whitespace
- tall
- declaration
- expression
- function
- invocation
- pattern
- preserve_trailing_commas
- regression
- 0000
- 0100
- 0200
- 0300
- 0400
- 0500
- 0600
- 0700
- 0800
- 0900
- 1000
- 1100
- 1200
- 1400
- 1500
- 1600
- other
- statement
- variable
- tool
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
126 files changed
+3661
-559
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | | - | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 73 | + | |
76 | 74 | | |
77 | 75 | | |
78 | 76 | | |
| |||
110 | 108 | | |
111 | 109 | | |
112 | 110 | | |
113 | | - | |
| 111 | + | |
114 | 112 | | |
115 | 113 | | |
116 | 114 | | |
117 | 115 | | |
118 | 116 | | |
119 | 117 | | |
120 | 118 | | |
121 | | - | |
| 119 | + | |
| 120 | + | |
122 | 121 | | |
123 | | - | |
| 122 | + | |
124 | 123 | | |
125 | | - | |
| 124 | + | |
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
424 | | - | |
425 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
426 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
427 | 462 | | |
428 | | - | |
| 463 | + | |
429 | 464 | | |
430 | 465 | | |
431 | | - | |
| 466 | + | |
432 | 467 | | |
433 | 468 | | |
434 | 469 | | |
435 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
436 | 486 | | |
437 | 487 | | |
438 | 488 | | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
439 | 493 | | |
440 | 494 | | |
441 | 495 | | |
| |||
445 | 499 | | |
446 | 500 | | |
447 | 501 | | |
448 | | - | |
| 502 | + | |
449 | 503 | | |
450 | 504 | | |
451 | 505 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
178 | 188 | | |
179 | | - | |
180 | | - | |
181 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
182 | 222 | | |
183 | 223 | | |
184 | 224 | | |
| |||
230 | 270 | | |
231 | 271 | | |
232 | 272 | | |
233 | | - | |
| 273 | + | |
234 | 274 | | |
235 | 275 | | |
236 | 276 | | |
| |||
261 | 301 | | |
262 | 302 | | |
263 | 303 | | |
264 | | - | |
265 | 304 | | |
266 | 305 | | |
267 | 306 | | |
268 | | - | |
269 | 307 | | |
270 | 308 | | |
271 | 309 | | |
| |||
328 | 366 | | |
329 | 367 | | |
330 | 368 | | |
331 | | - | |
| 369 | + | |
332 | 370 | | |
333 | 371 | | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
344 | 385 | | |
345 | 386 | | |
| 387 | + | |
| 388 | + | |
346 | 389 | | |
347 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
348 | 393 | | |
349 | 394 | | |
350 | 395 | | |
| |||
413 | 458 | | |
414 | 459 | | |
415 | 460 | | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
420 | 464 | | |
421 | 465 | | |
422 | 466 | | |
423 | 467 | | |
424 | | - | |
| 468 | + | |
425 | 469 | | |
426 | 470 | | |
427 | | - | |
| 471 | + | |
428 | 472 | | |
429 | 473 | | |
430 | 474 | | |
| |||
555 | 599 | | |
556 | 600 | | |
557 | 601 | | |
| 602 | + | |
| 603 | + | |
558 | 604 | | |
559 | 605 | | |
560 | 606 | | |
561 | 607 | | |
562 | 608 | | |
563 | | - | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
564 | 617 | | |
565 | 618 | | |
566 | 619 | | |
| |||
0 commit comments