Skip to content

fix(lsp): do not response error on pulling actions from GritQL files#6716

Merged
siketyan merged 2 commits intobiomejs:mainfrom
siketyan:fix/lsp-not-supported
Jul 6, 2025
Merged

fix(lsp): do not response error on pulling actions from GritQL files#6716
siketyan merged 2 commits intobiomejs:mainfrom
siketyan:fix/lsp-not-supported

Conversation

@siketyan
Copy link
Copy Markdown
Member

@siketyan siketyan commented Jul 5, 2025

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_actions in their Capabilities). Also fixed that the error contains only an empty message.

Test Plan

Added a test, also manually tested with the IntelliJ plugin.

@siketyan siketyan requested review from a team July 5, 2025 07:01
@siketyan siketyan self-assigned this Jul 5, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jul 5, 2025

🦋 Changeset detected

Latest commit: e54aa55

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

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

@github-actions github-actions Bot added A-Project Area: project A-LSP Area: language server protocol labels Jul 5, 2025
Comment on lines +421 to +440
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
)
}
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(_)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix.

Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!


impl biome_console::fmt::Display for DocumentFileSource {
fn fmt(&self, fmt: &mut Formatter) -> std::io::Result<()> {
fmt.write_str(self.to_string().as_str())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to avoid the allocation of a string?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it, fmt.write_fmt(format_args!("{self}"))

Copy link
Copy Markdown
Member

@ematipico ematipico Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also the type MessageAndDescription, which takes care of it, but whatever solution you found is fine 😉

@siketyan siketyan force-pushed the fix/lsp-not-supported branch from e54aa55 to 0d8041b Compare July 5, 2025 07:27
@siketyan siketyan merged commit ead03d1 into biomejs:main Jul 6, 2025
11 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LSP Area: language server protocol A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants