@@ -35,7 +35,7 @@ pub struct LspEvalContext {
3535 inner : EvalContext ,
3636 builtin_docs : HashMap < LspUrl , String > ,
3737 file_provider : Arc < dyn FileProvider > ,
38- resolution_cache : RwLock < HashMap < PathBuf , ResolutionResult > > ,
38+ resolution_cache : RwLock < HashMap < PathBuf , Arc < ResolutionResult > > > ,
3939 workspace_root_cache : RwLock < HashMap < PathBuf , PathBuf > > ,
4040 open_files : Arc < RwLock < HashMap < PathBuf , String > > > ,
4141 netlist_subscriptions : Arc < RwLock < HashMap < PathBuf , HashMap < String , JsonValue > > > > ,
@@ -273,8 +273,8 @@ impl LspEvalContext {
273273 let uri = LspUrl :: File ( path_buf. to_path_buf ( ) ) ;
274274 let maybe_contents = self . get_load_contents ( & uri) . ok ( ) . flatten ( ) ;
275275
276- let resolution = self . resolution_for ( path_buf) ;
277- let mut ctx = EvalContext :: new ( self . file_provider . clone ( ) , resolution )
276+ let config = self . config_for ( path_buf) ;
277+ let mut ctx = EvalContext :: from_session_and_config ( Default :: default ( ) , config )
278278 . set_source_path ( path_buf. to_path_buf ( ) ) ;
279279
280280 if let Some ( contents) = maybe_contents {
@@ -343,26 +343,28 @@ impl LspEvalContext {
343343 workspace_root
344344 }
345345
346- fn resolution_for ( & self , file_path : & Path ) -> ResolutionResult {
346+ /// Return the cached, canonicalized resolution for the workspace that owns `file_path`.
347+ fn resolution_for ( & self , file_path : & Path ) -> Arc < ResolutionResult > {
347348 let workspace_root = self . workspace_root_for ( file_path) ;
348349 if let Some ( cached) = self . resolution_cache . read ( ) . unwrap ( ) . get ( & workspace_root) {
349350 return cached. clone ( ) ;
350351 }
351352
352- let resolution = crate :: get_workspace_info ( & self . file_provider , & workspace_root)
353+ let mut resolution = crate :: get_workspace_info ( & self . file_provider , & workspace_root)
353354 . and_then ( |mut ws| crate :: resolve_dependencies ( & mut ws, false , false ) )
354355 . unwrap_or_else ( |_| ResolutionResult :: empty ( ) ) ;
356+ resolution. canonicalize_keys ( & * self . file_provider ) ;
357+ let resolution = Arc :: new ( resolution) ;
355358 self . resolution_cache
356359 . write ( )
357360 . unwrap ( )
358361 . insert ( workspace_root, resolution. clone ( ) ) ;
359362 resolution
360363 }
361364
362- /// Create an EvalContextConfig for the given file.
365+ /// Create a fresh EvalContextConfig for the given file.
363366 fn config_for ( & self , file_path : & Path ) -> EvalContextConfig {
364- let resolution = self . resolution_for ( file_path) ;
365- EvalContextConfig :: new ( self . file_provider . clone ( ) , resolution)
367+ EvalContextConfig :: new ( self . file_provider . clone ( ) , self . resolution_for ( file_path) )
366368 . set_eager ( self . inner . is_eager ( ) )
367369 }
368370
@@ -904,8 +906,9 @@ impl LspContext for LspEvalContext {
904906 let maybe_contents = self . get_load_contents ( & params. uri ) . ok ( ) . flatten ( ) ;
905907
906908 // Evaluate the module
907- let resolution = self . resolution_for ( path_buf) ;
908- let ctx = EvalContext :: new ( self . file_provider . clone ( ) , resolution) ;
909+ let config = self . config_for ( path_buf) ;
910+ let ctx =
911+ EvalContext :: from_session_and_config ( Default :: default ( ) , config) ;
909912
910913 let eval_result = if let Some ( contents) = maybe_contents {
911914 ctx. set_source_path ( path_buf. clone ( ) )
0 commit comments