@@ -400,6 +400,44 @@ impl <O: Output> InitActionContext<O> {
400400 }
401401 }
402402
403+ /// Create an InitActionContext for testing purposes
404+ ///
405+ /// This constructor is only available in test builds and provides a minimal
406+ /// but functional InitActionContext for testing LSP operations.
407+ #[ cfg( test) ]
408+ pub fn new_for_testing (
409+ analysis : Arc < Mutex < AnalysisStorage > > ,
410+ vfs : Arc < Vfs > ,
411+ ) -> InitActionContext < O > {
412+ let shut_down = Arc :: new ( AtomicBool :: new ( false ) ) ;
413+ let config = Arc :: new ( Mutex :: new ( Config :: default ( ) ) ) ;
414+
415+ InitActionContext {
416+ analysis,
417+ vfs,
418+ analysis_queue : Arc :: new ( AnalysisQueue :: init ( Arc :: clone ( & shut_down) ) ) ,
419+ current_notifier : Arc :: new ( Mutex :: new ( None ) ) ,
420+ quiescent : Arc :: new ( AtomicBool :: new ( false ) ) ,
421+ workspace_roots : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
422+ cached_path_resolver : Arc :: new ( Mutex :: new ( None ) ) ,
423+ direct_opens : Arc :: new ( Mutex :: new ( HashSet :: new ( ) ) ) ,
424+ compilation_info : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
425+ device_active_contexts : Arc :: new ( Mutex :: new ( HashSet :: new ( ) ) ) ,
426+ previously_checked_contexts : Arc :: new ( Mutex :: new ( HashSet :: new ( ) ) ) ,
427+ prev_changes : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
428+ active_waits : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
429+ outstanding_requests : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
430+ config,
431+ lint_config : Arc :: new ( Mutex :: new ( LintCfg :: default ( ) ) ) ,
432+ sent_warnings : Arc :: new ( Mutex :: new ( HashSet :: new ( ) ) ) ,
433+ jobs : Arc :: new ( Mutex :: new ( Jobs :: default ( ) ) ) ,
434+ client_capabilities : Arc :: new ( ClientCapabilities :: default ( ) ) ,
435+ has_notified_missing_builtins : false ,
436+ shut_down,
437+ pid : std:: process:: id ( ) ,
438+ }
439+ }
440+
403441 fn add_direct_open ( & self , path : PathBuf ) {
404442 // NOTE: from_path_buf already logs the error, no need to do it here
405443 let Some ( canon_path) = CanonPath :: from_path_buf ( path) else { return } ;
0 commit comments