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

Replace DocumentParser impl with a real parser #162

Closed
wants to merge 4 commits into from

Commits on Aug 9, 2024

  1. Add support for multiple workspaces

    Previously, the language server only knew about a single workspace root,
    so if your editor was using [WorkspaceFolders](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_workspaceFolders)
    the server would just pick the first one, and not load any others. This
    commit allows the server to load multiple workspaces. The primary
    challenge was handling state changes to individual workspaces
    independently. We use client-side file watchers and the
    `didChangeWatchedFiles` notification to make sure projects are up to
    date with new and deleted Smithy files, and any changes to build files
    (i.e. smithy-build.json). `didChangeWatchedFiles` sends a flat list of
    file events - not partitioned by workspace - so we have to figure out
    which projects each change applies to. This is done by creating a
    `PathMatcher` for each project's smithy files and build files, then
    matching on each file event. This way, we can apply changes to each
    individual project, rather than reloading everything. Selectors were
    also updated to select from all available projects.
    milesziemer committed Aug 9, 2024
    Configuration menu
    Copy the full SHA
    c4845cb View commit details
    Browse the repository at this point in the history
  2. Fix file patterns for windows

    The file patterns we were using for telling the client which files to
    watch, and to match file events in `didChangeWatchedFiles` to projects,
    were not working properly on windows because they didn't use the correct
    file separator.
    milesziemer committed Aug 9, 2024
    Configuration menu
    Copy the full SHA
    b68eda0 View commit details
    Browse the repository at this point in the history

Commits on Aug 11, 2024

  1. Use newer java features

    Refactors various things to make use of newer java features, including
    record classes, text blocks, and new APIs.
    milesziemer committed Aug 11, 2024
    Configuration menu
    Copy the full SHA
    ba4a3aa View commit details
    Browse the repository at this point in the history

Commits on Aug 26, 2024

  1. Replace DocumentParser impl with a real parser

    This commit is the first of a few that refactor the 'frontend' of the
    server, i.e. the completions, definition, hover, etc. It replaces the
    implementation of DocumentParser, which was used to compute specific
    syntactic information about a Smithy file, with an actual parser that
    will be used in future commits to overhaul language features like
    completions.
    
    For now, this is mostly a 1:1 swap - DocumentParser now
    does no parsing, but instead uses the results of the actual parser to
    compute the same info it used to. The only other real change to
    functionality is that DocumentParser no longer depends on the result of
    loading the model, and SmithyFiles are re-parsed synchronously on
    changes.
    
    The javadoc for the new `Syntax` class contains more detailed
    information on how the parser works, and why it works that way, but some
    of it may not make complete sense with the current code in the language
    server. The parser was built in tandem with the upgrades to completions,
    and was specifically designed to enhance such features. Those upgrades
    deserve their own commit, so I didn't include them here.
    milesziemer committed Aug 26, 2024
    Configuration menu
    Copy the full SHA
    1065402 View commit details
    Browse the repository at this point in the history