Remove Vfs from project model
This commit is contained in:
parent
12c70871cc
commit
50fd860471
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1055,7 +1055,6 @@ dependencies = [
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ra_arena 0.1.0",
|
||||
"ra_db 0.1.0",
|
||||
"ra_vfs 0.1.0",
|
||||
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"test_utils 0.1.0",
|
||||
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -58,8 +58,12 @@ pub fn new(root: PathBuf, workspaces: Vec<ProjectWorkspace>) -> ServerWorldState
|
||||
|
||||
// Create crate graph from all the workspaces
|
||||
let mut crate_graph = CrateGraph::default();
|
||||
let mut load = |path: &std::path::Path| {
|
||||
let vfs_file = vfs.load(path);
|
||||
vfs_file.map(|f| FileId(f.0.into()))
|
||||
};
|
||||
for ws in workspaces.iter() {
|
||||
crate_graph.extend(ws.to_crate_graph(&mut vfs));
|
||||
crate_graph.extend(ws.to_crate_graph(&mut load));
|
||||
}
|
||||
change.set_crate_graph(crate_graph);
|
||||
|
||||
|
@ -18,7 +18,6 @@ cargo_metadata = "0.7.0"
|
||||
|
||||
ra_arena = { path = "../ra_arena" }
|
||||
ra_db = { path = "../ra_db" }
|
||||
ra_vfs = { path = "../ra_vfs" }
|
||||
|
||||
[dev-dependencies]
|
||||
test_utils = { path = "../test_utils" }
|
||||
|
@ -7,7 +7,6 @@
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use ra_db::{CrateGraph, FileId};
|
||||
use ra_vfs::Vfs;
|
||||
|
||||
pub use crate::{
|
||||
cargo_workspace::{CargoWorkspace, Package, Target, TargetKind},
|
||||
@ -32,12 +31,11 @@ pub fn discover(path: &Path) -> Result<ProjectWorkspace> {
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
pub fn to_crate_graph(&self, vfs: &mut Vfs) -> CrateGraph {
|
||||
pub fn to_crate_graph(&self, load: &mut dyn FnMut(&Path) -> Option<FileId>) -> CrateGraph {
|
||||
let mut crate_graph = CrateGraph::default();
|
||||
let mut sysroot_crates = FxHashMap::default();
|
||||
for krate in self.sysroot.crates() {
|
||||
if let Some(file_id) = vfs.load(krate.root(&self.sysroot)) {
|
||||
let file_id = FileId(file_id.0.into());
|
||||
if let Some(file_id) = load(krate.root(&self.sysroot)) {
|
||||
sysroot_crates.insert(krate, crate_graph.add_crate_root(file_id));
|
||||
}
|
||||
}
|
||||
@ -63,8 +61,7 @@ pub fn to_crate_graph(&self, vfs: &mut Vfs) -> CrateGraph {
|
||||
let mut lib_tgt = None;
|
||||
for tgt in pkg.targets(&self.cargo) {
|
||||
let root = tgt.root(&self.cargo);
|
||||
if let Some(file_id) = vfs.load(root) {
|
||||
let file_id = FileId(file_id.0.into());
|
||||
if let Some(file_id) = load(root) {
|
||||
let crate_id = crate_graph.add_crate_root(file_id);
|
||||
if tgt.kind(&self.cargo) == TargetKind::Lib {
|
||||
lib_tgt = Some(crate_id);
|
||||
|
Loading…
Reference in New Issue
Block a user