aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/nameres.rs2
-rw-r--r--crates/ra_hir/src/resolve.rs5
-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
4 files changed, 41 insertions, 2 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index 68df083d8..f9da6bc83 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -34,7 +34,7 @@ use crate::{
34/// module, the set of visible items. 34/// module, the set of visible items.
35#[derive(Default, Debug, PartialEq, Eq)] 35#[derive(Default, Debug, PartialEq, Eq)]
36pub struct ItemMap { 36pub struct ItemMap {
37 extern_prelude: FxHashMap<Name, ModuleDef>, 37 pub(crate) extern_prelude: FxHashMap<Name, ModuleDef>,
38 per_module: ArenaMap<ModuleId, ModuleScope>, 38 per_module: ArenaMap<ModuleId, ModuleScope>,
39} 39}
40 40
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index 6c87d0df7..5ca7bacb5 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -197,7 +197,10 @@ impl Scope {
197 .entries() 197 .entries()
198 .for_each(|(name, res)| { 198 .for_each(|(name, res)| {
199 f(name.clone(), res.def.map(Resolution::Def)); 199 f(name.clone(), res.def.map(Resolution::Def));
200 }) 200 });
201 m.item_map.extern_prelude.iter().for_each(|(name, def)| {
202 f(name.clone(), PerNs::types(Resolution::Def(*def)));
203 });
201 } 204 }
202 Scope::GenericParams(gp) => { 205 Scope::GenericParams(gp) => {
203 for param in &gp.params { 206 for param in &gp.params {
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]