add --with-deps option to analysis-stats

This commit is contained in:
Aleksey Kladov 2019-10-24 12:32:19 +03:00
parent 018b621f61
commit 5750ee69ff
2 changed files with 10 additions and 8 deletions

View file

@ -13,6 +13,7 @@ pub fn run(
memory_usage: bool, memory_usage: bool,
path: &Path, path: &Path,
only: Option<&str>, only: Option<&str>,
with_deps: bool,
) -> Result<()> { ) -> Result<()> {
let db_load_time = Instant::now(); let db_load_time = Instant::now();
let (mut host, roots) = ra_batch::load_cargo(path)?; let (mut host, roots) = ra_batch::load_cargo(path)?;
@ -23,18 +24,17 @@ pub fn run(
let mut visited_modules = HashSet::new(); let mut visited_modules = HashSet::new();
let mut visit_queue = Vec::new(); let mut visit_queue = Vec::new();
let members = roots let members =
.into_iter() roots
.filter_map( .into_iter()
|(source_root_id, project_root)| { .filter_map(|(source_root_id, project_root)| {
if project_root.is_member() { if with_deps || project_root.is_member() {
Some(source_root_id) Some(source_root_id)
} else { } else {
None None
} }
}, })
) .collect::<HashSet<_>>();
.collect::<HashSet<_>>();
for krate in Crate::all(db) { for krate in Crate::all(db) {
let module = krate.root_module(db).expect("crate without root module"); let module = krate.root_module(db).expect("crate without root module");

View file

@ -96,6 +96,7 @@ fn main() -> Result<()> {
}; };
let memory_usage = matches.contains("--memory-usage"); let memory_usage = matches.contains("--memory-usage");
let only: Option<String> = matches.opt_value_from_str(["-o", "--only"])?; let only: Option<String> = matches.opt_value_from_str(["-o", "--only"])?;
let with_deps: bool = matches.contains("--with-deps");
let path = { let path = {
let mut trailing = matches.free()?; let mut trailing = matches.free()?;
if trailing.len() != 1 { if trailing.len() != 1 {
@ -109,6 +110,7 @@ fn main() -> Result<()> {
memory_usage, memory_usage,
path.as_ref(), path.as_ref(),
only.as_ref().map(String::as_ref), only.as_ref().map(String::as_ref),
with_deps,
)?; )?;
} }
"analysis-bench" => { "analysis-bench" => {