diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-28 22:24:25 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-28 22:24:25 +0100 |
commit | 1512ab31a046b181f8f6b8c18ea1394b28c037ae (patch) | |
tree | 26820b98a67547d3e4091b428645d1b8bc2e718a | |
parent | 5d829841cdab630d7953defd12e024e46ecc7c4f (diff) | |
parent | 46c453d0d3249bf83330c2f68fe352bd1dd36b5e (diff) |
Merge #1452
1452: Show macros in file structure r=matklad a=viorina
Co-authored-by: Ekaterina Babshukova <[email protected]>
-rw-r--r-- | crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap | 19 | ||||
-rw-r--r-- | crates/ra_ide_api/src/display/structure.rs | 11 |
2 files changed, 25 insertions, 5 deletions
diff --git a/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap b/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap index 3097977de..102efc026 100644 --- a/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap +++ b/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap | |||
@@ -1,5 +1,5 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-05-23T22:23:35.168422050Z" | 2 | created: "2019-06-28T20:46:18.274464142Z" |
3 | creator: [email protected] | 3 | creator: [email protected] |
4 | source: crates/ra_ide_api/src/display/structure.rs | 4 | source: crates/ra_ide_api/src/display/structure.rs |
5 | expression: structure | 5 | expression: structure |
@@ -159,9 +159,18 @@ expression: structure | |||
159 | }, | 159 | }, |
160 | StructureNode { | 160 | StructureNode { |
161 | parent: None, | 161 | parent: None, |
162 | label: "mc", | ||
163 | navigation_range: [284; 286), | ||
164 | node_range: [271; 303), | ||
165 | kind: MACRO_CALL, | ||
166 | detail: None, | ||
167 | deprecated: false, | ||
168 | }, | ||
169 | StructureNode { | ||
170 | parent: None, | ||
162 | label: "obsolete", | 171 | label: "obsolete", |
163 | navigation_range: [288; 296), | 172 | navigation_range: [322; 330), |
164 | node_range: [271; 301), | 173 | node_range: [305; 335), |
165 | kind: FN_DEF, | 174 | kind: FN_DEF, |
166 | detail: Some( | 175 | detail: Some( |
167 | "fn()", | 176 | "fn()", |
@@ -171,8 +180,8 @@ expression: structure | |||
171 | StructureNode { | 180 | StructureNode { |
172 | parent: None, | 181 | parent: None, |
173 | label: "very_obsolete", | 182 | label: "very_obsolete", |
174 | navigation_range: [341; 354), | 183 | navigation_range: [375; 388), |
175 | node_range: [303; 359), | 184 | node_range: [337; 393), |
176 | kind: FN_DEF, | 185 | kind: FN_DEF, |
177 | detail: Some( | 186 | detail: Some( |
178 | "fn()", | 187 | "fn()", |
diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs index 24ab7b59c..e5057e833 100644 --- a/crates/ra_ide_api/src/display/structure.rs +++ b/crates/ra_ide_api/src/display/structure.rs | |||
@@ -142,6 +142,13 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
142 | }; | 142 | }; |
143 | Some(node) | 143 | Some(node) |
144 | }) | 144 | }) |
145 | .visit(|mc: &ast::MacroCall| { | ||
146 | let first_token = mc.syntax().first_token().unwrap(); | ||
147 | if first_token.text().as_str() != "macro_rules" { | ||
148 | return None; | ||
149 | } | ||
150 | decl(mc) | ||
151 | }) | ||
145 | .accept(node)? | 152 | .accept(node)? |
146 | } | 153 | } |
147 | 154 | ||
@@ -177,6 +184,10 @@ impl E {} | |||
177 | 184 | ||
178 | impl fmt::Debug for E {} | 185 | impl fmt::Debug for E {} |
179 | 186 | ||
187 | macro_rules! mc { | ||
188 | () => {} | ||
189 | } | ||
190 | |||
180 | #[deprecated] | 191 | #[deprecated] |
181 | fn obsolete() {} | 192 | fn obsolete() {} |
182 | 193 | ||