-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove command prefix #1075
Remove command prefix #1075
Conversation
This removes generating a command prefix for the language client connecting to terraform-ls. This also removes registering prefixed commands to terraform-ls.
7ab7287
to
f60fba0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I wasn't able to reproduce any error cases we encountered in the past :)
This extracts the LanguageClient creation from ClientHandler and puts it directly inside the activation point. In order to implement hashicorp/terraform-ls#722 we need to add a new StaticFeature to register a client-side command for terraform-ls to call when it knows the `terraform.providers` view needs to be refreshed. StaticFeatures are registered using the LanguageClient.registerFeature method, which means the ClientHandler class needs to create the StaticFeature. The StaticFeature needs both the LanguageClient and `terraform.providers` view created before it can be initialized. The LanguageClient is created by the ClientHandler class. This all results in a cyclic dependency. We could resolve this cyclic dependency by adding more responsibility to ClientHandler, but this introduces more complexity to the class. This will become increasingly hard to deal with as more aspects like StaticFeature are added. We resolve this by extracting the creation of LanguageClient and moving dependent features like the StaticFeatures to the main activation method. This puts all the parts that rely on each other in the same place where the data needed is located to make decisions about whether they are activated or not. This builds on work done in: - #1073 - #1074 - #1075 - #1079
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
This removes generating a command prefix when registering commands for the language client connecting to terraform-ls.
Previously the extension would create a LanguageClient/terraform-ls pair per 'folder' in a workspace. This means there was a terraform-ls process per folder to keep track of. The hashicorp/terraform-ls#502 PR enabled a single terraform-ls process to handle multi-folder workspaces, which meant we could refactor the extension In #845 to use a single LanguageClient instance. A leftover from the original design was a prefix for commands registered between terraform-ls and the client. This ensured unique command IDs when multiple clients were present, but is no longer necessary with a single language client.
Acceptance tests:
Add Folder to workspace
to open a multi-folder workspacesomething.code-workspace
In each case, the extension should start with no errors. When adding additional folders to the workspace or when opening a mult-folder workspace directly, there should be no errors regarding duplicate commands.