aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-13 14:35:17 +0100
committerAleksey Kladov <[email protected]>2018-08-13 14:35:17 +0100
commit8ae56fa6d0e8a03d6ad75919d6be953f5fc27083 (patch)
treed93a4f3e1d279a27cc851546796bb488edfe2c65 /crates/libsyntax2/src
parent7fc91f41d8bd948cef3085d7c0d0ec92d1b2bc53 (diff)
Stupid goto definition
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs18
-rw-r--r--crates/libsyntax2/src/ast/mod.rs8
-rw-r--r--crates/libsyntax2/src/grammar.ron1
3 files changed, 27 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}
diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron
index d4e8c53d3..ee231931e 100644
--- a/crates/libsyntax2/src/grammar.ron
+++ b/crates/libsyntax2/src/grammar.ron
@@ -228,5 +228,6 @@ Grammar(
228 "StaticItem": ( traits: ["NameOwner"] ), 228 "StaticItem": ( traits: ["NameOwner"] ),
229 "TypeItem": ( traits: ["NameOwner"] ), 229 "TypeItem": ( traits: ["NameOwner"] ),
230 "Name": (), 230 "Name": (),
231 "NameRef": (),
231 }, 232 },
232) 233)