diff options
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 36 | ||||
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 4 |
2 files changed, 10 insertions, 30 deletions
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index a1b666899..ba0eb1cb8 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::{fmt, sync::Arc}; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_db::{ | 3 | use ra_db::{ |
4 | LocationIntener, BaseDatabase, FileId, Canceled, | 4 | BaseDatabase, FileId, Canceled, |
5 | salsa::{self, Database}, | 5 | salsa::{self, Database}, |
6 | }; | 6 | }; |
7 | 7 | ||
@@ -10,21 +10,7 @@ use crate::{symbol_index, LineIndex}; | |||
10 | #[derive(Debug)] | 10 | #[derive(Debug)] |
11 | pub(crate) struct RootDatabase { | 11 | pub(crate) struct RootDatabase { |
12 | runtime: salsa::Runtime<RootDatabase>, | 12 | runtime: salsa::Runtime<RootDatabase>, |
13 | id_maps: Arc<IdMaps>, | 13 | interner: Arc<hir::HirInterner>, |
14 | } | ||
15 | |||
16 | #[derive(Default)] | ||
17 | struct IdMaps { | ||
18 | defs: LocationIntener<hir::DefLoc, hir::DefId>, | ||
19 | macros: LocationIntener<hir::MacroCallLoc, hir::MacroCallId>, | ||
20 | } | ||
21 | |||
22 | impl fmt::Debug for IdMaps { | ||
23 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
24 | f.debug_struct("IdMaps") | ||
25 | .field("n_defs", &self.defs.len()) | ||
26 | .finish() | ||
27 | } | ||
28 | } | 14 | } |
29 | 15 | ||
30 | impl salsa::Database for RootDatabase { | 16 | impl salsa::Database for RootDatabase { |
@@ -40,7 +26,7 @@ impl Default for RootDatabase { | |||
40 | fn default() -> RootDatabase { | 26 | fn default() -> RootDatabase { |
41 | let mut db = RootDatabase { | 27 | let mut db = RootDatabase { |
42 | runtime: salsa::Runtime::default(), | 28 | runtime: salsa::Runtime::default(), |
43 | id_maps: Default::default(), | 29 | interner: Default::default(), |
44 | }; | 30 | }; |
45 | db.query_mut(ra_db::CrateGraphQuery) | 31 | db.query_mut(ra_db::CrateGraphQuery) |
46 | .set((), Default::default()); | 32 | .set((), Default::default()); |
@@ -56,22 +42,16 @@ impl salsa::ParallelDatabase for RootDatabase { | |||
56 | fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { | 42 | fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { |
57 | salsa::Snapshot::new(RootDatabase { | 43 | salsa::Snapshot::new(RootDatabase { |
58 | runtime: self.runtime.snapshot(self), | 44 | runtime: self.runtime.snapshot(self), |
59 | id_maps: self.id_maps.clone(), | 45 | interner: Arc::clone(&self.interner), |
60 | }) | 46 | }) |
61 | } | 47 | } |
62 | } | 48 | } |
63 | 49 | ||
64 | impl BaseDatabase for RootDatabase {} | 50 | impl BaseDatabase for RootDatabase {} |
65 | 51 | ||
66 | impl AsRef<LocationIntener<hir::DefLoc, hir::DefId>> for RootDatabase { | 52 | impl AsRef<hir::HirInterner> for RootDatabase { |
67 | fn as_ref(&self) -> &LocationIntener<hir::DefLoc, hir::DefId> { | 53 | fn as_ref(&self) -> &hir::HirInterner { |
68 | &self.id_maps.defs | 54 | &self.interner |
69 | } | ||
70 | } | ||
71 | |||
72 | impl AsRef<LocationIntener<hir::MacroCallLoc, hir::MacroCallId>> for RootDatabase { | ||
73 | fn as_ref(&self) -> &LocationIntener<hir::MacroCallLoc, hir::MacroCallId> { | ||
74 | &self.id_maps.macros | ||
75 | } | 55 | } |
76 | } | 56 | } |
77 | 57 | ||
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index d3e04be23..5c14cbdeb 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_db::{ | 1 | use ra_db::{ |
2 | LocationIntener, SourceFileQuery, | 2 | SourceFileQuery, |
3 | salsa::{Database, debug::DebugQueryTable}, | 3 | salsa::{Database, debug::DebugQueryTable}, |
4 | }; | 4 | }; |
5 | 5 | ||
@@ -8,7 +8,7 @@ use crate::db::RootDatabase; | |||
8 | pub(crate) fn status(db: &RootDatabase) -> String { | 8 | pub(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).keys::<Vec<_>>().len(); |
10 | let n_defs = { | 10 | let n_defs = { |
11 | let interner: &LocationIntener<hir::DefLoc, hir::DefId> = db.as_ref(); | 11 | let interner: &hir::HirInterner = db.as_ref(); |
12 | interner.len() | 12 | interner.len() |
13 | }; | 13 | }; |
14 | format!("#n_parsed_files {}\n#n_defs {}\n", n_parsed_files, n_defs) | 14 | format!("#n_parsed_files {}\n#n_defs {}\n", n_parsed_files, n_defs) |