aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_batch
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_batch')
-rw-r--r--crates/ra_batch/Cargo.toml3
-rw-r--r--crates/ra_batch/src/lib.rs10
2 files changed, 9 insertions, 4 deletions
diff --git a/crates/ra_batch/Cargo.toml b/crates/ra_batch/Cargo.toml
index 8e23826a4..5fc2703ee 100644
--- a/crates/ra_batch/Cargo.toml
+++ b/crates/ra_batch/Cargo.toml
@@ -7,8 +7,9 @@ authors = ["rust-analyzer developers"]
7[dependencies] 7[dependencies]
8log = "0.4.5" 8log = "0.4.5"
9rustc-hash = "1.0" 9rustc-hash = "1.0"
10crossbeam-channel = "0.3.5"
10 11
11ra_vfs = "0.2.0" 12ra_vfs = "0.3.0"
12ra_vfs_glob = { path = "../ra_vfs_glob" } 13ra_vfs_glob = { path = "../ra_vfs_glob" }
13ra_db = { path = "../ra_db" } 14ra_db = { path = "../ra_db" }
14ra_ide_api = { path = "../ra_ide_api" } 15ra_ide_api = { path = "../ra_ide_api" }
diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs
index f458ea300..4e5bad044 100644
--- a/crates/ra_batch/src/lib.rs
+++ b/crates/ra_batch/src/lib.rs
@@ -2,10 +2,11 @@ use std::{collections::HashSet, error::Error, path::Path};
2 2
3use rustc_hash::FxHashMap; 3use rustc_hash::FxHashMap;
4 4
5use crossbeam_channel::{unbounded, Receiver};
5use ra_db::{CrateGraph, FileId, SourceRootId}; 6use ra_db::{CrateGraph, FileId, SourceRootId};
6use ra_ide_api::{AnalysisChange, AnalysisHost, FeatureFlags}; 7use ra_ide_api::{AnalysisChange, AnalysisHost, FeatureFlags};
7use ra_project_model::{PackageRoot, ProjectWorkspace}; 8use ra_project_model::{PackageRoot, ProjectWorkspace};
8use ra_vfs::{RootEntry, Vfs, VfsChange}; 9use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask};
9use ra_vfs_glob::RustPackageFilterBuilder; 10use ra_vfs_glob::RustPackageFilterBuilder;
10 11
11type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>; 12type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>;
@@ -21,6 +22,8 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId,
21 let root = std::env::current_dir()?.join(root); 22 let root = std::env::current_dir()?.join(root);
22 let ws = ProjectWorkspace::discover(root.as_ref())?; 23 let ws = ProjectWorkspace::discover(root.as_ref())?;
23 let project_roots = ws.to_roots(); 24 let project_roots = ws.to_roots();
25 let (sender, receiver) = unbounded();
26 let sender = Box::new(move |t| sender.send(t).unwrap());
24 let (mut vfs, roots) = Vfs::new( 27 let (mut vfs, roots) = Vfs::new(
25 project_roots 28 project_roots
26 .iter() 29 .iter()
@@ -33,6 +36,7 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId,
33 ) 36 )
34 }) 37 })
35 .collect(), 38 .collect(),
39 sender,
36 ); 40 );
37 let crate_graph = ws.to_crate_graph(&mut |path: &Path| { 41 let crate_graph = ws.to_crate_graph(&mut |path: &Path| {
38 let vfs_file = vfs.load(path); 42 let vfs_file = vfs.load(path);
@@ -53,7 +57,7 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId,
53 (source_root_id, project_root) 57 (source_root_id, project_root)
54 }) 58 })
55 .collect::<FxHashMap<_, _>>(); 59 .collect::<FxHashMap<_, _>>();
56 let host = load(&source_roots, crate_graph, &mut vfs); 60 let host = load(&source_roots, crate_graph, &mut vfs, receiver);
57 Ok((host, source_roots)) 61 Ok((host, source_roots))
58} 62}
59 63
@@ -61,6 +65,7 @@ pub fn load(
61 source_roots: &FxHashMap<SourceRootId, PackageRoot>, 65 source_roots: &FxHashMap<SourceRootId, PackageRoot>,
62 crate_graph: CrateGraph, 66 crate_graph: CrateGraph,
63 vfs: &mut Vfs, 67 vfs: &mut Vfs,
68 receiver: Receiver<VfsTask>,
64) -> AnalysisHost { 69) -> AnalysisHost {
65 let lru_cap = std::env::var("RA_LRU_CAP").ok().and_then(|it| it.parse::<usize>().ok()); 70 let lru_cap = std::env::var("RA_LRU_CAP").ok().and_then(|it| it.parse::<usize>().ok());
66 let mut host = AnalysisHost::new(lru_cap, FeatureFlags::default()); 71 let mut host = AnalysisHost::new(lru_cap, FeatureFlags::default());
@@ -68,7 +73,6 @@ pub fn load(
68 analysis_change.set_crate_graph(crate_graph); 73 analysis_change.set_crate_graph(crate_graph);
69 74
70 // wait until Vfs has loaded all roots 75 // wait until Vfs has loaded all roots
71 let receiver = vfs.task_receiver().clone();
72 let mut roots_loaded = HashSet::new(); 76 let mut roots_loaded = HashSet::new();
73 for task in receiver { 77 for task in receiver {
74 vfs.handle_task(task); 78 vfs.handle_task(task);