aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-20 18:17:18 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-20 18:17:18 +0000
commitb89f8b6b4929ec09be4f9b13f87ad56b3235bd39 (patch)
tree0cdaf64f538467c3f5a974cac51413f495250f06 /crates/ra_lsp_server
parent3508ba9bc2c2180a6495238c2fafa493557f36d0 (diff)
parent73836cdbbc928f3512156f0bc0166e5a39ad9864 (diff)
Merge #580
580: extend selection expands macros and can totally panic r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 8f9db68a2..02393f728 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 lsp_types::{
8 WorkspaceEdit 8 WorkspaceEdit
9}; 9};
10use ra_ide_api::{ 10use ra_ide_api::{
11 FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity, 11 FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity, Cancelable,
12}; 12};
13use ra_syntax::{AstNode, TextUnit}; 13use ra_syntax::{AstNode, TextUnit};
14use rustc_hash::FxHashMap; 14use rustc_hash::FxHashMap;
@@ -40,9 +40,13 @@ pub fn handle_extend_selection(
40 .into_iter() 40 .into_iter()
41 .map_conv_with(&line_index) 41 .map_conv_with(&line_index)
42 .map(|range| FileRange { file_id, range }) 42 .map(|range| FileRange { file_id, range })
43 .map(|frange| world.analysis().extend_selection(frange)) 43 .map(|frange| {
44 .map_conv_with(&line_index) 44 world
45 .collect(); 45 .analysis()
46 .extend_selection(frange)
47 .map(|it| it.conv_with(&line_index))
48 })
49 .collect::<Cancelable<Vec<_>>>()?;
46 Ok(req::ExtendSelectionResult { selections }) 50 Ok(req::ExtendSelectionResult { selections })
47} 51}
48 52
@@ -51,7 +55,6 @@ pub fn handle_find_matching_brace(
51 params: req::FindMatchingBraceParams, 55 params: req::FindMatchingBraceParams,
52) -> Result<Vec<Position>> { 56) -> Result<Vec<Position>> {
53 let file_id = params.text_document.try_conv_with(&world)?; 57 let file_id = params.text_document.try_conv_with(&world)?;
54 let file = world.analysis().file_syntax(file_id);
55 let line_index = world.analysis().file_line_index(file_id); 58 let line_index = world.analysis().file_line_index(file_id);
56 let res = params 59 let res = params
57 .offsets 60 .offsets
@@ -60,7 +63,7 @@ pub fn handle_find_matching_brace(
60 .map(|offset| { 63 .map(|offset| {
61 world 64 world
62 .analysis() 65 .analysis()
63 .matching_brace(&file, offset) 66 .matching_brace(FilePosition { file_id, offset })
64 .unwrap_or(offset) 67 .unwrap_or(offset)
65 }) 68 })
66 .map_conv_with(&line_index) 69 .map_conv_with(&line_index)
@@ -315,7 +318,7 @@ pub fn handle_completion(
315 let mut res = false; 318 let mut res = false;
316 if let Some(ctx) = params.context { 319 if let Some(ctx) = params.context {
317 if ctx.trigger_character.unwrap_or_default() == ":" { 320 if ctx.trigger_character.unwrap_or_default() == ":" {
318 let source_file = world.analysis().file_syntax(position.file_id); 321 let source_file = world.analysis().parse(position.file_id);
319 let syntax = source_file.syntax(); 322 let syntax = source_file.syntax();
320 let text = syntax.text(); 323 let text = syntax.text();
321 if let Some(next_char) = text.char_at(position.offset) { 324 if let Some(next_char) = text.char_at(position.offset) {