Skip to content

Commit 50fd860

Browse files
committed
Remove Vfs from project model
1 parent 12c7087 commit 50fd860

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_lsp_server/src/server_world.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ impl ServerWorldState {
5858

5959
// Create crate graph from all the workspaces
6060
let mut crate_graph = CrateGraph::default();
61+
let mut load = |path: &std::path::Path| {
62+
let vfs_file = vfs.load(path);
63+
vfs_file.map(|f| FileId(f.0.into()))
64+
};
6165
for ws in workspaces.iter() {
62-
crate_graph.extend(ws.to_crate_graph(&mut vfs));
66+
crate_graph.extend(ws.to_crate_graph(&mut load));
6367
}
6468
change.set_crate_graph(crate_graph);
6569

crates/ra_project_model/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ cargo_metadata = "0.7.0"
1818

1919
ra_arena = { path = "../ra_arena" }
2020
ra_db = { path = "../ra_db" }
21-
ra_vfs = { path = "../ra_vfs" }
2221

2322
[dev-dependencies]
2423
test_utils = { path = "../test_utils" }

crates/ra_project_model/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use failure::bail;
77
use rustc_hash::FxHashMap;
88

99
use ra_db::{CrateGraph, FileId};
10-
use ra_vfs::Vfs;
1110

1211
pub use crate::{
1312
cargo_workspace::{CargoWorkspace, Package, Target, TargetKind},
@@ -32,12 +31,11 @@ impl ProjectWorkspace {
3231
Ok(res)
3332
}
3433

35-
pub fn to_crate_graph(&self, vfs: &mut Vfs) -> CrateGraph {
34+
pub fn to_crate_graph(&self, load: &mut dyn FnMut(&Path) -> Option<FileId>) -> CrateGraph {
3635
let mut crate_graph = CrateGraph::default();
3736
let mut sysroot_crates = FxHashMap::default();
3837
for krate in self.sysroot.crates() {
39-
if let Some(file_id) = vfs.load(krate.root(&self.sysroot)) {
40-
let file_id = FileId(file_id.0.into());
38+
if let Some(file_id) = load(krate.root(&self.sysroot)) {
4139
sysroot_crates.insert(krate, crate_graph.add_crate_root(file_id));
4240
}
4341
}
@@ -63,8 +61,7 @@ impl ProjectWorkspace {
6361
let mut lib_tgt = None;
6462
for tgt in pkg.targets(&self.cargo) {
6563
let root = tgt.root(&self.cargo);
66-
if let Some(file_id) = vfs.load(root) {
67-
let file_id = FileId(file_id.0.into());
64+
if let Some(file_id) = load(root) {
6865
let crate_id = crate_graph.add_crate_root(file_id);
6966
if tgt.kind(&self.cargo) == TargetKind::Lib {
7067
lib_tgt = Some(crate_id);

0 commit comments

Comments
 (0)