From eeff20d1727fd7de174b72ff150fd23afcc66d93 Mon Sep 17 00:00:00 2001 From: hkalbasi Date: Fri, 15 Mar 2024 16:28:59 +0330 Subject: [PATCH] Show compilation progress in test explorer --- crates/flycheck/src/test_runner.rs | 9 +++++---- crates/rust-analyzer/src/lsp/ext.rs | 7 +++++++ crates/rust-analyzer/src/main_loop.rs | 3 +++ docs/dev/lsp-extensions.md | 9 ++++++++- editors/code/src/lsp_ext.ts | 3 +++ editors/code/src/test_explorer.ts | 6 ++++++ 6 files changed, 32 insertions(+), 5 deletions(-) diff --git a/crates/flycheck/src/test_runner.rs b/crates/flycheck/src/test_runner.rs index 6dac5899ee3..31378716b3e 100644 --- a/crates/flycheck/src/test_runner.rs +++ b/crates/flycheck/src/test_runner.rs @@ -28,19 +28,20 @@ pub enum CargoTestMessage { }, Suite, Finished, + Custom { + text: String, + }, } impl ParseFromLine for CargoTestMessage { - fn from_line(line: &str, error: &mut String) -> Option { + fn from_line(line: &str, _: &mut String) -> Option { let mut deserializer = serde_json::Deserializer::from_str(line); deserializer.disable_recursion_limit(); if let Ok(message) = CargoTestMessage::deserialize(&mut deserializer) { return Some(message); } - error.push_str(line); - error.push('\n'); - None + Some(CargoTestMessage::Custom { text: line.to_owned() }) } fn from_eof() -> Option { diff --git a/crates/rust-analyzer/src/lsp/ext.rs b/crates/rust-analyzer/src/lsp/ext.rs index 86ab652f8ef..710ce7f8acb 100644 --- a/crates/rust-analyzer/src/lsp/ext.rs +++ b/crates/rust-analyzer/src/lsp/ext.rs @@ -234,6 +234,13 @@ impl Notification for EndRunTest { const METHOD: &'static str = "experimental/endRunTest"; } +pub enum AppendOutputToRunTest {} + +impl Notification for AppendOutputToRunTest { + type Params = String; + const METHOD: &'static str = "experimental/appendOutputToRunTest"; +} + pub enum AbortRunTest {} impl Notification for AbortRunTest { diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index e106a85c6eb..ffe56e41435 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -799,6 +799,9 @@ fn handle_cargo_test_msg(&mut self, message: flycheck::CargoTestMessage) { self.send_notification::(()); self.test_run_session = None; } + flycheck::CargoTestMessage::Custom { text } => { + self.send_notification::(text); + } } } diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index af5b4e51ef3..cf9ad5fe04d 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@