aboutsummaryrefslogtreecommitdiff
path: root/crates/vfs/src/file_set.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-06-11 10:04:09 +0100
committerAleksey Kladov <[email protected]>2020-06-23 16:51:06 +0100
commitdad1333b48c38bc7a5628fc0ff5304d003776a85 (patch)
tree29be52a980b4cae72f46a48c48135a15e31641e0 /crates/vfs/src/file_set.rs
parent7aa66371ee3e8b31217513204c8b4f683584419d (diff)
New VFS
Diffstat (limited to 'crates/vfs/src/file_set.rs')
-rw-r--r--crates/vfs/src/file_set.rs15
1 files changed, 5 insertions, 10 deletions
diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs
index 724606a3d..0173f7464 100644
--- a/crates/vfs/src/file_set.rs
+++ b/crates/vfs/src/file_set.rs
@@ -4,7 +4,6 @@
4//! the default `FileSet`. 4//! the default `FileSet`.
5use std::{fmt, iter}; 5use std::{fmt, iter};
6 6
7use paths::AbsPathBuf;
8use rustc_hash::FxHashMap; 7use rustc_hash::FxHashMap;
9 8
10use crate::{FileId, Vfs, VfsPath}; 9use crate::{FileId, Vfs, VfsPath};
@@ -41,7 +40,7 @@ impl fmt::Debug for FileSet {
41#[derive(Debug)] 40#[derive(Debug)]
42pub struct FileSetConfig { 41pub struct FileSetConfig {
43 n_file_sets: usize, 42 n_file_sets: usize,
44 roots: Vec<(AbsPathBuf, usize)>, 43 roots: Vec<(VfsPath, usize)>,
45} 44}
46 45
47impl Default for FileSetConfig { 46impl Default for FileSetConfig {
@@ -66,11 +65,7 @@ impl FileSetConfig {
66 self.n_file_sets 65 self.n_file_sets
67 } 66 }
68 fn classify(&self, path: &VfsPath) -> usize { 67 fn classify(&self, path: &VfsPath) -> usize {
69 let path = match path.as_path() { 68 let idx = match self.roots.binary_search_by(|(p, _)| p.cmp(path)) {
70 Some(it) => it,
71 None => return self.len() - 1,
72 };
73 let idx = match self.roots.binary_search_by(|(p, _)| p.as_path().cmp(path)) {
74 Ok(it) => it, 69 Ok(it) => it,
75 Err(it) => it.saturating_sub(1), 70 Err(it) => it.saturating_sub(1),
76 }; 71 };
@@ -83,7 +78,7 @@ impl FileSetConfig {
83} 78}
84 79
85pub struct FileSetConfigBuilder { 80pub struct FileSetConfigBuilder {
86 roots: Vec<Vec<AbsPathBuf>>, 81 roots: Vec<Vec<VfsPath>>,
87} 82}
88 83
89impl Default for FileSetConfigBuilder { 84impl Default for FileSetConfigBuilder {
@@ -96,12 +91,12 @@ impl FileSetConfigBuilder {
96 pub fn len(&self) -> usize { 91 pub fn len(&self) -> usize {
97 self.roots.len() 92 self.roots.len()
98 } 93 }
99 pub fn add_file_set(&mut self, roots: Vec<AbsPathBuf>) { 94 pub fn add_file_set(&mut self, roots: Vec<VfsPath>) {
100 self.roots.push(roots) 95 self.roots.push(roots)
101 } 96 }
102 pub fn build(self) -> FileSetConfig { 97 pub fn build(self) -> FileSetConfig {
103 let n_file_sets = self.roots.len() + 1; 98 let n_file_sets = self.roots.len() + 1;
104 let mut roots: Vec<(AbsPathBuf, usize)> = self 99 let mut roots: Vec<(VfsPath, usize)> = self
105 .roots 100 .roots
106 .into_iter() 101 .into_iter()
107 .enumerate() 102 .enumerate()