Skip to content

Commit 6c4a848

Browse files
committed
use restart to do the shakeEnqueue
1 parent 2997348 commit 6c4a848

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -625,23 +625,25 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
625625
-- Invalidate all the existing GhcSession build nodes by restarting the Shake session
626626
keys2 <- liftIO $ invalidateShakeCache
627627

628+
-- Typecheck all files in the project on startup
629+
checkProject <- liftIO $ getCheckProject
630+
cfps' <- liftIO $ filterM (IO.doesFileExist . fromNormalizedFilePath) (concatMap targetLocations all_targets)
631+
let typeCheckAll = if null new_deps || not checkProject
632+
then []
633+
else return $
634+
mkDelayedAction "InitialLoad" Debug $ void $ do
635+
mmt <- uses GetModificationTime cfps'
636+
let cs_exist = catMaybes (zipWith (<$) cfps' mmt)
637+
modIfaces <- uses GetModIface cs_exist
638+
-- update exports map
639+
shakeExtras <- getShakeExtras
640+
let !exportsMap' = createExportsMap $ mapMaybe (fmap hirModIface) modIfaces
641+
liftIO $ atomically $ modifyTVar' (exportsMap shakeExtras) (exportsMap' <>)
628642
-- todo this should be moving out of the session function
629643
restart <- liftIO $ async $ do
630-
restartShakeSession VFSUnmodified "new component" [] $ do
644+
restartShakeSession VFSUnmodified "new component" typeCheckAll $ do
631645
keys1 <- extendKnownTargets all_targets
632646
return [keys1, keys2]
633-
-- Typecheck all files in the project on startup
634-
checkProject <- liftIO $ getCheckProject
635-
liftIO $ unless (null new_deps || not checkProject) $ do
636-
cfps' <- liftIO $ filterM (IO.doesFileExist . fromNormalizedFilePath) (concatMap targetLocations all_targets)
637-
void $ shakeEnqueue extras $ mkDelayedAction "InitialLoad" Debug $ void $ do
638-
mmt <- uses GetModificationTime cfps'
639-
let cs_exist = catMaybes (zipWith (<$) cfps' mmt)
640-
modIfaces <- uses GetModIface cs_exist
641-
-- update exports map
642-
shakeExtras <- getShakeExtras
643-
let !exportsMap' = createExportsMap $ mapMaybe (fmap hirModIface) modIfaces
644-
liftIO $ atomically $ modifyTVar' (exportsMap shakeExtras) (exportsMap' <>)
645647
UnliftIO.wait restart
646648
return $ second Map.keys this_options
647649

0 commit comments

Comments
 (0)