aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assists
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-09-28 17:50:16 +0100
committerAleksey Kladov <[email protected]>2019-09-28 17:50:16 +0100
commit5dbbfda34ae423229487595fd0ae9e727ae42906 (patch)
tree647be92788a5d338bcfbb088ffb4e56582ad3367 /crates/ra_assists/src/assists
parentdbdf0e24d51ce425c0066a76a0efc723e41e5071 (diff)
simplify strip attrs
Diffstat (limited to 'crates/ra_assists/src/assists')
-rw-r--r--crates/ra_assists/src/assists/add_missing_impl_members.rs12
1 files changed, 3 insertions, 9 deletions
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 682455bce..3fce4a5b7 100644
--- a/crates/ra_assists/src/assists/add_missing_impl_members.rs
+++ b/crates/ra_assists/src/assists/add_missing_impl_members.rs
@@ -1,6 +1,6 @@
1use hir::{db::HirDatabase, HasSource}; 1use hir::{db::HirDatabase, HasSource};
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{self, make, AstNode, NameOwner}, 3 ast::{self, edit, make, AstNode, NameOwner},
4 SmolStr, 4 SmolStr,
5}; 5};
6 6
@@ -76,8 +76,8 @@ fn add_missing_impl_members_inner(
76 ctx.add_action(AssistId(assist_id), label, |edit| { 76 ctx.add_action(AssistId(assist_id), label, |edit| {
77 let n_existing_items = impl_item_list.impl_items().count(); 77 let n_existing_items = impl_item_list.impl_items().count();
78 let items = missing_items.into_iter().map(|it| match it { 78 let items = missing_items.into_iter().map(|it| match it {
79 ast::ImplItem::FnDef(def) => strip_docstring(add_body(def).into()), 79 ast::ImplItem::FnDef(def) => edit::strip_attrs_and_docs(add_body(def).into()),
80 _ => strip_docstring(it), 80 _ => edit::strip_attrs_and_docs(it),
81 }); 81 });
82 let mut ast_editor = AstEditor::new(impl_item_list); 82 let mut ast_editor = AstEditor::new(impl_item_list);
83 83
@@ -93,12 +93,6 @@ fn add_missing_impl_members_inner(
93 ctx.build() 93 ctx.build()
94} 94}
95 95
96fn strip_docstring(item: ast::ImplItem) -> ast::ImplItem {
97 let mut ast_editor = AstEditor::new(item);
98 ast_editor.strip_attrs_and_docs();
99 ast_editor.ast().to_owned()
100}
101
102fn add_body(fn_def: ast::FnDef) -> ast::FnDef { 96fn add_body(fn_def: ast::FnDef) -> ast::FnDef {
103 if fn_def.body().is_none() { 97 if fn_def.body().is_none() {
104 fn_def.with_body(make::block_from_expr(make::expr_unimplemented())) 98 fn_def.with_body(make::block_from_expr(make::expr_unimplemented()))