aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/ast_editor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/ast_editor.rs')
-rw-r--r--crates/ra_assists/src/ast_editor.rs9
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;
4use hir::Name; 4use hir::Name;
5use ra_fmt::leading_indent; 5use ra_fmt::leading_indent;
6use ra_syntax::{ 6use 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};
9use ra_text_edit::TextEditBuilder; 12use 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