diff options
Diffstat (limited to 'crates/ra_db/src/input.rs')
-rw-r--r-- | crates/ra_db/src/input.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index ad8e10c52..d1ee3c036 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -5,7 +5,7 @@ | |||
5 | /// Note that neither this module, nor any other part of the analyzer's core do | 5 | /// Note that neither this module, nor any other part of the analyzer's core do |
6 | /// actual IO. See `vfs` and `project_model` in the `ra_lsp_server` crate for how | 6 | /// actual IO. See `vfs` and `project_model` in the `ra_lsp_server` crate for how |
7 | /// actual IO is done and lowered to input. | 7 | /// actual IO is done and lowered to input. |
8 | use relative_path::RelativePathBuf; | 8 | use relative_path::{RelativePath, RelativePathBuf}; |
9 | use rustc_hash::FxHashMap; | 9 | use rustc_hash::FxHashMap; |
10 | 10 | ||
11 | use ra_syntax::SmolStr; | 11 | use ra_syntax::SmolStr; |
@@ -36,7 +36,7 @@ pub struct SourceRoot { | |||
36 | /// Libraries are considered mostly immutable, this assumption is used to | 36 | /// Libraries are considered mostly immutable, this assumption is used to |
37 | /// optimize salsa's query structure | 37 | /// optimize salsa's query structure |
38 | pub is_library: bool, | 38 | pub is_library: bool, |
39 | pub files: FxHashMap<RelativePathBuf, FileId>, | 39 | files: FxHashMap<RelativePathBuf, FileId>, |
40 | } | 40 | } |
41 | 41 | ||
42 | impl SourceRoot { | 42 | impl SourceRoot { |
@@ -46,6 +46,18 @@ impl SourceRoot { | |||
46 | pub fn new_library() -> SourceRoot { | 46 | pub fn new_library() -> SourceRoot { |
47 | SourceRoot { is_library: true, ..SourceRoot::new() } | 47 | SourceRoot { is_library: true, ..SourceRoot::new() } |
48 | } | 48 | } |
49 | pub fn file_by_relative_path(&self, path: &RelativePath) -> Option<FileId> { | ||
50 | self.files.get(path).copied() | ||
51 | } | ||
52 | pub fn insert_file(&mut self, path: RelativePathBuf, file_id: FileId) { | ||
53 | self.files.insert(path, file_id); | ||
54 | } | ||
55 | pub fn remove_file(&mut self, path: &RelativePath) { | ||
56 | self.files.remove(path); | ||
57 | } | ||
58 | pub fn walk(&self) -> impl Iterator<Item = FileId> + '_ { | ||
59 | self.files.values().copied() | ||
60 | } | ||
49 | } | 61 | } |
50 | 62 | ||
51 | /// `CrateGraph` is a bit of information which turns a set of text files into a | 63 | /// `CrateGraph` is a bit of information which turns a set of text files into a |