diff options
Diffstat (limited to 'crates/ra_db')
-rw-r--r-- | crates/ra_db/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_db/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ra_db/src/mock.rs | 30 |
3 files changed, 1 insertions, 32 deletions
diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 2d39b77ed..3bae22c74 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml | |||
@@ -5,8 +5,8 @@ version = "0.1.0" | |||
5 | authors = ["Aleksey Kladov <[email protected]>"] | 5 | authors = ["Aleksey Kladov <[email protected]>"] |
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | salsa = "0.10.0" | ||
8 | relative-path = "0.4.0" | 9 | relative-path = "0.4.0" |
9 | salsa = "0.10.0-alpha5" | ||
10 | rustc-hash = "1.0" | 10 | rustc-hash = "1.0" |
11 | parking_lot = "0.7.0" | 11 | parking_lot = "0.7.0" |
12 | 12 | ||
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 6e17f33f0..ca775030d 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -2,7 +2,6 @@ | |||
2 | mod cancellation; | 2 | mod cancellation; |
3 | mod input; | 3 | mod input; |
4 | mod loc2id; | 4 | mod loc2id; |
5 | pub mod mock; | ||
6 | 5 | ||
7 | use std::{ | 6 | use std::{ |
8 | panic, sync::Arc, | 7 | panic, sync::Arc, |
diff --git a/crates/ra_db/src/mock.rs b/crates/ra_db/src/mock.rs deleted file mode 100644 index 5e185062b..000000000 --- a/crates/ra_db/src/mock.rs +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | use rustc_hash::FxHashSet; | ||
2 | use relative_path::{RelativePath, RelativePathBuf}; | ||
3 | |||
4 | use crate::{FileId}; | ||
5 | |||
6 | #[derive(Default, Debug, Clone)] | ||
7 | pub struct FileMap(Vec<(FileId, RelativePathBuf)>); | ||
8 | |||
9 | impl FileMap { | ||
10 | pub fn add(&mut self, path: RelativePathBuf) -> FileId { | ||
11 | let file_id = FileId((self.0.len() + 1) as u32); | ||
12 | self.0.push((file_id, path)); | ||
13 | file_id | ||
14 | } | ||
15 | |||
16 | pub fn files(&self) -> FxHashSet<FileId> { | ||
17 | self.iter().map(|(id, _)| id).collect() | ||
18 | } | ||
19 | |||
20 | pub fn file_id(&self, path: &str) -> FileId { | ||
21 | assert!(path.starts_with('/')); | ||
22 | self.iter().find(|(_, p)| p == &path[1..]).unwrap().0 | ||
23 | } | ||
24 | |||
25 | fn iter<'a>(&'a self) -> impl Iterator<Item = (FileId, &'a RelativePath)> + 'a { | ||
26 | self.0 | ||
27 | .iter() | ||
28 | .map(|(id, path)| (*id, path.as_relative_path())) | ||
29 | } | ||
30 | } | ||