separete structure from symbols

This commit is contained in:
Aleksey Kladov 2018-08-14 11:20:09 +03:00
parent 49ab441024
commit 2b828c68e8
9 changed files with 131 additions and 39 deletions

View file

@ -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>> {

View file

@ -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>;
}

View file

@ -229,6 +229,7 @@ Grammar(
"ConstDef": ( traits: ["NameOwner"] ),
"StaticDef": ( traits: ["NameOwner"] ),
"TypeDef": ( traits: ["NameOwner"] ),
"ImplItem": (),
"Name": (),
"NameRef": (),
},