From 3bc33ae712d24f19f348828b0b18cda3d09a2360 Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 7 Mar 2019 00:53:26 +0100 Subject: Add test demonstrating logic for handling deps. --- crates/ra_lsp_server/tests/heavy_tests/main.rs | 45 +++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server/tests') diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index 641f84cfc..8e4e1fb88 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -279,7 +279,7 @@ fn main() {} PATH = tmp_dir.path().display() ); let server = project_with_tmpdir(tmp_dir, &code); - server.wait_for_feedback("workspace loaded"); + server.wait_for_message("workspace loaded"); let empty_context = || CodeActionContext { diagnostics: Vec::new(), only: None }; server.request::( CodeActionParams { @@ -321,3 +321,46 @@ fn main() {} json!([]), ); } + +#[test] +fn completes_items_from_second_crate_in_json_project() { + let tmp_dir = TempDir::new().unwrap(); + let code = format!( + r#" +//- rust-project.json +{{ + "roots": [ "{PATH}" ], + "crates": [ + {{ + "root_module": "{PATH}/foo/lib.rs", + "deps": [ + {{ + "name": "bar", + "crate": 1 + }} + ], + "edition": "2015" + }}, + {{ "root_module": "{PATH}/bar/lib.rs", "deps": [], "edition": "2015" }} + ] +}} + +//- bar/lib.rs +pub struct Spam; +pub struct CannedMeat; + +//- foo/lib.rs +extern crate bar; +use bar::Spam; +"#, + PATH = tmp_dir.path().display() + ); + let server = project_with_tmpdir(tmp_dir, &code); + server.wait_for_message("workspace loaded"); + let res = server.send_request::(CompletionParams { + text_document: server.doc_id("foo/lib.rs"), + context: None, + position: Position::new(1, 10), + }); + assert!(format!("{}", res).contains("CannedMeat")); +} -- cgit v1.2.3