Skip to content

Commit 292a047

Browse files
committed
explain why we restart a Shake session
1 parent 8799e77 commit 292a047

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ loadSessionWithOptions SessionLoadingOptions{..} dir = do
392392

393393
-- Invalidate all the existing GhcSession build nodes by restarting the Shake session
394394
invalidateShakeCache
395-
restartShakeSession []
395+
restartShakeSession "new component" []
396396

397397
-- Typecheck all files in the project on startup
398398
checkProject <- getCheckProject

ghcide/src/Development/IDE/Core/FileStore.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ setFileModified state saved nfp = do
270270
when (isJust setVirtualFileContents) $
271271
fail "setFileModified can't be called on this type of VFSHandle"
272272
recordDirtyKeys (shakeExtras state) GetModificationTime [nfp]
273-
restartShakeSession (shakeExtras state) []
273+
restartShakeSession (shakeExtras state) (fromNormalizedFilePath nfp ++ " (modified)") []
274274
when checkParents $
275275
typecheckParents state nfp
276276

@@ -293,16 +293,16 @@ typecheckParentsAction nfp = do
293293
-- | Note that some keys have been modified and restart the session
294294
-- Only valid if the virtual file system was initialised by LSP, as that
295295
-- independently tracks which files are modified.
296-
setSomethingModified :: IdeState -> [Key] -> IO ()
297-
setSomethingModified state keys = do
296+
setSomethingModified :: IdeState -> [Key] -> String -> IO ()
297+
setSomethingModified state keys reason = do
298298
VFSHandle{..} <- getIdeGlobalState state
299299
when (isJust setVirtualFileContents) $
300300
fail "setSomethingModified can't be called on this type of VFSHandle"
301301
-- Update database to remove any files that might have been renamed/deleted
302302
atomically $ writeTQueue (indexQueue $ hiedbWriter $ shakeExtras state) deleteMissingRealFiles
303303
atomicModifyIORef_ (dirtyKeys $ shakeExtras state) $ \x ->
304304
foldl' (flip HSet.insert) x keys
305-
void $ restartShakeSession (shakeExtras state) []
305+
void $ restartShakeSession (shakeExtras state) reason []
306306

307307
registerFileWatches :: [String] -> LSP.LspT Config IO Bool
308308
registerFileWatches globs = do

ghcide/src/Development/IDE/Core/Shake.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ data ShakeExtras = ShakeExtras
194194
,ideTesting :: IdeTesting
195195
-- ^ Whether to enable additional lsp messages used by the test suite for checking invariants
196196
,restartShakeSession
197-
:: [DelayedAction ()]
197+
:: String
198+
-> [DelayedAction ()]
198199
-> IO ()
199200
,ideNc :: IORef NameCache
200201
-- | A mapping of module name to known target (or candidate targets, if missing)
@@ -583,8 +584,8 @@ delayedAction a = do
583584
-- | Restart the current 'ShakeSession' with the given system actions.
584585
-- Any actions running in the current session will be aborted,
585586
-- but actions added via 'shakeEnqueue' will be requeued.
586-
shakeRestart :: IdeState -> [DelayedAction ()] -> IO ()
587-
shakeRestart IdeState{..} acts =
587+
shakeRestart :: IdeState -> String -> [DelayedAction ()] -> IO ()
588+
shakeRestart IdeState{..} reason acts =
588589
withMVar'
589590
shakeSession
590591
(\runner -> do
@@ -594,8 +595,9 @@ shakeRestart IdeState{..} acts =
594595
let profile = case res of
595596
Just fp -> ", profile saved at " <> fp
596597
_ -> ""
597-
let msg = T.pack $ "Restarting build session " ++ keysMsg ++ abortMsg
598-
keysMsg = "for keys " ++ show (HSet.toList backlog) ++ " "
598+
let msg = T.pack $ "Restarting build session " ++ reason' ++ keysMsg ++ abortMsg
599+
reason' = "due to " ++ reason
600+
keysMsg = " for keys " ++ show (HSet.toList backlog) ++ " "
599601
abortMsg = "(aborting the previous one took " ++ showDuration stopTime ++ profile ++ ")"
600602
logDebug (logger shakeExtras) msg
601603
notifyTestingLogMessage shakeExtras msg

ghcide/src/Development/IDE/LSP/Notifications.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ descriptor plId = (defaultPluginDescriptor plId) { pluginNotificationHandlers =
8282
\ide _ (DidChangeWatchedFilesParams (List fileEvents)) -> liftIO $ do
8383
-- See Note [File existence cache and LSP file watchers] which explains why we get these notifications and
8484
-- what we do with them
85-
let msg = Text.pack $ show fileEvents
86-
logDebug (ideLogger ide) $ "Watched file events: " <> msg
85+
let msg = show fileEvents
86+
logDebug (ideLogger ide) $ "Watched file events: " <> Text.pack msg
8787
modifyFileExists ide fileEvents
8888
resetFileStore ide fileEvents
89-
setSomethingModified ide []
89+
setSomethingModified ide [] msg
9090

9191
, mkPluginNotificationHandler LSP.SWorkspaceDidChangeWorkspaceFolders $
9292
\ide _ (DidChangeWorkspaceFoldersParams events) -> liftIO $ do
@@ -101,7 +101,7 @@ descriptor plId = (defaultPluginDescriptor plId) { pluginNotificationHandlers =
101101
let msg = Text.pack $ show cfg
102102
logDebug (ideLogger ide) $ "Configuration changed: " <> msg
103103
modifyClientSettings ide (const $ Just cfg)
104-
setSomethingModified ide [toKey GetClientSettings emptyFilePath ]
104+
setSomethingModified ide [toKey GetClientSettings emptyFilePath] "config change"
105105

106106
, mkPluginNotificationHandler LSP.SInitialized $ \ide _ _ -> do
107107
--------- Initialize Shake session --------------------------------------------------------------------

0 commit comments

Comments
 (0)