-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix formatting comments in operation errors list (#2283)
Fixes: #2261 For operation errors like: ``` errors // foo : // bar [ // baz MyError ] ``` you'd expect formatting of: ``` // foo // bar errors: [ // baz MyError ] ``` Prior to this commit, we were handling the cases of `foo` and `bar`, but inadvertently doing the same thing for `baz`. This is because we were looking for comments to pull out to above `errors` in the direct children of OPERATION_ERRORS, which include all WS within the `[]`. To make it work as expected, we need to only pull out comments in the first two positions (`foo`, `bar`), and leave the rest for BracketFormatter to format. BracketFormatter was expecting to operate on all the children of a given TreeCursor, so I modified it to act on an arbitrary stream of cursors, and added a way to get all remaining siblings after a cursor.
- Loading branch information
1 parent
e71e5c8
commit b33a062
Showing
5 changed files
with
118 additions
and
41 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
27 changes: 27 additions & 0 deletions
27
...ources/software/amazon/smithy/syntax/formatter/operation-errors-comments.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,27 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy.example | ||
|
||
operation Foo { | ||
errors: [ | ||
// a | ||
E1 | ||
// c | ||
E2 | ||
// d | ||
] | ||
} | ||
|
||
operation Bar { | ||
// a | ||
// b | ||
errors: [ | ||
// c | ||
] | ||
} | ||
|
||
@error("client") | ||
structure E1 {} | ||
|
||
@error("client") | ||
structure E2 {} |
27 changes: 27 additions & 0 deletions
27
...c/test/resources/software/amazon/smithy/syntax/formatter/operation-errors-comments.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,27 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy.example | ||
|
||
operation Foo { | ||
errors: [ | ||
// a | ||
E1 | ||
// c | ||
E2 | ||
// d | ||
] | ||
} | ||
|
||
operation Bar { | ||
errors // a | ||
: // b | ||
[ | ||
// c | ||
] | ||
} | ||
|
||
@error("client") | ||
structure E1 {} | ||
|
||
@error("client") | ||
structure E2 {} |