mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Auto merge of #15636 - 9999years:show-which-roots-are-scanned, r=Veykril
Show which roots are being scanned in progress messages This changes the `Roots Scanned` message to include the directory being scanned. Before: `Roots Scanned 206/210 (98%)` After: `Roots Scanned 206/210: .direnv (98%)` This makes it a lot easier to tell that `rust-analyzer` isn't crashed, it's just trying to scan a huge directory. See: #12613
This commit is contained in:
commit
c9afd41219
4 changed files with 48 additions and 7 deletions
|
@ -317,7 +317,7 @@ fn load_crate_graph(
|
||||||
// wait until Vfs has loaded all roots
|
// wait until Vfs has loaded all roots
|
||||||
for task in receiver {
|
for task in receiver {
|
||||||
match task {
|
match task {
|
||||||
vfs::loader::Message::Progress { n_done, n_total, config_version: _ } => {
|
vfs::loader::Message::Progress { n_done, n_total, .. } => {
|
||||||
if n_done == n_total {
|
if n_done == n_total {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -586,7 +586,7 @@ impl GlobalState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vfs::loader::Message::Progress { n_total, n_done, config_version } => {
|
vfs::loader::Message::Progress { n_total, n_done, dir, config_version } => {
|
||||||
always!(config_version <= self.vfs_config_version);
|
always!(config_version <= self.vfs_config_version);
|
||||||
|
|
||||||
self.vfs_progress_config_version = config_version;
|
self.vfs_progress_config_version = config_version;
|
||||||
|
@ -601,10 +601,23 @@ impl GlobalState {
|
||||||
assert_eq!(n_done, n_total);
|
assert_eq!(n_done, n_total);
|
||||||
Progress::End
|
Progress::End
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut message = format!("{n_done}/{n_total}");
|
||||||
|
if let Some(dir) = dir {
|
||||||
|
message += &format!(
|
||||||
|
": {}",
|
||||||
|
match dir.strip_prefix(&self.config.root_path()) {
|
||||||
|
Some(relative_path) => relative_path.as_ref(),
|
||||||
|
None => dir.as_ref(),
|
||||||
|
}
|
||||||
|
.display()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
self.report_progress(
|
self.report_progress(
|
||||||
"Roots Scanned",
|
"Roots Scanned",
|
||||||
state,
|
state,
|
||||||
Some(format!("{n_done}/{n_total}")),
|
Some(message),
|
||||||
Some(Progress::fraction(n_done, n_total)),
|
Some(Progress::fraction(n_done, n_total)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
|
@ -103,7 +103,12 @@ impl NotifyActor {
|
||||||
let config_version = config.version;
|
let config_version = config.version;
|
||||||
|
|
||||||
let n_total = config.load.len();
|
let n_total = config.load.len();
|
||||||
self.send(loader::Message::Progress { n_total, n_done: 0, config_version });
|
self.send(loader::Message::Progress {
|
||||||
|
n_total,
|
||||||
|
n_done: 0,
|
||||||
|
config_version,
|
||||||
|
dir: None,
|
||||||
|
});
|
||||||
|
|
||||||
self.watched_entries.clear();
|
self.watched_entries.clear();
|
||||||
|
|
||||||
|
@ -112,12 +117,19 @@ impl NotifyActor {
|
||||||
if watch {
|
if watch {
|
||||||
self.watched_entries.push(entry.clone());
|
self.watched_entries.push(entry.clone());
|
||||||
}
|
}
|
||||||
let files = self.load_entry(entry, watch);
|
let files =
|
||||||
|
self.load_entry(entry, watch, |file| loader::Message::Progress {
|
||||||
|
n_total,
|
||||||
|
n_done: i,
|
||||||
|
dir: Some(file),
|
||||||
|
config_version,
|
||||||
|
});
|
||||||
self.send(loader::Message::Loaded { files });
|
self.send(loader::Message::Loaded { files });
|
||||||
self.send(loader::Message::Progress {
|
self.send(loader::Message::Progress {
|
||||||
n_total,
|
n_total,
|
||||||
n_done: i + 1,
|
n_done: i + 1,
|
||||||
config_version,
|
config_version,
|
||||||
|
dir: None,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,6 +182,7 @@ impl NotifyActor {
|
||||||
&mut self,
|
&mut self,
|
||||||
entry: loader::Entry,
|
entry: loader::Entry,
|
||||||
watch: bool,
|
watch: bool,
|
||||||
|
make_message: impl Fn(AbsPathBuf) -> loader::Message,
|
||||||
) -> Vec<(AbsPathBuf, Option<Vec<u8>>)> {
|
) -> Vec<(AbsPathBuf, Option<Vec<u8>>)> {
|
||||||
match entry {
|
match entry {
|
||||||
loader::Entry::Files(files) => files
|
loader::Entry::Files(files) => files
|
||||||
|
@ -186,6 +199,7 @@ impl NotifyActor {
|
||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
|
|
||||||
for root in &dirs.include {
|
for root in &dirs.include {
|
||||||
|
self.send(make_message(root.clone()));
|
||||||
let walkdir =
|
let walkdir =
|
||||||
WalkDir::new(root).follow_links(true).into_iter().filter_entry(|entry| {
|
WalkDir::new(root).follow_links(true).into_iter().filter_entry(|entry| {
|
||||||
if !entry.file_type().is_dir() {
|
if !entry.file_type().is_dir() {
|
||||||
|
@ -197,9 +211,13 @@ impl NotifyActor {
|
||||||
});
|
});
|
||||||
|
|
||||||
let files = walkdir.filter_map(|it| it.ok()).filter_map(|entry| {
|
let files = walkdir.filter_map(|it| it.ok()).filter_map(|entry| {
|
||||||
|
let depth = entry.depth();
|
||||||
let is_dir = entry.file_type().is_dir();
|
let is_dir = entry.file_type().is_dir();
|
||||||
let is_file = entry.file_type().is_file();
|
let is_file = entry.file_type().is_file();
|
||||||
let abs_path = AbsPathBuf::assert(entry.into_path());
|
let abs_path = AbsPathBuf::assert(entry.into_path());
|
||||||
|
if depth < 2 && is_dir {
|
||||||
|
self.send(make_message(abs_path.clone()));
|
||||||
|
}
|
||||||
if is_dir && watch {
|
if is_dir && watch {
|
||||||
self.watch(abs_path.clone());
|
self.watch(abs_path.clone());
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,16 @@ pub enum Message {
|
||||||
/// Indicate a gradual progress.
|
/// Indicate a gradual progress.
|
||||||
///
|
///
|
||||||
/// This is supposed to be the number of loaded files.
|
/// This is supposed to be the number of loaded files.
|
||||||
Progress { n_total: usize, n_done: usize, config_version: u32 },
|
Progress {
|
||||||
|
/// The total files to be loaded.
|
||||||
|
n_total: usize,
|
||||||
|
/// The files that have been loaded successfully.
|
||||||
|
n_done: usize,
|
||||||
|
/// The dir being loaded, `None` if its for a file.
|
||||||
|
dir: Option<AbsPathBuf>,
|
||||||
|
/// The [`Config`] version.
|
||||||
|
config_version: u32,
|
||||||
|
},
|
||||||
/// The handle loaded the following files' content.
|
/// The handle loaded the following files' content.
|
||||||
Loaded { files: Vec<(AbsPathBuf, Option<Vec<u8>>)> },
|
Loaded { files: Vec<(AbsPathBuf, Option<Vec<u8>>)> },
|
||||||
/// The handle loaded the following files' content.
|
/// The handle loaded the following files' content.
|
||||||
|
@ -204,10 +213,11 @@ impl fmt::Debug for Message {
|
||||||
Message::Changed { files } => {
|
Message::Changed { files } => {
|
||||||
f.debug_struct("Changed").field("n_files", &files.len()).finish()
|
f.debug_struct("Changed").field("n_files", &files.len()).finish()
|
||||||
}
|
}
|
||||||
Message::Progress { n_total, n_done, config_version } => f
|
Message::Progress { n_total, n_done, dir, config_version } => f
|
||||||
.debug_struct("Progress")
|
.debug_struct("Progress")
|
||||||
.field("n_total", n_total)
|
.field("n_total", n_total)
|
||||||
.field("n_done", n_done)
|
.field("n_done", n_done)
|
||||||
|
.field("dir", dir)
|
||||||
.field("config_version", config_version)
|
.field("config_version", config_version)
|
||||||
.finish(),
|
.finish(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue