From ee932d464b2c15b9c130e734a01fc50e5a18d106 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 25 Aug 2019 13:04:56 +0300 Subject: :arrow_up: vfs --- crates/ra_batch/Cargo.toml | 3 ++- crates/ra_batch/src/lib.rs | 10 +++++++--- crates/ra_lsp_server/Cargo.toml | 2 +- crates/ra_lsp_server/src/main_loop.rs | 2 +- crates/ra_lsp_server/src/world.rs | 10 +++++++--- crates/ra_vfs_glob/Cargo.toml | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-) (limited to 'crates') 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"] [dependencies] log = "0.4.5" rustc-hash = "1.0" +crossbeam-channel = "0.3.5" -ra_vfs = "0.2.0" +ra_vfs = "0.3.0" ra_vfs_glob = { path = "../ra_vfs_glob" } ra_db = { path = "../ra_db" } 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}; use rustc_hash::FxHashMap; +use crossbeam_channel::{unbounded, Receiver}; use ra_db::{CrateGraph, FileId, SourceRootId}; use ra_ide_api::{AnalysisChange, AnalysisHost, FeatureFlags}; use ra_project_model::{PackageRoot, ProjectWorkspace}; -use ra_vfs::{RootEntry, Vfs, VfsChange}; +use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask}; use ra_vfs_glob::RustPackageFilterBuilder; type Result = std::result::Result>; @@ -21,6 +22,8 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap Result<(AnalysisHost, FxHashMap Result<(AnalysisHost, FxHashMap>(); - let host = load(&source_roots, crate_graph, &mut vfs); + let host = load(&source_roots, crate_graph, &mut vfs, receiver); Ok((host, source_roots)) } @@ -61,6 +65,7 @@ pub fn load( source_roots: &FxHashMap, crate_graph: CrateGraph, vfs: &mut Vfs, + receiver: Receiver, ) -> AnalysisHost { let lru_cap = std::env::var("RA_LRU_CAP").ok().and_then(|it| it.parse::().ok()); let mut host = AnalysisHost::new(lru_cap, FeatureFlags::default()); @@ -68,7 +73,6 @@ pub fn load( analysis_change.set_crate_graph(crate_graph); // wait until Vfs has loaded all roots - let receiver = vfs.task_receiver().clone(); let mut roots_loaded = HashSet::new(); for task in receiver { 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"] } rustc-hash = "1.0" parking_lot = "0.9.0" -ra_vfs = "0.2.7" +ra_vfs = "0.3.0" thread_worker = { path = "../thread_worker" } ra_syntax = { path = "../ra_syntax" } 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( Err(RecvError) => Err("client exited without shutdown")?, }, recv(task_receiver) -> task => Event::Task(task.unwrap()), - recv(state.vfs.read().task_receiver()) -> task => match task { + recv(state.task_receiver) -> task => match task { Ok(task) => Event::Vfs(task), Err(RecvError) => Err("vfs died")?, }, 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::{ sync::Arc, }; +use crossbeam_channel::{unbounded, Receiver}; use gen_lsp_server::ErrorCode; use lsp_types::Url; use parking_lot::RwLock; @@ -10,7 +11,7 @@ use ra_ide_api::{ Analysis, AnalysisChange, AnalysisHost, CrateGraph, FeatureFlags, FileId, LibraryData, SourceRootId, }; -use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot}; +use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot, VfsTask}; use ra_vfs_glob::{Glob, RustPackageFilterBuilder}; use relative_path::RelativePathBuf; @@ -39,6 +40,7 @@ pub struct WorldState { pub workspaces: Arc>, pub analysis_host: AnalysisHost, pub vfs: Arc>, + pub task_receiver: Receiver, pub latest_requests: Arc>, } @@ -80,8 +82,9 @@ impl WorldState { RootEntry::new(pkg_root.path().clone(), filter.into_vfs_filter()) })); } - - let (mut vfs, vfs_roots) = Vfs::new(roots); + let (task_sender, task_receiver) = unbounded(); + let task_sender = Box::new(move |t| task_sender.send(t).unwrap()); + let (mut vfs, vfs_roots) = Vfs::new(roots, task_sender); let roots_to_scan = vfs_roots.len(); for r in vfs_roots { let vfs_root_path = vfs.root2path(r); @@ -109,6 +112,7 @@ impl WorldState { workspaces: Arc::new(workspaces), analysis_host, vfs: Arc::new(RwLock::new(vfs)), + task_receiver, latest_requests: Default::default(), } } 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" authors = ["rust-analyzer developers"] [dependencies] -ra_vfs = "0.2.0" +ra_vfs = "0.3.0" globset = "0.4.4" -- cgit v1.2.3