aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs33
-rw-r--r--crates/ra_syntax/src/grammar.ron2
2 files changed, 34 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 99fcdbd9a..da8cf4ae8 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -175,6 +175,32 @@ impl Attr {
175 } 175 }
176} 176}
177 177
178// AwaitExpr
179#[derive(Debug, Clone, PartialEq, Eq, Hash)]
180pub struct AwaitExpr {
181 pub(crate) syntax: SyntaxNode,
182}
183
184impl AstNode for AwaitExpr {
185 fn can_cast(kind: SyntaxKind) -> bool {
186 match kind {
187 AWAIT_EXPR => true,
188 _ => false,
189 }
190 }
191 fn cast(syntax: SyntaxNode) -> Option<Self> {
192 if Self::can_cast(syntax.kind()) { Some(AwaitExpr { syntax }) } else { None }
193 }
194 fn syntax(&self) -> &SyntaxNode { &self.syntax }
195}
196
197
198impl AwaitExpr {
199 pub fn expr(&self) -> Option<Expr> {
200 super::child_opt(self)
201 }
202}
203
178// BinExpr 204// BinExpr
179#[derive(Debug, Clone, PartialEq, Eq, Hash)] 205#[derive(Debug, Clone, PartialEq, Eq, Hash)]
180pub struct BinExpr { 206pub struct BinExpr {
@@ -566,7 +592,7 @@ pub struct Expr {
566impl AstNode for Expr { 592impl AstNode for Expr {
567 fn can_cast(kind: SyntaxKind) -> bool { 593 fn can_cast(kind: SyntaxKind) -> bool {
568 match kind { 594 match kind {
569 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | STRUCT_LIT | CALL_EXPR | INDEX_EXPR | METHOD_CALL_EXPR | FIELD_EXPR | TRY_EXPR | TRY_BLOCK_EXPR | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => true, 595 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | STRUCT_LIT | CALL_EXPR | INDEX_EXPR | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => true,
570 _ => false, 596 _ => false,
571 } 597 }
572 } 598 }
@@ -599,6 +625,7 @@ pub enum ExprKind {
599 IndexExpr(IndexExpr), 625 IndexExpr(IndexExpr),
600 MethodCallExpr(MethodCallExpr), 626 MethodCallExpr(MethodCallExpr),
601 FieldExpr(FieldExpr), 627 FieldExpr(FieldExpr),
628 AwaitExpr(AwaitExpr),
602 TryExpr(TryExpr), 629 TryExpr(TryExpr),
603 TryBlockExpr(TryBlockExpr), 630 TryBlockExpr(TryBlockExpr),
604 CastExpr(CastExpr), 631 CastExpr(CastExpr),
@@ -669,6 +696,9 @@ impl From<MethodCallExpr> for Expr {
669impl From<FieldExpr> for Expr { 696impl From<FieldExpr> for Expr {
670 fn from(n: FieldExpr) -> Expr { Expr { syntax: n.syntax } } 697 fn from(n: FieldExpr) -> Expr { Expr { syntax: n.syntax } }
671} 698}
699impl From<AwaitExpr> for Expr {
700 fn from(n: AwaitExpr) -> Expr { Expr { syntax: n.syntax } }
701}
672impl From<TryExpr> for Expr { 702impl From<TryExpr> for Expr {
673 fn from(n: TryExpr) -> Expr { Expr { syntax: n.syntax } } 703 fn from(n: TryExpr) -> Expr { Expr { syntax: n.syntax } }
674} 704}
@@ -719,6 +749,7 @@ impl Expr {
719 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(self.syntax.clone()).unwrap()), 749 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(self.syntax.clone()).unwrap()),
720 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(self.syntax.clone()).unwrap()), 750 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(self.syntax.clone()).unwrap()),
721 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(self.syntax.clone()).unwrap()), 751 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(self.syntax.clone()).unwrap()),
752 AWAIT_EXPR => ExprKind::AwaitExpr(AwaitExpr::cast(self.syntax.clone()).unwrap()),
722 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(self.syntax.clone()).unwrap()), 753 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(self.syntax.clone()).unwrap()),
723 TRY_BLOCK_EXPR => ExprKind::TryBlockExpr(TryBlockExpr::cast(self.syntax.clone()).unwrap()), 754 TRY_BLOCK_EXPR => ExprKind::TryBlockExpr(TryBlockExpr::cast(self.syntax.clone()).unwrap()),
724 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(self.syntax.clone()).unwrap()), 755 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(self.syntax.clone()).unwrap()),
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 55494239e..817dedfbf 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -477,6 +477,7 @@ Grammar(
477 ), 477 ),
478 "IndexExpr": (), 478 "IndexExpr": (),
479 "FieldExpr": (options: ["Expr", "NameRef"]), 479 "FieldExpr": (options: ["Expr", "NameRef"]),
480 "AwaitExpr": (options: ["Expr"]),
480 "TryExpr": (options: ["Expr"]), 481 "TryExpr": (options: ["Expr"]),
481 "CastExpr": (options: ["Expr", "TypeRef"]), 482 "CastExpr": (options: ["Expr", "TypeRef"]),
482 "RefExpr": (options: ["Expr"]), 483 "RefExpr": (options: ["Expr"]),
@@ -508,6 +509,7 @@ Grammar(
508 "IndexExpr", 509 "IndexExpr",
509 "MethodCallExpr", 510 "MethodCallExpr",
510 "FieldExpr", 511 "FieldExpr",
512 "AwaitExpr",
511 "TryExpr", 513 "TryExpr",
512 "TryBlockExpr", 514 "TryBlockExpr",
513 "CastExpr", 515 "CastExpr",