Skip to content

Commit 4697009

Browse files
committed
move extends out of restart
1 parent eda4227 commit 4697009

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,14 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
481481
let hieYamlRule :: Rules ()
482482
hieYamlRule = defineNoDiagnostics (cmapWithPrio LogShake recorder) $ \HieYaml hieYaml -> do
483483
alwaysRerun
484+
-- v :: HashMap NormalizedFilePath (IdeResult HscEnvEq, DependencyInfo)
484485
v <- Map.findWithDefault HM.empty (Just $ fromNormalizedFilePath hieYaml) <$> (liftIO $ readVar fileToFlags)
486+
let deps = snd <$> HM.elems v
487+
let files = concatMap Map.keys deps
488+
-- use time for for deps files
489+
490+
491+
-- check if all dep is up to date, if not clear the cache
485492
return $ Just v
486493

487494
let cradleLocRule :: Rules ()
@@ -641,7 +648,8 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
641648
liftIO $ void $ modifyVar' filesMap $ flip HM.union (HM.fromList (map ((,hieYaml) . fst) $ concatMap toFlagsMap all_targets))
642649
-- The VFS doesn't change on cradle edits, re-use the old one.
643650
-- Invalidate all the existing GhcSession build nodes by restarting the Shake session
644-
keys2 <- liftIO $ invalidateShakeCache
651+
keys2 <- liftIO invalidateShakeCache
652+
keys1 <- liftIO $ extendKnownTargets all_targets
645653

646654
-- Typecheck all files in the project on startup
647655
checkProject <- liftIO $ getCheckProject
@@ -660,7 +668,6 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
660668
-- todo this should be moving out of the session function
661669
restart <- liftIO $ async $ do
662670
restartShakeSession VFSUnmodified "new component" typeCheckAll $ do
663-
keys1 <- extendKnownTargets all_targets
664671
return [keys1, keys2]
665672
UnliftIO.wait restart
666673
return $ second Map.keys this_options
@@ -745,17 +752,15 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
745752
-- If the dependencies are out of date then clear both caches and start
746753
-- again.
747754
clearCache
748-
-- fileToFlags is caching
749755
v <- Map.findWithDefault HM.empty hieYaml <$> (liftIO$readVar fileToFlags)
750756
case HM.lookup file v of
751757
Just (opts, old_di) -> do
752758
deps_ok <- liftIO $ checkDependencyInfo old_di
753759
if not deps_ok
754760
then do
755-
-- If the dependencies are out of date then clear both caches and start
756-
-- again.
757-
liftIO $ clearCache
761+
liftIO clearCache
758762
consultCradle file
763+
-- add the dependency info to the cache
759764
else return (opts, Map.keys old_di)
760765
Nothing -> consultCradle file
761766

0 commit comments

Comments
 (0)