mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
remove cancelable from symbols
This commit is contained in:
parent
11f3c8afb2
commit
fb012e5c1e
5 changed files with 12 additions and 14 deletions
|
@ -37,13 +37,13 @@ use salsa::ParallelDatabase;
|
|||
use rayon::prelude::*;
|
||||
|
||||
use crate::{
|
||||
Cancelable, FileId, Query,
|
||||
FileId, Query,
|
||||
db::RootDatabase,
|
||||
};
|
||||
|
||||
salsa::query_group! {
|
||||
pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
|
||||
fn file_symbols(file_id: FileId) -> Cancelable<Arc<SymbolIndex>> {
|
||||
fn file_symbols(file_id: FileId) -> Arc<SymbolIndex> {
|
||||
type FileSymbolsQuery;
|
||||
}
|
||||
fn library_symbols(id: SourceRootId) -> Arc<SymbolIndex> {
|
||||
|
@ -53,7 +53,7 @@ salsa::query_group! {
|
|||
}
|
||||
}
|
||||
|
||||
fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> {
|
||||
fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> {
|
||||
db.check_canceled();
|
||||
let source_file = db.source_file(file_id);
|
||||
let mut symbols = source_file
|
||||
|
@ -69,10 +69,10 @@ fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Cancelable<Arc<Sy
|
|||
symbols.push(FileSymbol { file_id, name, ptr })
|
||||
}
|
||||
|
||||
Ok(Arc::new(SymbolIndex::new(symbols)))
|
||||
Arc::new(SymbolIndex::new(symbols))
|
||||
}
|
||||
|
||||
pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Cancelable<Vec<FileSymbol>> {
|
||||
pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> {
|
||||
/// Need to wrap Snapshot to provide `Clone` impl for `map_with`
|
||||
struct Snap(salsa::Snapshot<RootDatabase>);
|
||||
impl Clone for Snap {
|
||||
|
@ -98,10 +98,9 @@ pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Cancelable<Vec<F
|
|||
files
|
||||
.par_iter()
|
||||
.map_with(snap, |db, &file_id| db.0.file_symbols(file_id))
|
||||
.filter_map(|it| it.ok())
|
||||
.collect()
|
||||
};
|
||||
Ok(query.search(&buf))
|
||||
query.search(&buf)
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue