From fb012e5c1e49af73b480127bcf56d8f5993b8032 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 15 Jan 2019 18:19:09 +0300 Subject: remove cancelable from symbols --- crates/ra_ide_api/src/call_info.rs | 2 +- crates/ra_ide_api/src/goto_definition.rs | 2 +- crates/ra_ide_api/src/imp.rs | 2 +- crates/ra_ide_api/src/lib.rs | 7 +++---- crates/ra_ide_api/src/symbol_index.rs | 13 ++++++------- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index 27b760780..efa320d83 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs @@ -20,7 +20,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Cancelable let name_ref = ctry!(calling_node.name_ref()); // Resolve the function's NameRef (NOTE: this isn't entirely accurate). - let file_symbols = db.index_resolve(name_ref)?; + let file_symbols = db.index_resolve(name_ref); let symbol = ctry!(file_symbols.into_iter().find(|it| it.ptr.kind() == FN_DEF)); let fn_file = db.source_file(symbol.file_id); let fn_def = symbol.ptr.resolve(&fn_file); diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index f759f7339..591f36cce 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs @@ -95,7 +95,7 @@ pub(crate) fn reference_definition( } // If that fails try the index based approach. let navs = db - .index_resolve(name_ref)? + .index_resolve(name_ref) .into_iter() .map(NavigationTarget::from_symbol) .collect(); diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs index 98b507ab3..76cb312dd 100644 --- a/crates/ra_ide_api/src/imp.rs +++ b/crates/ra_ide_api/src/imp.rs @@ -258,7 +258,7 @@ impl db::RootDatabase { .collect::>(); Ok(res) } - pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Cancelable> { + pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Vec { let name = name_ref.text(); let mut query = Query::new(name.to_string()); query.exact(); diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index abb50ff95..e0b8410d1 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs @@ -381,12 +381,11 @@ impl Analysis { /// Fuzzy searches for a symbol. pub fn symbol_search(&self, query: Query) -> Cancelable> { self.with_db(|db| { - let res = symbol_index::world_symbols(db, query)? + symbol_index::world_symbols(db, query) .into_iter() .map(NavigationTarget::from_symbol) - .collect::>(); - Ok(res) - })? + .collect::>() + }) } pub fn goto_definition( diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index e7827fdc9..74165d68f 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs @@ -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> { + fn file_symbols(file_id: FileId) -> Arc { type FileSymbolsQuery; } fn library_symbols(id: SourceRootId) -> Arc { @@ -53,7 +53,7 @@ salsa::query_group! { } } -fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Cancelable> { +fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc { 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 Cancelable> { +pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec { /// Need to wrap Snapshot to provide `Clone` impl for `map_with` struct Snap(salsa::Snapshot); impl Clone for Snap { @@ -98,10 +98,9 @@ pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Cancelable