diff options
Diffstat (limited to 'crates/ra_db/src/input.rs')
-rw-r--r-- | crates/ra_db/src/input.rs | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index ac144b991..cccf37cc2 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -1,10 +1,12 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use rustc_hash::{FxHashSet, FxHashMap}; | 3 | use rustc_hash::{FxHashMap}; |
4 | use relative_path::RelativePathBuf; | ||
4 | use ra_syntax::SmolStr; | 5 | use ra_syntax::SmolStr; |
5 | use salsa; | 6 | use salsa; |
6 | 7 | ||
7 | use crate::file_resolver::FileResolverImp; | 8 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] |
9 | pub struct SourceRootId(pub u32); | ||
8 | 10 | ||
9 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 11 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
10 | pub struct FileId(pub u32); | 12 | pub struct FileId(pub u32); |
@@ -85,6 +87,11 @@ salsa::query_group! { | |||
85 | type FileTextQuery; | 87 | type FileTextQuery; |
86 | storage input; | 88 | storage input; |
87 | } | 89 | } |
90 | /// Path to a file, relative to the root of its source root. | ||
91 | fn file_relative_path(file_id: FileId) -> RelativePathBuf { | ||
92 | type FileRelativePathQuery; | ||
93 | storage input; | ||
94 | } | ||
88 | fn file_source_root(file_id: FileId) -> SourceRootId { | 95 | fn file_source_root(file_id: FileId) -> SourceRootId { |
89 | type FileSourceRootQuery; | 96 | type FileSourceRootQuery; |
90 | storage input; | 97 | storage input; |
@@ -93,8 +100,12 @@ salsa::query_group! { | |||
93 | type SourceRootQuery; | 100 | type SourceRootQuery; |
94 | storage input; | 101 | storage input; |
95 | } | 102 | } |
96 | fn libraries() -> Arc<Vec<SourceRootId>> { | 103 | fn local_roots() -> Arc<Vec<SourceRootId>> { |
97 | type LibrariesQuery; | 104 | type LocalRootsQuery; |
105 | storage input; | ||
106 | } | ||
107 | fn library_roots() -> Arc<Vec<SourceRootId>> { | ||
108 | type LibraryRootsQuery; | ||
98 | storage input; | 109 | storage input; |
99 | } | 110 | } |
100 | fn crate_graph() -> Arc<CrateGraph> { | 111 | fn crate_graph() -> Arc<CrateGraph> { |
@@ -104,13 +115,7 @@ salsa::query_group! { | |||
104 | } | 115 | } |
105 | } | 116 | } |
106 | 117 | ||
107 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] | ||
108 | pub struct SourceRootId(pub u32); | ||
109 | |||
110 | #[derive(Default, Clone, Debug, PartialEq, Eq)] | 118 | #[derive(Default, Clone, Debug, PartialEq, Eq)] |
111 | pub struct SourceRoot { | 119 | pub struct SourceRoot { |
112 | pub file_resolver: FileResolverImp, | 120 | pub files: FxHashMap<RelativePathBuf, FileId>, |
113 | pub files: FxHashSet<FileId>, | ||
114 | } | 121 | } |
115 | |||
116 | pub const WORKSPACE: SourceRootId = SourceRootId(0); | ||