aboutsummaryrefslogtreecommitdiff
path: root/crates/server/src/main_loop
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-23 20:14:51 +0100
committerAleksey Kladov <[email protected]>2018-08-23 20:14:51 +0100
commit8ad586a44e2214a11c4e7d27e0d3c2d73e43f39f (patch)
tree70c553dd0231189acf0695b63688f21fb94867dc /crates/server/src/main_loop
parent18918769baf49acc4067eabdc0c3a0a98224d23f (diff)
JoinLines frontend
Diffstat (limited to 'crates/server/src/main_loop')
-rw-r--r--crates/server/src/main_loop/handlers.rs14
-rw-r--r--crates/server/src/main_loop/mod.rs4
2 files changed, 17 insertions, 1 deletions
diff --git a/crates/server/src/main_loop/handlers.rs b/crates/server/src/main_loop/handlers.rs
index b47cbc0fc..ae362ddaa 100644
--- a/crates/server/src/main_loop/handlers.rs
+++ b/crates/server/src/main_loop/handlers.rs
@@ -3,7 +3,7 @@ use std::collections::HashMap;
3use languageserver_types::{ 3use languageserver_types::{
4 Diagnostic, DiagnosticSeverity, Url, DocumentSymbol, 4 Diagnostic, DiagnosticSeverity, Url, DocumentSymbol,
5 Command, TextDocumentIdentifier, WorkspaceEdit, 5 Command, TextDocumentIdentifier, WorkspaceEdit,
6 SymbolInformation, Position, Location, 6 SymbolInformation, Position, Location, TextEdit,
7}; 7};
8use libanalysis::{Query}; 8use libanalysis::{Query};
9use libeditor; 9use libeditor;
@@ -58,6 +58,18 @@ pub fn handle_find_matching_brace(
58 Ok(res) 58 Ok(res)
59} 59}
60 60
61pub fn handle_join_lines(
62 world: ServerWorld,
63 params: req::JoinLinesParams,
64) -> Result<Vec<TextEdit>> {
65 let file_id = params.text_document.try_conv_with(&world)?;
66 let file = world.analysis().file_syntax(file_id)?;
67 let line_index = world.analysis().file_line_index(file_id)?;
68 let range = params.range.conv_with(&line_index);
69 let res = libeditor::join_lines(&file, range);
70 Ok(res.edit.conv_with(&line_index))
71}
72
61pub fn handle_document_symbol( 73pub fn handle_document_symbol(
62 world: ServerWorld, 74 world: ServerWorld,
63 params: req::DocumentSymbolParams, 75 params: req::DocumentSymbolParams,
diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs
index 9499b826c..1e65041e2 100644
--- a/crates/server/src/main_loop/mod.rs
+++ b/crates/server/src/main_loop/mod.rs
@@ -27,6 +27,7 @@ use {
27 handle_goto_definition, 27 handle_goto_definition,
28 handle_find_matching_brace, 28 handle_find_matching_brace,
29 handle_parent_module, 29 handle_parent_module,
30 handle_join_lines,
30 }, 31 },
31}; 32};
32 33
@@ -145,6 +146,9 @@ fn on_request(
145 handle_request_on_threadpool::<req::ParentModule>( 146 handle_request_on_threadpool::<req::ParentModule>(
146 &mut req, pool, world, sender, handle_parent_module, 147 &mut req, pool, world, sender, handle_parent_module,
147 )?; 148 )?;
149 handle_request_on_threadpool::<req::JoinLines>(
150 &mut req, pool, world, sender, handle_join_lines,
151 )?;
148 dispatch::handle_request::<req::ExecuteCommand, _>(&mut req, |params, resp| { 152 dispatch::handle_request::<req::ExecuteCommand, _>(&mut req, |params, resp| {
149 io.send(RawMsg::Response(resp.into_response(Ok(None))?)); 153 io.send(RawMsg::Response(resp.into_response(Ok(None))?));
150 154