aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api_light/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-02-06 12:23:26 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-02-06 12:23:26 +0000
commit736a55c97e69f95e6ff4a0c3dafb2018e8ea05f9 (patch)
tree4f82dda9b02ca33d154cefd46ced58596bc2065c /crates/ra_ide_api_light/src
parent569e1e871e737ade80616288241d63e1531dbb8d (diff)
parentd107926f8621dfc08010ffc5bf4a1ac6356c6c87 (diff)
Merge #748
748: Fill deprecation for LSP r=kjeremy a=kjeremy Co-authored-by: kjeremy <[email protected]> Co-authored-by: Jeremy Kolb <[email protected]>
Diffstat (limited to 'crates/ra_ide_api_light/src')
-rw-r--r--crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap70
-rw-r--r--crates/ra_ide_api_light/src/structure.rs24
2 files changed, 73 insertions, 21 deletions
diff --git a/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap b/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap
index 270f75a56..413f4a5ff 100644
--- a/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap
+++ b/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap
@@ -1,8 +1,8 @@
1--- 1---
2created: "2019-01-26T07:11:02.463391362+00:00" 2created: "2019-02-05T22:03:50.763530100Z"
3creator: [email protected] 3creator: [email protected]
4expression: structure
5source: crates/ra_ide_api_light/src/structure.rs 4source: crates/ra_ide_api_light/src/structure.rs
5expression: structure
6--- 6---
7[ 7[
8 StructureNode { 8 StructureNode {
@@ -11,7 +11,8 @@ source: crates/ra_ide_api_light/src/structure.rs
11 navigation_range: [8; 11), 11 navigation_range: [8; 11),
12 node_range: [1; 26), 12 node_range: [1; 26),
13 kind: STRUCT_DEF, 13 kind: STRUCT_DEF,
14 detail: None 14 detail: None,
15 deprecated: false
15 }, 16 },
16 StructureNode { 17 StructureNode {
17 parent: Some( 18 parent: Some(
@@ -23,7 +24,8 @@ source: crates/ra_ide_api_light/src/structure.rs
23 kind: NAMED_FIELD_DEF, 24 kind: NAMED_FIELD_DEF,
24 detail: Some( 25 detail: Some(
25 "i32" 26 "i32"
26 ) 27 ),
28 deprecated: false
27 }, 29 },
28 StructureNode { 30 StructureNode {
29 parent: None, 31 parent: None,
@@ -31,7 +33,8 @@ source: crates/ra_ide_api_light/src/structure.rs
31 navigation_range: [32; 33), 33 navigation_range: [32; 33),
32 node_range: [28; 158), 34 node_range: [28; 158),
33 kind: MODULE, 35 kind: MODULE,
34 detail: None 36 detail: None,
37 deprecated: false
35 }, 38 },
36 StructureNode { 39 StructureNode {
37 parent: Some( 40 parent: Some(
@@ -43,7 +46,8 @@ source: crates/ra_ide_api_light/src/structure.rs
43 kind: FN_DEF, 46 kind: FN_DEF,
44 detail: Some( 47 detail: Some(
45 "fn()" 48 "fn()"
46 ) 49 ),
50 deprecated: false
47 }, 51 },
48 StructureNode { 52 StructureNode {
49 parent: Some( 53 parent: Some(
@@ -55,7 +59,8 @@ source: crates/ra_ide_api_light/src/structure.rs
55 kind: FN_DEF, 59 kind: FN_DEF,
56 detail: Some( 60 detail: Some(
57 "fn<T>(t: T) -> T" 61 "fn<T>(t: T) -> T"
58 ) 62 ),
63 deprecated: false
59 }, 64 },
60 StructureNode { 65 StructureNode {
61 parent: Some( 66 parent: Some(
@@ -67,7 +72,8 @@ source: crates/ra_ide_api_light/src/structure.rs
67 kind: FN_DEF, 72 kind: FN_DEF,
68 detail: Some( 73 detail: Some(
69 "fn<A, B>(a: A, b: B) -> Vec< u32 >" 74 "fn<A, B>(a: A, b: B) -> Vec< u32 >"
70 ) 75 ),
76 deprecated: false
71 }, 77 },
72 StructureNode { 78 StructureNode {
73 parent: None, 79 parent: None,
@@ -75,7 +81,8 @@ source: crates/ra_ide_api_light/src/structure.rs
75 navigation_range: [165; 166), 81 navigation_range: [165; 166),
76 node_range: [160; 180), 82 node_range: [160; 180),
77 kind: ENUM_DEF, 83 kind: ENUM_DEF,
78 detail: None 84 detail: None,
85 deprecated: false
79 }, 86 },
80 StructureNode { 87 StructureNode {
81 parent: Some( 88 parent: Some(
@@ -85,7 +92,8 @@ source: crates/ra_ide_api_light/src/structure.rs
85 navigation_range: [169; 170), 92 navigation_range: [169; 170),
86 node_range: [169; 170), 93 node_range: [169; 170),
87 kind: ENUM_VARIANT, 94 kind: ENUM_VARIANT,
88 detail: None 95 detail: None,
96 deprecated: false
89 }, 97 },
90 StructureNode { 98 StructureNode {
91 parent: Some( 99 parent: Some(
@@ -95,7 +103,8 @@ source: crates/ra_ide_api_light/src/structure.rs
95 navigation_range: [172; 173), 103 navigation_range: [172; 173),
96 node_range: [172; 178), 104 node_range: [172; 178),
97 kind: ENUM_VARIANT, 105 kind: ENUM_VARIANT,
98 detail: None 106 detail: None,
107 deprecated: false
99 }, 108 },
100 StructureNode { 109 StructureNode {
101 parent: None, 110 parent: None,
@@ -105,7 +114,8 @@ source: crates/ra_ide_api_light/src/structure.rs
105 kind: TYPE_DEF, 114 kind: TYPE_DEF,
106 detail: Some( 115 detail: Some(
107 "()" 116 "()"
108 ) 117 ),
118 deprecated: false
109 }, 119 },
110 StructureNode { 120 StructureNode {
111 parent: None, 121 parent: None,
@@ -115,7 +125,8 @@ source: crates/ra_ide_api_light/src/structure.rs
115 kind: STATIC_DEF, 125 kind: STATIC_DEF,
116 detail: Some( 126 detail: Some(
117 "i32" 127 "i32"
118 ) 128 ),
129 deprecated: false
119 }, 130 },
120 StructureNode { 131 StructureNode {
121 parent: None, 132 parent: None,
@@ -125,7 +136,8 @@ source: crates/ra_ide_api_light/src/structure.rs
125 kind: CONST_DEF, 136 kind: CONST_DEF,
126 detail: Some( 137 detail: Some(
127 "i32" 138 "i32"
128 ) 139 ),
140 deprecated: false
129 }, 141 },
130 StructureNode { 142 StructureNode {
131 parent: None, 143 parent: None,
@@ -133,7 +145,8 @@ source: crates/ra_ide_api_light/src/structure.rs
133 navigation_range: [239; 240), 145 navigation_range: [239; 240),
134 node_range: [234; 243), 146 node_range: [234; 243),
135 kind: IMPL_BLOCK, 147 kind: IMPL_BLOCK,
136 detail: None 148 detail: None,
149 deprecated: false
137 }, 150 },
138 StructureNode { 151 StructureNode {
139 parent: None, 152 parent: None,
@@ -141,6 +154,29 @@ source: crates/ra_ide_api_light/src/structure.rs
141 navigation_range: [265; 266), 154 navigation_range: [265; 266),
142 node_range: [245; 269), 155 node_range: [245; 269),
143 kind: IMPL_BLOCK, 156 kind: IMPL_BLOCK,
144 detail: None 157 detail: None,
158 deprecated: false
159 },
160 StructureNode {
161 parent: None,
162 label: "obsolete",
163 navigation_range: [288; 296),
164 node_range: [271; 301),
165 kind: FN_DEF,
166 detail: Some(
167 "fn()"
168 ),
169 deprecated: true
170 },
171 StructureNode {
172 parent: None,
173 label: "very_obsolete",
174 navigation_range: [341; 354),
175 node_range: [303; 359),
176 kind: FN_DEF,
177 detail: Some(
178 "fn()"
179 ),
180 deprecated: true
145 } 181 }
146] 182]
diff --git a/crates/ra_ide_api_light/src/structure.rs b/crates/ra_ide_api_light/src/structure.rs
index 4e080ed03..330a3694c 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
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);