aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_db')
-rw-r--r--crates/ra_db/Cargo.toml2
-rw-r--r--crates/ra_db/src/input.rs65
-rw-r--r--crates/ra_db/src/lib.rs10
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]
8relative-path = "0.4.0" 8relative-path = "0.4.0"
9salsa = "0.9.2" 9salsa = "0.10.0-alpha1"
10rustc-hash = "1.0" 10rustc-hash = "1.0"
11parking_lot = "0.7.0" 11parking_lot = "0.7.0"
12ra_arena = { path = "../ra_arena" } 12ra_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
149salsa::query_group! { 149#[salsa::query_group]
150 pub trait FilesDatabase: salsa::Database { 150pub 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
10use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc}; 10use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc};
11 11
12pub use ::salsa as salsa;
12pub use crate::{ 13pub 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
54salsa::query_group! { 55#[salsa::query_group]
55 pub trait SyntaxDatabase: crate::input::FilesDatabase + BaseDatabase { 56pub 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
62fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc<SourceFile> { 60fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc<SourceFile> {