Merge #1735
1735: ⬆️ vfs r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
1fbe5ffba8
7 changed files with 25 additions and 15 deletions
|
|
@ -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" }
|
||||
|
|
|
|||
|
|
@ -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<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>;
|
||||
|
|
@ -21,6 +22,8 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId,
|
|||
let root = std::env::current_dir()?.join(root);
|
||||
let ws = ProjectWorkspace::discover(root.as_ref())?;
|
||||
let project_roots = ws.to_roots();
|
||||
let (sender, receiver) = unbounded();
|
||||
let sender = Box::new(move |t| sender.send(t).unwrap());
|
||||
let (mut vfs, roots) = Vfs::new(
|
||||
project_roots
|
||||
.iter()
|
||||
|
|
@ -33,6 +36,7 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId,
|
|||
)
|
||||
})
|
||||
.collect(),
|
||||
sender,
|
||||
);
|
||||
let crate_graph = ws.to_crate_graph(&mut |path: &Path| {
|
||||
let vfs_file = vfs.load(path);
|
||||
|
|
@ -53,7 +57,7 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId,
|
|||
(source_root_id, project_root)
|
||||
})
|
||||
.collect::<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<SourceRootId, PackageRoot>,
|
||||
crate_graph: CrateGraph,
|
||||
vfs: &mut Vfs,
|
||||
receiver: Receiver<VfsTask>,
|
||||
) -> AnalysisHost {
|
||||
let lru_cap = std::env::var("RA_LRU_CAP").ok().and_then(|it| it.parse::<usize>().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);
|
||||
|
|
|
|||
|
|
@ -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" }
|
||||
|
|
|
|||
|
|
@ -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")?,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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<Vec<ProjectWorkspace>>,
|
||||
pub analysis_host: AnalysisHost,
|
||||
pub vfs: Arc<RwLock<Vfs>>,
|
||||
pub task_receiver: Receiver<VfsTask>,
|
||||
pub latest_requests: Arc<RwLock<LatestRequests>>,
|
||||
}
|
||||
|
||||
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue