diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-25 16:12:27 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-25 16:12:27 +0000 |
commit | dc5ecf446991c65359cf49d52098fcec5f1a1f68 (patch) | |
tree | ca0ee39e7f1305019954b3a413a06f9431cb6648 /crates/ra_lsp_server/src | |
parent | 6df1f71b7d0db209978595dc9be496e7f2ef88ec (diff) | |
parent | f6adb85b681c23b64cc33197eb67d5d7fcf920f0 (diff) |
Merge #643
643: add gc request r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 27 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/req.rs | 8 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/server_world.rs | 4 |
3 files changed, 30 insertions, 9 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index f51576521..ddd20a41f 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -205,17 +205,26 @@ fn main_loop_inner( | |||
205 | Some(req) => req, | 205 | Some(req) => req, |
206 | None => return Ok(()), | 206 | None => return Ok(()), |
207 | }; | 207 | }; |
208 | match on_request(state, pending_requests, pool, &task_sender, req)? { | 208 | match req.cast::<req::CollectGarbage>() { |
209 | None => (), | 209 | Ok((id, ())) => { |
210 | Some(req) => { | 210 | state.collect_garbadge(); |
211 | log::error!("unknown request: {:?}", req); | 211 | let resp = RawResponse::ok::<req::CollectGarbage>(id, &()); |
212 | let resp = RawResponse::err( | ||
213 | req.id, | ||
214 | ErrorCode::MethodNotFound as i32, | ||
215 | "unknown request".to_string(), | ||
216 | ); | ||
217 | msg_sender.send(RawMessage::Response(resp)).unwrap() | 212 | msg_sender.send(RawMessage::Response(resp)).unwrap() |
218 | } | 213 | } |
214 | Err(req) => { | ||
215 | match on_request(state, pending_requests, pool, &task_sender, req)? { | ||
216 | None => (), | ||
217 | Some(req) => { | ||
218 | log::error!("unknown request: {:?}", req); | ||
219 | let resp = RawResponse::err( | ||
220 | req.id, | ||
221 | ErrorCode::MethodNotFound as i32, | ||
222 | "unknown request".to_string(), | ||
223 | ); | ||
224 | msg_sender.send(RawMessage::Response(resp)).unwrap() | ||
225 | } | ||
226 | } | ||
227 | } | ||
219 | } | 228 | } |
220 | } | 229 | } |
221 | RawMessage::Notification(not) => { | 230 | RawMessage::Notification(not) => { |
diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index ec6b6d905..5968e592b 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs | |||
@@ -19,6 +19,14 @@ impl Request for AnalyzerStatus { | |||
19 | const METHOD: &'static str = "ra/analyzerStatus"; | 19 | const METHOD: &'static str = "ra/analyzerStatus"; |
20 | } | 20 | } |
21 | 21 | ||
22 | pub enum CollectGarbage {} | ||
23 | |||
24 | impl Request for CollectGarbage { | ||
25 | type Params = (); | ||
26 | type Result = (); | ||
27 | const METHOD: &'static str = "ra/collectGarbage"; | ||
28 | } | ||
29 | |||
22 | pub enum SyntaxTree {} | 30 | pub enum SyntaxTree {} |
23 | 31 | ||
24 | impl Request for SyntaxTree { | 32 | impl Request for SyntaxTree { |
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index 5cb97b29b..bf04f1125 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs | |||
@@ -231,6 +231,10 @@ impl ServerWorldState { | |||
231 | vfs: Arc::clone(&self.vfs), | 231 | vfs: Arc::clone(&self.vfs), |
232 | } | 232 | } |
233 | } | 233 | } |
234 | |||
235 | pub fn collect_garbadge(&mut self) { | ||
236 | self.analysis_host.collect_garbage() | ||
237 | } | ||
234 | } | 238 | } |
235 | 239 | ||
236 | impl ServerWorld { | 240 | impl ServerWorld { |