aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-11 11:14:09 +0000
committerAleksey Kladov <[email protected]>2019-01-11 13:06:08 +0000
commit3aaf20bd6ec75a572b13d020520d4df563a2891c (patch)
treeaa2a0b8e64896423b9324a44ef1f36141ff757bb /crates/ra_lsp_server/src
parentf9ed8d4d23cd210f24ca303c72b436bfbe84741f (diff)
return ref ranges from gotodef
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/conv.rs11
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs9
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};
7use ra_ide_api::{ 7use 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};
12use ra_syntax::{SyntaxKind, TextRange, TextUnit}; 12use ra_syntax::{SyntaxKind, TextRange, TextUnit};
@@ -349,6 +349,15 @@ impl TryConvWith for &NavigationTarget {
349 } 349 }
350} 350}
351 351
352impl 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
352pub fn to_location( 361pub 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};
11use ra_ide_api::{ 11use ra_ide_api::{
12 FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, 12 FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, SourceChange, RangeInfo,
13}; 13};
14use ra_syntax::{TextUnit, AstNode}; 14use ra_syntax::{TextUnit, AstNode};
15use rustc_hash::FxHashMap; 15use 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)))