aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop/handlers.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-11 15:35:41 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-11 15:35:41 +0000
commitaad1bf877e4ba5ce9e28e8bde14f790ef8d1551b (patch)
tree9d3ea7f166adcd09fb77cfdb7fc1bad03efc95cd /crates/ra_lsp_server/src/main_loop/handlers.rs
parent0b83bde6e2f3782ea6acd907fa0a634912cebb3d (diff)
parentf23a13bfa7bae7e34070bfd14d22b70a82315022 (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.rs16
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};
11use ra_ide_api::{ 11use ra_ide_api::{
12 FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, 12 FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, RangeInfo,
13}; 13};
14use ra_syntax::{TextUnit, AstNode}; 14use ra_syntax::{TextUnit, AstNode};
15use rustc_hash::FxHashMap; 15use rustc_hash::FxHashMap;
@@ -17,7 +17,7 @@ use serde_json::to_value;
17use std::io::Write; 17use std::io::Write;
18 18
19use crate::{ 19use 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
222pub fn handle_parent_module( 226pub fn handle_parent_module(