diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-11 15:35:41 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-11 15:35:41 +0000 |
commit | aad1bf877e4ba5ce9e28e8bde14f790ef8d1551b (patch) | |
tree | 9d3ea7f166adcd09fb77cfdb7fc1bad03efc95cd /crates/ra_lsp_server/src/main_loop/handlers.rs | |
parent | 0b83bde6e2f3782ea6acd907fa0a634912cebb3d (diff) | |
parent | f23a13bfa7bae7e34070bfd14d22b70a82315022 (diff) |
Merge #496
496: Include two element ranges into the nav. r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 5f4b27149..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, | 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,15 +208,19 @@ 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 line_index = world.analysis().file_line_index(position.file_id); |
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, |
214 | }; | 215 | }; |
215 | let res = navs | 216 | let nav_range = nav_info.range; |
217 | let res = nav_info | ||
218 | .info | ||
216 | .into_iter() | 219 | .into_iter() |
217 | .map(|nav| nav.try_conv_with(&world)) | 220 | .map(|nav| RangeInfo::new(nav_range, nav)) |
221 | .map(|nav| to_location_link(&nav, &world, &line_index)) | ||
218 | .collect::<Result<Vec<_>>>()?; | 222 | .collect::<Result<Vec<_>>>()?; |
219 | Ok(Some(req::GotoDefinitionResponse::Array(res))) | 223 | Ok(Some(req::GotoDefinitionResponse::Link(res))) |
220 | } | 224 | } |
221 | 225 | ||
222 | pub fn handle_parent_module( | 226 | pub fn handle_parent_module( |