@@ -21,7 +21,7 @@ use url_serde::Ser;
2121
2222use crate :: {
2323 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 } ,
2525 req:: { self , Decoration } ,
2626 world:: WorldSnapshot ,
2727 LspError , Result ,
@@ -263,7 +263,6 @@ pub fn handle_goto_definition(
263263 params : req:: TextDocumentPositionParams ,
264264) -> Result < Option < req:: GotoDefinitionResponse > > {
265265 let position = params. try_conv_with ( & world) ?;
266- let line_index = world. analysis ( ) . file_line_index ( position. file_id ) ;
267266 let nav_info = match world. analysis ( ) . goto_definition ( position) ? {
268267 None => return Ok ( None ) ,
269268 Some ( it) => it,
@@ -272,9 +271,8 @@ pub fn handle_goto_definition(
272271 let res = nav_info
273272 . info
274273 . 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) ?;
278276 Ok ( Some ( res. into ( ) ) )
279277}
280278
@@ -283,7 +281,6 @@ pub fn handle_goto_implementation(
283281 params : req:: TextDocumentPositionParams ,
284282) -> Result < Option < req:: GotoImplementationResponse > > {
285283 let position = params. try_conv_with ( & world) ?;
286- let line_index = world. analysis ( ) . file_line_index ( position. file_id ) ;
287284 let nav_info = match world. analysis ( ) . goto_implementation ( position) ? {
288285 None => return Ok ( None ) ,
289286 Some ( it) => it,
@@ -292,9 +289,8 @@ pub fn handle_goto_implementation(
292289 let res = nav_info
293290 . info
294291 . 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) ?;
298294 Ok ( Some ( res. into ( ) ) )
299295}
300296
@@ -303,7 +299,6 @@ pub fn handle_goto_type_definition(
303299 params : req:: TextDocumentPositionParams ,
304300) -> Result < Option < req:: GotoTypeDefinitionResponse > > {
305301 let position = params. try_conv_with ( & world) ?;
306- let line_index = world. analysis ( ) . file_line_index ( position. file_id ) ;
307302 let nav_info = match world. analysis ( ) . goto_type_definition ( position) ? {
308303 None => return Ok ( None ) ,
309304 Some ( it) => it,
@@ -312,9 +307,8 @@ pub fn handle_goto_type_definition(
312307 let res = nav_info
313308 . info
314309 . 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) ?;
318312 Ok ( Some ( res. into ( ) ) )
319313}
320314
@@ -323,12 +317,7 @@ pub fn handle_parent_module(
323317 params : req:: TextDocumentPositionParams ,
324318) -> Result < Vec < Location > > {
325319 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)
332321}
333322
334323pub fn handle_runnables (
0 commit comments