diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_analysis/src/db/mod.rs | 9 | ||||
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 2 | ||||
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 19 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/mod.rs | 20 |
5 files changed, 36 insertions, 15 deletions
diff --git a/crates/ra_analysis/Cargo.toml b/crates/ra_analysis/Cargo.toml index 75a9dc844..b9f9cd7a7 100644 --- a/crates/ra_analysis/Cargo.toml +++ b/crates/ra_analysis/Cargo.toml | |||
@@ -5,6 +5,7 @@ version = "0.1.0" | |||
5 | authors = ["Aleksey Kladov <[email protected]>"] | 5 | authors = ["Aleksey Kladov <[email protected]>"] |
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | log = "0.4.5" | ||
8 | relative-path = "0.4.0" | 9 | relative-path = "0.4.0" |
9 | rayon = "1.0.2" | 10 | rayon = "1.0.2" |
10 | fst = "0.3.1" | 11 | fst = "0.3.1" |
diff --git a/crates/ra_analysis/src/db/mod.rs b/crates/ra_analysis/src/db/mod.rs index 8387118ad..1a9023697 100644 --- a/crates/ra_analysis/src/db/mod.rs +++ b/crates/ra_analysis/src/db/mod.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | pub(crate) mod input; | 1 | pub(crate) mod input; |
2 | 2 | ||
3 | use std::{ | 3 | use std::{ |
4 | fmt, | ||
5 | sync::Arc, | 4 | sync::Arc, |
6 | }; | 5 | }; |
7 | 6 | ||
@@ -17,17 +16,11 @@ use crate::{ | |||
17 | FileId, | 16 | FileId, |
18 | }; | 17 | }; |
19 | 18 | ||
20 | #[derive(Default)] | 19 | #[derive(Default, Debug)] |
21 | pub(crate) struct RootDatabase { | 20 | pub(crate) struct RootDatabase { |
22 | runtime: salsa::Runtime<RootDatabase>, | 21 | runtime: salsa::Runtime<RootDatabase>, |
23 | } | 22 | } |
24 | 23 | ||
25 | impl fmt::Debug for RootDatabase { | ||
26 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||
27 | fmt.write_str("RootDatabase { ... }") | ||
28 | } | ||
29 | } | ||
30 | |||
31 | impl salsa::Database for RootDatabase { | 24 | impl salsa::Database for RootDatabase { |
32 | fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> { | 25 | fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> { |
33 | &self.runtime | 26 | &self.runtime |
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 97ed55465..6c1a4749a 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -98,6 +98,8 @@ impl AnalysisHostImpl { | |||
98 | } | 98 | } |
99 | } | 99 | } |
100 | pub fn apply_change(&mut self, change: AnalysisChange) { | 100 | pub fn apply_change(&mut self, change: AnalysisChange) { |
101 | log::info!("apply_change {:?}", change); | ||
102 | |||
101 | for (file_id, text) in change.files_changed { | 103 | for (file_id, text) in change.files_changed { |
102 | self.db | 104 | self.db |
103 | .query(db::input::FileTextQuery) | 105 | .query(db::input::FileTextQuery) |
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 4a1ae3b64..703938cf9 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -13,7 +13,7 @@ mod symbol_index; | |||
13 | mod completion; | 13 | mod completion; |
14 | 14 | ||
15 | use std::{ | 15 | use std::{ |
16 | fmt::Debug, | 16 | fmt, |
17 | sync::Arc, | 17 | sync::Arc, |
18 | collections::BTreeMap, | 18 | collections::BTreeMap, |
19 | }; | 19 | }; |
@@ -60,12 +60,12 @@ pub struct CrateGraph { | |||
60 | pub crate_roots: BTreeMap<CrateId, FileId>, | 60 | pub crate_roots: BTreeMap<CrateId, FileId>, |
61 | } | 61 | } |
62 | 62 | ||
63 | pub trait FileResolver: Debug + Send + Sync + 'static { | 63 | pub trait FileResolver: fmt::Debug + Send + Sync + 'static { |
64 | fn file_stem(&self, file_id: FileId) -> String; | 64 | fn file_stem(&self, file_id: FileId) -> String; |
65 | fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId>; | 65 | fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId>; |
66 | } | 66 | } |
67 | 67 | ||
68 | #[derive(Debug, Default)] | 68 | #[derive(Default)] |
69 | pub struct AnalysisChange { | 69 | pub struct AnalysisChange { |
70 | files_added: Vec<(FileId, String)>, | 70 | files_added: Vec<(FileId, String)>, |
71 | files_changed: Vec<(FileId, String)>, | 71 | files_changed: Vec<(FileId, String)>, |
@@ -75,6 +75,19 @@ pub struct AnalysisChange { | |||
75 | file_resolver: Option<FileResolverImp>, | 75 | file_resolver: Option<FileResolverImp>, |
76 | } | 76 | } |
77 | 77 | ||
78 | impl fmt::Debug for AnalysisChange { | ||
79 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||
80 | fmt.debug_struct("AnalysisChange") | ||
81 | .field("files_added", &self.files_added.len()) | ||
82 | .field("files_changed", &self.files_changed.len()) | ||
83 | .field("files_removed", &self.files_removed.len()) | ||
84 | .field("libraries_added", &self.libraries_added.len()) | ||
85 | .field("crate_graph", &self.crate_graph) | ||
86 | .field("file_resolver", &self.file_resolver) | ||
87 | .finish() | ||
88 | } | ||
89 | } | ||
90 | |||
78 | 91 | ||
79 | impl AnalysisChange { | 92 | impl AnalysisChange { |
80 | pub fn new() -> AnalysisChange { | 93 | pub fn new() -> AnalysisChange { |
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 | }; |
10 | use languageserver_types::NumberOrString; | 10 | use languageserver_types::NumberOrString; |
11 | use ra_analysis::{FileId, LibraryData}; | 11 | use ra_analysis::{Canceled, FileId, LibraryData}; |
12 | use rayon::{self, ThreadPool}; | 12 | use rayon::{self, ThreadPool}; |
13 | use rustc_hash::FxHashSet; | 13 | use rustc_hash::FxHashSet; |
14 | use serde::{de::DeserializeOwned, Serialize}; | 14 | use 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>(¶ms); | 417 | let not = RawNotification::new::<req::PublishDiagnostics>(¶ms); |
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>(¶ms); | 428 | let not = RawNotification::new::<req::PublishDecorations>(¶ms); |
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 | |||
444 | fn is_canceled(e: &failure::Error) -> bool { | ||
445 | e.downcast_ref::<Canceled>().is_some() | ||
446 | } | ||