aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion/reference_completion.rs
diff options
context:
space:
mode:
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}