aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock14
-rw-r--r--crates/ra_db/Cargo.toml2
-rw-r--r--crates/ra_db/src/input.rs42
-rw-r--r--crates/ra_db/src/lib.rs68
-rw-r--r--crates/ra_hir/Cargo.toml2
-rw-r--r--crates/ra_hir/src/mock.rs50
-rw-r--r--crates/ra_ide_api/Cargo.toml1
-rw-r--r--crates/ra_ide_api/src/db.rs56
-rw-r--r--crates/ra_ide_api/src/status.rs2
9 files changed, 79 insertions, 158 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 55ac3e7de..bfa0bf2ed 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -726,7 +726,7 @@ dependencies = [
726 "ra_syntax 0.1.0", 726 "ra_syntax 0.1.0",
727 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 727 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
728 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 728 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
729 "salsa 0.10.0-alpha1 (registry+https://github.com/rust-lang/crates.io-index)", 729 "salsa 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)",
730 "test_utils 0.1.0", 730 "test_utils 0.1.0",
731] 731]
732 732
@@ -746,6 +746,7 @@ dependencies = [
746 "ra_syntax 0.1.0", 746 "ra_syntax 0.1.0",
747 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 747 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
748 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 748 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
749 "salsa 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)",
749 "test_utils 0.1.0", 750 "test_utils 0.1.0",
750] 751]
751 752
@@ -766,6 +767,7 @@ dependencies = [
766 "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 767 "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
767 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 768 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
768 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 769 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
770 "salsa 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)",
769 "test_utils 0.1.0", 771 "test_utils 0.1.0",
770 "unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 772 "unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
771] 773]
@@ -1088,7 +1090,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1088 1090
1089[[package]] 1091[[package]]
1090name = "salsa" 1092name = "salsa"
1091version = "0.10.0-alpha1" 1093version = "0.10.0-alpha3"
1092source = "registry+https://github.com/rust-lang/crates.io-index" 1094source = "registry+https://github.com/rust-lang/crates.io-index"
1093dependencies = [ 1095dependencies = [
1094 "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 1096 "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1097,13 +1099,13 @@ dependencies = [
1097 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 1099 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
1098 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 1100 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
1099 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1101 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1100 "salsa-macros 0.10.0-alpha1 (registry+https://github.com/rust-lang/crates.io-index)", 1102 "salsa-macros 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)",
1101 "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", 1103 "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
1102] 1104]
1103 1105
1104[[package]] 1106[[package]]
1105name = "salsa-macros" 1107name = "salsa-macros"
1106version = "0.10.0-alpha1" 1108version = "0.10.0-alpha3"
1107source = "registry+https://github.com/rust-lang/crates.io-index" 1109source = "registry+https://github.com/rust-lang/crates.io-index"
1108dependencies = [ 1110dependencies = [
1109 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 1111 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1694,8 +1696,8 @@ dependencies = [
1694"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 1696"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
1695"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c" 1697"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c"
1696"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" 1698"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
1697"checksum salsa 0.10.0-alpha1 (registry+https://github.com/rust-lang/crates.io-index)" = "4cc048429df53bf0720b93cfa5fa8c3fc3dc7dd65ab41b3f754a8870e7b5c834" 1699"checksum salsa 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)" = "135c0977b23f8a9dc16744dd5495989110e3763ba5ea41e386741c7f8901e285"
1698"checksum salsa-macros 0.10.0-alpha1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d5a1aeb618da4b1a00d2885d045154ac30deb04109f3ce73c1fd789caba4fb1" 1700"checksum salsa-macros 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)" = "c9c93b5efed7281334c4bed8470b278076d1ccd6a60da59a15cd0d57792afff8"
1699"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" 1701"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
1700"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" 1702"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
1701"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 1703"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml
index bb1b5eae7..3568da905 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.10.0-alpha1" 9salsa = "0.10.0-alpha3"
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 9825d52cf..275894252 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -5,11 +5,8 @@
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.
8use std::sync::Arc;
9
10use relative_path::RelativePathBuf; 8use relative_path::RelativePathBuf;
11use rustc_hash::FxHashMap; 9use rustc_hash::FxHashMap;
12use salsa;
13 10
14use ra_syntax::SmolStr; 11use ra_syntax::SmolStr;
15use rustc_hash::FxHashSet; 12use rustc_hash::FxHashSet;
@@ -146,45 +143,6 @@ impl CrateGraph {
146 } 143 }
147} 144}
148 145
149#[salsa::query_group]
150pub trait FilesDatabase: salsa::Database {
151 /// Text of the file.
152 #[salsa::input]
153 fn file_text(&self, file_id: FileId) -> Arc<String>;
154 /// Path to a file, relative to the root of its source root.
155 #[salsa::input]
156 fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf;
157 /// Source root of the file.
158 #[salsa::input]
159 fn file_source_root(&self, file_id: FileId) -> SourceRootId;
160 /// Contents of the source root.
161 #[salsa::input]
162 fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>;
163 fn source_root_crates(&self, id: SourceRootId) -> Arc<Vec<CrateId>>;
164 /// The set of "local" (that is, from the current workspace) roots.
165 /// Files in local roots are assumed to change frequently.
166 #[salsa::input]
167 fn local_roots(&self) -> Arc<Vec<SourceRootId>>;
168 /// The set of roots for crates.io libraries.
169 /// Files in libraries are assumed to never change.
170 #[salsa::input]
171 fn library_roots(&self) -> Arc<Vec<SourceRootId>>;
172 /// The crate graph.
173 #[salsa::input]
174 fn crate_graph(&self) -> Arc<CrateGraph>;
175}
176
177fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc<Vec<CrateId>> {
178 let root = db.source_root(id);
179 let graph = db.crate_graph();
180 let res = root
181 .files
182 .values()
183 .filter_map(|&it| graph.crate_id_for_crate_root(it))
184 .collect::<Vec<_>>();
185 Arc::new(res)
186}
187
188#[cfg(test)] 146#[cfg(test)]
189mod tests { 147mod tests {
190 use super::{CrateGraph, FileId, SmolStr}; 148 use super::{CrateGraph, FileId, SmolStr};
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index 84759c75a..7e13f70bc 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -4,17 +4,18 @@ mod input;
4mod loc2id; 4mod loc2id;
5pub mod mock; 5pub mod mock;
6 6
7use std::panic; 7use std::{
8 panic, sync::Arc,
9};
8 10
9use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc}; 11use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc};
12use relative_path::RelativePathBuf;
10 13
11pub use ::salsa as salsa; 14pub use ::salsa as salsa;
12pub use crate::{ 15pub use crate::{
13 cancellation::Canceled, 16 cancellation::Canceled,
14 input::{ 17 input::{
15 FilesDatabase, FileId, CrateId, SourceRoot, SourceRootId, CrateGraph, Dependency, 18 FileId, CrateId, SourceRoot, SourceRootId, CrateGraph, Dependency,
16 FileTextQuery, FileSourceRootQuery, SourceRootQuery, SourceRootCratesQuery, LocalRootsQuery, LibraryRootsQuery, CrateGraphQuery,
17 FileRelativePathQuery
18 }, 19 },
19 loc2id::LocationIntener, 20 loc2id::LocationIntener,
20}; 21};
@@ -50,16 +51,6 @@ pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe {
50 } 51 }
51} 52}
52 53
53#[salsa::query_group]
54pub trait SyntaxDatabase: crate::input::FilesDatabase + BaseDatabase {
55 fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>;
56}
57
58fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc<SourceFile> {
59 let text = db.file_text(file_id);
60 SourceFile::parse(&*text)
61}
62
63#[derive(Clone, Copy, Debug)] 54#[derive(Clone, Copy, Debug)]
64pub struct FilePosition { 55pub struct FilePosition {
65 pub file_id: FileId, 56 pub file_id: FileId,
@@ -71,3 +62,52 @@ pub struct FileRange {
71 pub file_id: FileId, 62 pub file_id: FileId,
72 pub range: TextRange, 63 pub range: TextRange,
73} 64}
65
66#[salsa::query_group]
67pub trait FilesDatabase: salsa::Database {
68 /// Text of the file.
69 #[salsa::input]
70 fn file_text(&self, file_id: FileId) -> Arc<String>;
71 /// Path to a file, relative to the root of its source root.
72 #[salsa::input]
73 fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf;
74 /// Source root of the file.
75 #[salsa::input]
76 fn file_source_root(&self, file_id: FileId) -> SourceRootId;
77 /// Contents of the source root.
78 #[salsa::input]
79 fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>;
80 fn source_root_crates(&self, id: SourceRootId) -> Arc<Vec<CrateId>>;
81 /// The set of "local" (that is, from the current workspace) roots.
82 /// Files in local roots are assumed to change frequently.
83 #[salsa::input]
84 fn local_roots(&self) -> Arc<Vec<SourceRootId>>;
85 /// The set of roots for crates.io libraries.
86 /// Files in libraries are assumed to never change.
87 #[salsa::input]
88 fn library_roots(&self) -> Arc<Vec<SourceRootId>>;
89 /// The crate graph.
90 #[salsa::input]
91 fn crate_graph(&self) -> Arc<CrateGraph>;
92}
93
94fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc<Vec<CrateId>> {
95 let root = db.source_root(id);
96 let graph = db.crate_graph();
97 let res = root
98 .files
99 .values()
100 .filter_map(|&it| graph.crate_id_for_crate_root(it))
101 .collect::<Vec<_>>();
102 Arc::new(res)
103}
104
105#[salsa::query_group]
106pub trait SyntaxDatabase: FilesDatabase + BaseDatabase {
107 fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>;
108}
109
110fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc<SourceFile> {
111 let text = db.file_text(file_id);
112 SourceFile::parse(&*text)
113}
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml
index 86937ccd8..3d802ade4 100644
--- a/crates/ra_hir/Cargo.toml
+++ b/crates/ra_hir/Cargo.toml
@@ -12,6 +12,8 @@ rustc-hash = "1.0"
12parking_lot = "0.7.0" 12parking_lot = "0.7.0"
13ena = "0.11" 13ena = "0.11"
14join_to_string = "0.1.3" 14join_to_string = "0.1.3"
15salsa = "0.10.0-alpha3"
16
15ra_syntax = { path = "../ra_syntax" } 17ra_syntax = { path = "../ra_syntax" }
16ra_arena = { path = "../ra_arena" } 18ra_arena = { path = "../ra_arena" }
17ra_db = { path = "../ra_db" } 19ra_db = { path = "../ra_db" }
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index 1a83a5c87..aa54336b8 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -12,6 +12,7 @@ use crate::{db, HirInterner};
12 12
13pub const WORKSPACE: SourceRootId = SourceRootId(0); 13pub const WORKSPACE: SourceRootId = SourceRootId(0);
14 14
15#[salsa::database(ra_db::FilesDatabase, ra_db::SyntaxDatabase, db::HirDatabase)]
15#[derive(Debug)] 16#[derive(Debug)]
16pub(crate) struct MockDatabase { 17pub(crate) struct MockDatabase {
17 events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, 18 events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>,
@@ -181,8 +182,7 @@ impl MockDatabase {
181 pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<MockDatabase>> { 182 pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<MockDatabase>> {
182 *self.events.lock() = Some(Vec::new()); 183 *self.events.lock() = Some(Vec::new());
183 f(); 184 f();
184 let events = self.events.lock().take().unwrap(); 185 self.events.lock().take().unwrap()
185 events
186 } 186 }
187 187
188 pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { 188 pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
@@ -192,51 +192,11 @@ impl MockDatabase {
192 .filter_map(|e| match e.kind { 192 .filter_map(|e| match e.kind {
193 // This pretty horrible, but `Debug` is the only way to inspect 193 // This pretty horrible, but `Debug` is the only way to inspect
194 // QueryDescriptor at the moment. 194 // QueryDescriptor at the moment.
195 salsa::EventKind::WillExecute { descriptor } => Some(format!("{:?}", descriptor)), 195 salsa::EventKind::WillExecute { database_key } => {
196 Some(format!("{:?}", database_key))
197 }
196 _ => None, 198 _ => None,
197 }) 199 })
198 .collect() 200 .collect()
199 } 201 }
200} 202}
201
202salsa::database_storage! {
203 pub(crate) struct MockDatabaseStorage for MockDatabase {
204 impl ra_db::FilesDatabase {
205 fn file_text() for ra_db::FileTextQuery;
206 fn file_relative_path() for ra_db::FileRelativePathQuery;
207 fn file_source_root() for ra_db::FileSourceRootQuery;
208 fn source_root() for ra_db::SourceRootQuery;
209 fn source_root_crates() for ra_db::SourceRootCratesQuery;
210 fn local_roots() for ra_db::LocalRootsQuery;
211 fn library_roots() for ra_db::LibraryRootsQuery;
212 fn crate_graph() for ra_db::CrateGraphQuery;
213 }
214 impl ra_db::SyntaxDatabase {
215 fn source_file() for ra_db::SourceFileQuery;
216 }
217 impl db::HirDatabase {
218 fn hir_source_file() for db::HirSourceFileQuery;
219 fn expand_macro_invocation() for db::ExpandMacroInvocationQuery;
220 fn module_tree() for db::ModuleTreeQuery;
221 fn fn_scopes() for db::FnScopesQuery;
222 fn file_items() for db::FileItemsQuery;
223 fn file_item() for db::FileItemQuery;
224 fn lower_module() for db::LowerModuleQuery;
225 fn lower_module_module() for db::LowerModuleModuleQuery;
226 fn lower_module_source_map() for db::LowerModuleSourceMapQuery;
227 fn item_map() for db::ItemMapQuery;
228 fn submodules() for db::SubmodulesQuery;
229 fn infer() for db::InferQuery;
230 fn type_for_def() for db::TypeForDefQuery;
231 fn type_for_field() for db::TypeForFieldQuery;
232 fn struct_data() for db::StructDataQuery;
233 fn enum_data() for db::EnumDataQuery;
234 fn impls_in_module() for db::ImplsInModuleQuery;
235 fn impls_in_crate() for db::ImplsInCrateQuery;
236 fn body_hir() for db::BodyHirQuery;
237 fn body_syntax_mapping() for db::BodySyntaxMappingQuery;
238 fn fn_signature() for db::FnSignatureQuery;
239 fn generic_params() for db::GenericParamsQuery;
240 }
241 }
242}
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml
index 20c911f8f..61942bbbb 100644
--- a/crates/ra_ide_api/Cargo.toml
+++ b/crates/ra_ide_api/Cargo.toml
@@ -13,6 +13,7 @@ fst = "0.3.1"
13rustc-hash = "1.0" 13rustc-hash = "1.0"
14parking_lot = "0.7.0" 14parking_lot = "0.7.0"
15unicase = "2.2.0" 15unicase = "2.2.0"
16salsa = "0.10.0-alpha3"
16 17
17ra_syntax = { path = "../ra_syntax" } 18ra_syntax = { path = "../ra_syntax" }
18ra_ide_api_light = { path = "../ra_ide_api_light" } 19ra_ide_api_light = { path = "../ra_ide_api_light" }
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs
index 11305613c..f0190ae51 100644
--- a/crates/ra_ide_api/src/db.rs
+++ b/crates/ra_ide_api/src/db.rs
@@ -7,6 +7,13 @@ use ra_db::{
7 7
8use crate::{symbol_index, LineIndex}; 8use crate::{symbol_index, LineIndex};
9 9
10#[salsa::database(
11 ra_db::FilesDatabase,
12 ra_db::SyntaxDatabase,
13 LineIndexDatabase,
14 symbol_index::SymbolsDatabase,
15 hir::db::HirDatabase
16)]
10#[derive(Debug)] 17#[derive(Debug)]
11pub(crate) struct RootDatabase { 18pub(crate) struct RootDatabase {
12 runtime: salsa::Runtime<RootDatabase>, 19 runtime: salsa::Runtime<RootDatabase>,
@@ -64,52 +71,3 @@ fn line_index(db: &impl ra_db::FilesDatabase, file_id: FileId) -> Arc<LineIndex>
64 let text = db.file_text(file_id); 71 let text = db.file_text(file_id);
65 Arc::new(LineIndex::new(&*text)) 72 Arc::new(LineIndex::new(&*text))
66} 73}
67
68salsa::database_storage! {
69 pub(crate) struct RootDatabaseStorage for RootDatabase {
70 impl ra_db::FilesDatabase {
71 fn file_text() for ra_db::FileTextQuery;
72 fn file_relative_path() for ra_db::FileRelativePathQuery;
73 fn file_source_root() for ra_db::FileSourceRootQuery;
74 fn source_root() for ra_db::SourceRootQuery;
75 fn source_root_crates() for ra_db::SourceRootCratesQuery;
76 fn local_roots() for ra_db::LocalRootsQuery;
77 fn library_roots() for ra_db::LibraryRootsQuery;
78 fn crate_graph() for ra_db::CrateGraphQuery;
79 }
80 impl ra_db::SyntaxDatabase {
81 fn source_file() for ra_db::SourceFileQuery;
82 }
83 impl LineIndexDatabase {
84 fn line_index() for LineIndexQuery;
85 }
86 impl symbol_index::SymbolsDatabase {
87 fn file_symbols() for symbol_index::FileSymbolsQuery;
88 fn library_symbols() for symbol_index::LibrarySymbolsQuery;
89 }
90 impl hir::db::HirDatabase {
91 fn hir_source_file() for hir::db::HirSourceFileQuery;
92 fn expand_macro_invocation() for hir::db::ExpandMacroInvocationQuery;
93 fn module_tree() for hir::db::ModuleTreeQuery;
94 fn fn_scopes() for hir::db::FnScopesQuery;
95 fn file_items() for hir::db::FileItemsQuery;
96 fn file_item() for hir::db::FileItemQuery;
97 fn lower_module() for hir::db::LowerModuleQuery;
98 fn lower_module_module() for hir::db::LowerModuleModuleQuery;
99 fn lower_module_source_map() for hir::db::LowerModuleSourceMapQuery;
100 fn item_map() for hir::db::ItemMapQuery;
101 fn submodules() for hir::db::SubmodulesQuery;
102 fn infer() for hir::db::InferQuery;
103 fn type_for_def() for hir::db::TypeForDefQuery;
104 fn type_for_field() for hir::db::TypeForFieldQuery;
105 fn struct_data() for hir::db::StructDataQuery;
106 fn enum_data() for hir::db::EnumDataQuery;
107 fn impls_in_module() for hir::db::ImplsInModuleQuery;
108 fn impls_in_crate() for hir::db::ImplsInCrateQuery;
109 fn body_hir() for hir::db::BodyHirQuery;
110 fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery;
111 fn fn_signature() for hir::db::FnSignatureQuery;
112 fn generic_params() for hir::db::GenericParamsQuery;
113 }
114 }
115}
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs
index 5c14cbdeb..d499dd878 100644
--- a/crates/ra_ide_api/src/status.rs
+++ b/crates/ra_ide_api/src/status.rs
@@ -6,7 +6,7 @@ use ra_db::{
6use crate::db::RootDatabase; 6use crate::db::RootDatabase;
7 7
8pub(crate) fn status(db: &RootDatabase) -> String { 8pub(crate) fn status(db: &RootDatabase) -> String {
9 let n_parsed_files = db.query(SourceFileQuery).keys::<Vec<_>>().len(); 9 let n_parsed_files = db.query(SourceFileQuery).entries::<Vec<_>>().len();
10 let n_defs = { 10 let n_defs = {
11 let interner: &hir::HirInterner = db.as_ref(); 11 let interner: &hir::HirInterner = db.as_ref();
12 interner.len() 12 interner.len()