mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
cleanup editor
This commit is contained in:
parent
05ca252fb5
commit
4acadbdca6
@ -75,10 +75,13 @@ fn add_missing_impl_members_inner(
|
||||
|
||||
ctx.add_action(AssistId(assist_id), label, |edit| {
|
||||
let n_existing_items = impl_item_list.impl_items().count();
|
||||
let items = missing_items.into_iter().map(|it| match it {
|
||||
ast::ImplItem::FnDef(def) => edit::strip_attrs_and_docs(add_body(def).into()),
|
||||
_ => edit::strip_attrs_and_docs(it),
|
||||
});
|
||||
let items = missing_items
|
||||
.into_iter()
|
||||
.map(|it| match it {
|
||||
ast::ImplItem::FnDef(def) => ast::ImplItem::FnDef(add_body(def)),
|
||||
_ => it,
|
||||
})
|
||||
.map(|it| edit::strip_attrs_and_docs(&it));
|
||||
let new_impl_item_list = impl_item_list.append_items(items);
|
||||
let cursor_position = {
|
||||
let first_new_item = new_impl_item_list.impl_items().nth(n_existing_items).unwrap();
|
||||
|
@ -187,6 +187,7 @@ impl ast::RecordFieldList {
|
||||
}
|
||||
|
||||
impl ast::TypeParam {
|
||||
#[must_use]
|
||||
pub fn remove_bounds(&self) -> ast::TypeParam {
|
||||
let colon = match self.colon_token() {
|
||||
Some(it) => it,
|
||||
@ -200,7 +201,8 @@ impl ast::TypeParam {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn strip_attrs_and_docs<N: ast::AttrsOwner>(node: N) -> N {
|
||||
#[must_use]
|
||||
pub fn strip_attrs_and_docs<N: ast::AttrsOwner>(node: &N) -> N {
|
||||
N::cast(strip_attrs_and_docs_inner(node.syntax().clone())).unwrap()
|
||||
}
|
||||
|
||||
@ -217,6 +219,7 @@ fn strip_attrs_and_docs_inner(mut node: SyntaxNode) -> SyntaxNode {
|
||||
node
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn replace_descendants<N: AstNode, D: AstNode>(
|
||||
parent: &N,
|
||||
replacement_map: impl Iterator<Item = (D, D)>,
|
||||
|
Loading…
Reference in New Issue
Block a user