diff options
author | Kirill Bulatov <[email protected]> | 2019-07-21 22:10:29 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2019-07-21 22:10:29 +0100 |
commit | 31aef808d96b779dbc8ce41e27857965e79bd96f (patch) | |
tree | 254d69a1ec3abe6d70b2dd9737ef699f33f88f62 /crates/ra_assists/src/ast_editor.rs | |
parent | ba76017d2eb1b7606106c15478ac658dc32b6dbd (diff) | |
parent | d690249bc81bc265cb3d1836c2922325f4fdb8af (diff) |
Merge branch 'master' into add-type-lenses
Diffstat (limited to 'crates/ra_assists/src/ast_editor.rs')
-rw-r--r-- | crates/ra_assists/src/ast_editor.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs index ab6c347ad..95b871b30 100644 --- a/crates/ra_assists/src/ast_editor.rs +++ b/crates/ra_assists/src/ast_editor.rs | |||
@@ -4,7 +4,10 @@ use arrayvec::ArrayVec; | |||
4 | use hir::Name; | 4 | use hir::Name; |
5 | use ra_fmt::leading_indent; | 5 | use ra_fmt::leading_indent; |
6 | use ra_syntax::{ | 6 | use ra_syntax::{ |
7 | ast, AstNode, Direction, InsertPosition, SourceFile, SyntaxElement, SyntaxKind::*, T, | 7 | algo::{insert_children, replace_children}, |
8 | ast, AstNode, Direction, InsertPosition, SourceFile, SyntaxElement, | ||
9 | SyntaxKind::*, | ||
10 | T, | ||
8 | }; | 11 | }; |
9 | use ra_text_edit::TextEditBuilder; | 12 | use ra_text_edit::TextEditBuilder; |
10 | 13 | ||
@@ -38,7 +41,7 @@ impl<N: AstNode> AstEditor<N> { | |||
38 | position: InsertPosition<SyntaxElement>, | 41 | position: InsertPosition<SyntaxElement>, |
39 | to_insert: impl Iterator<Item = SyntaxElement>, | 42 | to_insert: impl Iterator<Item = SyntaxElement>, |
40 | ) -> N { | 43 | ) -> N { |
41 | let new_syntax = self.ast().syntax().insert_children(position, to_insert); | 44 | let new_syntax = insert_children(self.ast().syntax(), position, to_insert); |
42 | N::cast(new_syntax).unwrap() | 45 | N::cast(new_syntax).unwrap() |
43 | } | 46 | } |
44 | 47 | ||
@@ -48,7 +51,7 @@ impl<N: AstNode> AstEditor<N> { | |||
48 | to_delete: RangeInclusive<SyntaxElement>, | 51 | to_delete: RangeInclusive<SyntaxElement>, |
49 | to_insert: impl Iterator<Item = SyntaxElement>, | 52 | to_insert: impl Iterator<Item = SyntaxElement>, |
50 | ) -> N { | 53 | ) -> N { |
51 | let new_syntax = self.ast().syntax().replace_children(to_delete, to_insert); | 54 | let new_syntax = replace_children(self.ast().syntax(), to_delete, to_insert); |
52 | N::cast(new_syntax).unwrap() | 55 | N::cast(new_syntax).unwrap() |
53 | } | 56 | } |
54 | 57 | ||