diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-27 14:35:22 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-27 14:35:22 +0000 |
commit | 3b820bcca3a66660d0c5960f2a5c8f765095333e (patch) | |
tree | b7e3edf5a0bebb168330ac56a261ed5b0a90d43e /crates/ra_analysis/src/completion/complete_dot.rs | |
parent | 7a1ed6400dbc57656eebc345f7e2ffa963bf808e (diff) | |
parent | e4de2c8d7f5ced7a24d0a76213ab113218c99d30 (diff) |
Merge #346
346: add function to completion ctx r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis/src/completion/complete_dot.rs')
-rw-r--r-- | crates/ra_analysis/src/completion/complete_dot.rs | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/crates/ra_analysis/src/completion/complete_dot.rs b/crates/ra_analysis/src/completion/complete_dot.rs index 93d657576..f24835d17 100644 --- a/crates/ra_analysis/src/completion/complete_dot.rs +++ b/crates/ra_analysis/src/completion/complete_dot.rs | |||
@@ -6,20 +6,9 @@ use crate::completion::{CompletionContext, Completions, CompletionKind, Completi | |||
6 | 6 | ||
7 | /// Complete dot accesses, i.e. fields or methods (currently only fields). | 7 | /// Complete dot accesses, i.e. fields or methods (currently only fields). |
8 | pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) -> Cancelable<()> { | 8 | pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) -> Cancelable<()> { |
9 | let module = if let Some(module) = &ctx.module { | 9 | let (function, receiver) = match (&ctx.function, ctx.dot_receiver) { |
10 | module | 10 | (Some(function), Some(receiver)) => (function, receiver), |
11 | } else { | 11 | _ => return Ok(()), |
12 | return Ok(()); | ||
13 | }; | ||
14 | let function = if let Some(fn_def) = ctx.enclosing_fn { | ||
15 | hir::source_binder::function_from_module(ctx.db, module, fn_def) | ||
16 | } else { | ||
17 | return Ok(()); | ||
18 | }; | ||
19 | let receiver = if let Some(receiver) = ctx.dot_receiver { | ||
20 | receiver | ||
21 | } else { | ||
22 | return Ok(()); | ||
23 | }; | 12 | }; |
24 | let infer_result = function.infer(ctx.db)?; | 13 | let infer_result = function.infer(ctx.db)?; |
25 | let receiver_ty = if let Some(ty) = infer_result.type_of_node(receiver.syntax()) { | 14 | let receiver_ty = if let Some(ty) = infer_result.type_of_node(receiver.syntax()) { |