From e6f3790106fdfa2aaf6a0510c737fd05939345e7 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Fri, 23 Aug 2019 13:04:58 -0700 Subject: Add `BoxPat` variant --- crates/ra_syntax/src/ast/generated.rs | 39 +++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'crates/ra_syntax/src/ast/generated.rs') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 07cc3e0db..90480b6ca 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -307,6 +307,33 @@ impl BlockExpr { } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct BoxPat { + pub(crate) syntax: SyntaxNode, +} +impl AstNode for BoxPat { + fn can_cast(kind: SyntaxKind) -> bool { + match kind { + BOX_PAT => true, + _ => false, + } + } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} +impl BoxPat { + pub fn pat(&self) -> Option { + AstChildren::new(&self.syntax).next() + } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct BreakExpr { pub(crate) syntax: SyntaxNode, } @@ -2063,6 +2090,7 @@ impl ParenType { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Pat { RefPat(RefPat), + BoxPat(BoxPat), BindPat(BindPat), PlaceholderPat(PlaceholderPat), PathPat(PathPat), @@ -2078,6 +2106,11 @@ impl From for Pat { Pat::RefPat(node) } } +impl From for Pat { + fn from(node: BoxPat) -> Pat { + Pat::BoxPat(node) + } +} impl From for Pat { fn from(node: BindPat) -> Pat { Pat::BindPat(node) @@ -2126,14 +2159,15 @@ impl From for Pat { impl AstNode for Pat { fn can_cast(kind: SyntaxKind) -> bool { match kind { - REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT - | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true, + REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | RECORD_PAT + | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { REF_PAT => Pat::RefPat(RefPat { syntax }), + BOX_PAT => Pat::BoxPat(BoxPat { syntax }), BIND_PAT => Pat::BindPat(BindPat { syntax }), PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), PATH_PAT => Pat::PathPat(PathPat { syntax }), @@ -2150,6 +2184,7 @@ impl AstNode for Pat { fn syntax(&self) -> &SyntaxNode { match self { Pat::RefPat(it) => &it.syntax, + Pat::BoxPat(it) => &it.syntax, Pat::BindPat(it) => &it.syntax, Pat::PlaceholderPat(it) => &it.syntax, Pat::PathPat(it) => &it.syntax, -- cgit v1.2.3