@@ -13,6 +13,7 @@ use crate::{
13
13
salsa:: { Database , ParallelDatabase , Snapshot } ,
14
14
Cancelled , CrateId , SourceDatabase , SourceRootDatabase ,
15
15
} ,
16
+ symbol_index:: SymbolsDatabase ,
16
17
FxIndexMap , RootDatabase ,
17
18
} ;
18
19
@@ -54,11 +55,13 @@ pub fn parallel_prime_caches(
54
55
let ( progress_sender, progress_receiver) = crossbeam_channel:: unbounded ( ) ;
55
56
let ( work_sender, work_receiver) = crossbeam_channel:: unbounded ( ) ;
56
57
let graph = graph. clone ( ) ;
58
+ let local_roots = db. local_roots ( ) ;
57
59
let prime_caches_worker = move |db : Snapshot < RootDatabase > | {
58
60
while let Ok ( ( crate_id, crate_name) ) = work_receiver. recv ( ) {
59
61
progress_sender
60
62
. send ( ParallelPrimeCacheWorkerProgress :: BeginCrate { crate_id, crate_name } ) ?;
61
63
64
+ // Compute the DefMap and possibly ImportMap
62
65
let file_id = graph[ crate_id] . root_file_id ;
63
66
let root_id = db. file_source_root ( file_id) ;
64
67
if db. source_root ( root_id) . is_library {
@@ -68,6 +71,19 @@ pub fn parallel_prime_caches(
68
71
db. import_map ( crate_id) ;
69
72
}
70
73
74
+ // Compute the symbol search index.
75
+ // This primes the cache for `ide_db::symbol_index::world_symbols()`.
76
+ //
77
+ // We do this for workspace crates only (members of local_roots), because doing it
78
+ // for all dependencies could be *very* unnecessarily slow in a large project.
79
+ //
80
+ // FIXME: We should do it unconditionally if the configuration is set to default to
81
+ // searching dependencies (rust-analyzer.workspace.symbol.search.scope), but we
82
+ // would need to pipe that configuration information down here.
83
+ if local_roots. contains ( & root_id) {
84
+ db. crate_symbols ( crate_id. into ( ) ) ;
85
+ }
86
+
71
87
progress_sender. send ( ParallelPrimeCacheWorkerProgress :: EndCrate { crate_id } ) ?;
72
88
}
73
89
0 commit comments