mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 11:20:54 +00:00
Add config: &CargoConfig
parameter to fn load_cargo(…)
This commit is contained in:
parent
433ad23988
commit
6d9c13c710
@ -59,7 +59,12 @@ impl BenchCmd {
|
||||
|
||||
let start = Instant::now();
|
||||
eprint!("loading: ");
|
||||
let (mut host, vfs) = load_cargo(&self.path, self.load_output_dirs, self.with_proc_macro)?;
|
||||
let (mut host, vfs) = load_cargo(
|
||||
&self.path,
|
||||
&Default::default(),
|
||||
self.load_output_dirs,
|
||||
self.with_proc_macro,
|
||||
)?;
|
||||
eprintln!("{:?}\n", start.elapsed());
|
||||
|
||||
let file_id = {
|
||||
|
@ -57,7 +57,12 @@ impl AnalysisStatsCmd {
|
||||
};
|
||||
|
||||
let mut db_load_sw = self.stop_watch();
|
||||
let (host, vfs) = load_cargo(&self.path, self.load_output_dirs, self.with_proc_macro)?;
|
||||
let (host, vfs) = load_cargo(
|
||||
&self.path,
|
||||
&Default::default(),
|
||||
self.load_output_dirs,
|
||||
self.with_proc_macro,
|
||||
)?;
|
||||
let db = host.raw_database();
|
||||
eprintln!("{:<20} {}", "Database loaded:", db_load_sw.elapsed());
|
||||
|
||||
|
@ -26,7 +26,7 @@ fn all_modules(db: &dyn HirDatabase) -> Vec<Module> {
|
||||
}
|
||||
|
||||
pub fn diagnostics(path: &Path, load_output_dirs: bool, with_proc_macro: bool) -> Result<()> {
|
||||
let (host, _vfs) = load_cargo(path, load_output_dirs, with_proc_macro)?;
|
||||
let (host, _vfs) = load_cargo(path, &Default::default(), load_output_dirs, with_proc_macro)?;
|
||||
let db = host.raw_database();
|
||||
let analysis = host.analysis();
|
||||
|
||||
|
@ -15,12 +15,13 @@ use crate::reload::{ProjectFolders, SourceRootConfig};
|
||||
|
||||
pub fn load_cargo(
|
||||
root: &Path,
|
||||
config: &CargoConfig,
|
||||
load_out_dirs_from_check: bool,
|
||||
with_proc_macro: bool,
|
||||
) -> Result<(AnalysisHost, vfs::Vfs)> {
|
||||
let root = AbsPathBuf::assert(std::env::current_dir()?.join(root));
|
||||
let root = ProjectManifest::discover_single(&root)?;
|
||||
let ws = ProjectWorkspace::load(root, &CargoConfig::default(), &|_| {})?;
|
||||
let ws = ProjectWorkspace::load(root, config, &|_| {})?;
|
||||
|
||||
let (sender, receiver) = unbounded();
|
||||
let mut vfs = vfs::Vfs::default();
|
||||
@ -116,7 +117,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_loading_rust_analyzer() {
|
||||
let path = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap();
|
||||
let (host, _vfs) = load_cargo(path, false, false).unwrap();
|
||||
let (host, _vfs) = load_cargo(path, &Default::default(), 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);
|
||||
|
@ -5,7 +5,7 @@ use ssr::{MatchFinder, SsrPattern, SsrRule};
|
||||
|
||||
pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
||||
use ide_db::base_db::SourceDatabaseExt;
|
||||
let (host, vfs) = load_cargo(&std::env::current_dir()?, true, true)?;
|
||||
let (host, vfs) = load_cargo(&std::env::current_dir()?, &Default::default(), true, true)?;
|
||||
let db = host.raw_database();
|
||||
let mut match_finder = MatchFinder::at_first_file(db)?;
|
||||
for rule in rules {
|
||||
@ -28,7 +28,7 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
||||
pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<String>) -> Result<()> {
|
||||
use ide_db::base_db::SourceDatabaseExt;
|
||||
use ide_db::symbol_index::SymbolsDatabase;
|
||||
let (host, _vfs) = load_cargo(&std::env::current_dir()?, true, true)?;
|
||||
let (host, _vfs) = load_cargo(&std::env::current_dir()?, &Default::default(), true, true)?;
|
||||
let db = host.raw_database();
|
||||
let mut match_finder = MatchFinder::at_first_file(db)?;
|
||||
for pattern in patterns {
|
||||
|
Loading…
x
Reference in New Issue
Block a user