diff --git a/crates/oxc_language_server/src/backend.rs b/crates/oxc_language_server/src/backend.rs index f86a0c070ce7d..f3d573e502506 100644 --- a/crates/oxc_language_server/src/backend.rs +++ b/crates/oxc_language_server/src/backend.rs @@ -1,4 +1,4 @@ -use std::{str::FromStr, sync::Arc}; +use std::sync::Arc; use futures::future::join_all; use log::{debug, info, warn}; @@ -216,7 +216,7 @@ impl LanguageServer for Backend { let content = self.file_system.read().await.get(uri); if let Some(diagnostics) = worker.run_diagnostic(uri, content.as_deref()).await { - new_diagnostics.push((uri.to_string(), diagnostics)); + new_diagnostics.push((uri.clone(), diagnostics)); } } } @@ -677,16 +677,16 @@ impl Backend { } async fn clear_diagnostics(&self, uris: Vec) { - let diagnostics: Vec<(String, Vec)> = - uris.into_iter().map(|uri| (uri.to_string(), vec![])).collect(); - self.publish_all_diagnostics(diagnostics).await; + self.publish_all_diagnostics(uris.into_iter().map(|uri| (uri, vec![])).collect()).await; } /// Publish diagnostics for all files. - async fn publish_all_diagnostics(&self, result: Vec<(String, Vec)>) { - join_all(result.into_iter().map(|(path, diagnostics)| { - self.client.publish_diagnostics(Uri::from_str(&path).unwrap(), diagnostics, None) - })) + async fn publish_all_diagnostics(&self, result: Vec<(Uri, Vec)>) { + join_all( + result + .into_iter() + .map(|(uri, diagnostics)| self.client.publish_diagnostics(uri, diagnostics, None)), + ) .await; } } diff --git a/crates/oxc_language_server/src/worker.rs b/crates/oxc_language_server/src/worker.rs index 35d29db1f8a7c..f86b3786ceac5 100644 --- a/crates/oxc_language_server/src/worker.rs +++ b/crates/oxc_language_server/src/worker.rs @@ -217,7 +217,7 @@ impl WorkspaceWorker { file_system: &LSPFileSystem, ) -> ( // Diagnostic reports that need to be revalidated - Option)>>, + Option)>>, // New watchers that need to be registered Vec, // Watchers that need to be unregistered @@ -245,7 +245,7 @@ impl WorkspaceWorker { file_system: &LSPFileSystem, ) -> ( // Diagnostic reports that need to be revalidated - Option)>>, + Option)>>, // New watchers that need to be registered Vec, // Watchers that need to be unregistered @@ -285,13 +285,13 @@ impl WorkspaceWorker { &self, file_system: &LSPFileSystem, change_handler: F, - ) -> (Option)>>, Vec, Vec) + ) -> (Option)>>, Vec, Vec) where F: Fn(&mut Box) -> ToolRestartChanges, { let mut registrations = vec![]; let mut unregistrations = vec![]; - let mut diagnostics: Option)>> = None; + let mut diagnostics: Option)>> = None; for tool in self.tools.write().await.iter_mut() { let change = change_handler(tool); @@ -314,9 +314,9 @@ impl WorkspaceWorker { tool.run_diagnostic(&uri, file_system.get(&uri).as_deref()) { if let Some(existing_diagnostics) = &mut diagnostics { - existing_diagnostics.push((uri.to_string(), reports)); + existing_diagnostics.push((uri, reports)); } else { - diagnostics = Some(vec![(uri.to_string(), reports)]); + diagnostics = Some(vec![(uri, reports)]); } } }