fix(lsp): do not response error on pulling actions from GritQL files#6716
fix(lsp): do not response error on pulling actions from GritQL files#6716siketyan merged 2 commits intobiomejs:mainfrom
Conversation
🦋 Changeset detectedLatest commit: e54aa55 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| fn description(&self, fmt: &mut Formatter<'_>) -> fmt::Result { | ||
| if self.file_source != DocumentFileSource::Unknown { | ||
| write!( | ||
| fmt, | ||
| "Biome doesn't support this feature for the language {}", | ||
| &self.file_source | ||
| ) | ||
| } else if let Some(ext) = self.extension.as_ref() { | ||
| write!( | ||
| fmt, | ||
| "Biome could not determine the language for the file extension {ext}" | ||
| ) | ||
| } else { | ||
| write!( | ||
| fmt, | ||
| "Biome could not determine the language for the file {} because it doesn't have a clear extension", | ||
| &self.path | ||
| ) | ||
| } | ||
| } |
There was a problem hiding this comment.
As LSP doesn't support any markups, we should also implement Diagnostic::description or we'll get an empty message returned from the server.
| return if matches!(err, WorkspaceError::FileIgnored(_)) { | ||
| return if matches!( | ||
| err, | ||
| WorkspaceError::FileIgnored(_) | WorkspaceError::SourceFileNotSupported(_) |
|
|
||
| impl biome_console::fmt::Display for DocumentFileSource { | ||
| fn fmt(&self, fmt: &mut Formatter) -> std::io::Result<()> { | ||
| fmt.write_str(self.to_string().as_str()) |
There was a problem hiding this comment.
Any chance to avoid the allocation of a string?
There was a problem hiding this comment.
I'd like to, but I don't know how to deal with the biome_console formatter. Is there something like an adapter between std::fmt::Formatter and biome_console::fmt::Formatter?
There was a problem hiding this comment.
I found it, fmt.write_fmt(format_args!("{self}"))
There was a problem hiding this comment.
There's also the type MessageAndDescription, which takes care of it, but whatever solution you found is fine 😉
e54aa55 to
0d8041b
Compare
Summary
This pull request fixes that the LSP server returns an error on pulling actions from a file that doesn't support any code actions (i.e. doesn't have
analyzer.code_actionsin theirCapabilities). Also fixed that the error contains only an empty message.Test Plan
Added a test, also manually tested with the IntelliJ plugin.