Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions crates/oxc_language_server/src/backend.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{str::FromStr, sync::Arc};
use std::sync::Arc;

use futures::future::join_all;
use log::{debug, info, warn};
Expand Down Expand Up @@ -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));
}
}
}
Expand Down Expand Up @@ -677,16 +677,16 @@ impl Backend {
}

async fn clear_diagnostics(&self, uris: Vec<Uri>) {
let diagnostics: Vec<(String, Vec<Diagnostic>)> =
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<Diagnostic>)>) {
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<Diagnostic>)>) {
join_all(
result
.into_iter()
.map(|(uri, diagnostics)| self.client.publish_diagnostics(uri, diagnostics, None)),
)
.await;
}
}
12 changes: 6 additions & 6 deletions crates/oxc_language_server/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl WorkspaceWorker {
file_system: &LSPFileSystem,
) -> (
// Diagnostic reports that need to be revalidated
Option<Vec<(String, Vec<Diagnostic>)>>,
Option<Vec<(Uri, Vec<Diagnostic>)>>,
// New watchers that need to be registered
Vec<Registration>,
// Watchers that need to be unregistered
Expand Down Expand Up @@ -245,7 +245,7 @@ impl WorkspaceWorker {
file_system: &LSPFileSystem,
) -> (
// Diagnostic reports that need to be revalidated
Option<Vec<(String, Vec<Diagnostic>)>>,
Option<Vec<(Uri, Vec<Diagnostic>)>>,
// New watchers that need to be registered
Vec<Registration>,
// Watchers that need to be unregistered
Expand Down Expand Up @@ -285,13 +285,13 @@ impl WorkspaceWorker {
&self,
file_system: &LSPFileSystem,
change_handler: F,
) -> (Option<Vec<(String, Vec<Diagnostic>)>>, Vec<Registration>, Vec<Unregistration>)
) -> (Option<Vec<(Uri, Vec<Diagnostic>)>>, Vec<Registration>, Vec<Unregistration>)
where
F: Fn(&mut Box<dyn Tool>) -> ToolRestartChanges,
{
let mut registrations = vec![];
let mut unregistrations = vec![];
let mut diagnostics: Option<Vec<(String, Vec<Diagnostic>)>> = None;
let mut diagnostics: Option<Vec<(Uri, Vec<Diagnostic>)>> = None;

for tool in self.tools.write().await.iter_mut() {
let change = change_handler(tool);
Expand All @@ -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)]);
}
}
}
Expand Down
Loading