@@ -109,6 +109,11 @@ descriptor recorder plId = (defaultCabalPluginDescriptor plId)
109
109
-- | Helper function to restart the shake session, specifically for modifying .cabal files.
110
110
-- No special logic, just group up a bunch of functions you need for the base
111
111
-- 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.
112
117
restartCabalShakeSession :: ShakeExtras -> VFS. VFS -> NormalizedFilePath -> String -> IO ()
113
118
restartCabalShakeSession shakeExtras vfs file actionMsg = do
114
119
join $ atomically $ Shake. recordDirtyKeys shakeExtras GetModificationTime [file]
@@ -131,6 +136,8 @@ cabalRules recorder = do
131
136
ofInterestRules recorder
132
137
-- Rule to produce diagnostics for cabal files.
133
138
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.
134
141
t <- use GetModificationTime file
135
142
log' Debug $ LogModificationTime file t
136
143
mVirtualFile <- Shake. getVirtualFile file
@@ -158,7 +165,7 @@ cabalRules recorder = do
158
165
log' = logWith recorder
159
166
160
167
-- | 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
162
169
-- actions to produce diagnostics for cabal files.
163
170
--
164
171
-- It is paramount that this kick-function can be run quickly, since it is a blocking
0 commit comments