Commit b324ae1
authored
Hide empty snippets for full-file diagnostics (#19653)
Summary
--
This is the other commit I wanted to spin off from #19415, currently
stacked on #19644.
This PR suppresses blank snippets for empty ranges at the very beginning
of a file, and for empty ranges in non-existent files. Ruff includes
empty ranges for IO errors, for example.
https://github.com/astral-sh/ruff/blob/f4e93b63351bfe035b1fc5a7bc605a52979e7841/crates/ruff_linter/src/message/text.rs#L100-L110
The diagnostics now look like this (new snapshot test):
```
error[test-diagnostic]: main diagnostic message
--> example.py:1:1
```
Instead of [^*]
```
error[test-diagnostic]: main diagnostic message
--> example.py:1:1
|
|
```
Test Plan
--
A new `ruff_db` test showing the expected output format
[^*]: This doesn't correspond precisely to the example in the PR because
of some details of the diagnostic builder helper methods in `ruff_db`,
but you can see another example in the current version of the summary in
#19415.1 parent 2db4e5d commit b324ae1
File tree
6 files changed
+88
-5
lines changed- crates
- ruff_annotate_snippets/src
- renderer
- ruff_db/src/diagnostic
- render
- ruff_linter/src/message
6 files changed
+88
-5
lines changedLines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1183 | 1183 | | |
1184 | 1184 | | |
1185 | 1185 | | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
1186 | 1201 | | |
1187 | 1202 | | |
1188 | 1203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
134 | 140 | | |
135 | 141 | | |
136 | 142 | | |
| |||
165 | 171 | | |
166 | 172 | | |
167 | 173 | | |
| 174 | + | |
168 | 175 | | |
169 | 176 | | |
170 | 177 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
712 | 712 | | |
713 | 713 | | |
714 | 714 | | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
715 | 720 | | |
716 | 721 | | |
717 | 722 | | |
| |||
730 | 735 | | |
731 | 736 | | |
732 | 737 | | |
| 738 | + | |
733 | 739 | | |
734 | 740 | | |
735 | 741 | | |
| |||
746 | 752 | | |
747 | 753 | | |
748 | 754 | | |
| 755 | + | |
749 | 756 | | |
750 | 757 | | |
751 | 758 | | |
| |||
811 | 818 | | |
812 | 819 | | |
813 | 820 | | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
814 | 836 | | |
815 | 837 | | |
816 | 838 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
| 390 | + | |
390 | 391 | | |
391 | 392 | | |
392 | 393 | | |
| |||
432 | 433 | | |
433 | 434 | | |
434 | 435 | | |
| 436 | + | |
435 | 437 | | |
436 | 438 | | |
437 | 439 | | |
| |||
653 | 655 | | |
654 | 656 | | |
655 | 657 | | |
| 658 | + | |
| 659 | + | |
656 | 660 | | |
657 | 661 | | |
658 | 662 | | |
| |||
670 | 674 | | |
671 | 675 | | |
672 | 676 | | |
| 677 | + | |
673 | 678 | | |
674 | 679 | | |
675 | 680 | | |
| |||
695 | 700 | | |
696 | 701 | | |
697 | 702 | | |
698 | | - | |
| 703 | + | |
699 | 704 | | |
700 | 705 | | |
701 | 706 | | |
| |||
2551 | 2556 | | |
2552 | 2557 | | |
2553 | 2558 | | |
2554 | | - | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
2555 | 2565 | | |
2556 | 2566 | | |
2557 | 2567 | | |
| |||
2574 | 2584 | | |
2575 | 2585 | | |
2576 | 2586 | | |
2577 | | - | |
| 2587 | + | |
2578 | 2588 | | |
2579 | 2589 | | |
2580 | 2590 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
267 | 288 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
74 | 82 | | |
75 | 83 | | |
76 | 84 | | |
| |||
0 commit comments