From 5a7fce4e4cd8846a49ce007910f72340007d9c8c Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 2 Feb 2019 00:18:10 +0100 Subject: Pass aliases to ImportData --- crates/ra_syntax/src/ast/generated.rs | 33 +++++++++++++++++++++++++++++++++ crates/ra_syntax/src/grammar.ron | 5 ++++- 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index d0561c495..60480c699 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -17,6 +17,35 @@ use crate::{ ast::{self, AstNode}, }; +// Alias +#[derive(Debug, PartialEq, Eq, Hash)] +#[repr(transparent)] +pub struct Alias { + pub(crate) syntax: SyntaxNode, +} +unsafe impl TransparentNewType for Alias { + type Repr = rowan::SyntaxNode; +} + +impl AstNode for Alias { + fn cast(syntax: &SyntaxNode) -> Option<&Self> { + match syntax.kind() { + ALIAS => Some(Alias::from_repr(syntax.into_repr())), + _ => None, + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} + +impl ToOwned for Alias { + type Owned = TreeArc; + fn to_owned(&self) -> TreeArc { TreeArc::cast(self.syntax.to_owned()) } +} + + +impl ast::NameOwner for Alias {} +impl Alias {} + // ArgList #[derive(Debug, PartialEq, Eq, Hash)] #[repr(transparent)] @@ -4176,6 +4205,10 @@ impl UseTree { pub fn use_tree_list(&self) -> Option<&UseTreeList> { super::child_opt(self) } + + pub fn alias(&self) -> Option<&Alias> { + super::child_opt(self) + } } // UseTreeList diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 47334bdf0..a2ccd7cb9 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -593,7 +593,10 @@ Grammar( options: [ "UseTree" ] ), "UseTree": ( - options: [ "Path", "UseTreeList" ] + options: [ "Path", "UseTreeList", "Alias" ] + ), + "Alias": ( + traits: ["NameOwner"], ), "UseTreeList": ( collections: [["use_trees", "UseTree"]] -- cgit v1.2.3