aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/completion/complete_scope.rs14
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__extern_prelude.snap22
-rw-r--r--crates/ra_ide_api/src/mock_analysis.rs12
3 files changed, 46 insertions, 2 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index 44514ab2b..8674b1e66 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -111,6 +111,20 @@ mod tests {
111 } 111 }
112 112
113 #[test] 113 #[test]
114 fn completes_extern_prelude() {
115 check_reference_completion(
116 "extern_prelude",
117 r"
118 //- /lib.rs
119 use <|>;
120
121 //- /other_crate/lib.rs
122 // nothing here
123 ",
124 );
125 }
126
127 #[test]
114 fn completes_module_items_in_nested_modules() { 128 fn completes_module_items_in_nested_modules() {
115 check_reference_completion( 129 check_reference_completion(
116 "module_items_in_nested_modules", 130 "module_items_in_nested_modules",
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__extern_prelude.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__extern_prelude.snap
new file mode 100644
index 000000000..d0e3a6188
--- /dev/null
+++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__extern_prelude.snap
@@ -0,0 +1,22 @@
1---
2created: "2019-02-04T21:08:32.615556587+00:00"
3creator: [email protected]
4expression: kind_completions
5source: crates/ra_ide_api/src/completion/completion_item.rs
6---
7[
8 CompletionItem {
9 completion_kind: Reference,
10 label: "other_crate",
11 kind: Some(
12 Module
13 ),
14 detail: None,
15 documentation: None,
16 lookup: None,
17 insert_text: None,
18 insert_text_format: PlainText,
19 source_range: [4; 4),
20 text_edit: None
21 }
22]
diff --git a/crates/ra_ide_api/src/mock_analysis.rs b/crates/ra_ide_api/src/mock_analysis.rs
index 0f2d22ab2..834b30541 100644
--- a/crates/ra_ide_api/src/mock_analysis.rs
+++ b/crates/ra_ide_api/src/mock_analysis.rs
@@ -86,17 +86,25 @@ impl MockAnalysis {
86 let mut change = AnalysisChange::new(); 86 let mut change = AnalysisChange::new();
87 change.add_root(source_root, true); 87 change.add_root(source_root, true);
88 let mut crate_graph = CrateGraph::default(); 88 let mut crate_graph = CrateGraph::default();
89 let mut root_crate = None;
89 for (i, (path, contents)) in self.files.into_iter().enumerate() { 90 for (i, (path, contents)) in self.files.into_iter().enumerate() {
90 assert!(path.starts_with('/')); 91 assert!(path.starts_with('/'));
91 let path = RelativePathBuf::from_path(&path[1..]).unwrap(); 92 let path = RelativePathBuf::from_path(&path[1..]).unwrap();
92 let file_id = FileId(i as u32 + 1); 93 let file_id = FileId(i as u32 + 1);
93 if path == "/lib.rs" || path == "/main.rs" { 94 if path == "/lib.rs" || path == "/main.rs" {
94 crate_graph.add_crate_root(file_id); 95 root_crate = Some(crate_graph.add_crate_root(file_id));
96 } else if path.ends_with("/lib.rs") {
97 let other_crate = crate_graph.add_crate_root(file_id);
98 let crate_name = path.parent().unwrap().file_name().unwrap();
99 if let Some(root_crate) = root_crate {
100 crate_graph
101 .add_dep(root_crate, crate_name.into(), other_crate)
102 .unwrap();
103 }
95 } 104 }
96 change.add_file(source_root, file_id, path, Arc::new(contents)); 105 change.add_file(source_root, file_id, path, Arc::new(contents));
97 } 106 }
98 change.set_crate_graph(crate_graph); 107 change.set_crate_graph(crate_graph);
99 // change.set_file_resolver(Arc::new(file_map));
100 host.apply_change(change); 108 host.apply_change(change);
101 host 109 host
102 } 110 }