From 9063dabcca0aaaa6d8bb3364cee21fd68023a059 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Tue, 5 Mar 2019 21:59:01 +0200 Subject: Send an actual ShowMessage instead of InternalFeedback in feedback() This now allows us to send a notification that can be shown in the UI when the workspace has been loaded. Additionally this removes the need for internal_mode flag. --- crates/ra_lsp_server/tests/heavy_tests/support.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'crates/ra_lsp_server/tests/heavy_tests') diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index f4e7eaf75..3a7c50309 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -13,6 +13,7 @@ use lsp_types::{ notification::DidOpenTextDocument, request::{Request, Shutdown}, DidOpenTextDocumentParams, TextDocumentIdentifier, TextDocumentItem, Url, + notification::{Notification, ShowMessage}, }; use serde::Serialize; use serde_json::{to_string_pretty, Value}; @@ -56,7 +57,7 @@ impl Server { "test server", 128, move |mut msg_receiver, mut msg_sender| { - main_loop(true, path, true, &mut msg_receiver, &mut msg_sender).unwrap() + main_loop(path, true, &mut msg_receiver, &mut msg_sender).unwrap() }, ); let res = Server { @@ -138,8 +139,9 @@ impl Server { } pub fn wait_for_feedback_n(&self, feedback: &str, n: usize) { let f = |msg: &RawMessage| match msg { - RawMessage::Notification(n) if n.method == "internalFeedback" => { - return n.clone().cast::().unwrap() == feedback; + RawMessage::Notification(n) if n.method == ShowMessage::METHOD => { + let message = n.clone().cast::().unwrap(); + message.message == feedback } _ => false, }; -- cgit v1.2.3 From ce118da149a0db1815f188c9914001608a5ac09e Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Tue, 5 Mar 2019 22:25:24 +0200 Subject: Rename feedback to show_message --- crates/ra_lsp_server/tests/heavy_tests/main.rs | 10 +++++----- crates/ra_lsp_server/tests/heavy_tests/support.rs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/ra_lsp_server/tests/heavy_tests') diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index 996bf8e01..1c099a78f 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -31,7 +31,7 @@ version = "0.0.0" use std::collections::Spam; "#, ); - server.wait_for_feedback("workspace loaded"); + server.wait_for_message("workspace loaded"); eprintln!("loading took {:?}", project_start.elapsed()); let completion_start = Instant::now(); let res = server.send_request::(CompletionParams { @@ -53,7 +53,7 @@ fn foo() { } ", ); - server.wait_for_feedback("workspace loaded"); + server.wait_for_message("workspace loaded"); server.request::( RunnablesParams { text_document: server.doc_id("lib.rs"), position: None }, json!([ @@ -107,7 +107,7 @@ pub fn foo() {} fn test_eggs() {} "#, ); - server.wait_for_feedback("workspace loaded"); + server.wait_for_message("workspace loaded"); server.request::( RunnablesParams { text_document: server.doc_id("tests/spam.rs"), @@ -167,7 +167,7 @@ fn main() { pub use std::collections::HashMap; "#, ); - server.wait_for_feedback("workspace loaded"); + server.wait_for_message("workspace loaded"); server.request::( DocumentFormattingParams { @@ -216,7 +216,7 @@ mod bar; fn main() {} "#, ); - server.wait_for_feedback("workspace loaded"); + server.wait_for_message("workspace loaded"); let empty_context = || CodeActionContext { diagnostics: Vec::new(), only: None }; server.request::( CodeActionParams { diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 3a7c50309..08f7ad6fd 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -134,14 +134,14 @@ impl Server { } panic!("no response"); } - pub fn wait_for_feedback(&self, feedback: &str) { - self.wait_for_feedback_n(feedback, 1) + pub fn wait_for_message(&self, message: &str) { + self.wait_for_message_n(message, 1) } - pub fn wait_for_feedback_n(&self, feedback: &str, n: usize) { + pub fn wait_for_message_n(&self, message: &str, n: usize) { let f = |msg: &RawMessage| match msg { RawMessage::Notification(n) if n.method == ShowMessage::METHOD => { - let message = n.clone().cast::().unwrap(); - message.message == feedback + let msg = n.clone().cast::().unwrap(); + msg.message == message } _ => false, }; -- cgit v1.2.3 From 0dcb1cb569417a17e27a4d8b34813ded41395268 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Wed, 6 Mar 2019 11:34:38 +0200 Subject: Add showWorkspaceLoadedNotification to vscode client This allows users to control whether or not they want to see the "workspace loaded" notification. This is done on the server side using InitializationOptions which are provided by the client. By default show_workspace_loaded is true, meaning the notification is sent. --- crates/ra_lsp_server/tests/heavy_tests/support.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server/tests/heavy_tests') diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 08f7ad6fd..8bfc8d622 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -23,6 +23,7 @@ use test_utils::{parse_fixture, find_mismatch}; use ra_lsp_server::{ main_loop, req, + InitializationOptions, }; pub fn project(fixture: &str) -> Server { @@ -57,7 +58,13 @@ impl Server { "test server", 128, move |mut msg_receiver, mut msg_sender| { - main_loop(path, true, &mut msg_receiver, &mut msg_sender).unwrap() + main_loop( + path, + InitializationOptions::default(), + &mut msg_receiver, + &mut msg_sender, + ) + .unwrap() }, ); let res = Server { -- cgit v1.2.3