-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the diagnostic renderer to avoid printing trailing whitespace (
#430) This PR refactors the renderer so that all writes go through a shared state type, to ensure fine control over whitespace and line endings. This is also an opportunity to somewhat better organize how values are passed between functions in the renderer.
- Loading branch information
Showing
49 changed files
with
609 additions
and
491 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
experimental/parser/testdata/lexer/braces/interleaved.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
experimental/parser/testdata/lexer/braces/stray-close.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
experimental/parser/testdata/lexer/braces/stray-open.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
experimental/parser/testdata/lexer/braces/unclosed.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
experimental/parser/testdata/lexer/braces/unopened.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
experimental/parser/testdata/lexer/comments/nested.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
experimental/parser/testdata/lexer/comments/unterminated.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions
22
experimental/parser/testdata/lexer/idents/non-ascii.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
error: unrecognized token | ||
--> testdata/lexer/idents/non-ascii.proto:1:7 | ||
| | ||
| | ||
1 | kitty_🐈<U+200D>⬛ | ||
| ^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^ | ||
|
||
error: non-ASCII identifiers are not allowed | ||
--> testdata/lexer/idents/non-ascii.proto:2:1 | ||
| | ||
2 | 黑猫 | ||
| ^^^^ | ||
| | ||
2 | 黑猫 | ||
| ^^^^ | ||
|
||
error: non-ASCII identifiers are not allowed | ||
--> testdata/lexer/idents/non-ascii.proto:3:1 | ||
| | ||
| | ||
3 | काली बिल्ली | ||
| ^^^^ | ||
| ^^^^ | ||
|
||
error: non-ASCII identifiers are not allowed | ||
--> testdata/lexer/idents/non-ascii.proto:3:6 | ||
| | ||
| | ||
3 | काली बिल्ली | ||
| ^^^^^ | ||
| ^^^^^ | ||
|
||
error: non-ASCII identifiers are not allowed | ||
--> testdata/lexer/idents/non-ascii.proto:4:1 | ||
| | ||
| | ||
4 | 黑猫_suffix | ||
| ^^^^^^^^^^^ | ||
| ^^^^^^^^^^^ | ||
|
||
encountered 5 errors |
20 changes: 10 additions & 10 deletions
20
experimental/parser/testdata/lexer/numbers/bad-digit.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
error: unexpected characters in integer literal | ||
--> testdata/lexer/numbers/bad-digit.proto:1:1 | ||
| | ||
| | ||
1 | 0f | ||
| ^^ | ||
| ^^ | ||
|
||
error: unexpected characters in integer literal | ||
--> testdata/lexer/numbers/bad-digit.proto:2:1 | ||
| | ||
| | ||
2 | 0b02 | ||
| ^^^^ | ||
| ^^^^ | ||
|
||
error: unexpected characters in integer literal | ||
--> testdata/lexer/numbers/bad-digit.proto:3:1 | ||
| | ||
| | ||
3 | 0o08 | ||
| ^^^^ | ||
| ^^^^ | ||
|
||
error: unexpected characters in integer literal | ||
--> testdata/lexer/numbers/bad-digit.proto:4:1 | ||
| | ||
| | ||
4 | 08 | ||
| ^^ | ||
| ^^ | ||
|
||
error: unexpected characters in integer literal | ||
--> testdata/lexer/numbers/bad-digit.proto:5:1 | ||
| | ||
| | ||
5 | 0x0G | ||
| ^^^^ | ||
| ^^^^ | ||
|
||
encountered 5 errors |
24 changes: 12 additions & 12 deletions
24
experimental/parser/testdata/lexer/numbers/exotic-base.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
error: unsupported base for integer literal | ||
--> testdata/lexer/numbers/exotic-base.proto:1:1 | ||
help: use a hexadecimal literal instead | ||
| | ||
| | ||
1 | - 0b1100101 | ||
1 | + 0x65 | ||
| | ||
| | ||
= note: Protobuf does not support binary literals | ||
|
||
error: unsupported base for integer literal | ||
--> testdata/lexer/numbers/exotic-base.proto:2:1 | ||
help: use a hexadecimal literal instead | ||
| | ||
| | ||
2 | - 0B1010101 | ||
2 | + 0x55 | ||
| | ||
| | ||
= note: Protobuf does not support binary literals | ||
|
||
error: unsupported base for integer literal | ||
--> testdata/lexer/numbers/exotic-base.proto:3:1 | ||
help: remove the `o` | ||
| | ||
| | ||
3 | - 0o1234567 | ||
3 | + 01234567 | ||
| | ||
| | ||
= note: octal literals are prefixed with `0`, not `0o` | ||
|
||
error: unsupported base for integer literal | ||
--> testdata/lexer/numbers/exotic-base.proto:4:1 | ||
help: remove the `o` | ||
| | ||
| | ||
4 | - 0O1234567 | ||
4 | + 01234567 | ||
| | ||
| | ||
= note: octal literals are prefixed with `0`, not `0o` | ||
|
||
error: unexpected characters in floating-point literal | ||
--> testdata/lexer/numbers/exotic-base.proto:6:1 | ||
| | ||
| | ||
6 | 0x10203.4 | ||
| ^^^^^^^^^ | ||
| ^^^^^^^^^ | ||
|
||
error: unexpected characters in floating-point literal | ||
--> testdata/lexer/numbers/exotic-base.proto:7:1 | ||
| | ||
| | ||
7 | 0X12.ffP10 | ||
| ^^^^^^^^^^ | ||
| ^^^^^^^^^^ | ||
|
||
encountered 6 errors |
24 changes: 12 additions & 12 deletions
24
experimental/parser/testdata/lexer/numbers/thousands.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
error: integer literal contains underscores | ||
--> testdata/lexer/numbers/thousands.proto:1:1 | ||
help: remove these underscores | ||
| | ||
| | ||
1 | - 1_000_000 | ||
1 | + 1000000 | ||
| | ||
| | ||
= note: Protobuf does not support Go/Java/Rust-style thousands separators | ||
|
||
error: unsupported base for integer literal | ||
--> testdata/lexer/numbers/thousands.proto:2:1 | ||
help: use a hexadecimal literal instead | ||
| | ||
| | ||
2 | - 0b1_000_000 | ||
2 | + 0x40 | ||
| | ||
| | ||
= note: Protobuf does not support binary literals | ||
|
||
error: unsupported base for integer literal | ||
--> testdata/lexer/numbers/thousands.proto:3:1 | ||
help: remove the `o` | ||
| | ||
| | ||
3 | - 0o1_000_000 | ||
3 | + 01_000_000 | ||
| | ||
| | ||
= note: octal literals are prefixed with `0`, not `0o` | ||
|
||
error: integer literal contains underscores | ||
--> testdata/lexer/numbers/thousands.proto:4:1 | ||
help: remove these underscores | ||
| | ||
| | ||
4 | - 0x1_000_000 | ||
4 | + 0x1000000 | ||
| | ||
| | ||
= note: Protobuf does not support Go/Java/Rust-style thousands separators | ||
|
||
error: integer literal contains underscores | ||
--> testdata/lexer/numbers/thousands.proto:5:1 | ||
help: remove these underscores | ||
| | ||
| | ||
5 | - 01_000_000 | ||
5 | + 01000000 | ||
| | ||
| | ||
= note: Protobuf does not support Go/Java/Rust-style thousands separators | ||
|
||
error: floating-point literal contains underscores | ||
--> testdata/lexer/numbers/thousands.proto:6:1 | ||
help: remove these underscores | ||
| | ||
| | ||
6 | - 1_000_000.00 | ||
6 | + 1000000.00 | ||
| | ||
| | ||
= note: Protobuf does not support Go/Java/Rust-style thousands separators | ||
|
||
encountered 6 errors |
36 changes: 18 additions & 18 deletions
36
experimental/parser/testdata/lexer/punct.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
error: unrecognized token | ||
--> testdata/lexer/punct.proto:2:1 | ||
| | ||
| | ||
2 | ! @ # $ % ^ & * + _ | ||
| ^ | ||
| ^ | ||
|
||
error: unrecognized token | ||
--> testdata/lexer/punct.proto:2:3 | ||
| | ||
| | ||
2 | ! @ # $ % ^ & * + _ | ||
| ^ | ||
| ^ | ||
|
||
error: unrecognized token | ||
--> testdata/lexer/punct.proto:2:5 | ||
| | ||
| | ||
2 | ! @ # $ % ^ & * + _ | ||
| ^ | ||
| ^ | ||
|
||
error: unrecognized token | ||
--> testdata/lexer/punct.proto:2:7 | ||
| | ||
| | ||
2 | ! @ # $ % ^ & * + _ | ||
| ^ | ||
| ^ | ||
|
||
error: unrecognized token | ||
--> testdata/lexer/punct.proto:2:9 | ||
| | ||
| | ||
2 | ! @ # $ % ^ & * + _ | ||
| ^ | ||
| ^ | ||
|
||
error: unrecognized token | ||
--> testdata/lexer/punct.proto:2:11 | ||
| | ||
| | ||
2 | ! @ # $ % ^ & * + _ | ||
| ^ | ||
| ^ | ||
|
||
error: unrecognized token | ||
--> testdata/lexer/punct.proto:2:13 | ||
| | ||
| | ||
2 | ! @ # $ % ^ & * + _ | ||
| ^ | ||
| ^ | ||
|
||
error: unrecognized token | ||
--> testdata/lexer/punct.proto:2:15 | ||
| | ||
| | ||
2 | ! @ # $ % ^ & * + _ | ||
| ^ | ||
| ^ | ||
|
||
error: unrecognized token | ||
--> testdata/lexer/punct.proto:2:17 | ||
| | ||
| | ||
2 | ! @ # $ % ^ & * + _ | ||
| ^ | ||
| ^ | ||
|
||
encountered 9 errors |
14 changes: 7 additions & 7 deletions
14
experimental/parser/testdata/lexer/strings/bad-contents.proto.stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.