From 71cbdddf1c6b6c34c05aea01b92bb8a105b32c71 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Oct 2018 22:29:26 +0300 Subject: make file-symbols query cancelable --- crates/ra_analysis/src/db.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'crates/ra_analysis/src/db.rs') diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index cce959669..d621b3b22 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs @@ -1,17 +1,19 @@ -use crate::{ - module_map::{ModuleDescriptorQuery, ModuleTreeQuery, ModulesDatabase}, - symbol_index::SymbolIndex, - FileId, FileResolverImp, +use std::{ + fmt, + hash::{Hash, Hasher}, + sync::Arc, }; + use ra_editor::LineIndex; use ra_syntax::File; use rustc_hash::FxHashSet; use salsa; -use std::{ - fmt, - hash::{Hash, Hasher}, - sync::Arc, +use crate::{ + Cancelable, + module_map::{ModuleDescriptorQuery, ModuleTreeQuery, ModulesDatabase}, + symbol_index::SymbolIndex, + FileId, FileResolverImp, }; #[derive(Default)] @@ -98,7 +100,7 @@ salsa::query_group! { fn file_lines(file_id: FileId) -> Arc { type FileLinesQuery; } - fn file_symbols(file_id: FileId) -> Arc { + fn file_symbols(file_id: FileId) -> Cancelable> { type FileSymbolsQuery; } } @@ -112,7 +114,7 @@ fn file_lines(db: &impl SyntaxDatabase, file_id: FileId) -> Arc { let text = db.file_text(file_id); Arc::new(LineIndex::new(&*text)) } -fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Arc { +fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Cancelable> { let syntax = db.file_syntax(file_id); - Arc::new(SymbolIndex::for_file(file_id, syntax)) + Ok(Arc::new(SymbolIndex::for_file(file_id, syntax))) } -- cgit v1.2.3