diff options
-rw-r--r-- | crates/ra_analysis/src/db.rs | 12 | ||||
-rw-r--r-- | crates/ra_db/src/loc2id.rs | 7 |
2 files changed, 17 insertions, 2 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index 3d0f13f34..94729d296 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use std::sync::Arc; | 1 | use std::{fmt, sync::Arc}; |
2 | use salsa::{self, Database}; | 2 | use salsa::{self, Database}; |
3 | use ra_db::{LocationIntener, BaseDatabase}; | 3 | use ra_db::{LocationIntener, BaseDatabase}; |
4 | use hir::{self, DefId, DefLoc}; | 4 | use hir::{self, DefId, DefLoc}; |
@@ -13,11 +13,19 @@ pub(crate) struct RootDatabase { | |||
13 | id_maps: Arc<IdMaps>, | 13 | id_maps: Arc<IdMaps>, |
14 | } | 14 | } |
15 | 15 | ||
16 | #[derive(Debug, Default)] | 16 | #[derive(Default)] |
17 | struct IdMaps { | 17 | struct IdMaps { |
18 | defs: LocationIntener<DefLoc, DefId>, | 18 | defs: LocationIntener<DefLoc, DefId>, |
19 | } | 19 | } |
20 | 20 | ||
21 | impl fmt::Debug for IdMaps { | ||
22 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
23 | f.debug_struct("IdMaps") | ||
24 | .field("n_defs", &self.defs.len()) | ||
25 | .finish() | ||
26 | } | ||
27 | } | ||
28 | |||
21 | impl salsa::Database for RootDatabase { | 29 | impl salsa::Database for RootDatabase { |
22 | fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> { | 30 | fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> { |
23 | &self.runtime | 31 | &self.runtime |
diff --git a/crates/ra_db/src/loc2id.rs b/crates/ra_db/src/loc2id.rs index 69ba43d0f..2dc7930d8 100644 --- a/crates/ra_db/src/loc2id.rs +++ b/crates/ra_db/src/loc2id.rs | |||
@@ -42,6 +42,10 @@ where | |||
42 | ID: NumericId, | 42 | ID: NumericId, |
43 | LOC: Clone + Eq + Hash, | 43 | LOC: Clone + Eq + Hash, |
44 | { | 44 | { |
45 | pub fn len(&self) -> usize { | ||
46 | self.loc2id.len() | ||
47 | } | ||
48 | |||
45 | pub fn loc2id(&mut self, loc: &LOC) -> ID { | 49 | pub fn loc2id(&mut self, loc: &LOC) -> ID { |
46 | match self.loc2id.get(loc) { | 50 | match self.loc2id.get(loc) { |
47 | Some(id) => return id.clone(), | 51 | Some(id) => return id.clone(), |
@@ -91,6 +95,9 @@ where | |||
91 | ID: NumericId, | 95 | ID: NumericId, |
92 | LOC: Clone + Eq + Hash, | 96 | LOC: Clone + Eq + Hash, |
93 | { | 97 | { |
98 | pub fn len(&self) -> usize { | ||
99 | self.map.lock().len() | ||
100 | } | ||
94 | pub fn loc2id(&self, loc: &LOC) -> ID { | 101 | pub fn loc2id(&self, loc: &LOC) -> ID { |
95 | self.map.lock().loc2id(loc) | 102 | self.map.lock().loc2id(loc) |
96 | } | 103 | } |