@@ -13,6 +13,7 @@ use crate::{
1313 salsa:: { Database , ParallelDatabase , Snapshot } ,
1414 Cancelled , CrateId , SourceDatabase , SourceRootDatabase ,
1515 } ,
16+ symbol_index:: SymbolsDatabase ,
1617 FxIndexMap , RootDatabase ,
1718} ;
1819
@@ -54,11 +55,13 @@ pub fn parallel_prime_caches(
5455 let ( progress_sender, progress_receiver) = crossbeam_channel:: unbounded ( ) ;
5556 let ( work_sender, work_receiver) = crossbeam_channel:: unbounded ( ) ;
5657 let graph = graph. clone ( ) ;
58+ let local_roots = db. local_roots ( ) ;
5759 let prime_caches_worker = move |db : Snapshot < RootDatabase > | {
5860 while let Ok ( ( crate_id, crate_name) ) = work_receiver. recv ( ) {
5961 progress_sender
6062 . send ( ParallelPrimeCacheWorkerProgress :: BeginCrate { crate_id, crate_name } ) ?;
6163
64+ // Compute the DefMap and possibly ImportMap
6265 let file_id = graph[ crate_id] . root_file_id ;
6366 let root_id = db. file_source_root ( file_id) ;
6467 if db. source_root ( root_id) . is_library {
@@ -68,6 +71,19 @@ pub fn parallel_prime_caches(
6871 db. import_map ( crate_id) ;
6972 }
7073
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+
7187 progress_sender. send ( ParallelPrimeCacheWorkerProgress :: EndCrate { crate_id } ) ?;
7288 }
7389
0 commit comments