//! Loads a Cargo project into a static instance of analysis, without support
//! for incorporating changes.
-use std::{convert::TryFrom, path::Path, sync::Arc};
+use std::{path::Path, sync::Arc};
use anyhow::Result;
use crossbeam_channel::{unbounded, Receiver};
-use ra_db::{AbsPathBuf, CrateGraph};
-use ra_ide::{AnalysisChange, AnalysisHost};
-use ra_project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace};
-use vfs::loader::Handle;
+use ide::{AnalysisHost, Change};
+use ide_db::base_db::CrateGraph;
+use project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace};
+use vfs::{loader::Handle, AbsPath, AbsPathBuf};
-use crate::global_state::{ProjectFolders, SourceRootConfig};
+use crate::reload::{ProjectFolders, SourceRootConfig};
pub fn load_cargo(
root: &Path,
load_out_dirs_from_check: bool,
with_proc_macro: bool,
) -> Result<(AnalysisHost, vfs::Vfs)> {
- let root = std::env::current_dir()?.join(root);
+ let root = AbsPathBuf::assert(std::env::current_dir()?.join(root));
let root = ProjectManifest::discover_single(&root)?;
let ws = ProjectWorkspace::load(
root,
let mut vfs = vfs::Vfs::default();
let mut loader = {
let loader =
- vfs_notify::LoaderHandle::spawn(Box::new(move |msg| sender.send(msg).unwrap()));
+ vfs_notify::NotifyHandle::spawn(Box::new(move |msg| sender.send(msg).unwrap()));
Box::new(loader)
};
ProcMacroClient::dummy()
};
- let crate_graph = ws.to_crate_graph(None, &proc_macro_client, &mut |path: &Path| {
- let path = AbsPathBuf::try_from(path.to_path_buf()).unwrap();
- let contents = loader.load_sync(&path);
- let path = vfs::VfsPath::from(path);
+ let crate_graph = ws.to_crate_graph(None, &proc_macro_client, &mut |path: &AbsPath| {
+ let contents = loader.load_sync(path);
+ let path = vfs::VfsPath::from(path.to_path_buf());
vfs.set_file_contents(path.clone(), contents);
vfs.file_id(&path)
});
Ok((host, vfs))
}
-pub(crate) fn load(
+fn load(
crate_graph: CrateGraph,
source_root_config: SourceRootConfig,
vfs: &mut vfs::Vfs,
) -> 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);
- let mut analysis_change = AnalysisChange::new();
+ let mut analysis_change = Change::new();
// wait until Vfs has loaded all roots
for task in receiver {
match task {
- vfs::loader::Message::Progress { n_entries_done, n_entries_total } => {
- if n_entries_done == n_entries_total {
+ vfs::loader::Message::Progress { n_done, n_total } => {
+ if n_done == n_total {
break;
}
}