diff options
Diffstat (limited to 'crates/ra_ide_api/src/symbol_index.rs')
-rw-r--r-- | crates/ra_ide_api/src/symbol_index.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index b7a3a3550..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; | |||
37 | use rayon::prelude::*; | 37 | use rayon::prelude::*; |
38 | 38 | ||
39 | use crate::{ | 39 | use crate::{ |
40 | Cancelable, FileId, Query, | 40 | FileId, Query, |
41 | db::RootDatabase, | 41 | db::RootDatabase, |
42 | }; | 42 | }; |
43 | 43 | ||
44 | salsa::query_group! { | 44 | salsa::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 | ||
56 | fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { | 56 | fn 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 |
@@ -63,16 +63,16 @@ fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Cancelable<Arc<Sy | |||
63 | .map(move |(name, ptr)| FileSymbol { name, ptr, file_id }) | 63 | .map(move |(name, ptr)| FileSymbol { name, ptr, file_id }) |
64 | .collect::<Vec<_>>(); | 64 | .collect::<Vec<_>>(); |
65 | 65 | ||
66 | for (name, text_range) in hir::source_binder::macro_symbols(db, file_id)? { | 66 | for (name, text_range) in hir::source_binder::macro_symbols(db, file_id) { |
67 | let node = find_covering_node(source_file.syntax(), text_range); | 67 | let node = find_covering_node(source_file.syntax(), text_range); |
68 | let ptr = LocalSyntaxPtr::new(node); | 68 | let ptr = LocalSyntaxPtr::new(node); |
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 | ||
75 | pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Cancelable<Vec<FileSymbol>> { | 75 | pub(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)] |