From fd33c89207f6dc621ef6e8c26ea288089448d811 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Dec 2018 18:15:19 +0300 Subject: switch to FileRange --- crates/ra_lsp_server/src/main_loop/handlers.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 0e9a66a8a..d6f3dbe28 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -8,7 +8,7 @@ use languageserver_types::{ PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents, }; -use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition, Severity}; +use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FileRange, FilePosition, Severity}; use ra_syntax::{TextUnit, text_utils::intersect}; use ra_text_edit::text_utils::contains_offset_nonstrict; use rustc_hash::FxHashMap; @@ -33,13 +33,13 @@ pub fn handle_extend_selection( params: req::ExtendSelectionParams, ) -> Result { let file_id = params.text_document.try_conv_with(&world)?; - let file = world.analysis().file_syntax(file_id); let line_index = world.analysis().file_line_index(file_id); let selections = params .selections .into_iter() .map_conv_with(&line_index) - .map(|r| world.analysis().extend_selection(&file, r)) + .map(|range| FileRange { file_id, range }) + .map(|frange| world.analysis().extend_selection(frange)) .map_conv_with(&line_index) .collect(); Ok(req::ExtendSelectionResult { selections }) @@ -71,13 +71,8 @@ pub fn handle_join_lines( world: ServerWorld, params: req::JoinLinesParams, ) -> Result { - let file_id = params.text_document.try_conv_with(&world)?; - let line_index = world.analysis().file_line_index(file_id); - let range = params.range.conv_with(&line_index); - world - .analysis() - .join_lines(file_id, range) - .try_conv_with(&world) + let frange = (¶ms.text_document, params.range).try_conv_with(&world)?; + world.analysis().join_lines(frange).try_conv_with(&world) } pub fn handle_on_enter( @@ -614,7 +609,10 @@ pub fn handle_code_action( let line_index = world.analysis().file_line_index(file_id); let range = params.range.conv_with(&line_index); - let assists = world.analysis().assists(file_id, range)?.into_iter(); + let assists = world + .analysis() + .assists(FileRange { file_id, range })? + .into_iter(); let fixes = world .analysis() .diagnostics(file_id)? -- cgit v1.2.3