diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-17 11:17:46 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-17 11:17:46 +0000 |
commit | 168c46ab777f6e3263bb2e58f0ce9b0b1619114e (patch) | |
tree | 0723f5b15899902811d027587a46698016d21d54 /crates/ra_db | |
parent | 454cc313589fb17de92d6f3dbf576a5ea5f4adf2 (diff) | |
parent | a2ca03d10b093ea20d7db8bfd78aa1e787482cc0 (diff) |
Merge #561
561: :arrow_up: salsa r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_db')
-rw-r--r-- | crates/ra_db/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_db/src/input.rs | 65 | ||||
-rw-r--r-- | crates/ra_db/src/lib.rs | 10 |
3 files changed, 30 insertions, 47 deletions
diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 21d987688..bb1b5eae7 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml | |||
@@ -6,7 +6,7 @@ authors = ["Aleksey Kladov <[email protected]>"] | |||
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | relative-path = "0.4.0" | 8 | relative-path = "0.4.0" |
9 | salsa = "0.9.2" | 9 | salsa = "0.10.0-alpha1" |
10 | rustc-hash = "1.0" | 10 | rustc-hash = "1.0" |
11 | parking_lot = "0.7.0" | 11 | parking_lot = "0.7.0" |
12 | ra_arena = { path = "../ra_arena" } | 12 | ra_arena = { path = "../ra_arena" } |
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 2b761ea0c..b5d63e820 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -146,46 +146,31 @@ impl CrateGraph { | |||
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | salsa::query_group! { | 149 | #[salsa::query_group] |
150 | pub trait FilesDatabase: salsa::Database { | 150 | pub trait FilesDatabase: salsa::Database { |
151 | /// Text of the file. | 151 | /// Text of the file. |
152 | fn file_text(file_id: FileId) -> Arc<String> { | 152 | #[salsa::input] |
153 | type FileTextQuery; | 153 | fn file_text(&self, file_id: FileId) -> Arc<String>; |
154 | storage input; | 154 | /// Path to a file, relative to the root of its source root. |
155 | } | 155 | #[salsa::input] |
156 | /// Path to a file, relative to the root of its source root. | 156 | fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; |
157 | fn file_relative_path(file_id: FileId) -> RelativePathBuf { | 157 | /// Source root of the file. |
158 | type FileRelativePathQuery; | 158 | #[salsa::input] |
159 | storage input; | 159 | fn file_source_root(&self, file_id: FileId) -> SourceRootId; |
160 | } | 160 | /// Contents of the source root. |
161 | /// Source root of the file. | 161 | #[salsa::input] |
162 | fn file_source_root(file_id: FileId) -> SourceRootId { | 162 | fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>; |
163 | type FileSourceRootQuery; | 163 | /// The set of "local" (that is, from the current workspace) roots. |
164 | storage input; | 164 | /// Files in local roots are assumed to change frequently. |
165 | } | 165 | #[salsa::input] |
166 | /// Contents of the source root. | 166 | fn local_roots(&self) -> Arc<Vec<SourceRootId>>; |
167 | fn source_root(id: SourceRootId) -> Arc<SourceRoot> { | 167 | /// The set of roots for crates.io libraries. |
168 | type SourceRootQuery; | 168 | /// Files in libraries are assumed to never change. |
169 | storage input; | 169 | #[salsa::input] |
170 | } | 170 | fn library_roots(&self) -> Arc<Vec<SourceRootId>>; |
171 | /// The set of "local" (that is, from the current workspace) roots. | 171 | /// The crate graph. |
172 | /// Files in local roots are assumed to change frequently. | 172 | #[salsa::input] |
173 | fn local_roots() -> Arc<Vec<SourceRootId>> { | 173 | fn crate_graph(&self) -> Arc<CrateGraph>; |
174 | type LocalRootsQuery; | ||
175 | storage input; | ||
176 | } | ||
177 | /// The set of roots for crates.io libraries. | ||
178 | /// Files in libraries are assumed to never change. | ||
179 | fn library_roots() -> Arc<Vec<SourceRootId>> { | ||
180 | type LibraryRootsQuery; | ||
181 | storage input; | ||
182 | } | ||
183 | /// The crate graph. | ||
184 | fn crate_graph() -> Arc<CrateGraph> { | ||
185 | type CrateGraphQuery; | ||
186 | storage input; | ||
187 | } | ||
188 | } | ||
189 | } | 174 | } |
190 | 175 | ||
191 | #[cfg(test)] | 176 | #[cfg(test)] |
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 89113e7a6..dbeb9ec71 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -9,6 +9,7 @@ use std::panic; | |||
9 | 9 | ||
10 | use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc}; | 10 | use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc}; |
11 | 11 | ||
12 | pub use ::salsa as salsa; | ||
12 | pub use crate::{ | 13 | pub use crate::{ |
13 | cancellation::Canceled, | 14 | cancellation::Canceled, |
14 | syntax_ptr::LocalSyntaxPtr, | 15 | syntax_ptr::LocalSyntaxPtr, |
@@ -51,12 +52,9 @@ pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe { | |||
51 | } | 52 | } |
52 | } | 53 | } |
53 | 54 | ||
54 | salsa::query_group! { | 55 | #[salsa::query_group] |
55 | pub trait SyntaxDatabase: crate::input::FilesDatabase + BaseDatabase { | 56 | pub trait SyntaxDatabase: crate::input::FilesDatabase + BaseDatabase { |
56 | fn source_file(file_id: FileId) -> TreeArc<SourceFile> { | 57 | fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>; |
57 | type SourceFileQuery; | ||
58 | } | ||
59 | } | ||
60 | } | 58 | } |
61 | 59 | ||
62 | fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc<SourceFile> { | 60 | fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc<SourceFile> { |