diff options
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 11 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 9 |
2 files changed, 16 insertions, 4 deletions
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 35c679a4a..0b9b18cbf 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -6,7 +6,7 @@ use languageserver_types::{ | |||
6 | }; | 6 | }; |
7 | use ra_ide_api::{ | 7 | use ra_ide_api::{ |
8 | CompletionItem, CompletionItemKind, FileId, FilePosition, FileRange, FileSystemEdit, | 8 | CompletionItem, CompletionItemKind, FileId, FilePosition, FileRange, FileSystemEdit, |
9 | InsertText, NavigationTarget, SourceChange, SourceFileEdit, | 9 | InsertText, NavigationTarget, SourceChange, SourceFileEdit, RangeInfo, |
10 | LineCol, LineIndex, translate_offset_with_edit | 10 | LineCol, LineIndex, translate_offset_with_edit |
11 | }; | 11 | }; |
12 | use ra_syntax::{SyntaxKind, TextRange, TextUnit}; | 12 | use ra_syntax::{SyntaxKind, TextRange, TextUnit}; |
@@ -349,6 +349,15 @@ impl TryConvWith for &NavigationTarget { | |||
349 | } | 349 | } |
350 | } | 350 | } |
351 | 351 | ||
352 | impl TryConvWith for &RangeInfo<NavigationTarget> { | ||
353 | type Ctx = ServerWorld; | ||
354 | type Output = Location; | ||
355 | fn try_conv_with(self, world: &ServerWorld) -> Result<Location> { | ||
356 | let line_index = world.analysis().file_line_index(self.info.file_id()); | ||
357 | to_location(self.info.file_id(), self.info.range(), &world, &line_index) | ||
358 | } | ||
359 | } | ||
360 | |||
352 | pub fn to_location( | 361 | pub fn to_location( |
353 | file_id: FileId, | 362 | file_id: FileId, |
354 | range: TextRange, | 363 | 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 5f4b27149..e3bf55ae7 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -9,7 +9,7 @@ use languageserver_types::{ | |||
9 | SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit, | 9 | SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit, |
10 | }; | 10 | }; |
11 | use ra_ide_api::{ | 11 | use ra_ide_api::{ |
12 | FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, | 12 | FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, SourceChange, RangeInfo, |
13 | }; | 13 | }; |
14 | use ra_syntax::{TextUnit, AstNode}; | 14 | use ra_syntax::{TextUnit, AstNode}; |
15 | use rustc_hash::FxHashMap; | 15 | use rustc_hash::FxHashMap; |
@@ -208,12 +208,15 @@ pub fn handle_goto_definition( | |||
208 | params: req::TextDocumentPositionParams, | 208 | params: req::TextDocumentPositionParams, |
209 | ) -> Result<Option<req::GotoDefinitionResponse>> { | 209 | ) -> Result<Option<req::GotoDefinitionResponse>> { |
210 | let position = params.try_conv_with(&world)?; | 210 | let position = params.try_conv_with(&world)?; |
211 | let navs = match world.analysis().goto_definition(position)? { | 211 | let nav_info = match world.analysis().goto_definition(position)? { |
212 | None => return Ok(None), | 212 | None => return Ok(None), |
213 | Some(it) => it, | 213 | Some(it) => it, |
214 | }; | 214 | }; |
215 | let res = navs | 215 | let nav_range = nav_info.range; |
216 | let res = nav_info | ||
217 | .info | ||
216 | .into_iter() | 218 | .into_iter() |
219 | .map(|nav| RangeInfo::new(nav_range, nav)) | ||
217 | .map(|nav| nav.try_conv_with(&world)) | 220 | .map(|nav| nav.try_conv_with(&world)) |
218 | .collect::<Result<Vec<_>>>()?; | 221 | .collect::<Result<Vec<_>>>()?; |
219 | Ok(Some(req::GotoDefinitionResponse::Array(res))) | 222 | Ok(Some(req::GotoDefinitionResponse::Array(res))) |