Skip to content
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

Track build file changes #168

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

milesziemer
Copy link
Contributor

This change makes the server register for document lifecycle events like
didChange for build files. Previous behavior was to register for file
system change events for build files, but eventually we want to give
diagnostics, completions, etc. for build files as you type, so we need
to track all changes. This change keeps existing behavior from the
user's perspective, as we still only reload projects on save, so it
serves mostly as a refactor.

I also extracted the state managed by SmithyLanguageServer to its own
class, ServerState, and flattened ProjectManager into that class, so we
can manage the state of the server in a more centralized location.

Depends on #167

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This commit makes the language server work with Smithy projects in
subdirectories of the folder (or folders, in the case of e.g. vscode
workspace folders) open in the editor. I previously added support for
multiple _workspace folders_ (an LSP concept), but I assumed only one
_project_ (Smithy LS concept) per workspace folder. So this commit fixes
that mixing, allowing many projects per workspace folder.

Now, the language server will search through subdirectories of all workspace
folders (by default, one workspace folder is open in the client) to find
projects. Changes to build files, i.e. smithy-build.json,
.smithy-project.json, are now tracked at the workspace level, so you can
add a new project to an existing workspace.

I also did _some_ cleanup of the project/workspace synchronization code,
and moved some things around. A note on some tests: I'm using a
`Files.createTempDirectory`, and adding the `TestWorkspace` as a subdir.
In a follow-up commit, I will be changing `TestWorkspace` to be
something like `TestProject`, which is more accurate. I didn't include
it here to avoid a bunch of noise.
Blocking on the future creating the progress token with the client means the
server can't actually receive the response from the client for that request.
Tests don't catch this because the mock client is called directly,
rather than through the server proxy.

I decided to just remove the progress token code for now so
didChangeWorkspaceFolders can work at all, rather than trying to make
the method work asynchronously, which is a larger lift considering it
mutates the server state. That change is coming though.
This change makes the server register for document lifecycle events like
didChange for build files. Previous behavior was to register for file
system change events for build files, but eventually we want to give
diagnostics, completions, etc. for build files as you type, so we need
to track all changes. This change keeps existing behavior from the
user's perspective, as we still only reload projects on save, so it
serves mostly as a refactor.

I also extracted the state managed by SmithyLanguageServer to its own
class, ServerState, and flattened ProjectManager into that class, so we
can manage the state of the server in a more centralized location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant