aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/syntax/src')
-rw-r--r--crates/syntax/src/ast/make.rs7
1 files changed, 7 insertions, 0 deletions
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