aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/fill_struct_fields.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-13 12:17:48 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-13 12:17:48 +0100
commit8887782c4ab97d22f3d5c10e142407e4371c5c61 (patch)
tree80b60b2c0c2f6104b98e16648b95d99d9b1d3463 /crates/ra_assists/src/fill_struct_fields.rs
parent34a05b7fea4add78446b2d93a64538982abacb9f (diff)
parent2facb5e061971afbf6bd2fabe3966d5de9d46489 (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_assists/src/fill_struct_fields.rs')
-rw-r--r--crates/ra_assists/src/fill_struct_fields.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ra_assists/src/fill_struct_fields.rs b/crates/ra_assists/src/fill_struct_fields.rs
index c7790dc72..663b4f669 100644
--- a/crates/ra_assists/src/fill_struct_fields.rs
+++ b/crates/ra_assists/src/fill_struct_fields.rs
@@ -1,6 +1,6 @@
1use std::fmt::Write; 1use std::fmt::Write;
2 2
3use hir::{AdtDef, db::HirDatabase, source_binder::function_from_child_node}; 3use hir::{AdtDef, db::HirDatabase};
4 4
5use ra_syntax::ast::{self, AstNode}; 5use ra_syntax::ast::{self, AstNode};
6 6
@@ -51,15 +51,13 @@ where
51 } 51 }
52 52
53 fn evaluate_struct_def_fields(&mut self) -> Option<()> { 53 fn evaluate_struct_def_fields(&mut self) -> Option<()> {
54 let function = function_from_child_node( 54 let analyzer = hir::SourceAnalyzer::new(
55 self.ctx.db, 55 self.ctx.db,
56 self.ctx.frange.file_id, 56 self.ctx.frange.file_id,
57 self.struct_lit.syntax(), 57 self.struct_lit.syntax(),
58 )?; 58 None,
59 let infer_result = function.infer(self.ctx.db); 59 );
60 let source_map = function.body_source_map(self.ctx.db); 60 let struct_lit_ty = analyzer.type_of(self.ctx.db, self.struct_lit.into())?;
61 let node_expr = source_map.node_expr(self.struct_lit.into())?;
62 let struct_lit_ty = infer_result[node_expr].clone();
63 let struct_def = match struct_lit_ty.as_adt() { 61 let struct_def = match struct_lit_ty.as_adt() {
64 Some((AdtDef::Struct(s), _)) => s, 62 Some((AdtDef::Struct(s), _)) => s,
65 _ => return None, 63 _ => return None,