From bfaa9eeea5c2535897e86194f280dbb511bc3ce1 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Tue, 30 Jun 2026 07:08:39 +0200 Subject: [PATCH] Fix Diagnostics #93 --- crates/analyzer/src/lib.rs | 30 +++++++++++++++++----------- crates/analyzer/src/rust_analyzer.rs | 17 ++++++++++++++++ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/crates/analyzer/src/lib.rs b/crates/analyzer/src/lib.rs index bbb7e17..5c7a025 100644 --- a/crates/analyzer/src/lib.rs +++ b/crates/analyzer/src/lib.rs @@ -1023,7 +1023,9 @@ impl LanguageServer for Backend { let text = if let Some(text) = ¶ms.text { text.clone() } else { - tokio::fs::read_to_string(&mist_path).await.expect("Failed to read file") + tokio::fs::read_to_string(&mist_path) + .await + .expect("Failed to read file") }; self.documents @@ -1036,6 +1038,14 @@ impl LanguageServer for Backend { .await { Self::write_transpiled_to_disk(&transpiled); + if let Some(rust_uri) = clean_lsp_url(&transpiled.rust_path) { + let _ = self + .rust_analyzer + .lock() + .await + .did_save(rust_uri, &transpiled.rust_content) + .await; + } } self.rebuild_module_tree(true).await; } @@ -1817,17 +1827,13 @@ async fn handle_ra_notifications( }; if let Some(mist_uri) = mist_uri.or(Some(rust_uri.clone())) { - let prev = previous_diagnostics.lock().await.get(&mist_uri).cloned(); - - if prev.as_ref() != Some(&mapped_diagnostics) { - previous_diagnostics - .lock() - .await - .insert(mist_uri.clone(), mapped_diagnostics.clone()); - client - .publish_diagnostics(mist_uri, mapped_diagnostics, None) - .await; - } + previous_diagnostics + .lock() + .await + .insert(mist_uri.clone(), mapped_diagnostics.clone()); + client + .publish_diagnostics(mist_uri, mapped_diagnostics, None) + .await; } } } diff --git a/crates/analyzer/src/rust_analyzer.rs b/crates/analyzer/src/rust_analyzer.rs index 3e55a45..12333d5 100644 --- a/crates/analyzer/src/rust_analyzer.rs +++ b/crates/analyzer/src/rust_analyzer.rs @@ -374,6 +374,23 @@ impl RustAnalyzer { .await } + pub async fn did_save( + &mut self, + uri: Url, + text: &str, + ) -> Result<(), Box> { + self.notify( + "textDocument/didSave", + json!({ + "textDocument": { + "uri": uri, + }, + "text": text, + }), + ) + .await + } + pub async fn did_close( &mut self, uri: Url,