mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
migrate to salsas interning
This commit is contained in:
parent
2fc2d4373b
commit
6b993a9760
8 changed files with 109 additions and 111 deletions
|
@ -9,7 +9,7 @@ use relative_path::RelativePathBuf;
|
|||
use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::{db, HirInterner, diagnostics::DiagnosticSink};
|
||||
use crate::{db, diagnostics::DiagnosticSink};
|
||||
|
||||
pub const WORKSPACE: SourceRootId = SourceRootId(0);
|
||||
|
||||
|
@ -18,7 +18,6 @@ pub const WORKSPACE: SourceRootId = SourceRootId(0);
|
|||
pub struct MockDatabase {
|
||||
events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>,
|
||||
runtime: salsa::Runtime<MockDatabase>,
|
||||
interner: Arc<HirInterner>,
|
||||
files: FxHashMap<String, FileId>,
|
||||
}
|
||||
|
||||
|
@ -195,7 +194,6 @@ impl Default for MockDatabase {
|
|||
let mut db = MockDatabase {
|
||||
events: Default::default(),
|
||||
runtime: salsa::Runtime::default(),
|
||||
interner: Default::default(),
|
||||
files: FxHashMap::default(),
|
||||
};
|
||||
db.set_crate_graph(Default::default());
|
||||
|
@ -208,19 +206,12 @@ impl salsa::ParallelDatabase for MockDatabase {
|
|||
salsa::Snapshot::new(MockDatabase {
|
||||
events: Default::default(),
|
||||
runtime: self.runtime.snapshot(self),
|
||||
interner: Arc::clone(&self.interner),
|
||||
// only the root database can be used to get file_id by path.
|
||||
files: FxHashMap::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<HirInterner> for MockDatabase {
|
||||
fn as_ref(&self) -> &HirInterner {
|
||||
&self.interner
|
||||
}
|
||||
}
|
||||
|
||||
impl MockDatabase {
|
||||
pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<MockDatabase>> {
|
||||
*self.events.lock() = Some(Vec::new());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue