From 162dea51bfa6b7f6d64d138a84c16c96495a0fcd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 17 Feb 2019 20:22:46 +0300 Subject: hide root config --- crates/ra_vfs/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/ra_vfs/src/lib.rs') diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index a740e82ef..c78096ee1 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs @@ -31,7 +31,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use crate::{ io::{TaskResult, Worker}, - roots::{RootConfig, Roots}, + roots::Roots, }; pub use crate::{ @@ -74,18 +74,18 @@ impl Vfs { let worker = io::start(Arc::clone(&roots)); let mut root2files = ArenaMap::default(); - for (root, config) in roots.iter() { + for root in roots.iter() { root2files.insert(root, Default::default()); - worker.sender().send(io::Task::AddRoot { root, config: Arc::clone(config) }).unwrap(); + worker.sender().send(io::Task::AddRoot { root }).unwrap(); } let res = Vfs { roots, files: Arena::default(), root2files, worker, pending_changes: Vec::new() }; - let vfs_roots = res.roots.iter().map(|(id, _)| id).collect(); + let vfs_roots = res.roots.iter().collect(); (res, vfs_roots) } pub fn root2path(&self, root: VfsRoot) -> PathBuf { - self.roots[root].root.clone() + self.roots.path(root).to_path_buf() } pub fn path2file(&self, path: &Path) -> Option { @@ -97,7 +97,7 @@ impl Vfs { pub fn file2path(&self, file: VfsFile) -> PathBuf { let rel_path = &self.files[file].path; - let root_path = &self.roots[self.files[file].root].root; + let root_path = &self.roots.path(self.files[file].root); rel_path.to_path(root_path) } @@ -232,7 +232,7 @@ impl Vfs { pub fn remove_file_overlay(&mut self, path: &Path) -> Option { if let Some((root, path, file)) = self.find_root(path) { let file = file.expect("can't remove a file which wasn't added"); - let full_path = path.to_path(&self.roots[root].root); + let full_path = path.to_path(&self.roots.path(root)); if let Ok(text) = fs::read_to_string(&full_path) { self.do_change_file(file, text, true); } else { -- cgit v1.2.3