Skip to content

Commit 1512ab3

Browse files
bors[bot]viorina
andcommitted
Merge #1452
1452: Show macros in file structure r=matklad a=viorina Co-authored-by: Ekaterina Babshukova <[email protected]>
2 parents 5d82984 + 46c453d commit 1512ab3

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
created: "2019-05-23T22:23:35.168422050Z"
2+
created: "2019-06-28T20:46:18.274464142Z"
33
creator: insta@0.8.1
44
source: crates/ra_ide_api/src/display/structure.rs
55
expression: structure
@@ -157,11 +157,20 @@ expression: structure
157157
detail: None,
158158
deprecated: false,
159159
},
160+
StructureNode {
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+
},
160169
StructureNode {
161170
parent: None,
162171
label: "obsolete",
163-
navigation_range: [288; 296),
164-
node_range: [271; 301),
172+
navigation_range: [322; 330),
173+
node_range: [305; 335),
165174
kind: FN_DEF,
166175
detail: Some(
167176
"fn()",
@@ -171,8 +180,8 @@ expression: structure
171180
StructureNode {
172181
parent: None,
173182
label: "very_obsolete",
174-
navigation_range: [341; 354),
175-
node_range: [303; 359),
183+
navigation_range: [375; 388),
184+
node_range: [337; 393),
176185
kind: FN_DEF,
177186
detail: Some(
178187
"fn()",

crates/ra_ide_api/src/display/structure.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
142142
};
143143
Some(node)
144144
})
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+
})
145152
.accept(node)?
146153
}
147154

@@ -177,6 +184,10 @@ impl E {}
177184
178185
impl fmt::Debug for E {}
179186
187+
macro_rules! mc {
188+
() => {}
189+
}
190+
180191
#[deprecated]
181192
fn obsolete() {}
182193

0 commit comments

Comments
 (0)