]> git.lizzy.rs Git - rust.git/commitdiff
Remove Vfs from project model
authorFlorian Diebold <flodiebold@gmail.com>
Sat, 9 Feb 2019 10:08:24 +0000 (11:08 +0100)
committerFlorian Diebold <flodiebold@gmail.com>
Sat, 9 Feb 2019 10:15:25 +0000 (11:15 +0100)
Cargo.lock
crates/ra_lsp_server/src/server_world.rs
crates/ra_project_model/Cargo.toml
crates/ra_project_model/src/lib.rs

index a76d0b2fe96e0645a15fc4f2a661a1456735a61f..2c554ec10d08d884bde5b9479edfdd4a8e22845d 100644 (file)
@@ -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)",
index 23270d0aa9d1de6c17539282f1f25b61fca76dee..f97d240fabb0ed35e5f9669cf73cad431f7dfe7b 100644 (file)
@@ -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);
 
index 996dce351e2abf84c4e57ee173110f13782806da..9cdf2b3228a7213c986f4f17e93c65f8ed8f8680 100644 (file)
@@ -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" }
index abc79684c51f0cb939954565788a967021b90e6e..156af9e7a29fba76a393c4572855ae833662dd91 100644 (file)
@@ -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);