diff options
Diffstat (limited to 'crates/ra_ide_api/src/display')
-rw-r--r-- | crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap | 191 | ||||
-rw-r--r-- | crates/ra_ide_api/src/display/structure.rs | 188 |
2 files changed, 187 insertions, 192 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 deleted file mode 100644 index 102efc026..000000000 --- a/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap +++ /dev/null | |||
@@ -1,191 +0,0 @@ | |||
1 | --- | ||
2 | created: "2019-06-28T20:46:18.274464142Z" | ||
3 | creator: [email protected] | ||
4 | source: crates/ra_ide_api/src/display/structure.rs | ||
5 | expression: structure | ||
6 | --- | ||
7 | [ | ||
8 | StructureNode { | ||
9 | parent: None, | ||
10 | label: "Foo", | ||
11 | navigation_range: [8; 11), | ||
12 | node_range: [1; 26), | ||
13 | kind: STRUCT_DEF, | ||
14 | detail: None, | ||
15 | deprecated: false, | ||
16 | }, | ||
17 | StructureNode { | ||
18 | parent: Some( | ||
19 | 0, | ||
20 | ), | ||
21 | label: "x", | ||
22 | navigation_range: [18; 19), | ||
23 | node_range: [18; 24), | ||
24 | kind: NAMED_FIELD_DEF, | ||
25 | detail: Some( | ||
26 | "i32", | ||
27 | ), | ||
28 | deprecated: false, | ||
29 | }, | ||
30 | StructureNode { | ||
31 | parent: None, | ||
32 | label: "m", | ||
33 | navigation_range: [32; 33), | ||
34 | node_range: [28; 158), | ||
35 | kind: MODULE, | ||
36 | detail: None, | ||
37 | deprecated: false, | ||
38 | }, | ||
39 | StructureNode { | ||
40 | parent: Some( | ||
41 | 2, | ||
42 | ), | ||
43 | label: "bar1", | ||
44 | navigation_range: [43; 47), | ||
45 | node_range: [40; 52), | ||
46 | kind: FN_DEF, | ||
47 | detail: Some( | ||
48 | "fn()", | ||
49 | ), | ||
50 | deprecated: false, | ||
51 | }, | ||
52 | StructureNode { | ||
53 | parent: Some( | ||
54 | 2, | ||
55 | ), | ||
56 | label: "bar2", | ||
57 | navigation_range: [60; 64), | ||
58 | node_range: [57; 81), | ||
59 | kind: FN_DEF, | ||
60 | detail: Some( | ||
61 | "fn<T>(t: T) -> T", | ||
62 | ), | ||
63 | deprecated: false, | ||
64 | }, | ||
65 | StructureNode { | ||
66 | parent: Some( | ||
67 | 2, | ||
68 | ), | ||
69 | label: "bar3", | ||
70 | navigation_range: [89; 93), | ||
71 | node_range: [86; 156), | ||
72 | kind: FN_DEF, | ||
73 | detail: Some( | ||
74 | "fn<A, B>(a: A, b: B) -> Vec< u32 >", | ||
75 | ), | ||
76 | deprecated: false, | ||
77 | }, | ||
78 | StructureNode { | ||
79 | parent: None, | ||
80 | label: "E", | ||
81 | navigation_range: [165; 166), | ||
82 | node_range: [160; 180), | ||
83 | kind: ENUM_DEF, | ||
84 | detail: None, | ||
85 | deprecated: false, | ||
86 | }, | ||
87 | StructureNode { | ||
88 | parent: Some( | ||
89 | 6, | ||
90 | ), | ||
91 | label: "X", | ||
92 | navigation_range: [169; 170), | ||
93 | node_range: [169; 170), | ||
94 | kind: ENUM_VARIANT, | ||
95 | detail: None, | ||
96 | deprecated: false, | ||
97 | }, | ||
98 | StructureNode { | ||
99 | parent: Some( | ||
100 | 6, | ||
101 | ), | ||
102 | label: "Y", | ||
103 | navigation_range: [172; 173), | ||
104 | node_range: [172; 178), | ||
105 | kind: ENUM_VARIANT, | ||
106 | detail: None, | ||
107 | deprecated: false, | ||
108 | }, | ||
109 | StructureNode { | ||
110 | parent: None, | ||
111 | label: "T", | ||
112 | navigation_range: [186; 187), | ||
113 | node_range: [181; 193), | ||
114 | kind: TYPE_ALIAS_DEF, | ||
115 | detail: Some( | ||
116 | "()", | ||
117 | ), | ||
118 | deprecated: false, | ||
119 | }, | ||
120 | StructureNode { | ||
121 | parent: None, | ||
122 | label: "S", | ||
123 | navigation_range: [201; 202), | ||
124 | node_range: [194; 213), | ||
125 | kind: STATIC_DEF, | ||
126 | detail: Some( | ||
127 | "i32", | ||
128 | ), | ||
129 | deprecated: false, | ||
130 | }, | ||
131 | StructureNode { | ||
132 | parent: None, | ||
133 | label: "C", | ||
134 | navigation_range: [220; 221), | ||
135 | node_range: [214; 232), | ||
136 | kind: CONST_DEF, | ||
137 | detail: Some( | ||
138 | "i32", | ||
139 | ), | ||
140 | deprecated: false, | ||
141 | }, | ||
142 | StructureNode { | ||
143 | parent: None, | ||
144 | label: "impl E", | ||
145 | navigation_range: [239; 240), | ||
146 | node_range: [234; 243), | ||
147 | kind: IMPL_BLOCK, | ||
148 | detail: None, | ||
149 | deprecated: false, | ||
150 | }, | ||
151 | StructureNode { | ||
152 | parent: None, | ||
153 | label: "impl fmt::Debug for E", | ||
154 | navigation_range: [265; 266), | ||
155 | node_range: [245; 269), | ||
156 | kind: IMPL_BLOCK, | ||
157 | detail: None, | ||
158 | deprecated: false, | ||
159 | }, | ||
160 | StructureNode { | ||
161 | parent: None, | ||
162 | label: "mc", | ||
163 | navigation_range: [284; 286), | ||
164 | node_range: [271; 303), | ||
165 | kind: MACRO_CALL, | ||
166 | detail: None, | ||
167 | deprecated: false, | ||
168 | }, | ||
169 | StructureNode { | ||
170 | parent: None, | ||
171 | label: "obsolete", | ||
172 | navigation_range: [322; 330), | ||
173 | node_range: [305; 335), | ||
174 | kind: FN_DEF, | ||
175 | detail: Some( | ||
176 | "fn()", | ||
177 | ), | ||
178 | deprecated: true, | ||
179 | }, | ||
180 | StructureNode { | ||
181 | parent: None, | ||
182 | label: "very_obsolete", | ||
183 | navigation_range: [375; 388), | ||
184 | node_range: [337; 393), | ||
185 | kind: FN_DEF, | ||
186 | detail: Some( | ||
187 | "fn()", | ||
188 | ), | ||
189 | deprecated: true, | ||
190 | }, | ||
191 | ] | ||
diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs index 2ba10b2ef..b026dfa59 100644 --- a/crates/ra_ide_api/src/display/structure.rs +++ b/crates/ra_ide_api/src/display/structure.rs | |||
@@ -204,6 +204,192 @@ fn very_obsolete() {} | |||
204 | .ok() | 204 | .ok() |
205 | .unwrap(); | 205 | .unwrap(); |
206 | let structure = file_structure(&file); | 206 | let structure = file_structure(&file); |
207 | assert_debug_snapshot_matches!("file_structure", structure); | 207 | assert_debug_snapshot_matches!(structure, |
208 | @r#"[ | ||
209 | StructureNode { | ||
210 | parent: None, | ||
211 | label: "Foo", | ||
212 | navigation_range: [8; 11), | ||
213 | node_range: [1; 26), | ||
214 | kind: STRUCT_DEF, | ||
215 | detail: None, | ||
216 | deprecated: false, | ||
217 | }, | ||
218 | StructureNode { | ||
219 | parent: Some( | ||
220 | 0, | ||
221 | ), | ||
222 | label: "x", | ||
223 | navigation_range: [18; 19), | ||
224 | node_range: [18; 24), | ||
225 | kind: NAMED_FIELD_DEF, | ||
226 | detail: Some( | ||
227 | "i32", | ||
228 | ), | ||
229 | deprecated: false, | ||
230 | }, | ||
231 | StructureNode { | ||
232 | parent: None, | ||
233 | label: "m", | ||
234 | navigation_range: [32; 33), | ||
235 | node_range: [28; 158), | ||
236 | kind: MODULE, | ||
237 | detail: None, | ||
238 | deprecated: false, | ||
239 | }, | ||
240 | StructureNode { | ||
241 | parent: Some( | ||
242 | 2, | ||
243 | ), | ||
244 | label: "bar1", | ||
245 | navigation_range: [43; 47), | ||
246 | node_range: [40; 52), | ||
247 | kind: FN_DEF, | ||
248 | detail: Some( | ||
249 | "fn()", | ||
250 | ), | ||
251 | deprecated: false, | ||
252 | }, | ||
253 | StructureNode { | ||
254 | parent: Some( | ||
255 | 2, | ||
256 | ), | ||
257 | label: "bar2", | ||
258 | navigation_range: [60; 64), | ||
259 | node_range: [57; 81), | ||
260 | kind: FN_DEF, | ||
261 | detail: Some( | ||
262 | "fn<T>(t: T) -> T", | ||
263 | ), | ||
264 | deprecated: false, | ||
265 | }, | ||
266 | StructureNode { | ||
267 | parent: Some( | ||
268 | 2, | ||
269 | ), | ||
270 | label: "bar3", | ||
271 | navigation_range: [89; 93), | ||
272 | node_range: [86; 156), | ||
273 | kind: FN_DEF, | ||
274 | detail: Some( | ||
275 | "fn<A, B>(a: A, b: B) -> Vec< u32 >", | ||
276 | ), | ||
277 | deprecated: false, | ||
278 | }, | ||
279 | StructureNode { | ||
280 | parent: None, | ||
281 | label: "E", | ||
282 | navigation_range: [165; 166), | ||
283 | node_range: [160; 180), | ||
284 | kind: ENUM_DEF, | ||
285 | detail: None, | ||
286 | deprecated: false, | ||
287 | }, | ||
288 | StructureNode { | ||
289 | parent: Some( | ||
290 | 6, | ||
291 | ), | ||
292 | label: "X", | ||
293 | navigation_range: [169; 170), | ||
294 | node_range: [169; 170), | ||
295 | kind: ENUM_VARIANT, | ||
296 | detail: None, | ||
297 | deprecated: false, | ||
298 | }, | ||
299 | StructureNode { | ||
300 | parent: Some( | ||
301 | 6, | ||
302 | ), | ||
303 | label: "Y", | ||
304 | navigation_range: [172; 173), | ||
305 | node_range: [172; 178), | ||
306 | kind: ENUM_VARIANT, | ||
307 | detail: None, | ||
308 | deprecated: false, | ||
309 | }, | ||
310 | StructureNode { | ||
311 | parent: None, | ||
312 | label: "T", | ||
313 | navigation_range: [186; 187), | ||
314 | node_range: [181; 193), | ||
315 | kind: TYPE_ALIAS_DEF, | ||
316 | detail: Some( | ||
317 | "()", | ||
318 | ), | ||
319 | deprecated: false, | ||
320 | }, | ||
321 | StructureNode { | ||
322 | parent: None, | ||
323 | label: "S", | ||
324 | navigation_range: [201; 202), | ||
325 | node_range: [194; 213), | ||
326 | kind: STATIC_DEF, | ||
327 | detail: Some( | ||
328 | "i32", | ||
329 | ), | ||
330 | deprecated: false, | ||
331 | }, | ||
332 | StructureNode { | ||
333 | parent: None, | ||
334 | label: "C", | ||
335 | navigation_range: [220; 221), | ||
336 | node_range: [214; 232), | ||
337 | kind: CONST_DEF, | ||
338 | detail: Some( | ||
339 | "i32", | ||
340 | ), | ||
341 | deprecated: false, | ||
342 | }, | ||
343 | StructureNode { | ||
344 | parent: None, | ||
345 | label: "impl E", | ||
346 | navigation_range: [239; 240), | ||
347 | node_range: [234; 243), | ||
348 | kind: IMPL_BLOCK, | ||
349 | detail: None, | ||
350 | deprecated: false, | ||
351 | }, | ||
352 | StructureNode { | ||
353 | parent: None, | ||
354 | label: "impl fmt::Debug for E", | ||
355 | navigation_range: [265; 266), | ||
356 | node_range: [245; 269), | ||
357 | kind: IMPL_BLOCK, | ||
358 | detail: None, | ||
359 | deprecated: false, | ||
360 | }, | ||
361 | StructureNode { | ||
362 | parent: None, | ||
363 | label: "mc", | ||
364 | navigation_range: [284; 286), | ||
365 | node_range: [271; 303), | ||
366 | kind: MACRO_CALL, | ||
367 | detail: None, | ||
368 | deprecated: false, | ||
369 | }, | ||
370 | StructureNode { | ||
371 | parent: None, | ||
372 | label: "obsolete", | ||
373 | navigation_range: [322; 330), | ||
374 | node_range: [305; 335), | ||
375 | kind: FN_DEF, | ||
376 | detail: Some( | ||
377 | "fn()", | ||
378 | ), | ||
379 | deprecated: true, | ||
380 | }, | ||
381 | StructureNode { | ||
382 | parent: None, | ||
383 | label: "very_obsolete", | ||
384 | navigation_range: [375; 388), | ||
385 | node_range: [337; 393), | ||
386 | kind: FN_DEF, | ||
387 | detail: Some( | ||
388 | "fn()", | ||
389 | ), | ||
390 | deprecated: true, | ||
391 | }, | ||
392 | ]"# | ||
393 | ); | ||
208 | } | 394 | } |
209 | } | 395 | } |