aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/db.rs')
-rw-r--r--crates/ra_analysis/src/db.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs
index 194f1a6b0..d78b6afb9 100644
--- a/crates/ra_analysis/src/db.rs
+++ b/crates/ra_analysis/src/db.rs
@@ -12,12 +12,14 @@ use crate::{
12 }, 12 },
13 symbol_index::SymbolIndex, 13 symbol_index::SymbolIndex,
14 syntax_ptr::SyntaxPtr, 14 syntax_ptr::SyntaxPtr,
15 loc2id::{IdMaps, IdDatabase},
15 Cancelable, Canceled, FileId, 16 Cancelable, Canceled, FileId,
16}; 17};
17 18
18#[derive(Debug)] 19#[derive(Debug)]
19pub(crate) struct RootDatabase { 20pub(crate) struct RootDatabase {
20 runtime: salsa::Runtime<RootDatabase>, 21 runtime: salsa::Runtime<RootDatabase>,
22 id_maps: IdMaps,
21} 23}
22 24
23impl salsa::Database for RootDatabase { 25impl salsa::Database for RootDatabase {
@@ -29,7 +31,8 @@ impl salsa::Database for RootDatabase {
29impl Default for RootDatabase { 31impl Default for RootDatabase {
30 fn default() -> RootDatabase { 32 fn default() -> RootDatabase {
31 let mut db = RootDatabase { 33 let mut db = RootDatabase {
32 runtime: Default::default(), 34 runtime: salsa::Runtime::default(),
35 id_maps: IdMaps::default(),
33 }; 36 };
34 db.query_mut(crate::input::SourceRootQuery) 37 db.query_mut(crate::input::SourceRootQuery)
35 .set(crate::input::WORKSPACE, Default::default()); 38 .set(crate::input::WORKSPACE, Default::default());
@@ -53,10 +56,17 @@ impl salsa::ParallelDatabase for RootDatabase {
53 fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { 56 fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
54 salsa::Snapshot::new(RootDatabase { 57 salsa::Snapshot::new(RootDatabase {
55 runtime: self.runtime.snapshot(self), 58 runtime: self.runtime.snapshot(self),
59 id_maps: self.id_maps.clone(),
56 }) 60 })
57 } 61 }
58} 62}
59 63
64impl IdDatabase for RootDatabase {
65 fn id_maps(&self) -> &IdMaps {
66 &self.id_maps
67 }
68}
69
60salsa::database_storage! { 70salsa::database_storage! {
61 pub(crate) struct RootDatabaseStorage for RootDatabase { 71 pub(crate) struct RootDatabaseStorage for RootDatabase {
62 impl crate::input::FilesDatabase { 72 impl crate::input::FilesDatabase {