diff options
author | Aleksey Kladov <[email protected]> | 2019-08-25 11:04:56 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-08-25 11:13:08 +0100 |
commit | ee932d464b2c15b9c130e734a01fc50e5a18d106 (patch) | |
tree | 04465e054f673c1433b1568ee2dedc9ba81ff425 /crates/ra_batch/src | |
parent | fdece911fe8e2f3c22760ea22038a6d00cb70dfa (diff) |
:arrow_up: vfs
Diffstat (limited to 'crates/ra_batch/src')
-rw-r--r-- | crates/ra_batch/src/lib.rs | 10 |
1 files changed, 7 insertions, 3 deletions
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 | ||
3 | use rustc_hash::FxHashMap; | 3 | use rustc_hash::FxHashMap; |
4 | 4 | ||
5 | use crossbeam_channel::{unbounded, Receiver}; | ||
5 | use ra_db::{CrateGraph, FileId, SourceRootId}; | 6 | use ra_db::{CrateGraph, FileId, SourceRootId}; |
6 | use ra_ide_api::{AnalysisChange, AnalysisHost, FeatureFlags}; | 7 | use ra_ide_api::{AnalysisChange, AnalysisHost, FeatureFlags}; |
7 | use ra_project_model::{PackageRoot, ProjectWorkspace}; | 8 | use ra_project_model::{PackageRoot, ProjectWorkspace}; |
8 | use ra_vfs::{RootEntry, Vfs, VfsChange}; | 9 | use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask}; |
9 | use ra_vfs_glob::RustPackageFilterBuilder; | 10 | use ra_vfs_glob::RustPackageFilterBuilder; |
10 | 11 | ||
11 | type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>; | 12 | type 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); |