Pass aliases to ImportData

This commit is contained in:
Florian Diebold 2019-02-02 00:18:10 +01:00
parent aa5f6a1ee8
commit 5a7fce4e4c
4 changed files with 47 additions and 8 deletions

View file

@ -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<RaTypes>;
}
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<Alias>;
fn to_owned(&self) -> TreeArc<Alias> { 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

View file

@ -593,7 +593,10 @@ Grammar(
options: [ "UseTree" ]
),
"UseTree": (
options: [ "Path", "UseTreeList" ]
options: [ "Path", "UseTreeList", "Alias" ]
),
"Alias": (
traits: ["NameOwner"],
),
"UseTreeList": (
collections: [["use_trees", "UseTree"]]