From 46c453d0d3249bf83330c2f68fe352bd1dd36b5e Mon Sep 17 00:00:00 2001 From: Ekaterina Babshukova Date: Sat, 29 Jun 2019 00:08:02 +0300 Subject: show macros in file structure --- .../src/display/snapshots/tests__file_structure.snap | 19 ++++++++++++++----- crates/ra_ide_api/src/display/structure.rs | 11 +++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap b/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap index 3097977de..102efc026 100644 --- a/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap +++ b/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap @@ -1,5 +1,5 @@ --- -created: "2019-05-23T22:23:35.168422050Z" +created: "2019-06-28T20:46:18.274464142Z" creator: insta@0.8.1 source: crates/ra_ide_api/src/display/structure.rs expression: structure @@ -157,11 +157,20 @@ expression: structure detail: None, deprecated: false, }, + StructureNode { + parent: None, + label: "mc", + navigation_range: [284; 286), + node_range: [271; 303), + kind: MACRO_CALL, + detail: None, + deprecated: false, + }, StructureNode { parent: None, label: "obsolete", - navigation_range: [288; 296), - node_range: [271; 301), + navigation_range: [322; 330), + node_range: [305; 335), kind: FN_DEF, detail: Some( "fn()", @@ -171,8 +180,8 @@ expression: structure StructureNode { parent: None, label: "very_obsolete", - navigation_range: [341; 354), - node_range: [303; 359), + navigation_range: [375; 388), + node_range: [337; 393), kind: FN_DEF, detail: Some( "fn()", diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs index 24ab7b59c..e5057e833 100644 --- a/crates/ra_ide_api/src/display/structure.rs +++ b/crates/ra_ide_api/src/display/structure.rs @@ -142,6 +142,13 @@ fn structure_node(node: &SyntaxNode) -> Option { }; Some(node) }) + .visit(|mc: &ast::MacroCall| { + let first_token = mc.syntax().first_token().unwrap(); + if first_token.text().as_str() != "macro_rules" { + return None; + } + decl(mc) + }) .accept(node)? } @@ -177,6 +184,10 @@ impl E {} impl fmt::Debug for E {} +macro_rules! mc { + () => {} +} + #[deprecated] fn obsolete() {} -- cgit v1.2.3