aboutsummaryrefslogtreecommitdiff
path: root/crates/server/src/main_loop/mod.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-13 00:38:34 +0100
committerAleksey Kladov <[email protected]>2018-08-13 00:38:34 +0100
commitbe742a587704f27f4e503c50f549aa9ec1527fcc (patch)
treefb15d3dd05c64c441c9cddbbce6aee3776d6ddd1 /crates/server/src/main_loop/mod.rs
parent25aebb5225da91d34a2cb946f93435f9f7e82a47 (diff)
Apply code actions
Diffstat (limited to 'crates/server/src/main_loop/mod.rs')
-rw-r--r--crates/server/src/main_loop/mod.rs46
1 files changed, 29 insertions, 17 deletions
diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs
index 3d367f5f6..5b7093ad7 100644
--- a/crates/server/src/main_loop/mod.rs
+++ b/crates/server/src/main_loop/mod.rs
@@ -6,6 +6,7 @@ use threadpool::ThreadPool;
6use crossbeam_channel::{Sender, Receiver}; 6use crossbeam_channel::{Sender, Receiver};
7use languageserver_types::Url; 7use languageserver_types::Url;
8use libanalysis::{World, WorldState}; 8use libanalysis::{World, WorldState};
9use serde_json::to_value;
9 10
10use { 11use {
11 req, dispatch, 12 req, dispatch,
@@ -19,6 +20,7 @@ use {
19 publish_decorations, 20 publish_decorations,
20 handle_document_symbol, 21 handle_document_symbol,
21 handle_code_action, 22 handle_code_action,
23 handle_execute_command,
22 }, 24 },
23}; 25};
24 26
@@ -79,7 +81,9 @@ pub(super) fn main_loop(
79 on_notification(io, world, pool, &sender, not)? 81 on_notification(io, world, pool, &sender, not)?
80 } 82 }
81 RawMsg::Response(resp) => { 83 RawMsg::Response(resp) => {
82 error!("unexpected response: {:?}", resp) 84 if !pending_requests.remove(&resp.id) {
85 error!("unexpected response: {:?}", resp)
86 }
83 } 87 }
84 } 88 }
85 } 89 }
@@ -107,22 +111,30 @@ fn on_request(
107 handle_request_on_threadpool::<req::CodeActionRequest>( 111 handle_request_on_threadpool::<req::CodeActionRequest>(
108 &mut req, pool, world, sender, handle_code_action, 112 &mut req, pool, world, sender, handle_code_action,
109 )?; 113 )?;
110// dispatch::handle_request::<req::ExecuteCommand, _>(&mut req, |(), resp| { 114 dispatch::handle_request::<req::ExecuteCommand, _>(&mut req, |params, resp| {
111// let world = world.snapshot(); 115 io.send(RawMsg::Response(resp.into_response(Ok(None))?));
112// let sender = sender.clone(); 116
113// pool.execute(move || { 117 let world = world.snapshot();
114// let task = match handle_execute_command(world, params) { 118 let sender = sender.clone();
115// Ok(req) => Task::Request(req), 119 pool.execute(move || {
116// Err(e) => Task::Die(e), 120 let task = match handle_execute_command(world, params) {
117// }; 121 Ok(req) => match to_value(req) {
118// sender.send(task) 122 Err(e) => Task::Die(e.into()),
119// }); 123 Ok(params) => {
120// 124 let request = RawRequest {
121// let resp = resp.into_response(Ok(()))?; 125 id: 0,
122// io.send(RawMsg::Response(resp)); 126 method: <req::ApplyWorkspaceEdit as req::ClientRequest>::METHOD.to_string(),
123// shutdown = true; 127 params,
124// Ok(()) 128 };
125// })?; 129 Task::Request(request)
130 }
131 },
132 Err(e) => Task::Die(e),
133 };
134 sender.send(task)
135 });
136 Ok(())
137 })?;
126 138
127 let mut shutdown = false; 139 let mut shutdown = false;
128 dispatch::handle_request::<req::Shutdown, _>(&mut req, |(), resp| { 140 dispatch::handle_request::<req::Shutdown, _>(&mut req, |(), resp| {