aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_vfs/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-04 13:01:06 +0000
committerAleksey Kladov <[email protected]>2019-01-04 13:58:10 +0000
commit291d578938d7dc9b1f9bbd1174e444cc831531d9 (patch)
tree153e44aa0ccb17be658acbc9ae2e62d2a87178ab /crates/ra_vfs/src/lib.rs
parent821fa7a50ab8c4886adc60a2093aa8e06cc3a9d6 (diff)
extract area to a crate
Diffstat (limited to 'crates/ra_vfs/src/lib.rs')
-rw-r--r--crates/ra_vfs/src/lib.rs34
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.
16mod arena;
17mod io; 16mod io;
18 17
19use std::{ 18use std::{
@@ -32,10 +31,7 @@ use relative_path::RelativePathBuf;
32use crossbeam_channel::Receiver; 31use crossbeam_channel::Receiver;
33use walkdir::DirEntry; 32use walkdir::DirEntry;
34use thread_worker::WorkerHandle; 33use thread_worker::WorkerHandle;
35 34use ra_arena::{Arena, RawId, impl_arena_id};
36use crate::{
37 arena::{ArenaId, Arena},
38};
39 35
40pub use crate::io::TaskResult as VfsTask; 36pub 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)]
72pub struct VfsRoot(pub u32); 68pub struct VfsRoot(pub RawId);
73 69impl_arena_id!(VfsRoot);
74impl 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)]
84pub struct VfsFile(pub u32);
85 70
86impl ArenaId for VfsFile { 71#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
87 fn from_u32(idx: u32) -> VfsFile { 72pub struct VfsFile(pub RawId);
88 VfsFile(idx) 73impl_arena_id!(VfsFile);
89 }
90 fn to_u32(self) -> u32 {
91 self.0
92 }
93}
94 74
95struct VfsFileData { 75struct VfsFileData {
96 root: VfsRoot, 76 root: VfsRoot,