diff options
author | Marcus Klaas de Vries <[email protected]> | 2019-01-18 13:52:31 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-19 12:37:26 +0000 |
commit | f9a6050034b2ab4358d8a46dd8432de41cebdf0c (patch) | |
tree | 9de2701b95000fc0a089213bebf8b88924ff61c4 /crates/ra_syntax/src/ast | |
parent | d2769837f1f9c94b977bd6022090f8e5cd02410c (diff) |
Move parsing of field pattern lists to the parser (where it belongs)
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 35 |
1 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 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 { | |||
858 | } | 858 | } |
859 | } | 859 | } |
860 | 860 | ||
861 | // FieldPat | ||
862 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
863 | #[repr(transparent)] | ||
864 | pub struct FieldPat { | ||
865 | pub(crate) syntax: SyntaxNode, | ||
866 | } | ||
867 | unsafe impl TransparentNewType for FieldPat { | ||
868 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
869 | } | ||
870 | |||
871 | impl AstNode for FieldPat { | ||
872 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
873 | match syntax.kind() { | ||
874 | FIELD_PAT => Some(FieldPat::from_repr(syntax.into_repr())), | ||
875 | _ => None, | ||
876 | } | ||
877 | } | ||
878 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
879 | fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) } | ||
880 | } | ||
881 | |||
882 | |||
883 | impl ast::NameOwner for FieldPat {} | ||
884 | impl FieldPat { | ||
885 | pub fn pat(&self) -> Option<&Pat> { | ||
886 | super::child_opt(self) | ||
887 | } | ||
888 | } | ||
889 | |||
861 | // FieldPatList | 890 | // FieldPatList |
862 | #[derive(Debug, PartialEq, Eq, Hash)] | 891 | #[derive(Debug, PartialEq, Eq, Hash)] |
863 | #[repr(transparent)] | 892 | #[repr(transparent)] |
@@ -880,7 +909,11 @@ impl AstNode for FieldPatList { | |||
880 | } | 909 | } |
881 | 910 | ||
882 | 911 | ||
883 | impl FieldPatList {} | 912 | impl FieldPatList { |
913 | pub fn pats(&self) -> impl Iterator<Item = &FieldPat> { | ||
914 | super::children(self) | ||
915 | } | ||
916 | } | ||
884 | 917 | ||
885 | // FloatNumber | 918 | // FloatNumber |
886 | #[derive(Debug, PartialEq, Eq, Hash)] | 919 | #[derive(Debug, PartialEq, Eq, Hash)] |