diff options
Diffstat (limited to 'crates/ra_analysis/src/db.rs')
-rw-r--r-- | crates/ra_analysis/src/db.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index 11154cc65..e0b7afac5 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs | |||
@@ -8,7 +8,7 @@ use salsa::{self, Database}; | |||
8 | use crate::{ | 8 | use crate::{ |
9 | hir, | 9 | hir, |
10 | symbol_index, | 10 | symbol_index, |
11 | loc2id::{IdMaps}, | 11 | loc2id::{IdMaps, LocationIntener, DefId, DefLoc, FnId}, |
12 | Cancelable, Canceled, FileId, | 12 | Cancelable, Canceled, FileId, |
13 | }; | 13 | }; |
14 | 14 | ||
@@ -20,7 +20,7 @@ pub(crate) struct RootDatabase { | |||
20 | events: (), | 20 | events: (), |
21 | 21 | ||
22 | runtime: salsa::Runtime<RootDatabase>, | 22 | runtime: salsa::Runtime<RootDatabase>, |
23 | id_maps: IdMaps, | 23 | id_maps: Arc<IdMaps>, |
24 | } | 24 | } |
25 | 25 | ||
26 | impl salsa::Database for RootDatabase { | 26 | impl salsa::Database for RootDatabase { |
@@ -45,7 +45,7 @@ impl Default for RootDatabase { | |||
45 | let mut db = RootDatabase { | 45 | let mut db = RootDatabase { |
46 | events: Default::default(), | 46 | events: Default::default(), |
47 | runtime: salsa::Runtime::default(), | 47 | runtime: salsa::Runtime::default(), |
48 | id_maps: IdMaps::default(), | 48 | id_maps: Default::default(), |
49 | }; | 49 | }; |
50 | db.query_mut(crate::input::SourceRootQuery) | 50 | db.query_mut(crate::input::SourceRootQuery) |
51 | .set(crate::input::WORKSPACE, Default::default()); | 51 | .set(crate::input::WORKSPACE, Default::default()); |
@@ -84,6 +84,18 @@ impl BaseDatabase for RootDatabase { | |||
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | impl AsRef<LocationIntener<DefLoc, DefId>> for RootDatabase { | ||
88 | fn as_ref(&self) -> &LocationIntener<DefLoc, DefId> { | ||
89 | &self.id_maps.defs | ||
90 | } | ||
91 | } | ||
92 | |||
93 | impl AsRef<LocationIntener<hir::SourceItemId, FnId>> for RootDatabase { | ||
94 | fn as_ref(&self) -> &LocationIntener<hir::SourceItemId, FnId> { | ||
95 | &self.id_maps.fns | ||
96 | } | ||
97 | } | ||
98 | |||
87 | #[cfg(test)] | 99 | #[cfg(test)] |
88 | impl RootDatabase { | 100 | impl RootDatabase { |
89 | pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<RootDatabase>> { | 101 | pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<RootDatabase>> { |