diff options
author | Kirill Bulatov <[email protected]> | 2020-03-19 22:49:26 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-03-30 11:39:14 +0100 |
commit | 2feaef91bd640dd842ee8e1f6244b877124eb8eb (patch) | |
tree | 46f4b34a85d8fb856512454479344887397bb5a8 | |
parent | a9dd4427333d410bebf8e0923d5907b2a31efb50 (diff) |
Read new config on the server side
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index c990a3951..a48368e30 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -243,7 +243,7 @@ pub fn main_loop( | |||
243 | break; | 243 | break; |
244 | }; | 244 | }; |
245 | } | 245 | } |
246 | loop_turn( | 246 | if let Some(new_server_config) = loop_turn( |
247 | &pool, | 247 | &pool, |
248 | &task_sender, | 248 | &task_sender, |
249 | &libdata_sender, | 249 | &libdata_sender, |
@@ -251,7 +251,9 @@ pub fn main_loop( | |||
251 | &mut world_state, | 251 | &mut world_state, |
252 | &mut loop_state, | 252 | &mut loop_state, |
253 | event, | 253 | event, |
254 | )?; | 254 | )? { |
255 | dbg!(new_server_config); | ||
256 | } | ||
255 | } | 257 | } |
256 | } | 258 | } |
257 | world_state.analysis_host.request_cancellation(); | 259 | world_state.analysis_host.request_cancellation(); |
@@ -361,7 +363,7 @@ fn loop_turn( | |||
361 | world_state: &mut WorldState, | 363 | world_state: &mut WorldState, |
362 | loop_state: &mut LoopState, | 364 | loop_state: &mut LoopState, |
363 | event: Event, | 365 | event: Event, |
364 | ) -> Result<()> { | 366 | ) -> Result<Option<ServerConfig>> { |
365 | let loop_start = Instant::now(); | 367 | let loop_start = Instant::now(); |
366 | 368 | ||
367 | // NOTE: don't count blocking select! call as a loop-turn time | 369 | // NOTE: don't count blocking select! call as a loop-turn time |
@@ -372,6 +374,8 @@ fn loop_turn( | |||
372 | log::info!("queued count = {}", queue_count); | 374 | log::info!("queued count = {}", queue_count); |
373 | } | 375 | } |
374 | 376 | ||
377 | let mut new_server_config = None; | ||
378 | |||
375 | match event { | 379 | match event { |
376 | Event::Task(task) => { | 380 | Event::Task(task) => { |
377 | on_task(task, &connection.sender, &mut loop_state.pending_requests, world_state); | 381 | on_task(task, &connection.sender, &mut loop_state.pending_requests, world_state); |
@@ -401,15 +405,20 @@ fn loop_turn( | |||
401 | on_notification(&connection.sender, world_state, loop_state, not)?; | 405 | on_notification(&connection.sender, world_state, loop_state, not)?; |
402 | } | 406 | } |
403 | Message::Response(resp) => { | 407 | Message::Response(resp) => { |
404 | if Some(&resp.id) == loop_state.configuration_request_id.as_ref() { | ||
405 | loop_state.configuration_request_id.take(); | ||
406 | eprintln!("!!!!!!!!!!!!!!1"); | ||
407 | dbg!(&resp); | ||
408 | } | ||
409 | let removed = loop_state.pending_responses.remove(&resp.id); | 408 | let removed = loop_state.pending_responses.remove(&resp.id); |
410 | if !removed { | 409 | if !removed { |
411 | log::error!("unexpected response: {:?}", resp) | 410 | log::error!("unexpected response: {:?}", resp) |
412 | } | 411 | } |
412 | if Some(&resp.id) == loop_state.configuration_request_id.as_ref() { | ||
413 | loop_state.configuration_request_id.take(); | ||
414 | let new_config = | ||
415 | serde_json::from_value::<Vec<ServerConfig>>(resp.result.unwrap()) | ||
416 | .unwrap() | ||
417 | .first() | ||
418 | .unwrap() | ||
419 | .to_owned(); | ||
420 | new_server_config = Some(new_config); | ||
421 | } | ||
413 | } | 422 | } |
414 | }, | 423 | }, |
415 | }; | 424 | }; |
@@ -479,7 +488,7 @@ fn loop_turn( | |||
479 | } | 488 | } |
480 | } | 489 | } |
481 | 490 | ||
482 | Ok(()) | 491 | Ok(new_server_config) |
483 | } | 492 | } |
484 | 493 | ||
485 | fn on_task( | 494 | fn on_task( |