aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src/mock.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-19 09:26:51 +0000
committerAleksey Kladov <[email protected]>2018-12-20 09:15:38 +0000
commit18aac1df45ca39d01d80a56e3afab7299de160f8 (patch)
tree7920ec1d929a27589187b185b5ea2ec28014703c /crates/ra_db/src/mock.rs
parent85290bc1342560d5560f0b2151cff1c0c6dac155 (diff)
kill file resolver
Diffstat (limited to 'crates/ra_db/src/mock.rs')
-rw-r--r--crates/ra_db/src/mock.rs17
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 @@
1use rustc_hash::FxHashSet; 1use rustc_hash::FxHashSet;
2use relative_path::{RelativePath, RelativePathBuf}; 2use relative_path::{RelativePath, RelativePathBuf};
3 3
4use crate::{FileId, FileResolver}; 4use crate::{FileId};
5 5
6#[derive(Default, Debug, Clone)] 6#[derive(Default, Debug, Clone)]
7pub struct FileMap(Vec<(FileId, RelativePathBuf)>); 7pub 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
36impl 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}