From 8ae56fa6d0e8a03d6ad75919d6be953f5fc27083 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 13 Aug 2018 16:35:17 +0300 Subject: Stupid goto definition --- crates/libsyntax2/src/ast/generated.rs | 18 ++++++++++++++++++ crates/libsyntax2/src/ast/mod.rs | 8 ++++++++ 2 files changed, 26 insertions(+) (limited to 'crates/libsyntax2/src/ast') 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 AstNode for Name { impl Name {} +// NameRef +#[derive(Debug, Clone, Copy)] +pub struct NameRef> { + syntax: SyntaxNode, +} + +impl AstNode for NameRef { + fn cast(syntax: SyntaxNode) -> Option { + match syntax.kind() { + NAME_REF => Some(NameRef { syntax }), + _ => None, + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} + +impl NameRef {} + // StaticItem #[derive(Debug, Clone, Copy)] pub struct StaticItem> { 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 Name { ident.leaf_text().unwrap() } } + +impl NameRef { + pub fn text(&self) -> SmolStr { + let ident = self.syntax().first_child() + .unwrap(); + ident.leaf_text().unwrap() + } +} -- cgit v1.2.3