aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-28 16:17:19 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-28 16:17:19 +0000
commit7a268b9b9635425176f93d3c893fb5345e84e9ce (patch)
tree6ea69024cb22d3fc48a3b392a0185163fa452014 /crates/ra_lsp_server/src/main_loop
parent9d6740a9c9ad2ca47c4885bd994f849e90bbef86 (diff)
parentb911ee542b2f4d1cd62a655f24197856cd9b9097 (diff)
Merge #350
350: Super simple macro support r=matklad a=matklad Super simple support for macros, mostly for figuring out how to fit them into the current architecture. Expansion is hard-coded and string based (mid-term, we should try to copy-paste macro-by-example expander from rustc). Ideally, we should handle * highlighting inside the macro (done) * extend selection inside the macro * completion inside the macro * indexing structs, produced by the macro Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs20
1 files changed, 9 insertions, 11 deletions
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::{
8 PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, 8 PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit,
9 WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents, 9 WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents,
10}; 10};
11use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition, Severity}; 11use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FileRange, FilePosition, Severity};
12use ra_syntax::{TextUnit, text_utils::intersect}; 12use ra_syntax::{TextUnit, text_utils::intersect};
13use ra_text_edit::text_utils::contains_offset_nonstrict; 13use ra_text_edit::text_utils::contains_offset_nonstrict;
14use rustc_hash::FxHashMap; 14use rustc_hash::FxHashMap;
@@ -33,13 +33,13 @@ pub fn handle_extend_selection(
33 params: req::ExtendSelectionParams, 33 params: req::ExtendSelectionParams,
34) -> Result<req::ExtendSelectionResult> { 34) -> Result<req::ExtendSelectionResult> {
35 let file_id = params.text_document.try_conv_with(&world)?; 35 let file_id = params.text_document.try_conv_with(&world)?;
36 let file = world.analysis().file_syntax(file_id);
37 let line_index = world.analysis().file_line_index(file_id); 36 let line_index = world.analysis().file_line_index(file_id);
38 let selections = params 37 let selections = params
39 .selections 38 .selections
40 .into_iter() 39 .into_iter()
41 .map_conv_with(&line_index) 40 .map_conv_with(&line_index)
42 .map(|r| world.analysis().extend_selection(&file, r)) 41 .map(|range| FileRange { file_id, range })
42 .map(|frange| world.analysis().extend_selection(frange))
43 .map_conv_with(&line_index) 43 .map_conv_with(&line_index)
44 .collect(); 44 .collect();
45 Ok(req::ExtendSelectionResult { selections }) 45 Ok(req::ExtendSelectionResult { selections })
@@ -71,13 +71,8 @@ pub fn handle_join_lines(
71 world: ServerWorld, 71 world: ServerWorld,
72 params: req::JoinLinesParams, 72 params: req::JoinLinesParams,
73) -> Result<req::SourceChange> { 73) -> Result<req::SourceChange> {
74 let file_id = params.text_document.try_conv_with(&world)?; 74 let frange = (&params.text_document, params.range).try_conv_with(&world)?;
75 let line_index = world.analysis().file_line_index(file_id); 75 world.analysis().join_lines(frange).try_conv_with(&world)
76 let range = params.range.conv_with(&line_index);
77 world
78 .analysis()
79 .join_lines(file_id, range)
80 .try_conv_with(&world)
81} 76}
82 77
83pub fn handle_on_enter( 78pub fn handle_on_enter(
@@ -614,7 +609,10 @@ pub fn handle_code_action(
614 let line_index = world.analysis().file_line_index(file_id); 609 let line_index = world.analysis().file_line_index(file_id);
615 let range = params.range.conv_with(&line_index); 610 let range = params.range.conv_with(&line_index);
616 611
617 let assists = world.analysis().assists(file_id, range)?.into_iter(); 612 let assists = world
613 .analysis()
614 .assists(FileRange { file_id, range })?
615 .into_iter();
618 let fixes = world 616 let fixes = world
619 .analysis() 617 .analysis()
620 .diagnostics(file_id)? 618 .diagnostics(file_id)?