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

fix(language_server): revalidate files when oxlint config is changing #7259

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions crates/oxc_language_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ use tower_lsp::{
lsp_types::{
CodeAction, CodeActionKind, CodeActionOptions, CodeActionOrCommand, CodeActionParams,
CodeActionProviderCapability, CodeActionResponse, ConfigurationItem, Diagnostic,
DidChangeConfigurationParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams,
DidOpenTextDocumentParams, DidSaveTextDocumentParams, InitializeParams, InitializeResult,
InitializedParams, OneOf, ServerCapabilities, ServerInfo, TextDocumentSyncCapability,
TextDocumentSyncKind, TextEdit, Url, WorkDoneProgressOptions, WorkspaceEdit,
WorkspaceFoldersServerCapabilities, WorkspaceServerCapabilities,
DidChangeConfigurationParams, DidChangeTextDocumentParams, DidChangeWatchedFilesParams,
DidCloseTextDocumentParams, DidOpenTextDocumentParams, DidSaveTextDocumentParams,
InitializeParams, InitializeResult, InitializedParams, OneOf, ServerCapabilities,
ServerInfo, TextDocumentSyncCapability, TextDocumentSyncKind, TextEdit, Url,
WorkDoneProgressOptions, WorkspaceEdit, WorkspaceFoldersServerCapabilities,
WorkspaceServerCapabilities,
},
Client, LanguageServer, LspService, Server,
};
Expand Down Expand Up @@ -172,6 +173,12 @@ impl LanguageServer for Backend {
*self.options.lock().await = changed_options;
}

async fn did_change_watched_files(&self, _params: DidChangeWatchedFilesParams) {
debug!("watched file did change");
self.init_linter_config().await;
self.revalidate_open_files().await;
}

async fn initialized(&self, _params: InitializedParams) {
debug!("oxc initialized.");
}
Expand Down Expand Up @@ -339,6 +346,15 @@ impl Backend {
.await;
}

async fn revalidate_open_files(&self) {
join_all(self.diagnostics_report_map.iter().map(|map| {
let url = Url::from_str(map.key()).expect("should convert to path");

self.handle_file_update(url, None, None)
}))
.await;
}

async fn init_linter_config(&self) {
let Some(Some(uri)) = self.root_uri.get() else {
return;
Expand Down
Loading