From f9a6050034b2ab4358d8a46dd8432de41cebdf0c Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Fri, 18 Jan 2019 14:52:31 +0100 Subject: Move parsing of field pattern lists to the parser (where it belongs) --- crates/ra_syntax/src/ast/generated.rs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (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 ead0f1293..23a573d74 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -858,6 +858,35 @@ impl FieldExpr { } } +// FieldPat +#[derive(Debug, PartialEq, Eq, Hash)] +#[repr(transparent)] +pub struct FieldPat { + pub(crate) syntax: SyntaxNode, +} +unsafe impl TransparentNewType for FieldPat { + type Repr = rowan::SyntaxNode; +} + +impl AstNode for FieldPat { + fn cast(syntax: &SyntaxNode) -> Option<&Self> { + match syntax.kind() { + FIELD_PAT => Some(FieldPat::from_repr(syntax.into_repr())), + _ => None, + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } + fn to_owned(&self) -> TreeArc { TreeArc::cast(self.syntax.to_owned()) } +} + + +impl ast::NameOwner for FieldPat {} +impl FieldPat { + pub fn pat(&self) -> Option<&Pat> { + super::child_opt(self) + } +} + // FieldPatList #[derive(Debug, PartialEq, Eq, Hash)] #[repr(transparent)] @@ -880,7 +909,11 @@ impl AstNode for FieldPatList { } -impl FieldPatList {} +impl FieldPatList { + pub fn pats(&self) -> impl Iterator { + super::children(self) + } +} // FloatNumber #[derive(Debug, PartialEq, Eq, Hash)] -- cgit v1.2.3