@@ -109,6 +109,11 @@ descriptor recorder plId = (defaultCabalPluginDescriptor plId)
109109-- | Helper function to restart the shake session, specifically for modifying .cabal files.
110110-- No special logic, just group up a bunch of functions you need for the base
111111-- Notification Handlers.
112+ --
113+ -- To make sure diagnostics are up to date, we need to tell shake that the file was touched and
114+ -- needs to be re-parsed. That's what we do when we record the dirty key that our parsing
115+ -- rule depends on.
116+ -- Then we restart the shake session, so that changes to our virtual files are actually picked up.
112117restartCabalShakeSession :: ShakeExtras -> VFS. VFS -> NormalizedFilePath -> String -> IO ()
113118restartCabalShakeSession shakeExtras vfs file actionMsg = do
114119 join $ atomically $ Shake. recordDirtyKeys shakeExtras GetModificationTime [file]
@@ -131,6 +136,8 @@ cabalRules recorder = do
131136 ofInterestRules recorder
132137 -- Rule to produce diagnostics for cabal files.
133138 define (cmapWithPrio LogShake recorder) $ \ ParseCabal file -> do
139+ -- whenever this key is marked as dirty (e.g., when a user writes stuff to it),
140+ -- we rerun this rule because this rule *depends* on GetModificationTime.
134141 t <- use GetModificationTime file
135142 log' Debug $ LogModificationTime file t
136143 mVirtualFile <- Shake. getVirtualFile file
@@ -158,7 +165,7 @@ cabalRules recorder = do
158165 log' = logWith recorder
159166
160167-- | This is the kick function for the cabal plugin.
161- -- We run this action, whenever we need to restart the shake session, which triggers
168+ -- We run this action, whenever we shake session us run/restarted , which triggers
162169-- actions to produce diagnostics for cabal files.
163170--
164171-- It is paramount that this kick-function can be run quickly, since it is a blocking
0 commit comments