diff options
-rw-r--r-- | Cargo.lock | 8 | ||||
-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 |
6 files changed, 41 insertions, 18 deletions
diff --git a/Cargo.lock b/Cargo.lock index d1a294c30..982463f0b 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -602,12 +602,13 @@ name = "ra_analysis" | |||
602 | version = "0.1.0" | 602 | version = "0.1.0" |
603 | dependencies = [ | 603 | dependencies = [ |
604 | "fst 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", | 604 | "fst 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", |
605 | "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
605 | "ra_editor 0.1.0", | 606 | "ra_editor 0.1.0", |
606 | "ra_syntax 0.1.0", | 607 | "ra_syntax 0.1.0", |
607 | "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 608 | "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
608 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 609 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
609 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 610 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
610 | "salsa 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", | 611 | "salsa 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", |
611 | "test_utils 0.1.0", | 612 | "test_utils 0.1.0", |
612 | ] | 613 | ] |
613 | 614 | ||
@@ -833,11 +834,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
833 | 834 | ||
834 | [[package]] | 835 | [[package]] |
835 | name = "salsa" | 836 | name = "salsa" |
836 | version = "0.6.0" | 837 | version = "0.6.1" |
837 | source = "registry+https://github.com/rust-lang/crates.io-index" | 838 | source = "registry+https://github.com/rust-lang/crates.io-index" |
838 | dependencies = [ | 839 | dependencies = [ |
839 | "derive-new 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", | 840 | "derive-new 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", |
840 | "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 841 | "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
842 | "lock_api 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", | ||
841 | "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", | 843 | "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", |
842 | "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", | 844 | "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", |
843 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 845 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1348,7 +1350,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1348 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" | 1350 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" |
1349 | "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" | 1351 | "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" |
1350 | "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" | 1352 | "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" |
1351 | "checksum salsa 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c8f8b59428c040fbac0f6a2e698ae892e33d23d7519713ba8b243edb3082dad" | 1353 | "checksum salsa 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fc085b9e4a2cf422e798387d0dc1091c6dae97411b2b177755950db9a26dace" |
1352 | "checksum same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10f7794e2fda7f594866840e95f5c5962e886e228e68b6505885811a94dd728c" | 1354 | "checksum same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10f7794e2fda7f594866840e95f5c5962e886e228e68b6505885811a94dd728c" |
1353 | "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" | 1355 | "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" |
1354 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" | 1356 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" |
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 | } | ||