diff options
author | Aleksey Kladov <[email protected]> | 2019-01-04 13:01:06 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-04 13:58:10 +0000 |
commit | 291d578938d7dc9b1f9bbd1174e444cc831531d9 (patch) | |
tree | 153e44aa0ccb17be658acbc9ae2e62d2a87178ab /crates/ra_vfs/src/lib.rs | |
parent | 821fa7a50ab8c4886adc60a2093aa8e06cc3a9d6 (diff) |
extract area to a crate
Diffstat (limited to 'crates/ra_vfs/src/lib.rs')
-rw-r--r-- | crates/ra_vfs/src/lib.rs | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 5bbc3e993..cdea18d73 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs | |||
@@ -13,7 +13,6 @@ | |||
13 | //! VFS is based on a concept of roots: a set of directories on the file system | 13 | //! VFS is based on a concept of roots: a set of directories on the file system |
14 | //! which are watched for changes. Typically, there will be a root for each | 14 | //! which are watched for changes. Typically, there will be a root for each |
15 | //! Cargo package. | 15 | //! Cargo package. |
16 | mod arena; | ||
17 | mod io; | 16 | mod io; |
18 | 17 | ||
19 | use std::{ | 18 | use std::{ |
@@ -32,10 +31,7 @@ use relative_path::RelativePathBuf; | |||
32 | use crossbeam_channel::Receiver; | 31 | use crossbeam_channel::Receiver; |
33 | use walkdir::DirEntry; | 32 | use walkdir::DirEntry; |
34 | use thread_worker::WorkerHandle; | 33 | use thread_worker::WorkerHandle; |
35 | 34 | use ra_arena::{Arena, RawId, impl_arena_id}; | |
36 | use crate::{ | ||
37 | arena::{ArenaId, Arena}, | ||
38 | }; | ||
39 | 35 | ||
40 | pub use crate::io::TaskResult as VfsTask; | 36 | pub use crate::io::TaskResult as VfsTask; |
41 | 37 | ||
@@ -68,29 +64,13 @@ fn has_rs_extension(p: &Path) -> bool { | |||
68 | p.extension() == Some(OsStr::new("rs")) | 64 | p.extension() == Some(OsStr::new("rs")) |
69 | } | 65 | } |
70 | 66 | ||
71 | #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] | 67 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
72 | pub struct VfsRoot(pub u32); | 68 | pub struct VfsRoot(pub RawId); |
73 | 69 | impl_arena_id!(VfsRoot); | |
74 | impl ArenaId for VfsRoot { | ||
75 | fn from_u32(idx: u32) -> VfsRoot { | ||
76 | VfsRoot(idx) | ||
77 | } | ||
78 | fn to_u32(self) -> u32 { | ||
79 | self.0 | ||
80 | } | ||
81 | } | ||
82 | |||
83 | #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] | ||
84 | pub struct VfsFile(pub u32); | ||
85 | 70 | ||
86 | impl ArenaId for VfsFile { | 71 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
87 | fn from_u32(idx: u32) -> VfsFile { | 72 | pub struct VfsFile(pub RawId); |
88 | VfsFile(idx) | 73 | impl_arena_id!(VfsFile); |
89 | } | ||
90 | fn to_u32(self) -> u32 { | ||
91 | self.0 | ||
92 | } | ||
93 | } | ||
94 | 74 | ||
95 | struct VfsFileData { | 75 | struct VfsFileData { |
96 | root: VfsRoot, | 76 | root: VfsRoot, |