aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/edit.rs11
-rw-r--r--crates/ra_syntax/src/ast/make.rs2
2 files changed, 6 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 0e78d8b63..d2630e9e9 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -276,7 +276,7 @@ pub fn replace_descendants<N: AstNode, D: AstNode>(
276 .into_iter() 276 .into_iter()
277 .map(|(from, to)| (from.syntax().clone().into(), to.syntax().clone().into())) 277 .map(|(from, to)| (from.syntax().clone().into(), to.syntax().clone().into()))
278 .collect::<FxHashMap<SyntaxElement, _>>(); 278 .collect::<FxHashMap<SyntaxElement, _>>();
279 let new_syntax = algo::replace_descendants(parent.syntax(), &|n| map.get(n).cloned()); 279 let new_syntax = algo::replace_descendants(parent.syntax(), |n| map.get(n).cloned());
280 N::cast(new_syntax).unwrap() 280 N::cast(new_syntax).unwrap()
281} 281}
282 282
@@ -331,7 +331,7 @@ impl IndentLevel {
331 ) 331 )
332 }) 332 })
333 .collect(); 333 .collect();
334 algo::replace_descendants(&node, &|n| replacements.get(n).cloned()) 334 algo::replace_descendants(&node, |n| replacements.get(n).cloned())
335 } 335 }
336 336
337 pub fn decrease_indent<N: AstNode>(self, node: N) -> N { 337 pub fn decrease_indent<N: AstNode>(self, node: N) -> N {
@@ -359,7 +359,7 @@ impl IndentLevel {
359 ) 359 )
360 }) 360 })
361 .collect(); 361 .collect();
362 algo::replace_descendants(&node, &|n| replacements.get(n).cloned()) 362 algo::replace_descendants(&node, |n| replacements.get(n).cloned())
363 } 363 }
364} 364}
365 365
@@ -389,7 +389,7 @@ fn insert_children<N: AstNode>(
389 position: InsertPosition<SyntaxElement>, 389 position: InsertPosition<SyntaxElement>,
390 to_insert: impl IntoIterator<Item = SyntaxElement>, 390 to_insert: impl IntoIterator<Item = SyntaxElement>,
391) -> N { 391) -> N {
392 let new_syntax = algo::insert_children(parent.syntax(), position, &mut to_insert.into_iter()); 392 let new_syntax = algo::insert_children(parent.syntax(), position, to_insert);
393 N::cast(new_syntax).unwrap() 393 N::cast(new_syntax).unwrap()
394} 394}
395 395
@@ -404,8 +404,7 @@ fn replace_children<N: AstNode>(
404 to_replace: RangeInclusive<SyntaxElement>, 404 to_replace: RangeInclusive<SyntaxElement>,
405 to_insert: impl IntoIterator<Item = SyntaxElement>, 405 to_insert: impl IntoIterator<Item = SyntaxElement>,
406) -> N { 406) -> N {
407 let new_syntax = 407 let new_syntax = algo::replace_children(parent.syntax(), to_replace, to_insert);
408 algo::replace_children(parent.syntax(), to_replace, &mut to_insert.into_iter());
409 N::cast(new_syntax).unwrap() 408 N::cast(new_syntax).unwrap()
410} 409}
411 410
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 60cd9d260..3f11b747f 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -15,7 +15,7 @@ pub fn name_ref(text: &str) -> ast::NameRef {
15pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment { 15pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment {
16 ast_from_text(&format!("use {};", name_ref.syntax())) 16 ast_from_text(&format!("use {};", name_ref.syntax()))
17} 17}
18pub fn path_unqalified(segment: ast::PathSegment) -> ast::Path { 18pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path {
19 path_from_text(&format!("use {}", segment.syntax())) 19 path_from_text(&format!("use {}", segment.syntax()))
20} 20}
21pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { 21pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path {