smithy/smithy-syntax
Miles Ziemer b33a062150
Fix formatting comments in operation errors list (#2283)
Fixes: https://github.com/smithy-lang/smithy/issues/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.
2024-05-09 14:22:01 -04:00
..
src Fix formatting comments in operation errors list (#2283) 2024-05-09 14:22:01 -04:00
build.gradle Shade prettier4j in smithy-syntax 2023-06-19 12:46:51 -05:00