From 182c05a96c25321ac3ff262cea098e0c4d7ed6f8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 13 Mar 2019 16:04:28 +0300 Subject: add name resolution from the old impl unlike the old impl, this also handles macro imports across crates --- crates/ra_syntax/src/ast.rs | 9 +++------ crates/ra_syntax/src/ast/generated.rs | 1 + crates/ra_syntax/src/grammar.ron | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 81c709bfb..d8c2cb063 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -114,6 +114,9 @@ pub trait AttrsOwner: AstNode { fn attrs(&self) -> AstChildren { children(self) } + fn has_atom_attr(&self, atom: &str) -> bool { + self.attrs().filter_map(|x| x.as_atom()).any(|x| x == atom) + } } pub trait DocCommentsOwner: AstNode { @@ -153,12 +156,6 @@ pub trait DocCommentsOwner: AstNode { } } -impl FnDef { - pub fn has_atom_attr(&self, atom: &str) -> bool { - self.attrs().filter_map(|x| x.as_atom()).any(|x| x == atom) - } -} - impl Attr { pub fn is_inner(&self) -> bool { let tt = match self.value() { diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 7572225b8..54b72f8c5 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -2108,6 +2108,7 @@ impl ToOwned for MacroCall { impl ast::NameOwner for MacroCall {} +impl ast::AttrsOwner for MacroCall {} impl MacroCall { pub fn token_tree(&self) -> Option<&TokenTree> { super::child_opt(self) diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 66f1339c1..4f8e19bd0 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -557,7 +557,7 @@ Grammar( "Name": (), "NameRef": (), "MacroCall": ( - traits: [ "NameOwner" ], + traits: [ "NameOwner", "AttrsOwner" ], options: [ "TokenTree", "Path" ], ), "Attr": ( options: [ ["value", "TokenTree"] ] ), -- cgit v1.2.3