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 | |
parent | fdece911fe8e2f3c22760ea22038a6d00cb70dfa (diff) |
:arrow_up: vfs
-rw-r--r-- | Cargo.lock | 11 | ||||
-rw-r--r-- | crates/ra_batch/Cargo.toml | 3 | ||||
-rw-r--r-- | crates/ra_batch/src/lib.rs | 10 | ||||
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/world.rs | 10 | ||||
-rw-r--r-- | crates/ra_vfs_glob/Cargo.toml | 2 |
7 files changed, 25 insertions, 15 deletions
diff --git a/Cargo.lock b/Cargo.lock index 84f9f8ccd..e2938b5f8 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -1080,12 +1080,13 @@ dependencies = [ | |||
1080 | name = "ra_batch" | 1080 | name = "ra_batch" |
1081 | version = "0.1.0" | 1081 | version = "0.1.0" |
1082 | dependencies = [ | 1082 | dependencies = [ |
1083 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1083 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1084 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1084 | "ra_db 0.1.0", | 1085 | "ra_db 0.1.0", |
1085 | "ra_hir 0.1.0", | 1086 | "ra_hir 0.1.0", |
1086 | "ra_ide_api 0.1.0", | 1087 | "ra_ide_api 0.1.0", |
1087 | "ra_project_model 0.1.0", | 1088 | "ra_project_model 0.1.0", |
1088 | "ra_vfs 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1089 | "ra_vfs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1089 | "ra_vfs_glob 0.1.0", | 1090 | "ra_vfs_glob 0.1.0", |
1090 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1091 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1091 | ] | 1092 | ] |
@@ -1191,7 +1192,7 @@ dependencies = [ | |||
1191 | "ra_project_model 0.1.0", | 1192 | "ra_project_model 0.1.0", |
1192 | "ra_syntax 0.1.0", | 1193 | "ra_syntax 0.1.0", |
1193 | "ra_text_edit 0.1.0", | 1194 | "ra_text_edit 0.1.0", |
1194 | "ra_vfs 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1195 | "ra_vfs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1195 | "ra_vfs_glob 0.1.0", | 1196 | "ra_vfs_glob 0.1.0", |
1196 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1197 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1197 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1198 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1300,7 +1301,7 @@ dependencies = [ | |||
1300 | 1301 | ||
1301 | [[package]] | 1302 | [[package]] |
1302 | name = "ra_vfs" | 1303 | name = "ra_vfs" |
1303 | version = "0.2.8" | 1304 | version = "0.3.0" |
1304 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1305 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1305 | dependencies = [ | 1306 | dependencies = [ |
1306 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", | 1307 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1318,7 +1319,7 @@ name = "ra_vfs_glob" | |||
1318 | version = "0.1.0" | 1319 | version = "0.1.0" |
1319 | dependencies = [ | 1320 | dependencies = [ |
1320 | "globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", | 1321 | "globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", |
1321 | "ra_vfs 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1322 | "ra_vfs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1322 | ] | 1323 | ] |
1323 | 1324 | ||
1324 | [[package]] | 1325 | [[package]] |
@@ -2120,7 +2121,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2120 | "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" | 2121 | "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" |
2121 | "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" | 2122 | "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" |
2122 | "checksum ra_rustc_lexer 0.1.0-pre.3 (registry+https://github.com/rust-lang/crates.io-index)" = "04371af481820ff8d35c7d12b503eb09cf9e1bd246269bf4a33e3d8c54fa3a4a" | 2123 | "checksum ra_rustc_lexer 0.1.0-pre.3 (registry+https://github.com/rust-lang/crates.io-index)" = "04371af481820ff8d35c7d12b503eb09cf9e1bd246269bf4a33e3d8c54fa3a4a" |
2123 | "checksum ra_vfs 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9e891866e1bb03f50a28cc01e3f244a62107c301ae674ba06b2e7a9b310ae75a" | 2124 | "checksum ra_vfs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc8b709e0b7ceec822513451b610df1b9370b01953a8bc545a041a6b3bfef01" |
2124 | "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" | 2125 | "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" |
2125 | "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" | 2126 | "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" |
2126 | "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" | 2127 | "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" |
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] |
8 | log = "0.4.5" | 8 | log = "0.4.5" |
9 | rustc-hash = "1.0" | 9 | rustc-hash = "1.0" |
10 | crossbeam-channel = "0.3.5" | ||
10 | 11 | ||
11 | ra_vfs = "0.2.0" | 12 | ra_vfs = "0.3.0" |
12 | ra_vfs_glob = { path = "../ra_vfs_glob" } | 13 | ra_vfs_glob = { path = "../ra_vfs_glob" } |
13 | ra_db = { path = "../ra_db" } | 14 | ra_db = { path = "../ra_db" } |
14 | ra_ide_api = { path = "../ra_ide_api" } | 15 | ra_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 | ||
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); |
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index afeac0d8a..e271c257b 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -16,7 +16,7 @@ lsp-types = { version = "0.60.0", features = ["proposed"] } | |||
16 | rustc-hash = "1.0" | 16 | rustc-hash = "1.0" |
17 | parking_lot = "0.9.0" | 17 | parking_lot = "0.9.0" |
18 | 18 | ||
19 | ra_vfs = "0.2.7" | 19 | ra_vfs = "0.3.0" |
20 | thread_worker = { path = "../thread_worker" } | 20 | thread_worker = { path = "../thread_worker" } |
21 | ra_syntax = { path = "../ra_syntax" } | 21 | ra_syntax = { path = "../ra_syntax" } |
22 | ra_text_edit = { path = "../ra_text_edit" } | 22 | ra_text_edit = { path = "../ra_text_edit" } |
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index ce25ff162..45bd52769 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -217,7 +217,7 @@ fn main_loop_inner( | |||
217 | Err(RecvError) => Err("client exited without shutdown")?, | 217 | Err(RecvError) => Err("client exited without shutdown")?, |
218 | }, | 218 | }, |
219 | recv(task_receiver) -> task => Event::Task(task.unwrap()), | 219 | recv(task_receiver) -> task => Event::Task(task.unwrap()), |
220 | recv(state.vfs.read().task_receiver()) -> task => match task { | 220 | recv(state.task_receiver) -> task => match task { |
221 | Ok(task) => Event::Vfs(task), | 221 | Ok(task) => Event::Vfs(task), |
222 | Err(RecvError) => Err("vfs died")?, | 222 | Err(RecvError) => Err("vfs died")?, |
223 | }, | 223 | }, |
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 6696dff71..cc7964469 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs | |||
@@ -3,6 +3,7 @@ use std::{ | |||
3 | sync::Arc, | 3 | sync::Arc, |
4 | }; | 4 | }; |
5 | 5 | ||
6 | use crossbeam_channel::{unbounded, Receiver}; | ||
6 | use gen_lsp_server::ErrorCode; | 7 | use gen_lsp_server::ErrorCode; |
7 | use lsp_types::Url; | 8 | use lsp_types::Url; |
8 | use parking_lot::RwLock; | 9 | use parking_lot::RwLock; |
@@ -10,7 +11,7 @@ use ra_ide_api::{ | |||
10 | Analysis, AnalysisChange, AnalysisHost, CrateGraph, FeatureFlags, FileId, LibraryData, | 11 | Analysis, AnalysisChange, AnalysisHost, CrateGraph, FeatureFlags, FileId, LibraryData, |
11 | SourceRootId, | 12 | SourceRootId, |
12 | }; | 13 | }; |
13 | use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot}; | 14 | use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot, VfsTask}; |
14 | use ra_vfs_glob::{Glob, RustPackageFilterBuilder}; | 15 | use ra_vfs_glob::{Glob, RustPackageFilterBuilder}; |
15 | use relative_path::RelativePathBuf; | 16 | use relative_path::RelativePathBuf; |
16 | 17 | ||
@@ -39,6 +40,7 @@ pub struct WorldState { | |||
39 | pub workspaces: Arc<Vec<ProjectWorkspace>>, | 40 | pub workspaces: Arc<Vec<ProjectWorkspace>>, |
40 | pub analysis_host: AnalysisHost, | 41 | pub analysis_host: AnalysisHost, |
41 | pub vfs: Arc<RwLock<Vfs>>, | 42 | pub vfs: Arc<RwLock<Vfs>>, |
43 | pub task_receiver: Receiver<VfsTask>, | ||
42 | pub latest_requests: Arc<RwLock<LatestRequests>>, | 44 | pub latest_requests: Arc<RwLock<LatestRequests>>, |
43 | } | 45 | } |
44 | 46 | ||
@@ -80,8 +82,9 @@ impl WorldState { | |||
80 | RootEntry::new(pkg_root.path().clone(), filter.into_vfs_filter()) | 82 | RootEntry::new(pkg_root.path().clone(), filter.into_vfs_filter()) |
81 | })); | 83 | })); |
82 | } | 84 | } |
83 | 85 | let (task_sender, task_receiver) = unbounded(); | |
84 | let (mut vfs, vfs_roots) = Vfs::new(roots); | 86 | let task_sender = Box::new(move |t| task_sender.send(t).unwrap()); |
87 | let (mut vfs, vfs_roots) = Vfs::new(roots, task_sender); | ||
85 | let roots_to_scan = vfs_roots.len(); | 88 | let roots_to_scan = vfs_roots.len(); |
86 | for r in vfs_roots { | 89 | for r in vfs_roots { |
87 | let vfs_root_path = vfs.root2path(r); | 90 | let vfs_root_path = vfs.root2path(r); |
@@ -109,6 +112,7 @@ impl WorldState { | |||
109 | workspaces: Arc::new(workspaces), | 112 | workspaces: Arc::new(workspaces), |
110 | analysis_host, | 113 | analysis_host, |
111 | vfs: Arc::new(RwLock::new(vfs)), | 114 | vfs: Arc::new(RwLock::new(vfs)), |
115 | task_receiver, | ||
112 | latest_requests: Default::default(), | 116 | latest_requests: Default::default(), |
113 | } | 117 | } |
114 | } | 118 | } |
diff --git a/crates/ra_vfs_glob/Cargo.toml b/crates/ra_vfs_glob/Cargo.toml index 0390d7da1..09ba3d3bf 100644 --- a/crates/ra_vfs_glob/Cargo.toml +++ b/crates/ra_vfs_glob/Cargo.toml | |||
@@ -5,5 +5,5 @@ version = "0.1.0" | |||
5 | authors = ["rust-analyzer developers"] | 5 | authors = ["rust-analyzer developers"] |
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | ra_vfs = "0.2.0" | 8 | ra_vfs = "0.3.0" |
9 | globset = "0.4.4" | 9 | globset = "0.4.4" |