Skip to content

Commit bb78a36

Browse files
committed
delay the restart
1 parent 4c99c47 commit bb78a36

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
570570

571571

572572
let session :: (Maybe FilePath, NormalizedFilePath, ComponentOptions, FilePath)
573-
-> IO ((IdeResult HscEnvEq,DependencyInfo), HashSet FilePath)
573+
-> IO ((IdeResult HscEnvEq,DependencyInfo), HashSet FilePath, IO ())
574574
session args@(hieYaml, _cfp, _opts, _libDir) = do
575575
(new_deps, old_deps) <- packageSetup args
576576

@@ -610,21 +610,21 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
610610
checkProject <- getCheckProject
611611
-- The VFS doesn't change on cradle edits, re-use the old one.
612612
-- Invalidate all the existing GhcSession build nodes by restarting the Shake session
613-
restartShakeSession VFSUnmodified "new component" [] $ do
614-
keys2 <- invalidateShakeCache
615-
keys1 <- extendKnownTargets all_targets
616-
unless (null new_deps || not checkProject) $ do
617-
cfps' <- liftIO $ filterM (IO.doesFileExist . fromNormalizedFilePath) (concatMap targetLocations all_targets)
618-
void $ shakeEnqueue extras $ mkDelayedAction "InitialLoad" Debug $ void $ do
619-
mmt <- uses GetModificationTime cfps'
620-
let cs_exist = catMaybes (zipWith (<$) cfps' mmt)
621-
modIfaces <- uses GetModIface cs_exist
622-
-- update exports map
623-
shakeExtras <- getShakeExtras
624-
let !exportsMap' = createExportsMap $ mapMaybe (fmap hirModIface) modIfaces
625-
liftIO $ atomically $ modifyTVar' (exportsMap shakeExtras) (exportsMap' <>)
626-
return [keys1, keys2]
627-
return $ (this_options, newLoaded)
613+
let restart = restartShakeSession VFSUnmodified "new component" [] $ do
614+
keys2 <- invalidateShakeCache
615+
keys1 <- extendKnownTargets all_targets
616+
unless (null new_deps || not checkProject) $ do
617+
cfps' <- liftIO $ filterM (IO.doesFileExist . fromNormalizedFilePath) (concatMap targetLocations all_targets)
618+
void $ shakeEnqueue extras $ mkDelayedAction "InitialLoad" Debug $ void $ do
619+
mmt <- uses GetModificationTime cfps'
620+
let cs_exist = catMaybes (zipWith (<$) cfps' mmt)
621+
modIfaces <- uses GetModIface cs_exist
622+
-- update exports map
623+
shakeExtras <- getShakeExtras
624+
let !exportsMap' = createExportsMap $ mapMaybe (fmap hirModIface) modIfaces
625+
liftIO $ atomically $ modifyTVar' (exportsMap shakeExtras) (exportsMap' <>)
626+
return [keys1, keys2]
627+
return (this_options, newLoaded, restart)
628628

629629
let consultCradle :: Maybe FilePath -> FilePath -> IO ()
630630
consultCradle hieYaml cfp = do
@@ -667,13 +667,14 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
667667
[] -> error $ "GHC version could not be parsed: " <> version
668668
((runTime, _):_)
669669
| compileTime == runTime -> do
670-
(_results, allNewLoaded) <- session (hieYaml, ncfp, opts, libDir)
670+
(_results, allNewLoaded, restart) <- session (hieYaml, ncfp, opts, libDir)
671671
let newLoaded = pendingFiles `Set.intersection` allNewLoaded
672672
-- log new loaded files
673673
logWith recorder Info $ LogSessionNewLoadedFiles $ Set.toList newLoaded
674674
-- remove all new loaded file from error loading files
675675
atomicModifyIORef' error_loading_files (\old -> (old `Set.difference` allNewLoaded, ()))
676676
atomicModifyIORef' cradle_files (\xs -> (newLoaded <> xs,()))
677+
restart
677678
| otherwise -> do
678679
-- delete cfp from pending files
679680
atomically $ do
@@ -782,7 +783,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
782783
-- before attempting to do so.
783784
let getOptionsWorker :: FilePath -> IO ()
784785
getOptionsWorker file = do
785-
logWith recorder Info (LogGetOptionsLoop file)
786+
logWith recorder Debug (LogGetOptionsLoop file)
786787
let ncfp = toNormalizedFilePath' file
787788
cachedHieYamlLocation <- atomically $ STM.lookup ncfp filesMap
788789
hieYaml <- cradleLoc file
@@ -808,7 +809,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
808809
Extra.whenM (S.lookup absFile pendingFileSet) STM.retry
809810
-- check if in the cache
810811
checkInCache ncfp
811-
logWith recorder Info $ LogLookupSessionCache absFile
812+
logWith recorder Debug $ LogLookupSessionCache absFile
812813
updateDateRes <- case res of
813814
Just r -> do
814815
depOk <- checkDependencyInfo (snd r)

0 commit comments

Comments
 (0)