From 78f41ea707cc8aeaa8d1ba8a7216cb8712f13e98 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 11 Aug 2018 10:56:40 +0300 Subject: more renames --- crates/libsyntax2/src/ast/generated.rs | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'crates/libsyntax2/src/ast') diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 12e5a1c3e..c9b587ecb 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -4,6 +4,30 @@ use { SyntaxKind::*, }; +#[derive(Debug, Clone, Copy)] +pub struct Enum> { + syntax: SyntaxNode, +} + +impl AstNode for Enum { + fn cast(syntax: SyntaxNode) -> Option { + match syntax.kind() { + ENUM => Some(Enum { syntax }), + _ => None, + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} + +impl Enum { + pub fn name(&self) -> Option> { + self.syntax() + .children() + .filter_map(Name::cast) + .next() + } +} + #[derive(Debug, Clone, Copy)] pub struct File> { syntax: SyntaxNode, @@ -68,3 +92,27 @@ impl AstNode for Name { impl Name {} +#[derive(Debug, Clone, Copy)] +pub struct Struct> { + syntax: SyntaxNode, +} + +impl AstNode for Struct { + fn cast(syntax: SyntaxNode) -> Option { + match syntax.kind() { + STRUCT => Some(Struct { syntax }), + _ => None, + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} + +impl Struct { + pub fn name(&self) -> Option> { + self.syntax() + .children() + .filter_map(Name::cast) + .next() + } +} + -- cgit v1.2.3