smithy-lang / smithy-vscode

A Visual Studio Code extension to provide syntax highlighting for the Smithy IDL.
https://marketplace.visualstudio.com/items?itemName=smithy.smithy-vscode-extension
Apache License 2.0
37 stars 14 forks source link

Ignore build directory when scanning for models #59

Closed mtdowling closed 1 month ago

mtdowling commented 1 year ago

It looks like we're including the build directory when loading the semantic model. We should ignore the build directory since it will have duplicate shapes and could have conflicting shapes when using things like projections. For example, this shows up in the logs:

WARNING: Ignoring duplicate but equivalent shape definition: smithy.example#Post defined at /Users/x/projects/smithy-demo-model/build/smithy/source/sources/post.smithy [4, 1] and /Users/x/projects/smithy-demo-model/model/post.smithy [4, 1]

One negative effect of not filtering out the build directory is that you can get validation warnings that a previously built model conflicts with the model in your IDE. For example, build the model using the CLI or Gradle, then edit a member to target a different shape, and the IDE will tell you that the member in the IDE conflicts with the member in the build output.

milesziemer commented 1 year ago

We could add an excludeDirs property to the extension, which by default is ${workspaceRoot}/build, and pass that to the language server as an argument. That way if someone is using an output directory other than build/, they can also ignore them. We will have to adjust the language server to accept this argument and ignore the directory when searching for model files.

eduardomourar commented 1 year ago

This would be really useful for us. And we are just using the default build folder.

milesziemer commented 1 month ago

Fixed in https://github.com/smithy-lang/smithy-vscode/releases/tag/0.6.0