Skip to content

Commit db15176

Browse files
committed
Fix file_structure() to recognize macro_rules!
where first token != "macro_rules"
1 parent d0b52e5 commit db15176

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

crates/ra_ide/src/display/structure.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,24 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
151151
Some(node)
152152
},
153153
ast::MacroCall(it) => {
154-
let first_token = it.syntax().first_token().unwrap();
155-
if first_token.text().as_str() != "macro_rules" {
156-
return None;
154+
let macro_name = it.syntax()
155+
.children()
156+
.find(|c|
157+
![
158+
SyntaxKind::COMMENT,
159+
SyntaxKind::WHITESPACE,
160+
SyntaxKind::ATTR
161+
].iter()
162+
.any(|&k| k == c.kind())
163+
);
164+
165+
match macro_name {
166+
None => return None,
167+
Some(n) => if n.first_token().unwrap().text().as_str() != "macro_rules" {
168+
return None;
169+
}
157170
}
171+
158172
decl(it)
159173
},
160174
_ => None,

0 commit comments

Comments
 (0)