aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-10-25 16:04:48 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-10-25 16:04:48 +0100
commit5932bd0bb5fcd066a9d16abcd1597b7097978085 (patch)
tree7b6ea86855fe34c3d45d14262c8cf94e315566e8 /crates/ra_lsp_server/src/main_loop
parent2cb2074c4b7219b32993abdcc7084637c0123d49 (diff)
parent363adf07b7763cfe7e13fac0ee148361d51834e4 (diff)
Merge #162
162: Db everywhere r=matklad a=matklad This PR continues our switch to salsa. Now *all* state is handled by a single salsa database. Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r--crates/ra_lsp_server/src/main_loop/mod.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs
index e681062ca..9ddc3fd0b 100644
--- a/crates/ra_lsp_server/src/main_loop/mod.rs
+++ b/crates/ra_lsp_server/src/main_loop/mod.rs
@@ -8,7 +8,7 @@ use gen_lsp_server::{
8 handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse, 8 handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse,
9}; 9};
10use languageserver_types::NumberOrString; 10use languageserver_types::NumberOrString;
11use ra_analysis::{FileId, LibraryData}; 11use ra_analysis::{Canceled, FileId, LibraryData};
12use rayon::{self, ThreadPool}; 12use rayon::{self, ThreadPool};
13use rustc_hash::FxHashSet; 13use rustc_hash::FxHashSet;
14use serde::{de::DeserializeOwned, Serialize}; 14use serde::{de::DeserializeOwned, Serialize};
@@ -376,7 +376,7 @@ impl<'a> PoolDispatcher<'a> {
376 Err(e) => { 376 Err(e) => {
377 match e.downcast::<LspError>() { 377 match e.downcast::<LspError>() {
378 Ok(lsp_error) => RawResponse::err(id, lsp_error.code, lsp_error.message), 378 Ok(lsp_error) => RawResponse::err(id, lsp_error.code, lsp_error.message),
379 Err(e) => RawResponse::err(id, ErrorCode::InternalError as i32, e.to_string()) 379 Err(e) => RawResponse::err(id, ErrorCode::InternalError as i32, format!("{}\n{}", e, e.backtrace()))
380 } 380 }
381 } 381 }
382 }; 382 };
@@ -408,14 +408,22 @@ fn update_file_notifications_on_threadpool(
408 pool.spawn(move || { 408 pool.spawn(move || {
409 for file_id in subscriptions { 409 for file_id in subscriptions {
410 match handlers::publish_diagnostics(&world, file_id) { 410 match handlers::publish_diagnostics(&world, file_id) {
411 Err(e) => error!("failed to compute diagnostics: {:?}", e), 411 Err(e) => {
412 if !is_canceled(&e) {
413 error!("failed to compute diagnostics: {:?}", e);
414 }
415 },
412 Ok(params) => { 416 Ok(params) => {
413 let not = RawNotification::new::<req::PublishDiagnostics>(&params); 417 let not = RawNotification::new::<req::PublishDiagnostics>(&params);
414 sender.send(Task::Notify(not)); 418 sender.send(Task::Notify(not));
415 } 419 }
416 } 420 }
417 match handlers::publish_decorations(&world, file_id) { 421 match handlers::publish_decorations(&world, file_id) {
418 Err(e) => error!("failed to compute decorations: {:?}", e), 422 Err(e) => {
423 if !is_canceled(&e) {
424 error!("failed to compute decorations: {:?}", e);
425 }
426 },
419 Ok(params) => { 427 Ok(params) => {
420 let not = RawNotification::new::<req::PublishDecorations>(&params); 428 let not = RawNotification::new::<req::PublishDecorations>(&params);
421 sender.send(Task::Notify(not)) 429 sender.send(Task::Notify(not))
@@ -432,3 +440,7 @@ fn feedback(intrnal_mode: bool, msg: &str, sender: &Sender<RawMessage>) {
432 let not = RawNotification::new::<req::InternalFeedback>(&msg.to_string()); 440 let not = RawNotification::new::<req::InternalFeedback>(&msg.to_string());
433 sender.send(RawMessage::Notification(not)); 441 sender.send(RawMessage::Notification(not));
434} 442}
443
444fn is_canceled(e: &failure::Error) -> bool {
445 e.downcast_ref::<Canceled>().is_some()
446}