mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
generalize location interner
This commit is contained in:
parent
ec45dfea1e
commit
b2de95879a
8 changed files with 101 additions and 51 deletions
|
@ -8,7 +8,7 @@ use salsa::{self, Database};
|
|||
use crate::{
|
||||
hir,
|
||||
symbol_index,
|
||||
loc2id::{IdMaps},
|
||||
loc2id::{IdMaps, LocationIntener, DefId, DefLoc, FnId},
|
||||
Cancelable, Canceled, FileId,
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,7 @@ pub(crate) struct RootDatabase {
|
|||
events: (),
|
||||
|
||||
runtime: salsa::Runtime<RootDatabase>,
|
||||
id_maps: IdMaps,
|
||||
id_maps: Arc<IdMaps>,
|
||||
}
|
||||
|
||||
impl salsa::Database for RootDatabase {
|
||||
|
@ -45,7 +45,7 @@ impl Default for RootDatabase {
|
|||
let mut db = RootDatabase {
|
||||
events: Default::default(),
|
||||
runtime: salsa::Runtime::default(),
|
||||
id_maps: IdMaps::default(),
|
||||
id_maps: Default::default(),
|
||||
};
|
||||
db.query_mut(crate::input::SourceRootQuery)
|
||||
.set(crate::input::WORKSPACE, Default::default());
|
||||
|
@ -84,6 +84,18 @@ impl BaseDatabase for RootDatabase {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsRef<LocationIntener<DefLoc, DefId>> for RootDatabase {
|
||||
fn as_ref(&self) -> &LocationIntener<DefLoc, DefId> {
|
||||
&self.id_maps.defs
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<LocationIntener<hir::SourceItemId, FnId>> for RootDatabase {
|
||||
fn as_ref(&self) -> &LocationIntener<hir::SourceItemId, FnId> {
|
||||
&self.id_maps.fns
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl RootDatabase {
|
||||
pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<RootDatabase>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue