From 2b828c68e8acda628d6e3a36827d1ffd9c9aaec6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov <aleksey.kladov@gmail.com> Date: Tue, 14 Aug 2018 11:20:09 +0300 Subject: separete structure from symbols --- crates/libsyntax2/src/ast/generated.rs | 18 ++++++++++++++++++ crates/libsyntax2/src/ast/mod.rs | 5 +++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'crates/libsyntax2/src/ast') diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index b347a05b4..13668b803 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -86,6 +86,24 @@ impl<R: TreeRoot> AstNode<R> for FnDef<R> { impl<R: TreeRoot> ast::NameOwner<R> for FnDef<R> {} impl<R: TreeRoot> FnDef<R> {} +// ImplItem +#[derive(Debug, Clone, Copy)] +pub struct ImplItem<R: TreeRoot = Arc<SyntaxRoot>> { + syntax: SyntaxNode<R>, +} + +impl<R: TreeRoot> AstNode<R> for ImplItem<R> { + fn cast(syntax: SyntaxNode<R>) -> Option<Self> { + match syntax.kind() { + IMPL_ITEM => Some(ImplItem { syntax }), + _ => None, + } + } + fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } +} + +impl<R: TreeRoot> ImplItem<R> {} + // Module #[derive(Debug, Clone, Copy)] pub struct Module<R: TreeRoot = Arc<SyntaxRoot>> { diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs index 18a9f5d17..f001d340e 100644 --- a/crates/libsyntax2/src/ast/mod.rs +++ b/crates/libsyntax2/src/ast/mod.rs @@ -10,8 +10,9 @@ use { }; pub use self::generated::*; -pub trait AstNode<R: TreeRoot>: Sized { - fn cast(syntax: SyntaxNode<R>) -> Option<Self>; +pub trait AstNode<R: TreeRoot> { + fn cast(syntax: SyntaxNode<R>) -> Option<Self> + where Self: Sized; fn syntax(&self) -> &SyntaxNode<R>; } -- cgit v1.2.3