@@ -500,6 +500,23 @@ completeFileProcessing state hieYaml ncfp file flags = do
500
500
insertFileMapping state hieYaml ncfp
501
501
removeFromPending state file
502
502
503
+ -- | Handle successful loading by updating session state with the new file maps
504
+ updateSessionOnSuccess :: Recorder (WithPriority Log ) -> SessionState -> Maybe FilePath -> HashMap NormalizedFilePath (IdeResult HscEnvEq , DependencyInfo ) -> [TargetDetails ] -> IO ()
505
+ updateSessionOnSuccess recorder state hieYaml this_flags_map all_targets = do
506
+ let newLoaded = Set. fromList $ fromNormalizedFilePath <$> HM. keys this_flags_map
507
+ atomically $ do
508
+ STM. insert this_flags_map hieYaml (fileToFlags state)
509
+ insertAllFileMappings state $ map ((hieYaml,) . fst ) $ concatMap toFlagsMap all_targets
510
+ forM_ newLoaded $ flip S. delete (pendingFileSet state)
511
+ pendingFiles <- getPendingFiles state
512
+ let newLoaded = pendingFiles `Set.intersection` newLoaded
513
+ -- log new loaded files
514
+ logWith recorder Info $ LogSessionNewLoadedFiles $ Set. toList newLoaded
515
+ -- remove all new loaded file from error loading files
516
+ mapM_ (removeErrorLoadingFile state) (Set. toList newLoaded)
517
+ addCradleFiles state newLoaded
518
+ return ()
519
+
503
520
-- | Insert multiple file mappings at once
504
521
insertAllFileMappings :: SessionState -> [(Maybe FilePath , NormalizedFilePath )] -> STM ()
505
522
insertAllFileMappings state mappings =
@@ -711,11 +728,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
711
728
Nothing
712
729
713
730
let newLoaded = Set. fromList $ fromNormalizedFilePath <$> HM. keys this_flags_map
714
- atomically $ do
715
- STM. insert this_flags_map hieYaml (fileToFlags sessionState)
716
- insertAllFileMappings sessionState $ map ((hieYaml,) . fst ) $ concatMap toFlagsMap all_targets
717
- forM_ newLoaded $ flip S. delete (pendingFileSet sessionState)
718
-
731
+ updateSessionOnSuccess recorder sessionState hieYaml this_flags_map all_targets
719
732
-- Typecheck all files in the project on startup
720
733
checkProject <- getCheckProject
721
734
-- The VFS doesn't change on cradle edits, re-use the old one.
@@ -769,14 +782,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
769
782
[] -> error $ " GHC version could not be parsed: " <> version
770
783
((runTime, _): _)
771
784
| compileTime == runTime -> do
772
- (_results, allNewLoaded, restart) <- session (hieYaml, ncfp, opts, libDir)
773
- pendingFiles <- getPendingFiles sessionState
774
- let newLoaded = pendingFiles `Set.intersection` allNewLoaded
775
- -- log new loaded files
776
- logWith recorder Info $ LogSessionNewLoadedFiles $ Set. toList newLoaded
777
- -- remove all new loaded file from error loading files
778
- mapM_ (removeErrorLoadingFile sessionState) (Set. toList allNewLoaded)
779
- addCradleFiles sessionState newLoaded
785
+ (_results, _allNewLoaded, restart) <- session (hieYaml, ncfp, opts, libDir)
780
786
restart
781
787
| otherwise -> do
782
788
-- Use the common pattern here: updateFileState
0 commit comments