mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
add gc request
This commit is contained in:
parent
6df1f71b7d
commit
f6adb85b68
7 changed files with 44 additions and 11 deletions
|
@ -205,17 +205,26 @@ fn main_loop_inner(
|
|||
Some(req) => req,
|
||||
None => return Ok(()),
|
||||
};
|
||||
match on_request(state, pending_requests, pool, &task_sender, req)? {
|
||||
None => (),
|
||||
Some(req) => {
|
||||
log::error!("unknown request: {:?}", req);
|
||||
let resp = RawResponse::err(
|
||||
req.id,
|
||||
ErrorCode::MethodNotFound as i32,
|
||||
"unknown request".to_string(),
|
||||
);
|
||||
match req.cast::<req::CollectGarbage>() {
|
||||
Ok((id, ())) => {
|
||||
state.collect_garbadge();
|
||||
let resp = RawResponse::ok::<req::CollectGarbage>(id, &());
|
||||
msg_sender.send(RawMessage::Response(resp)).unwrap()
|
||||
}
|
||||
Err(req) => {
|
||||
match on_request(state, pending_requests, pool, &task_sender, req)? {
|
||||
None => (),
|
||||
Some(req) => {
|
||||
log::error!("unknown request: {:?}", req);
|
||||
let resp = RawResponse::err(
|
||||
req.id,
|
||||
ErrorCode::MethodNotFound as i32,
|
||||
"unknown request".to_string(),
|
||||
);
|
||||
msg_sender.send(RawMessage::Response(resp)).unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RawMessage::Notification(not) => {
|
||||
|
|
|
@ -19,6 +19,14 @@ impl Request for AnalyzerStatus {
|
|||
const METHOD: &'static str = "ra/analyzerStatus";
|
||||
}
|
||||
|
||||
pub enum CollectGarbage {}
|
||||
|
||||
impl Request for CollectGarbage {
|
||||
type Params = ();
|
||||
type Result = ();
|
||||
const METHOD: &'static str = "ra/collectGarbage";
|
||||
}
|
||||
|
||||
pub enum SyntaxTree {}
|
||||
|
||||
impl Request for SyntaxTree {
|
||||
|
|
|
@ -231,6 +231,10 @@ impl ServerWorldState {
|
|||
vfs: Arc::clone(&self.vfs),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn collect_garbadge(&mut self) {
|
||||
self.analysis_host.collect_garbage()
|
||||
}
|
||||
}
|
||||
|
||||
impl ServerWorld {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue