mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Merge #7474
7474: Make logger-based debugging more pleasant r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
4a88d93499
3 changed files with 19 additions and 4 deletions
|
@ -76,7 +76,6 @@ impl FlycheckHandle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum Message {
|
pub enum Message {
|
||||||
/// Request adding a diagnostic with fixes included to a file
|
/// Request adding a diagnostic with fixes included to a file
|
||||||
AddDiagnostic { workspace_root: PathBuf, diagnostic: Diagnostic },
|
AddDiagnostic { workspace_root: PathBuf, diagnostic: Diagnostic },
|
||||||
|
@ -89,6 +88,21 @@ pub enum Message {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Message {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
Message::AddDiagnostic { workspace_root, diagnostic } => f
|
||||||
|
.debug_struct("AddDiagnostic")
|
||||||
|
.field("workspace_root", workspace_root)
|
||||||
|
.field("diagnostic_code", &diagnostic.code.as_ref().map(|it| &it.code))
|
||||||
|
.finish(),
|
||||||
|
Message::Progress { id, progress } => {
|
||||||
|
f.debug_struct("Progress").field("id", id).field("progress", progress).finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Progress {
|
pub enum Progress {
|
||||||
DidStart,
|
DidStart,
|
||||||
|
|
|
@ -51,6 +51,7 @@ pub enum ProjectWorkspace {
|
||||||
|
|
||||||
impl fmt::Debug for ProjectWorkspace {
|
impl fmt::Debug for ProjectWorkspace {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
// Make sure this isn't too verbose.
|
||||||
match self {
|
match self {
|
||||||
ProjectWorkspace::Cargo { cargo, sysroot, rustc, rustc_cfg } => f
|
ProjectWorkspace::Cargo { cargo, sysroot, rustc, rustc_cfg } => f
|
||||||
.debug_struct("Cargo")
|
.debug_struct("Cargo")
|
||||||
|
@ -60,7 +61,7 @@ impl fmt::Debug for ProjectWorkspace {
|
||||||
"n_rustc_compiler_crates",
|
"n_rustc_compiler_crates",
|
||||||
&rustc.as_ref().map_or(0, |rc| rc.packages().len()),
|
&rustc.as_ref().map_or(0, |rc| rc.packages().len()),
|
||||||
)
|
)
|
||||||
.field("rustc_cfg", rustc_cfg)
|
.field("n_rustc_cfg", &rustc_cfg.len())
|
||||||
.finish(),
|
.finish(),
|
||||||
ProjectWorkspace::Json { project, sysroot, rustc_cfg } => {
|
ProjectWorkspace::Json { project, sysroot, rustc_cfg } => {
|
||||||
let mut debug_struct = f.debug_struct("Json");
|
let mut debug_struct = f.debug_struct("Json");
|
||||||
|
@ -68,7 +69,7 @@ impl fmt::Debug for ProjectWorkspace {
|
||||||
if let Some(sysroot) = sysroot {
|
if let Some(sysroot) = sysroot {
|
||||||
debug_struct.field("n_sysroot_crates", &sysroot.crates().len());
|
debug_struct.field("n_sysroot_crates", &sysroot.crates().len());
|
||||||
}
|
}
|
||||||
debug_struct.field("rustc_cfg", rustc_cfg);
|
debug_struct.field("n_rustc_cfg", &rustc_cfg.len());
|
||||||
debug_struct.finish()
|
debug_struct.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,10 +103,10 @@ impl GlobalState {
|
||||||
self.fetch_workspaces_queue.request_op()
|
self.fetch_workspaces_queue.request_op()
|
||||||
}
|
}
|
||||||
pub(crate) fn fetch_workspaces_if_needed(&mut self) {
|
pub(crate) fn fetch_workspaces_if_needed(&mut self) {
|
||||||
log::info!("will fetch workspaces");
|
|
||||||
if !self.fetch_workspaces_queue.should_start_op() {
|
if !self.fetch_workspaces_queue.should_start_op() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
log::info!("will fetch workspaces");
|
||||||
|
|
||||||
self.task_pool.handle.spawn_with_sender({
|
self.task_pool.handle.spawn_with_sender({
|
||||||
let linked_projects = self.config.linked_projects();
|
let linked_projects = self.config.linked_projects();
|
||||||
|
|
Loading…
Reference in a new issue