diff options
author | Aleksey Kladov <[email protected]> | 2019-01-11 13:01:48 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-11 13:06:22 +0000 |
commit | 8a5f74a24f726a839f3a0e154cfadec23040e14c (patch) | |
tree | 2d21c8b094aa6c7fd10fa541b84413c9609c2c8a /crates/ra_lsp_server/src/main_loop/handlers.rs | |
parent | 3aaf20bd6ec75a572b13d020520d4df563a2891c (diff) |
use location link in goto def
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index e3bf55ae7..aad9d6568 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, SourceChange, RangeInfo, | 12 | FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, 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; |
@@ -17,7 +17,7 @@ use serde_json::to_value; | |||
17 | use std::io::Write; | 17 | use std::io::Write; |
18 | 18 | ||
19 | use crate::{ | 19 | use crate::{ |
20 | conv::{to_location, Conv, ConvWith, MapConvWith, TryConvWith}, | 20 | conv::{to_location, to_location_link, Conv, ConvWith, MapConvWith, TryConvWith}, |
21 | project_model::TargetKind, | 21 | project_model::TargetKind, |
22 | req::{self, Decoration}, | 22 | req::{self, Decoration}, |
23 | server_world::ServerWorld, | 23 | server_world::ServerWorld, |
@@ -208,6 +208,7 @@ 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 line_index = world.analysis().file_line_index(position.file_id); | ||
211 | let nav_info = match world.analysis().goto_definition(position)? { | 212 | let nav_info = match world.analysis().goto_definition(position)? { |
212 | None => return Ok(None), | 213 | None => return Ok(None), |
213 | Some(it) => it, | 214 | Some(it) => it, |
@@ -217,9 +218,9 @@ pub fn handle_goto_definition( | |||
217 | .info | 218 | .info |
218 | .into_iter() | 219 | .into_iter() |
219 | .map(|nav| RangeInfo::new(nav_range, nav)) | 220 | .map(|nav| RangeInfo::new(nav_range, nav)) |
220 | .map(|nav| nav.try_conv_with(&world)) | 221 | .map(|nav| to_location_link(&nav, &world, &line_index)) |
221 | .collect::<Result<Vec<_>>>()?; | 222 | .collect::<Result<Vec<_>>>()?; |
222 | Ok(Some(req::GotoDefinitionResponse::Array(res))) | 223 | Ok(Some(req::GotoDefinitionResponse::Link(res))) |
223 | } | 224 | } |
224 | 225 | ||
225 | pub fn handle_parent_module( | 226 | pub fn handle_parent_module( |