@@ -21,7 +21,7 @@ use url_serde::Ser;
21
21
22
22
use crate :: {
23
23
cargo_target_spec:: { runnable_args, CargoTargetSpec } ,
24
- conv:: { to_location, to_location_link , Conv , ConvWith , MapConvWith , TryConvWith } ,
24
+ conv:: { to_location, Conv , ConvWith , MapConvWith , TryConvWith , TryConvWithToVec } ,
25
25
req:: { self , Decoration } ,
26
26
world:: WorldSnapshot ,
27
27
LspError , Result ,
@@ -263,7 +263,6 @@ pub fn handle_goto_definition(
263
263
params : req:: TextDocumentPositionParams ,
264
264
) -> Result < Option < req:: GotoDefinitionResponse > > {
265
265
let position = params. try_conv_with ( & world) ?;
266
- let line_index = world. analysis ( ) . file_line_index ( position. file_id ) ;
267
266
let nav_info = match world. analysis ( ) . goto_definition ( position) ? {
268
267
None => return Ok ( None ) ,
269
268
Some ( it) => it,
@@ -272,9 +271,8 @@ pub fn handle_goto_definition(
272
271
let res = nav_info
273
272
. info
274
273
. into_iter ( )
275
- . map ( |nav| RangeInfo :: new ( nav_range, nav) )
276
- . map ( |nav| to_location_link ( & nav, & world, & line_index) )
277
- . collect :: < Result < Vec < _ > > > ( ) ?;
274
+ . map ( |nav| ( position. file_id , RangeInfo :: new ( nav_range, nav) ) )
275
+ . try_conv_with_to_vec ( & world) ?;
278
276
Ok ( Some ( res. into ( ) ) )
279
277
}
280
278
@@ -283,7 +281,6 @@ pub fn handle_goto_implementation(
283
281
params : req:: TextDocumentPositionParams ,
284
282
) -> Result < Option < req:: GotoImplementationResponse > > {
285
283
let position = params. try_conv_with ( & world) ?;
286
- let line_index = world. analysis ( ) . file_line_index ( position. file_id ) ;
287
284
let nav_info = match world. analysis ( ) . goto_implementation ( position) ? {
288
285
None => return Ok ( None ) ,
289
286
Some ( it) => it,
@@ -292,9 +289,8 @@ pub fn handle_goto_implementation(
292
289
let res = nav_info
293
290
. info
294
291
. into_iter ( )
295
- . map ( |nav| RangeInfo :: new ( nav_range, nav) )
296
- . map ( |nav| to_location_link ( & nav, & world, & line_index) )
297
- . collect :: < Result < Vec < _ > > > ( ) ?;
292
+ . map ( |nav| ( position. file_id , RangeInfo :: new ( nav_range, nav) ) )
293
+ . try_conv_with_to_vec ( & world) ?;
298
294
Ok ( Some ( res. into ( ) ) )
299
295
}
300
296
@@ -303,7 +299,6 @@ pub fn handle_goto_type_definition(
303
299
params : req:: TextDocumentPositionParams ,
304
300
) -> Result < Option < req:: GotoTypeDefinitionResponse > > {
305
301
let position = params. try_conv_with ( & world) ?;
306
- let line_index = world. analysis ( ) . file_line_index ( position. file_id ) ;
307
302
let nav_info = match world. analysis ( ) . goto_type_definition ( position) ? {
308
303
None => return Ok ( None ) ,
309
304
Some ( it) => it,
@@ -312,9 +307,8 @@ pub fn handle_goto_type_definition(
312
307
let res = nav_info
313
308
. info
314
309
. into_iter ( )
315
- . map ( |nav| RangeInfo :: new ( nav_range, nav) )
316
- . map ( |nav| to_location_link ( & nav, & world, & line_index) )
317
- . collect :: < Result < Vec < _ > > > ( ) ?;
310
+ . map ( |nav| ( position. file_id , RangeInfo :: new ( nav_range, nav) ) )
311
+ . try_conv_with_to_vec ( & world) ?;
318
312
Ok ( Some ( res. into ( ) ) )
319
313
}
320
314
@@ -323,12 +317,7 @@ pub fn handle_parent_module(
323
317
params : req:: TextDocumentPositionParams ,
324
318
) -> Result < Vec < Location > > {
325
319
let position = params. try_conv_with ( & world) ?;
326
- world
327
- . analysis ( )
328
- . parent_module ( position) ?
329
- . into_iter ( )
330
- . map ( |nav| nav. try_conv_with ( & world) )
331
- . collect :: < Result < Vec < _ > > > ( )
320
+ world. analysis ( ) . parent_module ( position) ?. iter ( ) . try_conv_with_to_vec ( & world)
332
321
}
333
322
334
323
pub fn handle_runnables (
0 commit comments