diff options
author | Aleksey Kladov <[email protected]> | 2021-01-28 14:04:44 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-01-28 14:07:53 +0000 |
commit | 4b59c3a538f27238b0466898f1b4ac69d1f9e778 (patch) | |
tree | 24c652859d30afdf198883e7f0cbe15f609682b6 | |
parent | a44f6c18fb8b87c9e8deb1ff878f2fef84912b3f (diff) |
Make logger-based debugging more pleasant
-rw-r--r-- | crates/flycheck/src/lib.rs | 16 | ||||
-rw-r--r-- | crates/project_model/src/workspace.rs | 5 | ||||
-rw-r--r-- | crates/rust-analyzer/src/reload.rs | 2 |
3 files changed, 19 insertions, 4 deletions
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 4388e8c67..e04208006 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs | |||
@@ -76,7 +76,6 @@ impl FlycheckHandle { | |||
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | #[derive(Debug)] | ||
80 | pub enum Message { | 79 | pub enum Message { |
81 | /// Request adding a diagnostic with fixes included to a file | 80 | /// Request adding a diagnostic with fixes included to a file |
82 | AddDiagnostic { workspace_root: PathBuf, diagnostic: Diagnostic }, | 81 | AddDiagnostic { workspace_root: PathBuf, diagnostic: Diagnostic }, |
@@ -89,6 +88,21 @@ pub enum Message { | |||
89 | }, | 88 | }, |
90 | } | 89 | } |
91 | 90 | ||
91 | impl fmt::Debug for Message { | ||
92 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
93 | match self { | ||
94 | Message::AddDiagnostic { workspace_root, diagnostic } => f | ||
95 | .debug_struct("AddDiagnostic") | ||
96 | .field("workspace_root", workspace_root) | ||
97 | .field("diagnostic_code", &diagnostic.code.as_ref().map(|it| &it.code)) | ||
98 | .finish(), | ||
99 | Message::Progress { id, progress } => { | ||
100 | f.debug_struct("Progress").field("id", id).field("progress", progress).finish() | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | |||
92 | #[derive(Debug)] | 106 | #[derive(Debug)] |
93 | pub enum Progress { | 107 | pub enum Progress { |
94 | DidStart, | 108 | DidStart, |
diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs index bc5041e5a..559f4e7bf 100644 --- a/crates/project_model/src/workspace.rs +++ b/crates/project_model/src/workspace.rs | |||
@@ -51,6 +51,7 @@ pub enum ProjectWorkspace { | |||
51 | 51 | ||
52 | impl fmt::Debug for ProjectWorkspace { | 52 | impl fmt::Debug for ProjectWorkspace { |
53 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | 53 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
54 | // Make sure this isn't too verbose. | ||
54 | match self { | 55 | match self { |
55 | ProjectWorkspace::Cargo { cargo, sysroot, rustc, rustc_cfg } => f | 56 | ProjectWorkspace::Cargo { cargo, sysroot, rustc, rustc_cfg } => f |
56 | .debug_struct("Cargo") | 57 | .debug_struct("Cargo") |
@@ -60,7 +61,7 @@ impl fmt::Debug for ProjectWorkspace { | |||
60 | "n_rustc_compiler_crates", | 61 | "n_rustc_compiler_crates", |
61 | &rustc.as_ref().map_or(0, |rc| rc.packages().len()), | 62 | &rustc.as_ref().map_or(0, |rc| rc.packages().len()), |
62 | ) | 63 | ) |
63 | .field("rustc_cfg", rustc_cfg) | 64 | .field("n_rustc_cfg", &rustc_cfg.len()) |
64 | .finish(), | 65 | .finish(), |
65 | ProjectWorkspace::Json { project, sysroot, rustc_cfg } => { | 66 | ProjectWorkspace::Json { project, sysroot, rustc_cfg } => { |
66 | let mut debug_struct = f.debug_struct("Json"); | 67 | let mut debug_struct = f.debug_struct("Json"); |
@@ -68,7 +69,7 @@ impl fmt::Debug for ProjectWorkspace { | |||
68 | if let Some(sysroot) = sysroot { | 69 | if let Some(sysroot) = sysroot { |
69 | debug_struct.field("n_sysroot_crates", &sysroot.crates().len()); | 70 | debug_struct.field("n_sysroot_crates", &sysroot.crates().len()); |
70 | } | 71 | } |
71 | debug_struct.field("rustc_cfg", rustc_cfg); | 72 | debug_struct.field("n_rustc_cfg", &rustc_cfg.len()); |
72 | debug_struct.finish() | 73 | debug_struct.finish() |
73 | } | 74 | } |
74 | } | 75 | } |
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 0507186dc..ef73099cf 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs | |||
@@ -103,10 +103,10 @@ impl GlobalState { | |||
103 | self.fetch_workspaces_queue.request_op() | 103 | self.fetch_workspaces_queue.request_op() |
104 | } | 104 | } |
105 | pub(crate) fn fetch_workspaces_if_needed(&mut self) { | 105 | pub(crate) fn fetch_workspaces_if_needed(&mut self) { |
106 | log::info!("will fetch workspaces"); | ||
107 | if !self.fetch_workspaces_queue.should_start_op() { | 106 | if !self.fetch_workspaces_queue.should_start_op() { |
108 | return; | 107 | return; |
109 | } | 108 | } |
109 | log::info!("will fetch workspaces"); | ||
110 | 110 | ||
111 | self.task_pool.handle.spawn_with_sender({ | 111 | self.task_pool.handle.spawn_with_sender({ |
112 | let linked_projects = self.config.linked_projects(); | 112 | let linked_projects = self.config.linked_projects(); |