]> git.lizzy.rs Git - rust.git/commitdiff
Read new config on the server side
authorKirill Bulatov <mail4score@gmail.com>
Thu, 19 Mar 2020 22:49:26 +0000 (00:49 +0200)
committerKirill Bulatov <mail4score@gmail.com>
Mon, 30 Mar 2020 10:39:14 +0000 (13:39 +0300)
crates/rust-analyzer/src/main_loop.rs

index c990a395195ed28892acfe5f2e7547bc91e14bb7..a48368e3027252068c0552263d1c01ae95bc549e 100644 (file)
@@ -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<Option<ServerConfig>> {
     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::<Vec<ServerConfig>>(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(