diff options
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 13 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 30 |
2 files changed, 20 insertions, 23 deletions
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index fc01b1c0e..d0bdc94aa 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -412,6 +412,19 @@ impl TryConvWith for (FileId, RangeInfo<NavigationTarget>) { | |||
412 | } | 412 | } |
413 | } | 413 | } |
414 | 414 | ||
415 | impl TryConvWith for (FileId, RangeInfo<Vec<NavigationTarget>>) { | ||
416 | type Ctx = WorldSnapshot; | ||
417 | type Output = req::GotoDefinitionResponse; | ||
418 | fn try_conv_with(self, world: &WorldSnapshot) -> Result<req::GotoTypeDefinitionResponse> { | ||
419 | let (file_id, RangeInfo { range, info: navs }) = self; | ||
420 | let links = navs | ||
421 | .into_iter() | ||
422 | .map(|nav| (file_id, RangeInfo::new(range, nav))) | ||
423 | .try_conv_with_to_vec(world)?; | ||
424 | Ok(links.into()) | ||
425 | } | ||
426 | } | ||
427 | |||
415 | pub fn to_location( | 428 | pub fn to_location( |
416 | file_id: FileId, | 429 | file_id: FileId, |
417 | range: TextRange, | 430 | range: TextRange, |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 8f07f5027..ab9ed5080 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -9,8 +9,7 @@ use lsp_types::{ | |||
9 | TextDocumentIdentifier, TextEdit, WorkspaceEdit, | 9 | TextDocumentIdentifier, TextEdit, WorkspaceEdit, |
10 | }; | 10 | }; |
11 | use ra_ide_api::{ | 11 | use ra_ide_api::{ |
12 | AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, | 12 | AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, |
13 | RunnableKind, Severity, | ||
14 | }; | 13 | }; |
15 | use ra_prof::profile; | 14 | use ra_prof::profile; |
16 | use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; | 15 | use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; |
@@ -267,13 +266,8 @@ pub fn handle_goto_definition( | |||
267 | None => return Ok(None), | 266 | None => return Ok(None), |
268 | Some(it) => it, | 267 | Some(it) => it, |
269 | }; | 268 | }; |
270 | let nav_range = nav_info.range; | 269 | let res = (position.file_id, nav_info).try_conv_with(&world)?; |
271 | let res = nav_info | 270 | Ok(Some(res)) |
272 | .info | ||
273 | .into_iter() | ||
274 | .map(|nav| (position.file_id, RangeInfo::new(nav_range, nav))) | ||
275 | .try_conv_with_to_vec(&world)?; | ||
276 | Ok(Some(res.into())) | ||
277 | } | 271 | } |
278 | 272 | ||
279 | pub fn handle_goto_implementation( | 273 | pub fn handle_goto_implementation( |
@@ -285,13 +279,8 @@ pub fn handle_goto_implementation( | |||
285 | None => return Ok(None), | 279 | None => return Ok(None), |
286 | Some(it) => it, | 280 | Some(it) => it, |
287 | }; | 281 | }; |
288 | let nav_range = nav_info.range; | 282 | let res = (position.file_id, nav_info).try_conv_with(&world)?; |
289 | let res = nav_info | 283 | Ok(Some(res)) |
290 | .info | ||
291 | .into_iter() | ||
292 | .map(|nav| (position.file_id, RangeInfo::new(nav_range, nav))) | ||
293 | .try_conv_with_to_vec(&world)?; | ||
294 | Ok(Some(res.into())) | ||
295 | } | 284 | } |
296 | 285 | ||
297 | pub fn handle_goto_type_definition( | 286 | pub fn handle_goto_type_definition( |
@@ -303,13 +292,8 @@ pub fn handle_goto_type_definition( | |||
303 | None => return Ok(None), | 292 | None => return Ok(None), |
304 | Some(it) => it, | 293 | Some(it) => it, |
305 | }; | 294 | }; |
306 | let nav_range = nav_info.range; | 295 | let res = (position.file_id, nav_info).try_conv_with(&world)?; |
307 | let res = nav_info | 296 | Ok(Some(res)) |
308 | .info | ||
309 | .into_iter() | ||
310 | .map(|nav| (position.file_id, RangeInfo::new(nav_range, nav))) | ||
311 | .try_conv_with_to_vec(&world)?; | ||
312 | Ok(Some(res.into())) | ||
313 | } | 297 | } |
314 | 298 | ||
315 | pub fn handle_parent_module( | 299 | pub fn handle_parent_module( |