aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/ast')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs18
-rw-r--r--crates/libsyntax2/src/ast/mod.rs8
2 files changed, 26 insertions, 0 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs
index 31f5ecc44..b1fd0a8ad 100644
--- a/crates/libsyntax2/src/ast/generated.rs
+++ b/crates/libsyntax2/src/ast/generated.rs
@@ -123,6 +123,24 @@ impl<R: TreeRoot> AstNode<R> for Name<R> {
123 123
124impl<R: TreeRoot> Name<R> {} 124impl<R: TreeRoot> Name<R> {}
125 125
126// NameRef
127#[derive(Debug, Clone, Copy)]
128pub struct NameRef<R: TreeRoot = Arc<SyntaxRoot>> {
129 syntax: SyntaxNode<R>,
130}
131
132impl<R: TreeRoot> AstNode<R> for NameRef<R> {
133 fn cast(syntax: SyntaxNode<R>) -> Option<Self> {
134 match syntax.kind() {
135 NAME_REF => Some(NameRef { syntax }),
136 _ => None,
137 }
138 }
139 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
140}
141
142impl<R: TreeRoot> NameRef<R> {}
143
126// StaticItem 144// StaticItem
127#[derive(Debug, Clone, Copy)] 145#[derive(Debug, Clone, Copy)]
128pub struct StaticItem<R: TreeRoot = Arc<SyntaxRoot>> { 146pub struct StaticItem<R: TreeRoot = Arc<SyntaxRoot>> {
diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs
index e9362d048..2e1fb2d1c 100644
--- a/crates/libsyntax2/src/ast/mod.rs
+++ b/crates/libsyntax2/src/ast/mod.rs
@@ -73,3 +73,11 @@ impl<R: TreeRoot> Name<R> {
73 ident.leaf_text().unwrap() 73 ident.leaf_text().unwrap()
74 } 74 }
75} 75}
76
77impl<R: TreeRoot> NameRef<R> {
78 pub fn text(&self) -> SmolStr {
79 let ident = self.syntax().first_child()
80 .unwrap();
81 ident.leaf_text().unwrap()
82 }
83}