aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion/complete_dot.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-01-06 15:47:59 +0000
committerFlorian Diebold <[email protected]>2019-01-06 23:05:19 +0000
commit6210e82041849bad6129331b9e45ac0bae6fe569 (patch)
tree43656452729519e45f4aa036372526b2934a230c /crates/ra_analysis/src/completion/complete_dot.rs
parent3c945ceb5e0dc287139de0589cc9a4b285911f17 (diff)
Use HIR Expr for type inference
Now we can reuse the type inference inside a function when typing whitespace etc. :)
Diffstat (limited to 'crates/ra_analysis/src/completion/complete_dot.rs')
-rw-r--r--crates/ra_analysis/src/completion/complete_dot.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/ra_analysis/src/completion/complete_dot.rs b/crates/ra_analysis/src/completion/complete_dot.rs
index 031d8b98f..ef3f4271b 100644
--- a/crates/ra_analysis/src/completion/complete_dot.rs
+++ b/crates/ra_analysis/src/completion/complete_dot.rs
@@ -1,3 +1,4 @@
1use ra_db::LocalSyntaxPtr;
1use ra_syntax::ast::AstNode; 2use ra_syntax::ast::AstNode;
2use hir::{Ty, Def}; 3use hir::{Ty, Def};
3 4
@@ -11,11 +12,14 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) -> Ca
11 _ => return Ok(()), 12 _ => return Ok(()),
12 }; 13 };
13 let infer_result = function.infer(ctx.db)?; 14 let infer_result = function.infer(ctx.db)?;
14 let receiver_ty = if let Some(ty) = infer_result.type_of_node(receiver.syntax()) { 15 let syntax_mapping = function.body_syntax_mapping(ctx.db)?;
15 ty 16 let expr =
16 } else { 17 if let Some(expr) = syntax_mapping.syntax_expr(LocalSyntaxPtr::new(receiver.syntax())) {
17 return Ok(()); 18 expr
18 }; 19 } else {
20 return Ok(());
21 };
22 let receiver_ty = infer_result[expr].clone();
19 if !ctx.is_method_call { 23 if !ctx.is_method_call {
20 complete_fields(acc, ctx, receiver_ty)?; 24 complete_fields(acc, ctx, receiver_ty)?;
21 } 25 }