aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion/reference_completion.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-11-21 09:57:05 +0000
committerAleksey Kladov <[email protected]>2018-11-21 09:57:05 +0000
commit049f8df93cca05af395ce873738dc85d5a25f3fc (patch)
tree55614a697cc531a53f2836c994d3211c6cd756c2 /crates/ra_analysis/src/completion/reference_completion.rs
parentb70b6bce19981df5d0cda6a0193fb9b07da6ea51 (diff)
switch completion to new scope
Diffstat (limited to 'crates/ra_analysis/src/completion/reference_completion.rs')
-rw-r--r--crates/ra_analysis/src/completion/reference_completion.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/crates/ra_analysis/src/completion/reference_completion.rs b/crates/ra_analysis/src/completion/reference_completion.rs
index c94d9af75..84383b547 100644
--- a/crates/ra_analysis/src/completion/reference_completion.rs
+++ b/crates/ra_analysis/src/completion/reference_completion.rs
@@ -39,14 +39,17 @@ pub(super) fn completions(
39 let module_scope = module.scope(db)?; 39 let module_scope = module.scope(db)?;
40 acc.extend( 40 acc.extend(
41 module_scope 41 module_scope
42 .entries() 42 .items
43 .iter() 43 .iter()
44 .filter(|entry| { 44 .filter(|(_name, res)| {
45 // Don't expose this item 45 // Don't expose this item
46 !entry.ptr().range().is_subrange(&name_ref.syntax().range()) 46 match res.import_name {
47 None => true,
48 Some(ptr) => !ptr.range().is_subrange(&name_ref.syntax().range()),
49 }
47 }) 50 })
48 .map(|entry| CompletionItem { 51 .map(|(name, _res)| CompletionItem {
49 label: entry.name().to_string(), 52 label: name.to_string(),
50 lookup: None, 53 lookup: None,
51 snippet: None, 54 snippet: None,
52 }), 55 }),
@@ -173,11 +176,14 @@ fn complete_path(
173 Some(it) => it, 176 Some(it) => it,
174 }; 177 };
175 let module_scope = target_module.scope(db)?; 178 let module_scope = target_module.scope(db)?;
176 let completions = module_scope.entries().iter().map(|entry| CompletionItem { 179 let completions = module_scope
177 label: entry.name().to_string(), 180 .items
178 lookup: None, 181 .iter()
179 snippet: None, 182 .map(|(name, _res)| CompletionItem {
180 }); 183 label: name.to_string(),
184 lookup: None,
185 snippet: None,
186 });
181 acc.extend(completions); 187 acc.extend(completions);
182 Ok(()) 188 Ok(())
183} 189}