aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-15 15:19:09 +0000
committerAleksey Kladov <[email protected]>2019-01-15 15:19:09 +0000
commitfb012e5c1e49af73b480127bcf56d8f5993b8032 (patch)
tree6a71bcb433b82e4c473238d439aad2ef76144157
parent11f3c8afb23d67acde8cc7642aea3a2ca06a2361 (diff)
remove cancelable from symbols
-rw-r--r--crates/ra_ide_api/src/call_info.rs2
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs2
-rw-r--r--crates/ra_ide_api/src/imp.rs2
-rw-r--r--crates/ra_ide_api/src/lib.rs7
-rw-r--r--crates/ra_ide_api/src/symbol_index.rs13
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
20 let name_ref = ctry!(calling_node.name_ref()); 20 let name_ref = ctry!(calling_node.name_ref());
21 21
22 // Resolve the function's NameRef (NOTE: this isn't entirely accurate). 22 // Resolve the function's NameRef (NOTE: this isn't entirely accurate).
23 let file_symbols = db.index_resolve(name_ref)?; 23 let file_symbols = db.index_resolve(name_ref);
24 let symbol = ctry!(file_symbols.into_iter().find(|it| it.ptr.kind() == FN_DEF)); 24 let symbol = ctry!(file_symbols.into_iter().find(|it| it.ptr.kind() == FN_DEF));
25 let fn_file = db.source_file(symbol.file_id); 25 let fn_file = db.source_file(symbol.file_id);
26 let fn_def = symbol.ptr.resolve(&fn_file); 26 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(
95 } 95 }
96 // If that fails try the index based approach. 96 // If that fails try the index based approach.
97 let navs = db 97 let navs = db
98 .index_resolve(name_ref)? 98 .index_resolve(name_ref)
99 .into_iter() 99 .into_iter()
100 .map(NavigationTarget::from_symbol) 100 .map(NavigationTarget::from_symbol)
101 .collect(); 101 .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 {
258 .collect::<Vec<_>>(); 258 .collect::<Vec<_>>();
259 Ok(res) 259 Ok(res)
260 } 260 }
261 pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Cancelable<Vec<FileSymbol>> { 261 pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
262 let name = name_ref.text(); 262 let name = name_ref.text();
263 let mut query = Query::new(name.to_string()); 263 let mut query = Query::new(name.to_string());
264 query.exact(); 264 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 {
381 /// Fuzzy searches for a symbol. 381 /// Fuzzy searches for a symbol.
382 pub fn symbol_search(&self, query: Query) -> Cancelable<Vec<NavigationTarget>> { 382 pub fn symbol_search(&self, query: Query) -> Cancelable<Vec<NavigationTarget>> {
383 self.with_db(|db| { 383 self.with_db(|db| {
384 let res = symbol_index::world_symbols(db, query)? 384 symbol_index::world_symbols(db, query)
385 .into_iter() 385 .into_iter()
386 .map(NavigationTarget::from_symbol) 386 .map(NavigationTarget::from_symbol)
387 .collect::<Vec<_>>(); 387 .collect::<Vec<_>>()
388 Ok(res) 388 })
389 })?
390 } 389 }
391 390
392 pub fn goto_definition( 391 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;
37use rayon::prelude::*; 37use rayon::prelude::*;
38 38
39use crate::{ 39use crate::{
40 Cancelable, FileId, Query, 40 FileId, Query,
41 db::RootDatabase, 41 db::RootDatabase,
42}; 42};
43 43
44salsa::query_group! { 44salsa::query_group! {
45 pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { 45 pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
46 fn file_symbols(file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { 46 fn file_symbols(file_id: FileId) -> Arc<SymbolIndex> {
47 type FileSymbolsQuery; 47 type FileSymbolsQuery;
48 } 48 }
49 fn library_symbols(id: SourceRootId) -> Arc<SymbolIndex> { 49 fn library_symbols(id: SourceRootId) -> Arc<SymbolIndex> {
@@ -53,7 +53,7 @@ salsa::query_group! {
53 } 53 }
54} 54}
55 55
56fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { 56fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> {
57 db.check_canceled(); 57 db.check_canceled();
58 let source_file = db.source_file(file_id); 58 let source_file = db.source_file(file_id);
59 let mut symbols = source_file 59 let mut symbols = source_file
@@ -69,10 +69,10 @@ fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Cancelable<Arc<Sy
69 symbols.push(FileSymbol { file_id, name, ptr }) 69 symbols.push(FileSymbol { file_id, name, ptr })
70 } 70 }
71 71
72 Ok(Arc::new(SymbolIndex::new(symbols))) 72 Arc::new(SymbolIndex::new(symbols))
73} 73}
74 74
75pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Cancelable<Vec<FileSymbol>> { 75pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> {
76 /// Need to wrap Snapshot to provide `Clone` impl for `map_with` 76 /// Need to wrap Snapshot to provide `Clone` impl for `map_with`
77 struct Snap(salsa::Snapshot<RootDatabase>); 77 struct Snap(salsa::Snapshot<RootDatabase>);
78 impl Clone for Snap { 78 impl Clone for Snap {
@@ -98,10 +98,9 @@ pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Cancelable<Vec<F
98 files 98 files
99 .par_iter() 99 .par_iter()
100 .map_with(snap, |db, &file_id| db.0.file_symbols(file_id)) 100 .map_with(snap, |db, &file_id| db.0.file_symbols(file_id))
101 .filter_map(|it| it.ok())
102 .collect() 101 .collect()
103 }; 102 };
104 Ok(query.search(&buf)) 103 query.search(&buf)
105} 104}
106 105
107#[derive(Default, Debug)] 106#[derive(Default, Debug)]