aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/syntax/src')
-rw-r--r--crates/syntax/src/ast/edit.rs3
-rw-r--r--crates/syntax/src/ast/make.rs7
2 files changed, 10 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs
index 2667d9af4..190746e09 100644
--- a/crates/syntax/src/ast/edit.rs
+++ b/crates/syntax/src/ast/edit.rs
@@ -601,6 +601,9 @@ pub trait AstNodeEdit: AstNode + Clone + Sized {
601 } 601 }
602 rewriter.rewrite_ast(self) 602 rewriter.rewrite_ast(self)
603 } 603 }
604 fn indent_level(&self) -> IndentLevel {
605 IndentLevel::from_node(self.syntax())
606 }
604 #[must_use] 607 #[must_use]
605 fn indent(&self, level: IndentLevel) -> Self { 608 fn indent(&self, level: IndentLevel) -> Self {
606 Self::cast(level.increase_indent(self.syntax().clone())).unwrap() 609 Self::cast(level.increase_indent(self.syntax().clone())).unwrap()
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs
index 3009faed7..d20c085aa 100644
--- a/crates/syntax/src/ast/make.rs
+++ b/crates/syntax/src/ast/make.rs
@@ -134,6 +134,9 @@ pub fn expr_prefix(op: SyntaxKind, expr: ast::Expr) -> ast::Expr {
134 let token = token(op); 134 let token = token(op);
135 expr_from_text(&format!("{}{}", token, expr)) 135 expr_from_text(&format!("{}{}", token, expr))
136} 136}
137pub fn expr_call(f: ast::Expr, arg_list: ast::ArgList) -> ast::Expr {
138 expr_from_text(&format!("{}{}", f, arg_list))
139}
137fn expr_from_text(text: &str) -> ast::Expr { 140fn expr_from_text(text: &str) -> ast::Expr {
138 ast_from_text(&format!("const C: () = {};", text)) 141 ast_from_text(&format!("const C: () = {};", text))
139} 142}
@@ -151,6 +154,10 @@ pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition {
151 } 154 }
152} 155}
153 156
157pub fn arg_list(args: impl IntoIterator<Item = ast::Expr>) -> ast::ArgList {
158 ast_from_text(&format!("fn main() {{ ()({}) }}", args.into_iter().format(", ")))
159}
160
154pub fn ident_pat(name: ast::Name) -> ast::IdentPat { 161pub fn ident_pat(name: ast::Name) -> ast::IdentPat {
155 return from_text(name.text()); 162 return from_text(name.text());
156 163