aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/tests/heavy_tests/main.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-07 11:36:04 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-07 11:36:04 +0000
commit5232099977d07492c1b6d5e6163c70d4f6eb07df (patch)
tree0660079034d3c2f30147e946f2c473d2f651eef2 /crates/ra_lsp_server/tests/heavy_tests/main.rs
parentb94e1eee8341cb2a16b89711d65b382549fd2bde (diff)
parent4cd757c1e32f0cf1f281b82cd55615d0e47edb24 (diff)
Merge #939
939: Initial implementation of project-lock.json. r=davidtwco a=davidtwco Fixes #792. This PR adds a initial implementation of project-lock.json, a build system agnostic method of specifying the crate graph and roots. Co-authored-by: David Wood <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/tests/heavy_tests/main.rs')
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/main.rs65
1 files changed, 64 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs
index 1c099a78f..41c240139 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/main.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs
@@ -12,8 +12,9 @@ use ra_lsp_server::req::{
12 CodeActionParams, CodeActionRequest, Formatting, Runnables, RunnablesParams, CompletionParams, Completion, 12 CodeActionParams, CodeActionRequest, Formatting, Runnables, RunnablesParams, CompletionParams, Completion,
13}; 13};
14use serde_json::json; 14use serde_json::json;
15use tempfile::TempDir;
15 16
16use crate::support::project; 17use crate::support::{project, project_with_tmpdir};
17 18
18const LOG: &'static str = ""; 19const LOG: &'static str = "";
19 20
@@ -258,3 +259,65 @@ fn main() {}
258 json!([]), 259 json!([]),
259 ); 260 );
260} 261}
262
263#[test]
264fn test_missing_module_code_action_in_json_project() {
265 let tmp_dir = TempDir::new().unwrap();
266 let code = format!(
267 r#"
268//- rust-project.json
269{{
270 "roots": [ "{PATH}" ],
271 "crates": [ {{ "root_module": "{PATH}/src/lib.rs", "deps": [], "edition": "2015" }} ]
272}}
273
274//- src/lib.rs
275mod bar;
276
277fn main() {}
278"#,
279 PATH = tmp_dir.path().display()
280 );
281 let server = project_with_tmpdir(tmp_dir, &code);
282 server.wait_for_message("workspace loaded");
283 let empty_context = || CodeActionContext { diagnostics: Vec::new(), only: None };
284 server.request::<CodeActionRequest>(
285 CodeActionParams {
286 text_document: server.doc_id("src/lib.rs"),
287 range: Range::new(Position::new(0, 4), Position::new(0, 7)),
288 context: empty_context(),
289 },
290 json!([
291 {
292 "command": {
293 "arguments": [
294 {
295 "cursorPosition": null,
296 "label": "create module",
297 "workspaceEdit": {
298 "documentChanges": [
299 {
300 "kind": "create",
301 "uri": "file:///[..]/src/bar.rs"
302 }
303 ]
304 }
305 }
306 ],
307 "command": "rust-analyzer.applySourceChange",
308 "title": "create module"
309 },
310 "title": "create module"
311 }
312 ]),
313 );
314
315 server.request::<CodeActionRequest>(
316 CodeActionParams {
317 text_document: server.doc_id("src/lib.rs"),
318 range: Range::new(Position::new(2, 4), Position::new(2, 7)),
319 context: empty_context(),
320 },
321 json!([]),
322 );
323}