aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/tests/heavy_tests
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-06 09:56:16 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-06 09:56:16 +0000
commitefff77406813ecc561c255c48090c58d2235f7a2 (patch)
tree123896a906abdfb6de3c0e3f13e0c69e98e3cc01 /crates/ra_lsp_server/tests/heavy_tests
parentab288a32f9a95e3ca5e9e42f9c6f59bb3849f26e (diff)
parent0dcb1cb569417a17e27a4d8b34813ded41395268 (diff)
Merge #940
940: Show workspace loaded notification r=matklad a=vipentti This fixes #935 This adds support for more `InitializationOptions` which are provided by the client. Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/tests/heavy_tests')
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/main.rs10
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/support.rs21
2 files changed, 20 insertions, 11 deletions
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"
31use std::collections::Spam; 31use std::collections::Spam;
32"#, 32"#,
33 ); 33 );
34 server.wait_for_feedback("workspace loaded"); 34 server.wait_for_message("workspace loaded");
35 eprintln!("loading took {:?}", project_start.elapsed()); 35 eprintln!("loading took {:?}", project_start.elapsed());
36 let completion_start = Instant::now(); 36 let completion_start = Instant::now();
37 let res = server.send_request::<Completion>(CompletionParams { 37 let res = server.send_request::<Completion>(CompletionParams {
@@ -53,7 +53,7 @@ fn foo() {
53} 53}
54", 54",
55 ); 55 );
56 server.wait_for_feedback("workspace loaded"); 56 server.wait_for_message("workspace loaded");
57 server.request::<Runnables>( 57 server.request::<Runnables>(
58 RunnablesParams { text_document: server.doc_id("lib.rs"), position: None }, 58 RunnablesParams { text_document: server.doc_id("lib.rs"), position: None },
59 json!([ 59 json!([
@@ -107,7 +107,7 @@ pub fn foo() {}
107fn test_eggs() {} 107fn test_eggs() {}
108"#, 108"#,
109 ); 109 );
110 server.wait_for_feedback("workspace loaded"); 110 server.wait_for_message("workspace loaded");
111 server.request::<Runnables>( 111 server.request::<Runnables>(
112 RunnablesParams { 112 RunnablesParams {
113 text_document: server.doc_id("tests/spam.rs"), 113 text_document: server.doc_id("tests/spam.rs"),
@@ -167,7 +167,7 @@ fn main() {
167pub use std::collections::HashMap; 167pub use std::collections::HashMap;
168"#, 168"#,
169 ); 169 );
170 server.wait_for_feedback("workspace loaded"); 170 server.wait_for_message("workspace loaded");
171 171
172 server.request::<Formatting>( 172 server.request::<Formatting>(
173 DocumentFormattingParams { 173 DocumentFormattingParams {
@@ -216,7 +216,7 @@ mod bar;
216fn main() {} 216fn main() {}
217"#, 217"#,
218 ); 218 );
219 server.wait_for_feedback("workspace loaded"); 219 server.wait_for_message("workspace loaded");
220 let empty_context = || CodeActionContext { diagnostics: Vec::new(), only: None }; 220 let empty_context = || CodeActionContext { diagnostics: Vec::new(), only: None };
221 server.request::<CodeActionRequest>( 221 server.request::<CodeActionRequest>(
222 CodeActionParams { 222 CodeActionParams {
diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs
index f4e7eaf75..8bfc8d622 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::{
13 notification::DidOpenTextDocument, 13 notification::DidOpenTextDocument,
14 request::{Request, Shutdown}, 14 request::{Request, Shutdown},
15 DidOpenTextDocumentParams, TextDocumentIdentifier, TextDocumentItem, Url, 15 DidOpenTextDocumentParams, TextDocumentIdentifier, TextDocumentItem, Url,
16 notification::{Notification, ShowMessage},
16}; 17};
17use serde::Serialize; 18use serde::Serialize;
18use serde_json::{to_string_pretty, Value}; 19use serde_json::{to_string_pretty, Value};
@@ -22,6 +23,7 @@ use test_utils::{parse_fixture, find_mismatch};
22 23
23use ra_lsp_server::{ 24use ra_lsp_server::{
24 main_loop, req, 25 main_loop, req,
26 InitializationOptions,
25}; 27};
26 28
27pub fn project(fixture: &str) -> Server { 29pub fn project(fixture: &str) -> Server {
@@ -56,7 +58,13 @@ impl Server {
56 "test server", 58 "test server",
57 128, 59 128,
58 move |mut msg_receiver, mut msg_sender| { 60 move |mut msg_receiver, mut msg_sender| {
59 main_loop(true, path, true, &mut msg_receiver, &mut msg_sender).unwrap() 61 main_loop(
62 path,
63 InitializationOptions::default(),
64 &mut msg_receiver,
65 &mut msg_sender,
66 )
67 .unwrap()
60 }, 68 },
61 ); 69 );
62 let res = Server { 70 let res = Server {
@@ -133,13 +141,14 @@ impl Server {
133 } 141 }
134 panic!("no response"); 142 panic!("no response");
135 } 143 }
136 pub fn wait_for_feedback(&self, feedback: &str) { 144 pub fn wait_for_message(&self, message: &str) {
137 self.wait_for_feedback_n(feedback, 1) 145 self.wait_for_message_n(message, 1)
138 } 146 }
139 pub fn wait_for_feedback_n(&self, feedback: &str, n: usize) { 147 pub fn wait_for_message_n(&self, message: &str, n: usize) {
140 let f = |msg: &RawMessage| match msg { 148 let f = |msg: &RawMessage| match msg {
141 RawMessage::Notification(n) if n.method == "internalFeedback" => { 149 RawMessage::Notification(n) if n.method == ShowMessage::METHOD => {
142 return n.clone().cast::<req::InternalFeedback>().unwrap() == feedback; 150 let msg = n.clone().cast::<req::ShowMessage>().unwrap();
151 msg.message == message
143 } 152 }
144 _ => false, 153 _ => false,
145 }; 154 };