diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-13 12:17:48 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-13 12:17:48 +0100 |
commit | 8887782c4ab97d22f3d5c10e142407e4371c5c61 (patch) | |
tree | 80b60b2c0c2f6104b98e16648b95d99d9b1d3463 /crates/ra_ide_api/src/completion/complete_struct_literal.rs | |
parent | 34a05b7fea4add78446b2d93a64538982abacb9f (diff) | |
parent | 2facb5e061971afbf6bd2fabe3966d5de9d46489 (diff) |
Merge #1129
1129: introduce SourceAnalyzer API for ides r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_struct_literal.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_struct_literal.rs | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_struct_literal.rs index f58bcd03e..48fbf67f7 100644 --- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs +++ b/crates/ra_ide_api/src/completion/complete_struct_literal.rs | |||
@@ -4,17 +4,10 @@ use crate::completion::{CompletionContext, Completions}; | |||
4 | 4 | ||
5 | /// Complete fields in fields literals. | 5 | /// Complete fields in fields literals. |
6 | pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionContext) { | 6 | pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionContext) { |
7 | let (function, struct_lit) = match (&ctx.function, ctx.struct_lit_syntax) { | 7 | let ty = match ctx.struct_lit_syntax.and_then(|it| ctx.analyzer.type_of(ctx.db, it.into())) { |
8 | (Some(function), Some(struct_lit)) => (function, struct_lit), | 8 | Some(it) => it, |
9 | _ => return, | ||
10 | }; | ||
11 | let infer_result = function.infer(ctx.db); | ||
12 | let source_map = function.body_source_map(ctx.db); | ||
13 | let expr = match source_map.node_expr(struct_lit.into()) { | ||
14 | Some(expr) => expr, | ||
15 | None => return, | 9 | None => return, |
16 | }; | 10 | }; |
17 | let ty = infer_result[expr].clone(); | ||
18 | let (adt, substs) = match ty.as_adt() { | 11 | let (adt, substs) = match ty.as_adt() { |
19 | Some(res) => res, | 12 | Some(res) => res, |
20 | _ => return, | 13 | _ => return, |