aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/ast/generated.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/ast/generated.rs')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs66
1 files changed, 60 insertions, 6 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs
index 1dd161f52..6891e857c 100644
--- a/crates/libsyntax2/src/ast/generated.rs
+++ b/crates/libsyntax2/src/ast/generated.rs
@@ -141,7 +141,11 @@ impl<'a> AstNode<'a> for BlockExpr<'a> {
141 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 141 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
142} 142}
143 143
144impl<'a> BlockExpr<'a> {} 144impl<'a> BlockExpr<'a> {
145 pub fn block(self) -> Option<Block<'a>> {
146 super::child_opt(self)
147 }
148}
145 149
146// BreakExpr 150// BreakExpr
147#[derive(Debug, Clone, Copy)] 151#[derive(Debug, Clone, Copy)]
@@ -197,6 +201,32 @@ impl<'a> AstNode<'a> for CastExpr<'a> {
197 201
198impl<'a> CastExpr<'a> {} 202impl<'a> CastExpr<'a> {}
199 203
204// Condition
205#[derive(Debug, Clone, Copy)]
206pub struct Condition<'a> {
207 syntax: SyntaxNodeRef<'a>,
208}
209
210impl<'a> AstNode<'a> for Condition<'a> {
211 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
212 match syntax.kind() {
213 CONDITION => Some(Condition { syntax }),
214 _ => None,
215 }
216 }
217 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
218}
219
220impl<'a> Condition<'a> {
221 pub fn pat(self) -> Option<Pat<'a>> {
222 super::child_opt(self)
223 }
224
225 pub fn expr(self) -> Option<Expr<'a>> {
226 super::child_opt(self)
227 }
228}
229
200// ConstDef 230// ConstDef
201#[derive(Debug, Clone, Copy)] 231#[derive(Debug, Clone, Copy)]
202pub struct ConstDef<'a> { 232pub struct ConstDef<'a> {
@@ -403,7 +433,11 @@ impl<'a> AstNode<'a> for ExprStmt<'a> {
403 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 433 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
404} 434}
405 435
406impl<'a> ExprStmt<'a> {} 436impl<'a> ExprStmt<'a> {
437 pub fn expr(self) -> Option<Expr<'a>> {
438 super::child_opt(self)
439 }
440}
407 441
408// FieldExpr 442// FieldExpr
409#[derive(Debug, Clone, Copy)] 443#[derive(Debug, Clone, Copy)]
@@ -504,7 +538,11 @@ impl<'a> AstNode<'a> for ForExpr<'a> {
504 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 538 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
505} 539}
506 540
507impl<'a> ForExpr<'a> {} 541impl<'a> ForExpr<'a> {
542 pub fn body(self) -> Option<Block<'a>> {
543 super::child_opt(self)
544 }
545}
508 546
509// ForType 547// ForType
510#[derive(Debug, Clone, Copy)] 548#[derive(Debug, Clone, Copy)]
@@ -540,7 +578,11 @@ impl<'a> AstNode<'a> for IfExpr<'a> {
540 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 578 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
541} 579}
542 580
543impl<'a> IfExpr<'a> {} 581impl<'a> IfExpr<'a> {
582 pub fn condition(self) -> Option<Condition<'a>> {
583 super::child_opt(self)
584 }
585}
544 586
545// ImplItem 587// ImplItem
546#[derive(Debug, Clone, Copy)] 588#[derive(Debug, Clone, Copy)]
@@ -674,7 +716,11 @@ impl<'a> AstNode<'a> for LoopExpr<'a> {
674 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 716 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
675} 717}
676 718
677impl<'a> LoopExpr<'a> {} 719impl<'a> LoopExpr<'a> {
720 pub fn body(self) -> Option<Block<'a>> {
721 super::child_opt(self)
722 }
723}
678 724
679// MatchArm 725// MatchArm
680#[derive(Debug, Clone, Copy)] 726#[derive(Debug, Clone, Copy)]
@@ -1742,5 +1788,13 @@ impl<'a> AstNode<'a> for WhileExpr<'a> {
1742 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1788 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1743} 1789}
1744 1790
1745impl<'a> WhileExpr<'a> {} 1791impl<'a> WhileExpr<'a> {
1792 pub fn condition(self) -> Option<Condition<'a>> {
1793 super::child_opt(self)
1794 }
1795
1796 pub fn body(self) -> Option<Block<'a>> {
1797 super::child_opt(self)
1798 }
1799}
1746 1800