From 2feaef91bd640dd842ee8e1f6244b877124eb8eb Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 20 Mar 2020 00:49:26 +0200 Subject: Read new config on the server side --- crates/rust-analyzer/src/main_loop.rs | 27 ++++++++++++++++++--------- 1 file 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( break; }; } - loop_turn( + if let Some(new_server_config) = loop_turn( &pool, &task_sender, &libdata_sender, @@ -251,7 +251,9 @@ pub fn main_loop( &mut world_state, &mut loop_state, event, - )?; + )? { + dbg!(new_server_config); + } } } world_state.analysis_host.request_cancellation(); @@ -361,7 +363,7 @@ fn loop_turn( world_state: &mut WorldState, loop_state: &mut LoopState, event: Event, -) -> Result<()> { +) -> Result> { let loop_start = Instant::now(); // NOTE: don't count blocking select! call as a loop-turn time @@ -372,6 +374,8 @@ fn loop_turn( log::info!("queued count = {}", queue_count); } + let mut new_server_config = None; + match event { Event::Task(task) => { on_task(task, &connection.sender, &mut loop_state.pending_requests, world_state); @@ -401,15 +405,20 @@ fn loop_turn( on_notification(&connection.sender, world_state, loop_state, not)?; } Message::Response(resp) => { - if Some(&resp.id) == loop_state.configuration_request_id.as_ref() { - loop_state.configuration_request_id.take(); - eprintln!("!!!!!!!!!!!!!!1"); - dbg!(&resp); - } let removed = loop_state.pending_responses.remove(&resp.id); if !removed { log::error!("unexpected response: {:?}", resp) } + if Some(&resp.id) == loop_state.configuration_request_id.as_ref() { + loop_state.configuration_request_id.take(); + let new_config = + serde_json::from_value::>(resp.result.unwrap()) + .unwrap() + .first() + .unwrap() + .to_owned(); + new_server_config = Some(new_config); + } } }, }; @@ -479,7 +488,7 @@ fn loop_turn( } } - Ok(()) + Ok(new_server_config) } fn on_task( -- cgit v1.2.3