mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
cleanup
This commit is contained in:
parent
2d773a46c9
commit
15efd58274
1 changed files with 48 additions and 35 deletions
|
@ -470,42 +470,16 @@ impl<'a> PoolDispatcher<'a> {
|
||||||
self.world.cancel_requests();
|
self.world.cancel_requests();
|
||||||
}
|
}
|
||||||
|
|
||||||
let world = self.world.snapshot();
|
self.pool.execute({
|
||||||
let sender = self.sender.clone();
|
let world = self.world.snapshot();
|
||||||
self.pool.execute(move || {
|
let sender = self.sender.clone();
|
||||||
let response = match f(world, params) {
|
move || {
|
||||||
Ok(resp) => RawResponse::ok::<R>(id, &resp),
|
let result = f(world, params);
|
||||||
Err(e) => match e.downcast::<LspError>() {
|
let task = result_to_task::<R>(id, result);
|
||||||
Ok(lsp_error) => RawResponse::err(id, lsp_error.code, lsp_error.message),
|
sender.send(task).unwrap();
|
||||||
Err(e) => {
|
}
|
||||||
if is_canceled(&e) {
|
|
||||||
// FIXME: When https://github.com/Microsoft/vscode-languageserver-node/issues/457
|
|
||||||
// gets fixed, we can return the proper response.
|
|
||||||
// This works around the issue where "content modified" error would continuously
|
|
||||||
// show an message pop-up in VsCode
|
|
||||||
// RawResponse::err(
|
|
||||||
// id,
|
|
||||||
// ErrorCode::ContentModified as i32,
|
|
||||||
// "content modified".to_string(),
|
|
||||||
// )
|
|
||||||
RawResponse {
|
|
||||||
id,
|
|
||||||
result: Some(serde_json::to_value(&()).unwrap()),
|
|
||||||
error: None,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
RawResponse::err(
|
|
||||||
id,
|
|
||||||
ErrorCode::InternalError as i32,
|
|
||||||
format!("{}\n{}", e, e.backtrace()),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
let task = Task::Respond(response);
|
|
||||||
sender.send(task).unwrap();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,6 +492,45 @@ impl<'a> PoolDispatcher<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn result_to_task<R>(id: u64, result: Result<R::Result>) -> Task
|
||||||
|
where
|
||||||
|
R: req::Request + 'static,
|
||||||
|
R::Params: DeserializeOwned + Send + 'static,
|
||||||
|
R::Result: Serialize + 'static,
|
||||||
|
{
|
||||||
|
let response = match result {
|
||||||
|
Ok(resp) => RawResponse::ok::<R>(id, &resp),
|
||||||
|
Err(e) => match e.downcast::<LspError>() {
|
||||||
|
Ok(lsp_error) => RawResponse::err(id, lsp_error.code, lsp_error.message),
|
||||||
|
Err(e) => {
|
||||||
|
if is_canceled(&e) {
|
||||||
|
// FIXME: When https://github.com/Microsoft/vscode-languageserver-node/issues/457
|
||||||
|
// gets fixed, we can return the proper response.
|
||||||
|
// This works around the issue where "content modified" error would continuously
|
||||||
|
// show an message pop-up in VsCode
|
||||||
|
// RawResponse::err(
|
||||||
|
// id,
|
||||||
|
// ErrorCode::ContentModified as i32,
|
||||||
|
// "content modified".to_string(),
|
||||||
|
// )
|
||||||
|
RawResponse {
|
||||||
|
id,
|
||||||
|
result: Some(serde_json::to_value(&()).unwrap()),
|
||||||
|
error: None,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RawResponse::err(
|
||||||
|
id,
|
||||||
|
ErrorCode::InternalError as i32,
|
||||||
|
format!("{}\n{}", e, e.backtrace()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
Task::Respond(response)
|
||||||
|
}
|
||||||
|
|
||||||
fn update_file_notifications_on_threadpool(
|
fn update_file_notifications_on_threadpool(
|
||||||
pool: &ThreadPool,
|
pool: &ThreadPool,
|
||||||
world: ServerWorld,
|
world: ServerWorld,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue