-
Notifications
You must be signed in to change notification settings - Fork 656
feat(rome_service): allow workspace clients to provide a language hint #3140
Conversation
…as a hint for paths without a file extension
Deploying with Cloudflare Pages
|
}, | ||
) | ||
.await? | ||
.context("formatting returned None")?; |
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.
What's this .context
call? Is it something like expect
?
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.
The context
(and with_context
) methods come from anyhow
and wrap an existing Result
(or in this case Option
) with a new error object that contains the provided "context" as an the error message.
It's primarily intended to easily let functions propagate inner error results to the outer context while attaching additional information about the error (that's how the error handling in crates/rome_bin/src/service/mod.rs
works for instance), and is a concept I'm think we could integrate in the diagnostics refactor if we start using diagnostics as a generic tool for error reporting across the codebase.
But in this case I'm using it as a simple way to turn an Option<T>
into a Result<T, Error>
with a custom message, so it's very similar to an expect
method that returns an error instead of panicking
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
✅ Deploy Preview for rometools canceled.
|
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
#3140) * feat(vscode): add a status bar item for the language server * feat(rome_service): allow workspace clients to provide a language ID as a hint for paths without a file extension * Update crates/rome_service/src/workspace/server.rs Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * fix bindings codegen Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Summary
Fixes #3006
This PR adds a new
language_hint
field to the parameters of theopen_file
Workspace method. It lets clients specify a language ID as a hint for the file type resolver, for instance for files that do not have a file extension yet in the editor. To support this I've merged theEditorLanguage
enum inrome_lsp
into theLanguage
enum inrome_service
, and refactored error handling across the code base to make the lack of a file extension a non-fatal error in file type determination.Test Plan
I've added an additional test for the LSP to verify we can correctly format files without an extension