aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api_light/src/structure.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api_light/src/structure.rs')
-rw-r--r--crates/ra_ide_api_light/src/structure.rs24
1 files changed, 20 insertions, 4 deletions
diff --git a/crates/ra_ide_api_light/src/structure.rs b/crates/ra_ide_api_light/src/structure.rs
index 4e080ed03..dc3534498 100644
--- a/crates/ra_ide_api_light/src/structure.rs
+++ b/crates/ra_ide_api_light/src/structure.rs
@@ -2,7 +2,7 @@ use crate::TextRange;
2 2
3use ra_syntax::{ 3use ra_syntax::{
4 algo::visit::{visitor, Visitor}, 4 algo::visit::{visitor, Visitor},
5 ast::{self, NameOwner, TypeParamsOwner}, 5 ast::{self, AttrsOwner, NameOwner, TypeParamsOwner},
6 AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, 6 AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent,
7}; 7};
8 8
@@ -14,6 +14,7 @@ pub struct StructureNode {
14 pub node_range: TextRange, 14 pub node_range: TextRange,
15 pub kind: SyntaxKind, 15 pub kind: SyntaxKind,
16 pub detail: Option<String>, 16 pub detail: Option<String>,
17 pub deprecated: bool,
17} 18}
18 19
19pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> { 20pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
@@ -40,11 +41,11 @@ pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
40} 41}
41 42
42fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { 43fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
43 fn decl<N: NameOwner>(node: &N) -> Option<StructureNode> { 44 fn decl<N: NameOwner + AttrsOwner>(node: &N) -> Option<StructureNode> {
44 decl_with_detail(node, None) 45 decl_with_detail(node, None)
45 } 46 }
46 47
47 fn decl_with_type_ref<N: NameOwner>( 48 fn decl_with_type_ref<N: NameOwner + AttrsOwner>(
48 node: &N, 49 node: &N,
49 type_ref: Option<&ast::TypeRef>, 50 type_ref: Option<&ast::TypeRef>,
50 ) -> Option<StructureNode> { 51 ) -> Option<StructureNode> {
@@ -56,8 +57,12 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
56 decl_with_detail(node, detail) 57 decl_with_detail(node, detail)
57 } 58 }
58 59
59 fn decl_with_detail<N: NameOwner>(node: &N, detail: Option<String>) -> Option<StructureNode> { 60 fn decl_with_detail<N: NameOwner + AttrsOwner>(
61 node: &N,
62 detail: Option<String>,
63 ) -> Option<StructureNode> {
60 let name = node.name()?; 64 let name = node.name()?;
65 dbg!(name.text().to_string());
61 Some(StructureNode { 66 Some(StructureNode {
62 parent: None, 67 parent: None,
63 label: name.text().to_string(), 68 label: name.text().to_string(),
@@ -65,6 +70,10 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
65 node_range: node.syntax().range(), 70 node_range: node.syntax().range(),
66 kind: node.syntax().kind(), 71 kind: node.syntax().kind(),
67 detail, 72 detail,
73 deprecated: node
74 .attrs()
75 .filter_map(|x| x.as_named())
76 .any(|x| x == "deprecated"),
68 }) 77 })
69 } 78 }
70 79
@@ -128,6 +137,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
128 node_range: im.syntax().range(), 137 node_range: im.syntax().range(),
129 kind: im.syntax().kind(), 138 kind: im.syntax().kind(),
130 detail: None, 139 detail: None,
140 deprecated: false,
131 }; 141 };
132 Some(node) 142 Some(node)
133 }) 143 })
@@ -165,6 +175,12 @@ const C: i32 = 92;
165impl E {} 175impl E {}
166 176
167impl fmt::Debug for E {} 177impl fmt::Debug for E {}
178
179#[deprecated]
180fn obsolete() {}
181
182#[deprecated(note = "for awhile")]
183fn very_obsolete() {}
168"#, 184"#,
169 ); 185 );
170 let structure = file_structure(&file); 186 let structure = file_structure(&file);