2788: Fix file_structure()  to recognize macro_rules! r=flodiebold a=ruabmbua

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/2774.

Not sure what to do about classifying macro definitions. Maybe make all macro invocations a function invocation?

Co-authored-by: Roland Ruckerbauer <roland.rucky@gmail.com>
This commit is contained in:
bors[bot] 2020-01-12 17:34:47 +00:00 committed by GitHub
commit a05970da46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,11 +151,11 @@ fn collapse_ws(node: &SyntaxNode, output: &mut String) {
Some(node) Some(node)
}, },
ast::MacroCall(it) => { ast::MacroCall(it) => {
let first_token = it.syntax().first_token().unwrap(); match it.path().and_then(|it| it.segment()).and_then(|it| it.name_ref()) {
if first_token.text().as_str() != "macro_rules" { Some(path_segment) if path_segment.text() == "macro_rules"
return None; => decl(it),
_ => None,
} }
decl(it)
}, },
_ => None, _ => None,
} }
@ -198,6 +198,16 @@ macro_rules! mc {
() => {} () => {}
} }
#[macro_export]
macro_rules! mcexp {
() => {}
}
/// Doc comment
macro_rules! mcexp {
() => {}
}
#[deprecated] #[deprecated]
fn obsolete() {} fn obsolete() {}
@ -372,11 +382,29 @@ fn very_obsolete() {}
detail: None, detail: None,
deprecated: false, deprecated: false,
}, },
StructureNode {
parent: None,
label: "mcexp",
navigation_range: [334; 339),
node_range: [305; 356),
kind: MACRO_CALL,
detail: None,
deprecated: false,
},
StructureNode {
parent: None,
label: "mcexp",
navigation_range: [387; 392),
node_range: [358; 409),
kind: MACRO_CALL,
detail: None,
deprecated: false,
},
StructureNode { StructureNode {
parent: None, parent: None,
label: "obsolete", label: "obsolete",
navigation_range: [322; 330), navigation_range: [428; 436),
node_range: [305; 335), node_range: [411; 441),
kind: FN_DEF, kind: FN_DEF,
detail: Some( detail: Some(
"fn()", "fn()",
@ -386,8 +414,8 @@ fn very_obsolete() {}
StructureNode { StructureNode {
parent: None, parent: None,
label: "very_obsolete", label: "very_obsolete",
navigation_range: [375; 388), navigation_range: [481; 494),
node_range: [337; 393), node_range: [443; 499),
kind: FN_DEF, kind: FN_DEF,
detail: Some( detail: Some(
"fn()", "fn()",