From 43e52ac9e2b26ec287b1778823bad10851cfd44e Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 9 Feb 2019 13:06:12 +0100 Subject: Implement BatchDatabase construction --- crates/ra_vfs/src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crates/ra_vfs') diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 6b4eb6842..2d861f832 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs @@ -94,6 +94,7 @@ impl Roots { let mut roots = Arena::default(); // A hack to make nesting work. paths.sort_by_key(|it| Reverse(it.as_os_str().len())); + paths.dedup(); for (i, path) in paths.iter().enumerate() { let nested_roots = paths[..i] .iter() @@ -161,6 +162,13 @@ impl Vfs { self.roots[root].root.clone() } + pub fn path2root(&self, path: &Path) -> Option { + match self.find_root(path) { + Some((root, _path, _file)) => Some(root), + _ => None, + } + } + pub fn path2file(&self, path: &Path) -> Option { if let Some((_root, _path, Some(file))) = self.find_root(path) { return Some(file); @@ -181,6 +189,10 @@ impl Vfs { None } + pub fn num_roots(&self) -> usize { + self.roots.len() + } + pub fn load(&mut self, path: &Path) -> Option { if let Some((root, rel_path, file)) = self.find_root(path) { return if let Some(file) = file { -- cgit v1.2.3 From b18863f987ef14d44a67c0b8ebaa9c7a7fed7f59 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 10 Feb 2019 11:48:59 +0100 Subject: Clean up a bit --- crates/ra_vfs/src/lib.rs | 7 ------- 1 file changed, 7 deletions(-) (limited to 'crates/ra_vfs') diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 2d861f832..3805be570 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs @@ -162,13 +162,6 @@ impl Vfs { self.roots[root].root.clone() } - pub fn path2root(&self, path: &Path) -> Option { - match self.find_root(path) { - Some((root, _path, _file)) => Some(root), - _ => None, - } - } - pub fn path2file(&self, path: &Path) -> Option { if let Some((_root, _path, Some(file))) = self.find_root(path) { return Some(file); -- cgit v1.2.3