aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-17 09:59:04 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-17 09:59:04 +0000
commit7d3f48cdaf20d718e711f999573adf3303e9396a (patch)
treedf584fbb044cad23e196da5ae0b3636b06bfeeff /crates/ra_syntax
parent65e763fa84ae70ec9cee13f434acaae5371ad8e5 (diff)
parent3a770233652cbf3e48688dd5f1d9f3c363eda5a8 (diff)
Merge #968
968: Macro aware name resoltion r=matklad a=matklad The first commit lays the ground work for new name resolution, including * extracting position-indendent items from parse trees * walking the tree of modules * old-style macro_rules resolve cc @pnkfelix: this looks like an API name resolution should interact with. Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast.rs9
-rw-r--r--crates/ra_syntax/src/ast/generated.rs1
-rw-r--r--crates/ra_syntax/src/grammar.ron2
3 files changed, 5 insertions, 7 deletions
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 {
114 fn attrs(&self) -> AstChildren<Attr> { 114 fn attrs(&self) -> AstChildren<Attr> {
115 children(self) 115 children(self)
116 } 116 }
117 fn has_atom_attr(&self, atom: &str) -> bool {
118 self.attrs().filter_map(|x| x.as_atom()).any(|x| x == atom)
119 }
117} 120}
118 121
119pub trait DocCommentsOwner: AstNode { 122pub trait DocCommentsOwner: AstNode {
@@ -153,12 +156,6 @@ pub trait DocCommentsOwner: AstNode {
153 } 156 }
154} 157}
155 158
156impl FnDef {
157 pub fn has_atom_attr(&self, atom: &str) -> bool {
158 self.attrs().filter_map(|x| x.as_atom()).any(|x| x == atom)
159 }
160}
161
162impl Attr { 159impl Attr {
163 pub fn is_inner(&self) -> bool { 160 pub fn is_inner(&self) -> bool {
164 let tt = match self.value() { 161 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 {
2108 2108
2109 2109
2110impl ast::NameOwner for MacroCall {} 2110impl ast::NameOwner for MacroCall {}
2111impl ast::AttrsOwner for MacroCall {}
2111impl MacroCall { 2112impl MacroCall {
2112 pub fn token_tree(&self) -> Option<&TokenTree> { 2113 pub fn token_tree(&self) -> Option<&TokenTree> {
2113 super::child_opt(self) 2114 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(
557 "Name": (), 557 "Name": (),
558 "NameRef": (), 558 "NameRef": (),
559 "MacroCall": ( 559 "MacroCall": (
560 traits: [ "NameOwner" ], 560 traits: [ "NameOwner", "AttrsOwner" ],
561 options: [ "TokenTree", "Path" ], 561 options: [ "TokenTree", "Path" ],
562 ), 562 ),
563 "Attr": ( options: [ ["value", "TokenTree"] ] ), 563 "Attr": ( options: [ ["value", "TokenTree"] ] ),