From d847d53e36571c8f7925b72cedf66bb203976148 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 26 Sep 2019 22:08:44 +0300 Subject: Start simplifying editing API --- crates/ra_assists/src/assists/add_missing_impl_members.rs | 8 +++----- crates/ra_assists/src/assists/auto_import.rs | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'crates/ra_assists/src/assists') diff --git a/crates/ra_assists/src/assists/add_missing_impl_members.rs b/crates/ra_assists/src/assists/add_missing_impl_members.rs index 23da1e65f..682455bce 100644 --- a/crates/ra_assists/src/assists/add_missing_impl_members.rs +++ b/crates/ra_assists/src/assists/add_missing_impl_members.rs @@ -100,12 +100,11 @@ fn strip_docstring(item: ast::ImplItem) -> ast::ImplItem { } fn add_body(fn_def: ast::FnDef) -> ast::FnDef { - let mut ast_editor = AstEditor::new(fn_def.clone()); if fn_def.body().is_none() { - let body = make::block_from_expr(make::expr_unimplemented()); - ast_editor.set_body(&body); + fn_def.with_body(make::block_from_expr(make::expr_unimplemented())) + } else { + fn_def } - ast_editor.ast().to_owned() } /// Given an `ast::ImplBlock`, resolves the target trait (the one being @@ -332,5 +331,4 @@ impl Foo for S { }", ) } - } diff --git a/crates/ra_assists/src/assists/auto_import.rs b/crates/ra_assists/src/assists/auto_import.rs index 5aae98546..a91c170b9 100644 --- a/crates/ra_assists/src/assists/auto_import.rs +++ b/crates/ra_assists/src/assists/auto_import.rs @@ -448,7 +448,6 @@ fn make_assist_add_in_tree_list( fmt_segments_raw(target, &mut buf); edit.insert(offset, buf); } else { - } } -- cgit v1.2.3