aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-01-12 17:34:47 +0000
committerGitHub <[email protected]>2020-01-12 17:34:47 +0000
commita05970da4671bd78457635deefa5ed8a2d24b00c (patch)
tree621b44a5a65722c2563ee87a0b1f1fbd1245745a
parentd0b52e5d84b8c371b74d4d5d43f45be91f103d12 (diff)
parent20b8d283ae7d18faaa8aec86e029a573e755a1dd (diff)
Merge #2788
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 <[email protected]>
-rw-r--r--crates/ra_ide/src/display/structure.rs44
1 files changed, 36 insertions, 8 deletions
diff --git a/crates/ra_ide/src/display/structure.rs b/crates/ra_ide/src/display/structure.rs
index a80d65ac7..944cc79df 100644
--- a/crates/ra_ide/src/display/structure.rs
+++ b/crates/ra_ide/src/display/structure.rs
@@ -151,11 +151,11 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
151 Some(node) 151 Some(node)
152 }, 152 },
153 ast::MacroCall(it) => { 153 ast::MacroCall(it) => {
154 let first_token = it.syntax().first_token().unwrap(); 154 match it.path().and_then(|it| it.segment()).and_then(|it| it.name_ref()) {
155 if first_token.text().as_str() != "macro_rules" { 155 Some(path_segment) if path_segment.text() == "macro_rules"
156 return None; 156 => decl(it),
157 _ => None,
157 } 158 }
158 decl(it)
159 }, 159 },
160 _ => None, 160 _ => None,
161 } 161 }
@@ -198,6 +198,16 @@ macro_rules! mc {
198 () => {} 198 () => {}
199} 199}
200 200
201#[macro_export]
202macro_rules! mcexp {
203 () => {}
204}
205
206/// Doc comment
207macro_rules! mcexp {
208 () => {}
209}
210
201#[deprecated] 211#[deprecated]
202fn obsolete() {} 212fn obsolete() {}
203 213
@@ -374,9 +384,27 @@ fn very_obsolete() {}
374 }, 384 },
375 StructureNode { 385 StructureNode {
376 parent: None, 386 parent: None,
387 label: "mcexp",
388 navigation_range: [334; 339),
389 node_range: [305; 356),
390 kind: MACRO_CALL,
391 detail: None,
392 deprecated: false,
393 },
394 StructureNode {
395 parent: None,
396 label: "mcexp",
397 navigation_range: [387; 392),
398 node_range: [358; 409),
399 kind: MACRO_CALL,
400 detail: None,
401 deprecated: false,
402 },
403 StructureNode {
404 parent: None,
377 label: "obsolete", 405 label: "obsolete",
378 navigation_range: [322; 330), 406 navigation_range: [428; 436),
379 node_range: [305; 335), 407 node_range: [411; 441),
380 kind: FN_DEF, 408 kind: FN_DEF,
381 detail: Some( 409 detail: Some(
382 "fn()", 410 "fn()",
@@ -386,8 +414,8 @@ fn very_obsolete() {}
386 StructureNode { 414 StructureNode {
387 parent: None, 415 parent: None,
388 label: "very_obsolete", 416 label: "very_obsolete",
389 navigation_range: [375; 388), 417 navigation_range: [481; 494),
390 node_range: [337; 393), 418 node_range: [443; 499),
391 kind: FN_DEF, 419 kind: FN_DEF,
392 detail: Some( 420 detail: Some(
393 "fn()", 421 "fn()",