From 39e444d70145cbf61ddfdd202572d9c6a7f2fd3c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 19 Aug 2019 13:58:49 +0300 Subject: remove ast::*Kind enums With the new owned trees, we don't need an indirection here --- crates/ra_syntax/src/ast/generated.rs | 684 +++++++++++++++++----------------- 1 file changed, 339 insertions(+), 345 deletions(-) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 016668380..9c5789701 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -591,34 +591,7 @@ impl EnumVariantList { } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct Expr { - pub(crate) syntax: SyntaxNode, -} -impl AstNode for Expr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - 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 - } - _ => false, - } - } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { - &self.syntax - } -} -pub enum ExprKind { +pub enum Expr { TupleExpr(TupleExpr), ArrayExpr(ArrayExpr), ParenExpr(ParenExpr), @@ -652,189 +625,235 @@ pub enum ExprKind { } impl From for Expr { fn from(node: TupleExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::TupleExpr(node) } } impl From for Expr { fn from(node: ArrayExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::ArrayExpr(node) } } impl From for Expr { fn from(node: ParenExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::ParenExpr(node) } } impl From for Expr { fn from(node: PathExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::PathExpr(node) } } impl From for Expr { fn from(node: LambdaExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::LambdaExpr(node) } } impl From for Expr { fn from(node: IfExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::IfExpr(node) } } impl From for Expr { fn from(node: LoopExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::LoopExpr(node) } } impl From for Expr { fn from(node: ForExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::ForExpr(node) } } impl From for Expr { fn from(node: WhileExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::WhileExpr(node) } } impl From for Expr { fn from(node: ContinueExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::ContinueExpr(node) } } impl From for Expr { fn from(node: BreakExpr) -> Expr { - Expr { syntax: node.syntax } + Expr::BreakExpr(node) } } impl From