Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-db/src/symbol_index.rs')
| -rw-r--r-- | crates/ide-db/src/symbol_index.rs | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/crates/ide-db/src/symbol_index.rs b/crates/ide-db/src/symbol_index.rs index 2737436993..5fea97b32d 100644 --- a/crates/ide-db/src/symbol_index.rs +++ b/crates/ide-db/src/symbol_index.rs @@ -27,10 +27,7 @@ use std::{ ops::ControlFlow, }; -use base_db::{ - ra_salsa::{self, ParallelDatabase}, - SourceRootDatabase, SourceRootId, Upcast, -}; +use base_db::{RootQueryDb, SourceDatabase, SourceRootId, Upcast}; use fst::{raw::IndexedValue, Automaton, Streamer}; use hir::{ db::HirDatabase, @@ -99,8 +96,8 @@ impl Query { } } -#[ra_salsa::query_group(SymbolsDatabaseStorage)] -pub trait SymbolsDatabase: HirDatabase + SourceRootDatabase + Upcast<dyn HirDatabase> { +#[query_group::query_group] +pub trait SymbolsDatabase: HirDatabase + SourceDatabase + Upcast<dyn HirDatabase> { /// The symbol index for a given module. These modules should only be in source roots that /// are inside local_roots. fn module_symbols(&self, module: Module) -> Arc<SymbolIndex>; @@ -108,18 +105,18 @@ pub trait SymbolsDatabase: HirDatabase + SourceRootDatabase + Upcast<dyn HirData /// The symbol index for a given source root within library_roots. fn library_symbols(&self, source_root_id: SourceRootId) -> Arc<SymbolIndex>; - #[ra_salsa::transparent] + #[salsa::transparent] /// The symbol indices of modules that make up a given crate. fn crate_symbols(&self, krate: Crate) -> Box<[Arc<SymbolIndex>]>; /// The set of "local" (that is, from the current workspace) roots. /// Files in local roots are assumed to change frequently. - #[ra_salsa::input] + #[salsa::input] fn local_roots(&self) -> Arc<FxHashSet<SourceRootId>>; /// The set of roots for crates.io libraries. /// Files in libraries are assumed to never change. - #[ra_salsa::input] + #[salsa::input] fn library_roots(&self) -> Arc<FxHashSet<SourceRootId>>; } @@ -150,26 +147,6 @@ pub fn crate_symbols(db: &dyn SymbolsDatabase, krate: Crate) -> Box<[Arc<SymbolI krate.modules(db.upcast()).into_iter().map(|module| db.module_symbols(module)).collect() } -/// Need to wrap Snapshot to provide `Clone` impl for `map_with` -struct Snap<DB>(DB); -impl<DB: ParallelDatabase> Snap<ra_salsa::Snapshot<DB>> { - fn new(db: &DB) -> Self { - Self(db.snapshot()) - } -} -impl<DB: ParallelDatabase> Clone for Snap<ra_salsa::Snapshot<DB>> { - fn clone(&self) -> Snap<ra_salsa::Snapshot<DB>> { - Snap(self.0.snapshot()) - } -} -impl<DB> std::ops::Deref for Snap<DB> { - type Target = DB; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - // Feature: Workspace Symbol // // Uses fuzzy-search to find types, modules and functions by name across your @@ -201,7 +178,7 @@ pub fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> { let indices: Vec<_> = if query.libs { db.library_roots() .par_iter() - .map_with(Snap::new(db), |snap, &root| snap.library_symbols(root)) + .map_with(db.clone(), |snap, &root| snap.library_symbols(root)) .collect() } else { let mut crates = Vec::new(); @@ -211,7 +188,7 @@ pub fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> { } let indices: Vec<_> = crates .into_par_iter() - .map_with(Snap::new(db), |snap, krate| snap.crate_symbols(krate.into())) + .map_with(db.clone(), |snap, krate| snap.crate_symbols(krate.into())) .collect(); indices.iter().flat_map(|indices| indices.iter().cloned()).collect() }; |