aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/completion')
-rw-r--r--crates/ra_analysis/src/completion/complete_scope.rs44
1 files changed, 23 insertions, 21 deletions
diff --git a/crates/ra_analysis/src/completion/complete_scope.rs b/crates/ra_analysis/src/completion/complete_scope.rs
index 82610d63f..a57670e3b 100644
--- a/crates/ra_analysis/src/completion/complete_scope.rs
+++ b/crates/ra_analysis/src/completion/complete_scope.rs
@@ -10,32 +10,34 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
10 if !ctx.is_trivial_path { 10 if !ctx.is_trivial_path {
11 return Ok(()); 11 return Ok(());
12 } 12 }
13 let module = match &ctx.module {
14 Some(it) => it,
15 None => return Ok(()),
16 };
13 if let Some(fn_def) = ctx.enclosing_fn { 17 if let Some(fn_def) = ctx.enclosing_fn {
14 let scopes = hir::FnScopes::new(fn_def); 18 let function = hir::source_binder::function_from_module(ctx.db, module, fn_def);
19 let scopes = function.scopes(ctx.db);
15 complete_fn(acc, &scopes, ctx.offset); 20 complete_fn(acc, &scopes, ctx.offset);
16 } 21 }
17 22
18 if let Some(module) = &ctx.module { 23 let module_scope = module.scope(ctx.db)?;
19 let module_scope = module.scope(ctx.db)?; 24 module_scope
20 module_scope 25 .entries()
21 .entries() 26 .filter(|(_name, res)| {
22 .filter(|(_name, res)| { 27 // Don't expose this item
23 // Don't expose this item 28 match res.import {
24 match res.import { 29 None => true,
25 None => true, 30 Some(import) => {
26 Some(import) => { 31 let range = import.range(ctx.db, module.source().file_id());
27 let range = import.range(ctx.db, module.source().file_id()); 32 !range.is_subrange(&ctx.leaf.range())
28 !range.is_subrange(&ctx.leaf.range())
29 }
30 } 33 }
31 }) 34 }
32 .for_each(|(name, res)| { 35 })
33 CompletionItem::new(CompletionKind::Reference, name.to_string()) 36 .for_each(|(name, res)| {
34 .from_resolution(ctx.db, res) 37 CompletionItem::new(CompletionKind::Reference, name.to_string())
35 .add_to(acc) 38 .from_resolution(ctx.db, res)
36 }); 39 .add_to(acc)
37 } 40 });
38
39 Ok(()) 41 Ok(())
40} 42}
41 43