aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/syntax')
-rw-r--r--crates/syntax/src/ast/edit.rs12
-rw-r--r--crates/syntax/src/ast/make.rs3
2 files changed, 4 insertions, 11 deletions
diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs
index 8c60927e4..cbc75f922 100644
--- a/crates/syntax/src/ast/edit.rs
+++ b/crates/syntax/src/ast/edit.rs
@@ -665,18 +665,8 @@ pub trait AstNodeEdit: AstNode + Clone + Sized {
665 665
666 #[must_use] 666 #[must_use]
667 fn replace_descendant<D: AstNode>(&self, old: D, new: D) -> Self { 667 fn replace_descendant<D: AstNode>(&self, old: D, new: D) -> Self {
668 self.replace_descendants(iter::once((old, new)))
669 }
670
671 #[must_use]
672 fn replace_descendants<D: AstNode>(
673 &self,
674 replacement_map: impl IntoIterator<Item = (D, D)>,
675 ) -> Self {
676 let mut rewriter = SyntaxRewriter::default(); 668 let mut rewriter = SyntaxRewriter::default();
677 for (from, to) in replacement_map { 669 rewriter.replace(old.syntax(), new.syntax());
678 rewriter.replace(from.syntax(), to.syntax())
679 }
680 rewriter.rewrite_ast(self) 670 rewriter.rewrite_ast(self)
681 } 671 }
682 fn indent_level(&self) -> IndentLevel { 672 fn indent_level(&self) -> IndentLevel {
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs
index f8b508a90..5a6687397 100644
--- a/crates/syntax/src/ast/make.rs
+++ b/crates/syntax/src/ast/make.rs
@@ -275,6 +275,9 @@ pub fn expr_tuple(elements: impl IntoIterator<Item = ast::Expr>) -> ast::Expr {
275 let expr = elements.into_iter().format(", "); 275 let expr = elements.into_iter().format(", ");
276 expr_from_text(&format!("({})", expr)) 276 expr_from_text(&format!("({})", expr))
277} 277}
278pub fn expr_assignment(lhs: ast::Expr, rhs: ast::Expr) -> ast::Expr {
279 expr_from_text(&format!("{} = {}", lhs, rhs))
280}
278fn expr_from_text(text: &str) -> ast::Expr { 281fn expr_from_text(text: &str) -> ast::Expr {
279 ast_from_text(&format!("const C: () = {};", text)) 282 ast_from_text(&format!("const C: () = {};", text))
280} 283}