mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Pass aliases to ImportData
This commit is contained in:
parent
aa5f6a1ee8
commit
5a7fce4e4c
4 changed files with 47 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -593,7 +593,10 @@ Grammar(
|
|||
options: [ "UseTree" ]
|
||||
),
|
||||
"UseTree": (
|
||||
options: [ "Path", "UseTreeList" ]
|
||||
options: [ "Path", "UseTreeList", "Alias" ]
|
||||
),
|
||||
"Alias": (
|
||||
traits: ["NameOwner"],
|
||||
),
|
||||
"UseTreeList": (
|
||||
collections: [["use_trees", "UseTree"]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue