aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-07-08 11:39:16 +0100
committerAleksey Kladov <[email protected]>2019-07-08 11:39:16 +0100
commit227bc0b6d478564c45f49cb47dac963d9c37a528 (patch)
tree413a8bdd3690dc27c570b85d0e50c97d860c6bb9 /crates/ra_lsp_server/src/main_loop
parent5ce2b4819ec37faa6b7ac1afe006ae03865ad544 (diff)
add try_conv_with_to_vec
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs27
1 files changed, 8 insertions, 19 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 62c8cbf71..8f07f5027 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -21,7 +21,7 @@ use url_serde::Ser;
21 21
22use crate::{ 22use crate::{
23 cargo_target_spec::{runnable_args, CargoTargetSpec}, 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 req::{self, Decoration}, 25 req::{self, Decoration},
26 world::WorldSnapshot, 26 world::WorldSnapshot,
27 LspError, Result, 27 LspError, Result,
@@ -263,7 +263,6 @@ pub fn handle_goto_definition(
263 params: req::TextDocumentPositionParams, 263 params: req::TextDocumentPositionParams,
264) -> Result<Option<req::GotoDefinitionResponse>> { 264) -> Result<Option<req::GotoDefinitionResponse>> {
265 let position = params.try_conv_with(&world)?; 265 let position = params.try_conv_with(&world)?;
266 let line_index = world.analysis().file_line_index(position.file_id);
267 let nav_info = match world.analysis().goto_definition(position)? { 266 let nav_info = match world.analysis().goto_definition(position)? {
268 None => return Ok(None), 267 None => return Ok(None),
269 Some(it) => it, 268 Some(it) => it,
@@ -272,9 +271,8 @@ pub fn handle_goto_definition(
272 let res = nav_info 271 let res = nav_info
273 .info 272 .info
274 .into_iter() 273 .into_iter()
275 .map(|nav| RangeInfo::new(nav_range, nav)) 274 .map(|nav| (position.file_id, RangeInfo::new(nav_range, nav)))
276 .map(|nav| to_location_link(&nav, &world, &line_index)) 275 .try_conv_with_to_vec(&world)?;
277 .collect::<Result<Vec<_>>>()?;
278 Ok(Some(res.into())) 276 Ok(Some(res.into()))
279} 277}
280 278
@@ -283,7 +281,6 @@ pub fn handle_goto_implementation(
283 params: req::TextDocumentPositionParams, 281 params: req::TextDocumentPositionParams,
284) -> Result<Option<req::GotoImplementationResponse>> { 282) -> Result<Option<req::GotoImplementationResponse>> {
285 let position = params.try_conv_with(&world)?; 283 let position = params.try_conv_with(&world)?;
286 let line_index = world.analysis().file_line_index(position.file_id);
287 let nav_info = match world.analysis().goto_implementation(position)? { 284 let nav_info = match world.analysis().goto_implementation(position)? {
288 None => return Ok(None), 285 None => return Ok(None),
289 Some(it) => it, 286 Some(it) => it,
@@ -292,9 +289,8 @@ pub fn handle_goto_implementation(
292 let res = nav_info 289 let res = nav_info
293 .info 290 .info
294 .into_iter() 291 .into_iter()
295 .map(|nav| RangeInfo::new(nav_range, nav)) 292 .map(|nav| (position.file_id, RangeInfo::new(nav_range, nav)))
296 .map(|nav| to_location_link(&nav, &world, &line_index)) 293 .try_conv_with_to_vec(&world)?;
297 .collect::<Result<Vec<_>>>()?;
298 Ok(Some(res.into())) 294 Ok(Some(res.into()))
299} 295}
300 296
@@ -303,7 +299,6 @@ pub fn handle_goto_type_definition(
303 params: req::TextDocumentPositionParams, 299 params: req::TextDocumentPositionParams,
304) -> Result<Option<req::GotoTypeDefinitionResponse>> { 300) -> Result<Option<req::GotoTypeDefinitionResponse>> {
305 let position = params.try_conv_with(&world)?; 301 let position = params.try_conv_with(&world)?;
306 let line_index = world.analysis().file_line_index(position.file_id);
307 let nav_info = match world.analysis().goto_type_definition(position)? { 302 let nav_info = match world.analysis().goto_type_definition(position)? {
308 None => return Ok(None), 303 None => return Ok(None),
309 Some(it) => it, 304 Some(it) => it,
@@ -312,9 +307,8 @@ pub fn handle_goto_type_definition(
312 let res = nav_info 307 let res = nav_info
313 .info 308 .info
314 .into_iter() 309 .into_iter()
315 .map(|nav| RangeInfo::new(nav_range, nav)) 310 .map(|nav| (position.file_id, RangeInfo::new(nav_range, nav)))
316 .map(|nav| to_location_link(&nav, &world, &line_index)) 311 .try_conv_with_to_vec(&world)?;
317 .collect::<Result<Vec<_>>>()?;
318 Ok(Some(res.into())) 312 Ok(Some(res.into()))
319} 313}
320 314
@@ -323,12 +317,7 @@ pub fn handle_parent_module(
323 params: req::TextDocumentPositionParams, 317 params: req::TextDocumentPositionParams,
324) -> Result<Vec<Location>> { 318) -> Result<Vec<Location>> {
325 let position = params.try_conv_with(&world)?; 319 let position = params.try_conv_with(&world)?;
326 world 320 world.analysis().parent_module(position)?.iter().try_conv_with_to_vec(&world)
327 .analysis()
328 .parent_module(position)?
329 .into_iter()
330 .map(|nav| nav.try_conv_with(&world))
331 .collect::<Result<Vec<_>>>()
332} 321}
333 322
334pub fn handle_runnables( 323pub fn handle_runnables(