diff options
Diffstat (limited to 'crates/vfs/src/loader.rs')
-rw-r--r-- | crates/vfs/src/loader.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/crates/vfs/src/loader.rs b/crates/vfs/src/loader.rs index 5a0ca68f3..6de2e5b3f 100644 --- a/crates/vfs/src/loader.rs +++ b/crates/vfs/src/loader.rs | |||
@@ -1,21 +1,22 @@ | |||
1 | //! Object safe interface for file watching and reading. | 1 | //! Object safe interface for file watching and reading. |
2 | use std::fmt; | 2 | use std::fmt; |
3 | 3 | ||
4 | use paths::AbsPathBuf; | 4 | use paths::{AbsPath, AbsPathBuf}; |
5 | 5 | ||
6 | #[derive(Debug)] | ||
6 | pub enum Entry { | 7 | pub enum Entry { |
7 | Files(Vec<AbsPathBuf>), | 8 | Files(Vec<AbsPathBuf>), |
8 | Directory { path: AbsPathBuf, globs: Vec<String> }, | 9 | Directory { path: AbsPathBuf, include: Vec<String> }, |
9 | } | 10 | } |
10 | 11 | ||
12 | #[derive(Debug)] | ||
11 | pub struct Config { | 13 | pub struct Config { |
12 | pub load: Vec<Entry>, | 14 | pub load: Vec<Entry>, |
13 | pub watch: Vec<usize>, | 15 | pub watch: Vec<usize>, |
14 | } | 16 | } |
15 | 17 | ||
16 | pub enum Message { | 18 | pub enum Message { |
17 | DidSwitchConfig { n_entries: usize }, | 19 | Progress { n_total: usize, n_done: usize }, |
18 | DidLoadAllEntries, | ||
19 | Loaded { files: Vec<(AbsPathBuf, Option<Vec<u8>>)> }, | 20 | Loaded { files: Vec<(AbsPathBuf, Option<Vec<u8>>)> }, |
20 | } | 21 | } |
21 | 22 | ||
@@ -27,20 +28,20 @@ pub trait Handle: fmt::Debug { | |||
27 | Self: Sized; | 28 | Self: Sized; |
28 | fn set_config(&mut self, config: Config); | 29 | fn set_config(&mut self, config: Config); |
29 | fn invalidate(&mut self, path: AbsPathBuf); | 30 | fn invalidate(&mut self, path: AbsPathBuf); |
30 | fn load_sync(&mut self, path: &AbsPathBuf) -> Option<Vec<u8>>; | 31 | fn load_sync(&mut self, path: &AbsPath) -> Option<Vec<u8>>; |
31 | } | 32 | } |
32 | 33 | ||
33 | impl Entry { | 34 | impl Entry { |
34 | pub fn rs_files_recursively(base: AbsPathBuf) -> Entry { | 35 | pub fn rs_files_recursively(base: AbsPathBuf) -> Entry { |
35 | Entry::Directory { path: base, globs: globs(&["*.rs"]) } | 36 | Entry::Directory { path: base, include: globs(&["*.rs", "!/.git/"]) } |
36 | } | 37 | } |
37 | pub fn local_cargo_package(base: AbsPathBuf) -> Entry { | 38 | pub fn local_cargo_package(base: AbsPathBuf) -> Entry { |
38 | Entry::Directory { path: base, globs: globs(&["*.rs", "!/target/"]) } | 39 | Entry::Directory { path: base, include: globs(&["*.rs", "!/target/", "!/.git/"]) } |
39 | } | 40 | } |
40 | pub fn cargo_package_dependency(base: AbsPathBuf) -> Entry { | 41 | pub fn cargo_package_dependency(base: AbsPathBuf) -> Entry { |
41 | Entry::Directory { | 42 | Entry::Directory { |
42 | path: base, | 43 | path: base, |
43 | globs: globs(&["*.rs", "!/tests/", "!/examples/", "!/benches/"]), | 44 | include: globs(&["*.rs", "!/tests/", "!/examples/", "!/benches/", "!/.git/"]), |
44 | } | 45 | } |
45 | } | 46 | } |
46 | } | 47 | } |
@@ -55,10 +56,11 @@ impl fmt::Debug for Message { | |||
55 | Message::Loaded { files } => { | 56 | Message::Loaded { files } => { |
56 | f.debug_struct("Loaded").field("n_files", &files.len()).finish() | 57 | f.debug_struct("Loaded").field("n_files", &files.len()).finish() |
57 | } | 58 | } |
58 | Message::DidSwitchConfig { n_entries } => { | 59 | Message::Progress { n_total, n_done } => f |
59 | f.debug_struct("DidSwitchConfig").field("n_entries", n_entries).finish() | 60 | .debug_struct("Progress") |
60 | } | 61 | .field("n_total", n_total) |
61 | Message::DidLoadAllEntries => f.debug_struct("DidLoadAllEntries").finish(), | 62 | .field("n_done", n_done) |
63 | .finish(), | ||
62 | } | 64 | } |
63 | } | 65 | } |
64 | } | 66 | } |