mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Stupid goto definition
This commit is contained in:
parent
7fc91f41d8
commit
8ae56fa6d0
9 changed files with 109 additions and 14 deletions
|
@ -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>> {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,5 +228,6 @@ Grammar(
|
|||
"StaticItem": ( traits: ["NameOwner"] ),
|
||||
"TypeItem": ( traits: ["NameOwner"] ),
|
||||
"Name": (),
|
||||
"NameRef": (),
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue