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)
},
ast::MacroCall(it) => {
let first_token = it.syntax().first_token().unwrap();
if first_token.text().as_str() != "macro_rules" {
return None;
match it.path().and_then(|it| it.segment()).and_then(|it| it.name_ref()) {
Some(path_segment) if path_segment.text() == "macro_rules"
=> decl(it),
_ => None,
}
decl(it)
},
_ => None,
}
@ -198,6 +198,16 @@ macro_rules! mc {
() => {}
}
#[macro_export]
macro_rules! mcexp {
() => {}
}
/// Doc comment
macro_rules! mcexp {
() => {}
}
#[deprecated]
fn obsolete() {}
@ -372,11 +382,29 @@ fn very_obsolete() {}
detail: None,
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 {
parent: None,
label: "obsolete",
navigation_range: [322; 330),
node_range: [305; 335),
navigation_range: [428; 436),
node_range: [411; 441),
kind: FN_DEF,
detail: Some(
"fn()",
@ -386,8 +414,8 @@ fn very_obsolete() {}
StructureNode {
parent: None,
label: "very_obsolete",
navigation_range: [375; 388),
node_range: [337; 393),
navigation_range: [481; 494),
node_range: [443; 499),
kind: FN_DEF,
detail: Some(
"fn()",