mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Add Loc2IdMap
This commit is contained in:
parent
f1d8558cd5
commit
cb22a799d6
6 changed files with 84 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use ra_editor::LineIndex;
|
||||
use ra_syntax::{SourceFileNode, SyntaxNode};
|
||||
use salsa::{self, Database};
|
||||
|
@ -9,15 +11,19 @@ use crate::{
|
|||
descriptors::{
|
||||
DescriptorDatabase, FnScopesQuery, FnSyntaxQuery, ModuleScopeQuery, ModuleTreeQuery,
|
||||
SubmodulesQuery,
|
||||
module::{ModuleSource, ModuleId},
|
||||
},
|
||||
input::SourceRootId,
|
||||
symbol_index::SymbolIndex,
|
||||
syntax_ptr::SyntaxPtr,
|
||||
loc2id::Loc2IdMap,
|
||||
Cancelable, Canceled, FileId,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct RootDatabase {
|
||||
runtime: salsa::Runtime<RootDatabase>,
|
||||
loc2id: Arc<Mutex<Loc2IdMap<(SourceRootId, ModuleSource), ModuleId>>>,
|
||||
}
|
||||
|
||||
impl salsa::Database for RootDatabase {
|
||||
|
@ -30,6 +36,7 @@ impl Default for RootDatabase {
|
|||
fn default() -> RootDatabase {
|
||||
let mut db = RootDatabase {
|
||||
runtime: Default::default(),
|
||||
loc2id: Default::default(),
|
||||
};
|
||||
db.query_mut(crate::input::SourceRootQuery)
|
||||
.set(crate::input::WORKSPACE, Default::default());
|
||||
|
@ -53,6 +60,7 @@ 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),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue