diff options
Diffstat (limited to 'crates/server/src/main_loop')
-rw-r--r-- | crates/server/src/main_loop/mod.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs index ce61265a2..3d131274f 100644 --- a/crates/server/src/main_loop/mod.rs +++ b/crates/server/src/main_loop/mod.rs | |||
@@ -10,7 +10,7 @@ use threadpool::ThreadPool; | |||
10 | use serde::{Serialize, de::DeserializeOwned}; | 10 | use serde::{Serialize, de::DeserializeOwned}; |
11 | use crossbeam_channel::{bounded, Sender, Receiver}; | 11 | use crossbeam_channel::{bounded, Sender, Receiver}; |
12 | use languageserver_types::{NumberOrString}; | 12 | use languageserver_types::{NumberOrString}; |
13 | use libanalysis::{FileId, JobHandle, JobToken}; | 13 | use libanalysis::{FileId, JobHandle, JobToken, LibraryData}; |
14 | use gen_lsp_server::{ | 14 | use gen_lsp_server::{ |
15 | RawRequest, RawNotification, RawMessage, RawResponse, ErrorCode, | 15 | RawRequest, RawNotification, RawMessage, RawResponse, ErrorCode, |
16 | handle_shutdown, | 16 | handle_shutdown, |
@@ -94,6 +94,7 @@ fn main_loop_inner( | |||
94 | pending_requests: &mut HashMap<u64, JobHandle>, | 94 | pending_requests: &mut HashMap<u64, JobHandle>, |
95 | subs: &mut Subscriptions, | 95 | subs: &mut Subscriptions, |
96 | ) -> Result<()> { | 96 | ) -> Result<()> { |
97 | let (libdata_sender, libdata_receiver) = bounded(1024); | ||
97 | ws_sender.send(ws_root.clone()); | 98 | ws_sender.send(ws_root.clone()); |
98 | fs_sender.send(ws_root.clone()); | 99 | fs_sender.send(ws_root.clone()); |
99 | loop { | 100 | loop { |
@@ -103,6 +104,7 @@ fn main_loop_inner( | |||
103 | Task(Task), | 104 | Task(Task), |
104 | Fs(PathBuf, Vec<FileEvent>), | 105 | Fs(PathBuf, Vec<FileEvent>), |
105 | Ws(Result<CargoWorkspace>), | 106 | Ws(Result<CargoWorkspace>), |
107 | Lib(LibraryData), | ||
106 | } | 108 | } |
107 | trace!("selecting"); | 109 | trace!("selecting"); |
108 | let event = select! { | 110 | let event = select! { |
@@ -119,6 +121,7 @@ fn main_loop_inner( | |||
119 | None => bail!("workspace watcher died"), | 121 | None => bail!("workspace watcher died"), |
120 | Some(ws) => Event::Ws(ws), | 122 | Some(ws) => Event::Ws(ws), |
121 | } | 123 | } |
124 | recv(libdata_receiver, data) => Event::Lib(data.unwrap()) | ||
122 | }; | 125 | }; |
123 | trace!("selected {:?}", event); | 126 | trace!("selected {:?}", event); |
124 | let mut state_changed = false; | 127 | let mut state_changed = false; |
@@ -129,7 +132,12 @@ fn main_loop_inner( | |||
129 | if root == ws_root { | 132 | if root == ws_root { |
130 | state.apply_fs_changes(events); | 133 | state.apply_fs_changes(events); |
131 | } else { | 134 | } else { |
132 | state.add_library(events); | 135 | let files = state.events_to_files(events); |
136 | let sender = libdata_sender.clone(); | ||
137 | pool.execute(move || { | ||
138 | let data = LibraryData::prepare(files); | ||
139 | sender.send(data); | ||
140 | }); | ||
133 | } | 141 | } |
134 | state_changed = true; | 142 | state_changed = true; |
135 | } | 143 | } |
@@ -152,6 +160,9 @@ fn main_loop_inner( | |||
152 | Err(e) => warn!("loading workspace failed: {}", e), | 160 | Err(e) => warn!("loading workspace failed: {}", e), |
153 | } | 161 | } |
154 | } | 162 | } |
163 | Event::Lib(lib) => { | ||
164 | state.add_lib(lib); | ||
165 | } | ||
155 | Event::Msg(msg) => { | 166 | Event::Msg(msg) => { |
156 | match msg { | 167 | match msg { |
157 | RawMessage::Request(req) => { | 168 | RawMessage::Request(req) => { |