diff options
author | Aleksey Kladov <[email protected]> | 2018-08-10 22:55:32 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-10 22:55:32 +0100 |
commit | 9863b9161d8d702848516be70c5c8161b7f382e8 (patch) | |
tree | 3aa95abbacf0897e4e738e1fc8ccf10492b7c60c /crates/server/src/main.rs | |
parent | 836e0c1863eaea5dffdf76a658c2ee9d7bc22e6f (diff) |
decorations
Diffstat (limited to 'crates/server/src/main.rs')
-rw-r--r-- | crates/server/src/main.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index 0e4f5f86a..900ee555f 100644 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs | |||
@@ -12,6 +12,7 @@ extern crate threadpool; | |||
12 | #[macro_use] | 12 | #[macro_use] |
13 | extern crate log; | 13 | extern crate log; |
14 | extern crate url; | 14 | extern crate url; |
15 | extern crate url_serde; | ||
15 | extern crate flexi_logger; | 16 | extern crate flexi_logger; |
16 | extern crate libeditor; | 17 | extern crate libeditor; |
17 | extern crate libanalysis; | 18 | extern crate libanalysis; |
@@ -31,7 +32,7 @@ use libanalysis::{WorldState, World}; | |||
31 | 32 | ||
32 | use ::{ | 33 | use ::{ |
33 | io::{Io, RawMsg, RawRequest}, | 34 | io::{Io, RawMsg, RawRequest}, |
34 | handlers::{handle_syntax_tree, handle_extend_selection, publish_diagnostics}, | 35 | handlers::{handle_syntax_tree, handle_extend_selection, publish_diagnostics, publish_decorations}, |
35 | util::{FilePath, FnBox} | 36 | util::{FilePath, FnBox} |
36 | }; | 37 | }; |
37 | 38 | ||
@@ -198,7 +199,7 @@ fn main_loop( | |||
198 | dispatch::handle_notification::<req::DidOpenTextDocument, _>(&mut not, |params| { | 199 | dispatch::handle_notification::<req::DidOpenTextDocument, _>(&mut not, |params| { |
199 | let path = params.text_document.file_path()?; | 200 | let path = params.text_document.file_path()?; |
200 | world.change_overlay(path, Some(params.text_document.text)); | 201 | world.change_overlay(path, Some(params.text_document.text)); |
201 | update_diagnostics_on_threadpool( | 202 | update_file_notifications_on_threadpool( |
202 | pool, world.snapshot(), sender.clone(), params.text_document.uri, | 203 | pool, world.snapshot(), sender.clone(), params.text_document.uri, |
203 | ); | 204 | ); |
204 | Ok(()) | 205 | Ok(()) |
@@ -209,7 +210,7 @@ fn main_loop( | |||
209 | .ok_or_else(|| format_err!("empty changes"))? | 210 | .ok_or_else(|| format_err!("empty changes"))? |
210 | .text; | 211 | .text; |
211 | world.change_overlay(path, Some(text)); | 212 | world.change_overlay(path, Some(text)); |
212 | update_diagnostics_on_threadpool( | 213 | update_file_notifications_on_threadpool( |
213 | pool, world.snapshot(), sender.clone(), params.text_document.uri, | 214 | pool, world.snapshot(), sender.clone(), params.text_document.uri, |
214 | ); | 215 | ); |
215 | Ok(()) | 216 | Ok(()) |
@@ -254,14 +255,14 @@ fn handle_request_on_threadpool<R: req::ClientRequest>( | |||
254 | }) | 255 | }) |
255 | } | 256 | } |
256 | 257 | ||
257 | fn update_diagnostics_on_threadpool( | 258 | fn update_file_notifications_on_threadpool( |
258 | pool: &ThreadPool, | 259 | pool: &ThreadPool, |
259 | world: World, | 260 | world: World, |
260 | sender: Sender<Thunk>, | 261 | sender: Sender<Thunk>, |
261 | uri: Url, | 262 | uri: Url, |
262 | ) { | 263 | ) { |
263 | pool.execute(move || { | 264 | pool.execute(move || { |
264 | match publish_diagnostics(world, uri) { | 265 | match publish_diagnostics(world.clone(), uri.clone()) { |
265 | Err(e) => { | 266 | Err(e) => { |
266 | error!("failed to compute diagnostics: {:?}", e) | 267 | error!("failed to compute diagnostics: {:?}", e) |
267 | } | 268 | } |
@@ -271,5 +272,15 @@ fn update_diagnostics_on_threadpool( | |||
271 | })) | 272 | })) |
272 | } | 273 | } |
273 | } | 274 | } |
275 | match publish_decorations(world, uri) { | ||
276 | Err(e) => { | ||
277 | error!("failed to compute decortions: {:?}", e) | ||
278 | } | ||
279 | Ok(params) => { | ||
280 | sender.send(Box::new(|io: &mut Io| { | ||
281 | dispatch::send_notification::<req::PublishDecorations>(io, params) | ||
282 | })) | ||
283 | } | ||
284 | } | ||
274 | }); | 285 | }); |
275 | } | 286 | } |