smithy-lang / smithy-language-server

A Language Server Protocol implementation for the Smithy IDL
https://smithy.io
Apache License 2.0
33 stars 18 forks source link

Adding the `@output` or `@input` trait on non-inlined struct can break lsp #132

Closed daddykotex closed 7 months ago

daddykotex commented 7 months ago

As far as I can tell, this is a valid model:

$version: "2"

namespace test

service Service {
    version: "1"
    operations: [HelloWorld]
}

operation HelloWorld {
    input: Other
}

@input
structure Other {
    @required
    value: String
}

But it will crash the lsp because it fails while collecting locations. This happens because the input structure test#Other is not suffixed by Input. The code here assumes it is and does some string manipulation that is wrong.

I think the original code is written with this assumption because inlined input/output shape will be annotated with @intput/@output, respectively, while also being suffixed. But this is not a hard requirement. The model above is valid and while it emits a warning because Other does not start with HelloWorld, it is still valid.