diff options
Diffstat (limited to 'crates/ra_lsp_server/src/conv.rs')
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 0b9b18cbf..aad698da1 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use languageserver_types::{ | 1 | use languageserver_types::{ |
2 | self, CreateFile, DocumentChangeOperation, DocumentChanges, InsertTextFormat, Location, | 2 | self, CreateFile, DocumentChangeOperation, DocumentChanges, InsertTextFormat, Location, LocationLink, |
3 | Position, Range, RenameFile, ResourceOp, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, | 3 | Position, Range, RenameFile, ResourceOp, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, |
4 | TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, | 4 | TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, |
5 | WorkspaceEdit, | 5 | WorkspaceEdit, |
@@ -349,13 +349,25 @@ impl TryConvWith for &NavigationTarget { | |||
349 | } | 349 | } |
350 | } | 350 | } |
351 | 351 | ||
352 | impl TryConvWith for &RangeInfo<NavigationTarget> { | 352 | pub fn to_location_link( |
353 | type Ctx = ServerWorld; | 353 | target: &RangeInfo<NavigationTarget>, |
354 | type Output = Location; | 354 | world: &ServerWorld, |
355 | fn try_conv_with(self, world: &ServerWorld) -> Result<Location> { | 355 | // line index for original range file |
356 | let line_index = world.analysis().file_line_index(self.info.file_id()); | 356 | line_index: &LineIndex, |
357 | to_location(self.info.file_id(), self.info.range(), &world, &line_index) | 357 | ) -> Result<LocationLink> { |
358 | } | 358 | let url = target.info.file_id().try_conv_with(world)?; |
359 | let tgt_line_index = world.analysis().file_line_index(target.info.file_id()); | ||
360 | |||
361 | let res = LocationLink { | ||
362 | origin_selection_range: Some(target.range.conv_with(line_index)), | ||
363 | target_uri: url.to_string(), | ||
364 | target_range: target.info.range().conv_with(&tgt_line_index), | ||
365 | target_selection_range: target | ||
366 | .info | ||
367 | .focus_range() | ||
368 | .map(|it| it.conv_with(&tgt_line_index)), | ||
369 | }; | ||
370 | Ok(res) | ||
359 | } | 371 | } |
360 | 372 | ||
361 | pub fn to_location( | 373 | pub fn to_location( |