diff options
Diffstat (limited to 'crates/ra_db/src/mock.rs')
-rw-r--r-- | crates/ra_db/src/mock.rs | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/crates/ra_db/src/mock.rs b/crates/ra_db/src/mock.rs index efe987bdd..5e185062b 100644 --- a/crates/ra_db/src/mock.rs +++ b/crates/ra_db/src/mock.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use rustc_hash::FxHashSet; | 1 | use rustc_hash::FxHashSet; |
2 | use relative_path::{RelativePath, RelativePathBuf}; | 2 | use relative_path::{RelativePath, RelativePathBuf}; |
3 | 3 | ||
4 | use crate::{FileId, FileResolver}; | 4 | use crate::{FileId}; |
5 | 5 | ||
6 | #[derive(Default, Debug, Clone)] | 6 | #[derive(Default, Debug, Clone)] |
7 | pub struct FileMap(Vec<(FileId, RelativePathBuf)>); | 7 | pub struct FileMap(Vec<(FileId, RelativePathBuf)>); |
@@ -27,19 +27,4 @@ impl FileMap { | |||
27 | .iter() | 27 | .iter() |
28 | .map(|(id, path)| (*id, path.as_relative_path())) | 28 | .map(|(id, path)| (*id, path.as_relative_path())) |
29 | } | 29 | } |
30 | |||
31 | fn path(&self, id: FileId) -> &RelativePath { | ||
32 | self.iter().find(|&(it, _)| it == id).unwrap().1 | ||
33 | } | ||
34 | } | ||
35 | |||
36 | impl FileResolver for FileMap { | ||
37 | fn file_stem(&self, id: FileId) -> String { | ||
38 | self.path(id).file_stem().unwrap().to_string() | ||
39 | } | ||
40 | fn resolve(&self, id: FileId, rel: &RelativePath) -> Option<FileId> { | ||
41 | let path = self.path(id).join(rel).normalize(); | ||
42 | let id = self.iter().find(|&(_, p)| path == p)?.0; | ||
43 | Some(id) | ||
44 | } | ||
45 | } | 30 | } |