mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-21 02:50:21 +00:00
separete structure from symbols
This commit is contained in:
parent
49ab441024
commit
2b828c68e8
9 changed files with 131 additions and 39 deletions
|
@ -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>> {
|
||||
|
|
|
@ -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>;
|
||||
}
|
||||
|
||||
|
|
|
@ -229,6 +229,7 @@ Grammar(
|
|||
"ConstDef": ( traits: ["NameOwner"] ),
|
||||
"StaticDef": ( traits: ["NameOwner"] ),
|
||||
"TypeDef": ( traits: ["NameOwner"] ),
|
||||
"ImplItem": (),
|
||||
"Name": (),
|
||||
"NameRef": (),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue