aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-06 13:45:22 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-06 13:45:22 +0000
commiteaf553dade9a28b41631387d7c88b09fd0ba64e2 (patch)
treef5043da62c6cf4e2f082f68746843de7dfe53d03 /crates/ra_analysis/src/completion
parentcbac31cbdb2168b18fc6fb89f5cf069238cc6ccb (diff)
parent98957f4e6f66469310072dff5dfc3e521a7cd555 (diff)
Merge #441
441: hir::Expr r=matklad a=flodiebold Still a bit to do, but I already adapted `FnScopes` and thought I'd get feedback already. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_analysis/src/completion')
-rw-r--r--crates/ra_analysis/src/completion/complete_scope.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/crates/ra_analysis/src/completion/complete_scope.rs b/crates/ra_analysis/src/completion/complete_scope.rs
index 4dead3689..21d77aa97 100644
--- a/crates/ra_analysis/src/completion/complete_scope.rs
+++ b/crates/ra_analysis/src/completion/complete_scope.rs
@@ -15,7 +15,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
15 None => return Ok(()), 15 None => return Ok(()),
16 }; 16 };
17 if let Some(function) = &ctx.function { 17 if let Some(function) = &ctx.function {
18 let scopes = function.scopes(ctx.db); 18 let scopes = function.scopes(ctx.db)?;
19 complete_fn(acc, &scopes, ctx.offset); 19 complete_fn(acc, &scopes, ctx.offset);
20 } 20 }
21 21
@@ -40,20 +40,17 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
40 Ok(()) 40 Ok(())
41} 41}
42 42
43fn complete_fn(acc: &mut Completions, scopes: &hir::FnScopes, offset: TextUnit) { 43fn complete_fn(acc: &mut Completions, scopes: &hir::ScopesWithSyntaxMapping, offset: TextUnit) {
44 let mut shadowed = FxHashSet::default(); 44 let mut shadowed = FxHashSet::default();
45 scopes 45 scopes
46 .scope_chain_for_offset(offset) 46 .scope_chain_for_offset(offset)
47 .flat_map(|scope| scopes.entries(scope).iter()) 47 .flat_map(|scope| scopes.scopes.entries(scope).iter())
48 .filter(|entry| shadowed.insert(entry.name())) 48 .filter(|entry| shadowed.insert(entry.name()))
49 .for_each(|entry| { 49 .for_each(|entry| {
50 CompletionItem::new(CompletionKind::Reference, entry.name().to_string()) 50 CompletionItem::new(CompletionKind::Reference, entry.name().to_string())
51 .kind(CompletionItemKind::Binding) 51 .kind(CompletionItemKind::Binding)
52 .add_to(acc) 52 .add_to(acc)
53 }); 53 });
54 if scopes.self_param.is_some() {
55 CompletionItem::new(CompletionKind::Reference, "self").add_to(acc);
56 }
57} 54}
58 55
59#[cfg(test)] 56#[cfg(test)]