diff options
Diffstat (limited to 'crates/syntax/src/ast')
-rw-r--r-- | crates/syntax/src/ast/generated/nodes.rs | 3 | ||||
-rw-r--r-- | crates/syntax/src/ast/make.rs | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs index 3d49309d1..6317407c6 100644 --- a/crates/syntax/src/ast/generated/nodes.rs +++ b/crates/syntax/src/ast/generated/nodes.rs | |||
@@ -66,6 +66,7 @@ impl ParamList { | |||
66 | pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) } | 66 | pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) } |
67 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } | 67 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } |
68 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 68 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
69 | pub fn pipe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![|]) } | ||
69 | } | 70 | } |
70 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 71 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
71 | pub struct RetType { | 72 | pub struct RetType { |
@@ -809,7 +810,7 @@ pub struct MethodCallExpr { | |||
809 | impl ast::AttrsOwner for MethodCallExpr {} | 810 | impl ast::AttrsOwner for MethodCallExpr {} |
810 | impl ast::ArgListOwner for MethodCallExpr {} | 811 | impl ast::ArgListOwner for MethodCallExpr {} |
811 | impl MethodCallExpr { | 812 | impl MethodCallExpr { |
812 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 813 | pub fn receiver(&self) -> Option<Expr> { support::child(&self.syntax) } |
813 | pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } | 814 | pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } |
814 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 815 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
815 | pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) } | 816 | pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) } |
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index d20c085aa..7958721e2 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs | |||
@@ -7,7 +7,7 @@ | |||
7 | use itertools::Itertools; | 7 | use itertools::Itertools; |
8 | use stdx::format_to; | 8 | use stdx::format_to; |
9 | 9 | ||
10 | use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxToken}; | 10 | use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxText, SyntaxToken}; |
11 | 11 | ||
12 | pub fn name(text: &str) -> ast::Name { | 12 | pub fn name(text: &str) -> ast::Name { |
13 | ast_from_text(&format!("mod {};", text)) | 13 | ast_from_text(&format!("mod {};", text)) |
@@ -137,6 +137,12 @@ pub fn expr_prefix(op: SyntaxKind, expr: ast::Expr) -> ast::Expr { | |||
137 | pub fn expr_call(f: ast::Expr, arg_list: ast::ArgList) -> ast::Expr { | 137 | pub fn expr_call(f: ast::Expr, arg_list: ast::ArgList) -> ast::Expr { |
138 | expr_from_text(&format!("{}{}", f, arg_list)) | 138 | expr_from_text(&format!("{}{}", f, arg_list)) |
139 | } | 139 | } |
140 | pub fn expr_method_call<F>(text: &str, caller: F) -> Option<ast::Expr> | ||
141 | where | ||
142 | F: FnOnce() -> Option<SyntaxText>, | ||
143 | { | ||
144 | try_expr_from_text(&format!("{}.{}()", caller()?, text)) | ||
145 | } | ||
140 | fn expr_from_text(text: &str) -> ast::Expr { | 146 | fn expr_from_text(text: &str) -> ast::Expr { |
141 | ast_from_text(&format!("const C: () = {};", text)) | 147 | ast_from_text(&format!("const C: () = {};", text)) |
142 | } | 148 | } |