Add with-proc-macro in bench ,stats and diagnositcs

This commit is contained in:
Edwin Cheng
2020-04-12 18:25:31 +08:00
parent aa887d7ab4
commit 22e33f308a
6 changed files with 49 additions and 13 deletions

View File

@@ -47,12 +47,13 @@ pub fn analysis_bench(
path: &Path,
what: BenchWhat,
load_output_dirs: bool,
with_proc_macro: bool,
) -> Result<()> {
ra_prof::init();
let start = Instant::now();
eprint!("loading: ");
let (mut host, roots) = load_cargo(path, load_output_dirs)?;
let (mut host, roots) = load_cargo(path, load_output_dirs, with_proc_macro)?;
let db = host.raw_database();
eprintln!("{:?}\n", start.elapsed());

View File

@@ -25,9 +25,10 @@ pub fn analysis_stats(
with_deps: bool,
randomize: bool,
load_output_dirs: bool,
with_proc_macro: bool,
) -> Result<()> {
let db_load_time = Instant::now();
let (mut host, roots) = load_cargo(path, load_output_dirs)?;
let (mut host, roots) = load_cargo(path, load_output_dirs, with_proc_macro)?;
let db = host.raw_database();
println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed());
let analysis_time = Instant::now();

View File

@@ -9,8 +9,13 @@ use std::{collections::HashSet, path::Path};
use crate::cli::{load_cargo::load_cargo, Result};
use hir::Semantics;
pub fn diagnostics(path: &Path, load_output_dirs: bool, all: bool) -> Result<()> {
let (host, roots) = load_cargo(path, load_output_dirs)?;
pub fn diagnostics(
path: &Path,
load_output_dirs: bool,
with_proc_macro: bool,
all: bool,
) -> Result<()> {
let (host, roots) = load_cargo(path, load_output_dirs, with_proc_macro)?;
let db = host.raw_database();
let analysis = host.analysis();
let semantics = Semantics::new(db);

View File

@@ -25,6 +25,7 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId {
pub(crate) fn load_cargo(
root: &Path,
load_out_dirs_from_check: bool,
with_proc_macro: bool,
) -> Result<(AnalysisHost, FxHashMap<SourceRootId, PackageRoot>)> {
let root = std::env::current_dir()?.join(root);
let ws = ProjectWorkspace::discover(
@@ -69,7 +70,11 @@ pub(crate) fn load_cargo(
})
.collect::<FxHashMap<_, _>>();
let proc_macro_client = ProcMacroClient::dummy();
let proc_macro_client = if with_proc_macro {
ProcMacroClient::dummy()
} else {
ProcMacroClient::extern_process(Path::new("ra_proc_macro_srv")).unwrap()
};
let host = load(&source_roots, ws, &mut vfs, receiver, extern_dirs, &proc_macro_client);
Ok((host, source_roots))
}
@@ -175,7 +180,7 @@ mod tests {
#[test]
fn test_loading_rust_analyzer() {
let path = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap();
let (host, _roots) = load_cargo(path, false).unwrap();
let (host, _roots) = load_cargo(path, false, false).unwrap();
let n_crates = Crate::all(host.raw_database()).len();
// RA has quite a few crates, but the exact count doesn't matter
assert!(n_crates > 20);