smithy-lang / smithy

Smithy is a protocol-agnostic interface definition language and set of tools for generating clients, servers, and documentation for any programming language.
https://smithy.io
Apache License 2.0
1.77k stars 209 forks source link

Broken/unexpected formatting of comments after members #2279

Open milesziemer opened 4 months ago

milesziemer commented 4 months ago
  1. Trailing comments get moved to a weird spot:

    structure A {
    a: String // a
    }

    becomes

    structure A {
    a: String
    
    // a
    }
  2. With default value assignments, you get an extra newline if you had a trailing comment in the shape body:

    structure A {
    a: String = ""
    // a
    }

    becomes:

    
    structure A {
    a: String = ""
    
    // a

}

3. Invalid doc comments also aren't fixed if they come after a default value assignment:

structure A { a: String = "" /// a }

structure B { b: String = "" /// a }


don't change.

Not sure about 1, but for 2 and 3, it has something to do with the fact that [ValueAssignment](https://smithy.io/2.0/spec/idl.html#grammar-token-smithy-ValueAssignment) contains all whitespace following it (through [BR](https://smithy.io/2.0/spec/idl.html#grammar-token-smithy-BR))