Stupid goto definition

This commit is contained in:
Aleksey Kladov 2018-08-13 16:35:17 +03:00
parent 7fc91f41d8
commit 8ae56fa6d0
9 changed files with 109 additions and 14 deletions

View file

@ -123,6 +123,24 @@ impl<R: TreeRoot> AstNode<R> for Name<R> {
impl<R: TreeRoot> Name<R> {}
// NameRef
#[derive(Debug, Clone, Copy)]
pub struct NameRef<R: TreeRoot = Arc<SyntaxRoot>> {
syntax: SyntaxNode<R>,
}
impl<R: TreeRoot> AstNode<R> for NameRef<R> {
fn cast(syntax: SyntaxNode<R>) -> Option<Self> {
match syntax.kind() {
NAME_REF => Some(NameRef { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
}
impl<R: TreeRoot> NameRef<R> {}
// StaticItem
#[derive(Debug, Clone, Copy)]
pub struct StaticItem<R: TreeRoot = Arc<SyntaxRoot>> {

View file

@ -73,3 +73,11 @@ impl<R: TreeRoot> Name<R> {
ident.leaf_text().unwrap()
}
}
impl<R: TreeRoot> NameRef<R> {
pub fn text(&self) -> SmolStr {
let ident = self.syntax().first_child()
.unwrap();
ident.leaf_text().unwrap()
}
}

View file

@ -228,5 +228,6 @@ Grammar(
"StaticItem": ( traits: ["NameOwner"] ),
"TypeItem": ( traits: ["NameOwner"] ),
"Name": (),
"NameRef": (),
},
)