diff options
Diffstat (limited to 'crates/ra_ide/src/display/structure.rs')
-rw-r--r-- | crates/ra_ide/src/display/structure.rs | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/crates/ra_ide/src/display/structure.rs b/crates/ra_ide/src/display/structure.rs index 8bdb971fe..fdd589648 100644 --- a/crates/ra_ide/src/display/structure.rs +++ b/crates/ra_ide/src/display/structure.rs | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | use crate::TextRange; | 3 | use crate::TextRange; |
4 | 4 | ||
5 | use hir::{name, AsName, Path}; | ||
5 | use ra_syntax::{ | 6 | use ra_syntax::{ |
6 | ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, | 7 | ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, |
7 | match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, | 8 | match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, |
@@ -151,25 +152,12 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
151 | Some(node) | 152 | Some(node) |
152 | }, | 153 | }, |
153 | ast::MacroCall(it) => { | 154 | ast::MacroCall(it) => { |
154 | let macro_name = it.syntax() | 155 | match it.path().and_then(|p| Path::from_ast(p)) { |
155 | .children() | 156 | Some(path) if path.mod_path().segments.as_slice() == [name![macro_rules]] |
156 | .find(|c| | 157 | && it.name().map(|n| n.as_name()).is_some() |
157 | ![ | 158 | => decl(it), |
158 | SyntaxKind::COMMENT, | 159 | _ => None, |
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 | } | ||
170 | } | 160 | } |
171 | |||
172 | decl(it) | ||
173 | }, | 161 | }, |
174 | _ => None, | 162 | _ => None, |
175 | } | 163 | } |
@@ -217,6 +205,11 @@ macro_rules! mcexp { | |||
217 | () => {} | 205 | () => {} |
218 | } | 206 | } |
219 | 207 | ||
208 | /// Doc comment | ||
209 | macro_rules! mcexp { | ||
210 | () => {} | ||
211 | } | ||
212 | |||
220 | #[deprecated] | 213 | #[deprecated] |
221 | fn obsolete() {} | 214 | fn obsolete() {} |
222 | 215 | ||
@@ -402,9 +395,18 @@ fn very_obsolete() {} | |||
402 | }, | 395 | }, |
403 | StructureNode { | 396 | StructureNode { |
404 | parent: None, | 397 | parent: None, |
398 | label: "mcexp", | ||
399 | navigation_range: [387; 392), | ||
400 | node_range: [358; 409), | ||
401 | kind: MACRO_CALL, | ||
402 | detail: None, | ||
403 | deprecated: false, | ||
404 | }, | ||
405 | StructureNode { | ||
406 | parent: None, | ||
405 | label: "obsolete", | 407 | label: "obsolete", |
406 | navigation_range: [375; 383), | 408 | navigation_range: [428; 436), |
407 | node_range: [358; 388), | 409 | node_range: [411; 441), |
408 | kind: FN_DEF, | 410 | kind: FN_DEF, |
409 | detail: Some( | 411 | detail: Some( |
410 | "fn()", | 412 | "fn()", |
@@ -414,8 +416,8 @@ fn very_obsolete() {} | |||
414 | StructureNode { | 416 | StructureNode { |
415 | parent: None, | 417 | parent: None, |
416 | label: "very_obsolete", | 418 | label: "very_obsolete", |
417 | navigation_range: [428; 441), | 419 | navigation_range: [481; 494), |
418 | node_range: [390; 446), | 420 | node_range: [443; 499), |
419 | kind: FN_DEF, | 421 | kind: FN_DEF, |
420 | detail: Some( | 422 | detail: Some( |
421 | "fn()", | 423 | "fn()", |