-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix off-by-one issues in TokenTree and TreeCursor (#1891)
Fixes an issue in TokenTree where if the smithy file was missing a trailing newline, any trees containing the last piece of text in the file would have an end location of (0, 0). This happened because the BR TreeType didn't append any tokens for the EOF case, so the BR tree had no end location. Fixes an issue in TreeCursor::findAt where if you tried to get the tree at a location right at the start of a tree, you would get the previous tree. Tests were added for both of these cases in TreeCursorTest.
- Loading branch information
1 parent
8db9d56
commit 59578f3
Showing
8 changed files
with
81 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
11 changes: 11 additions & 0 deletions
11
.../resources/software/amazon/smithy/syntax/formatter/incorrect-indentation.formatted.smithy
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy.example | ||
|
||
structure Foo {} | ||
|
||
structure Bar {} | ||
|
||
// Comment | ||
@input | ||
structure Baz {} |
11 changes: 11 additions & 0 deletions
11
...x/src/test/resources/software/amazon/smithy/syntax/formatter/incorrect-indentation.smithy
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy.example | ||
|
||
structure Foo {} | ||
|
||
structure Bar {} | ||
|
||
// Comment | ||
@input | ||
structure Baz {} |
9 changes: 9 additions & 0 deletions
9
...sources/software/amazon/smithy/syntax/formatter/missing-trailing-newline.formatted.smithy
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy.example | ||
|
||
@trait | ||
structure foo {} | ||
|
||
@foo | ||
structure Bar {} |
9 changes: 9 additions & 0 deletions
9
...rc/test/resources/software/amazon/smithy/syntax/formatter/missing-trailing-newline.smithy
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy.example | ||
|
||
@trait | ||
structure foo {} | ||
|
||
@foo | ||
structure Bar {} |