use loc2id for FnIds

This commit is contained in:
Aleksey Kladov 2018-11-18 16:21:23 +03:00
parent cb22a799d6
commit 4e48917c00
6 changed files with 70 additions and 22 deletions

View file

@ -1,7 +1,5 @@
use std::sync::Arc;
use parking_lot::Mutex;
use ra_editor::LineIndex;
use ra_syntax::{SourceFileNode, SyntaxNode};
use salsa::{self, Database};
@ -11,19 +9,17 @@ use crate::{
descriptors::{
DescriptorDatabase, FnScopesQuery, FnSyntaxQuery, ModuleScopeQuery, ModuleTreeQuery,
SubmodulesQuery,
module::{ModuleSource, ModuleId},
},
input::SourceRootId,
symbol_index::SymbolIndex,
syntax_ptr::SyntaxPtr,
loc2id::Loc2IdMap,
loc2id::{IdMaps, IdDatabase},
Cancelable, Canceled, FileId,
};
#[derive(Debug)]
pub(crate) struct RootDatabase {
runtime: salsa::Runtime<RootDatabase>,
loc2id: Arc<Mutex<Loc2IdMap<(SourceRootId, ModuleSource), ModuleId>>>,
id_maps: IdMaps,
}
impl salsa::Database for RootDatabase {
@ -35,8 +31,8 @@ impl salsa::Database for RootDatabase {
impl Default for RootDatabase {
fn default() -> RootDatabase {
let mut db = RootDatabase {
runtime: Default::default(),
loc2id: Default::default(),
runtime: salsa::Runtime::default(),
id_maps: IdMaps::default(),
};
db.query_mut(crate::input::SourceRootQuery)
.set(crate::input::WORKSPACE, Default::default());
@ -60,11 +56,17 @@ impl salsa::ParallelDatabase for RootDatabase {
fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
salsa::Snapshot::new(RootDatabase {
runtime: self.runtime.snapshot(self),
loc2id: Arc::clone(&self.loc2id),
id_maps: self.id_maps.clone(),
})
}
}
impl IdDatabase for RootDatabase {
fn id_maps(&self) -> &IdMaps {
&self.id_maps
}
}
salsa::database_storage! {
pub(crate) struct RootDatabaseStorage for RootDatabase {
impl crate::input::FilesDatabase {