aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_vfs/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-17 17:22:46 +0000
committerAleksey Kladov <[email protected]>2019-02-17 17:22:46 +0000
commit162dea51bfa6b7f6d64d138a84c16c96495a0fcd (patch)
treef321f11cd0d9c88c8c684f65312041d8db5598d2 /crates/ra_vfs/src/lib.rs
parent6b5d90972ae2f288ae7cf57e209c0d5d8c7a1fd2 (diff)
hide root config
Diffstat (limited to 'crates/ra_vfs/src/lib.rs')
-rw-r--r--crates/ra_vfs/src/lib.rs14
1 files changed, 7 insertions, 7 deletions
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};
31 31
32use crate::{ 32use crate::{
33 io::{TaskResult, Worker}, 33 io::{TaskResult, Worker},
34 roots::{RootConfig, Roots}, 34 roots::Roots,
35}; 35};
36 36
37pub use crate::{ 37pub use crate::{
@@ -74,18 +74,18 @@ impl Vfs {
74 let worker = io::start(Arc::clone(&roots)); 74 let worker = io::start(Arc::clone(&roots));
75 let mut root2files = ArenaMap::default(); 75 let mut root2files = ArenaMap::default();
76 76
77 for (root, config) in roots.iter() { 77 for root in roots.iter() {
78 root2files.insert(root, Default::default()); 78 root2files.insert(root, Default::default());
79 worker.sender().send(io::Task::AddRoot { root, config: Arc::clone(config) }).unwrap(); 79 worker.sender().send(io::Task::AddRoot { root }).unwrap();
80 } 80 }
81 let res = 81 let res =
82 Vfs { roots, files: Arena::default(), root2files, worker, pending_changes: Vec::new() }; 82 Vfs { roots, files: Arena::default(), root2files, worker, pending_changes: Vec::new() };
83 let vfs_roots = res.roots.iter().map(|(id, _)| id).collect(); 83 let vfs_roots = res.roots.iter().collect();
84 (res, vfs_roots) 84 (res, vfs_roots)
85 } 85 }
86 86
87 pub fn root2path(&self, root: VfsRoot) -> PathBuf { 87 pub fn root2path(&self, root: VfsRoot) -> PathBuf {
88 self.roots[root].root.clone() 88 self.roots.path(root).to_path_buf()
89 } 89 }
90 90
91 pub fn path2file(&self, path: &Path) -> Option<VfsFile> { 91 pub fn path2file(&self, path: &Path) -> Option<VfsFile> {
@@ -97,7 +97,7 @@ impl Vfs {
97 97
98 pub fn file2path(&self, file: VfsFile) -> PathBuf { 98 pub fn file2path(&self, file: VfsFile) -> PathBuf {
99 let rel_path = &self.files[file].path; 99 let rel_path = &self.files[file].path;
100 let root_path = &self.roots[self.files[file].root].root; 100 let root_path = &self.roots.path(self.files[file].root);
101 rel_path.to_path(root_path) 101 rel_path.to_path(root_path)
102 } 102 }
103 103
@@ -232,7 +232,7 @@ impl Vfs {
232 pub fn remove_file_overlay(&mut self, path: &Path) -> Option<VfsFile> { 232 pub fn remove_file_overlay(&mut self, path: &Path) -> Option<VfsFile> {
233 if let Some((root, path, file)) = self.find_root(path) { 233 if let Some((root, path, file)) = self.find_root(path) {
234 let file = file.expect("can't remove a file which wasn't added"); 234 let file = file.expect("can't remove a file which wasn't added");
235 let full_path = path.to_path(&self.roots[root].root); 235 let full_path = path.to_path(&self.roots.path(root));
236 if let Ok(text) = fs::read_to_string(&full_path) { 236 if let Ok(text) = fs::read_to_string(&full_path) {
237 self.do_change_file(file, text, true); 237 self.do_change_file(file, text, true);
238 } else { 238 } else {