Skip to content

Commit 7bf6fde

Browse files
committed
always wait for restart
1 parent b4d3c49 commit 7bf6fde

File tree

7 files changed

+23
-40
lines changed

7 files changed

+23
-40
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ import Ide.Logger (Pretty (pretty),
6868
vcat, viaShow, (<+>))
6969
import Ide.Types (Config,
7070
SessionLoadingPreferenceConfig (..),
71-
ShouldWait (..),
7271
sessionLoading)
7372
import Language.LSP.Protocol.Message
7473
import Language.LSP.Server
@@ -626,7 +625,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
626625
, ..
627626
}
628627
sessionShake = SessionShake
629-
{ restartSession = restartShakeSession extras ShouldWait
628+
{ restartSession = restartShakeSession extras
630629
, invalidateCache = invalidateShakeCache
631630
, enqueueActions = shakeEnqueue extras
632631
}

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ module Development.IDE.Core.FileStore(
2222
registerFileWatches,
2323
shareFilePath,
2424
Log(..),
25-
setSomethingModifiedWait,
2625
) where
2726

2827
import Control.Concurrent.STM.Stats (STM, atomically)
@@ -280,7 +279,7 @@ setFileModified recorder vfs state saved nfp actionBefore = do
280279
AlwaysCheck -> True
281280
CheckOnSave -> saved
282281
_ -> False
283-
restartShakeSession (shakeExtras state) ShouldNotWait vfs (fromNormalizedFilePath nfp ++ " (modified)") ([mkDelayedAction "ParentTC" L.Debug (typecheckParentsAction recorder nfp) | checkParents]) $ do
282+
restartShakeSession (shakeExtras state) vfs (fromNormalizedFilePath nfp ++ " (modified)") ([mkDelayedAction "ParentTC" L.Debug (typecheckParentsAction recorder nfp) | checkParents]) $ do
284283
keys<-actionBefore
285284
return (toKey GetModificationTime nfp:keys)
286285

@@ -300,16 +299,11 @@ typecheckParentsAction recorder nfp = do
300299
-- | Note that some keys have been modified and restart the session
301300
-- Only valid if the virtual file system was initialised by LSP, as that
302301
-- independently tracks which files are modified.
303-
setSomethingModified' :: ShouldWait -> VFSModified -> IdeState -> String -> IO [Key] -> IO ()
304-
setSomethingModified' shouldWait vfs state reason actionBetweenSession = do
302+
setSomethingModified :: VFSModified -> IdeState -> String -> IO [Key] -> IO ()
303+
setSomethingModified vfs state reason actionBetweenSession = do
305304
-- Update database to remove any files that might have been renamed/deleted
306305
atomically $ writeTaskQueue (indexQueue $ hiedbWriter $ shakeExtras state) (\withHieDb -> withHieDb deleteMissingRealFiles)
307-
void $ restartShakeSession (shakeExtras state) shouldWait vfs reason [] actionBetweenSession
308-
setSomethingModified :: VFSModified -> IdeState -> String -> IO [Key] -> IO ()
309-
setSomethingModified vfs state reason actionBetweenSession = setSomethingModified' ShouldNotWait vfs state reason actionBetweenSession
310-
311-
setSomethingModifiedWait :: VFSModified -> IdeState -> String -> IO [Key] -> IO ()
312-
setSomethingModifiedWait vfs state reason actionBetweenSession = setSomethingModified' ShouldWait vfs state reason actionBetweenSession
306+
void $ restartShakeSession (shakeExtras state) vfs reason [] actionBetweenSession
313307

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

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ data ShakeExtras = ShakeExtras
344344
,ideTesting :: IdeTesting
345345
-- ^ Whether to enable additional lsp messages used by the test suite for checking invariants
346346
,restartShakeSession
347-
:: ShouldWait
348-
-> VFSModified
347+
:: VFSModified
349348
-> String
350349
-> [DelayedAction ()]
351350
-> IO [Key]
@@ -890,21 +889,15 @@ instance Semigroup ShakeRestartArgs where
890889
-- | Restart the current 'ShakeSession' with the given system actions.
891890
-- Any actions running in the current session will be aborted,
892891
-- but actions added via 'shakeEnqueue' will be requeued.
893-
shakeRestart :: ShakeControlQueue -> ShouldWait -> VFSModified -> String -> [DelayedAction ()] -> IO [Key] -> IO ()
894-
shakeRestart rts b vfs reason acts ioActionBetweenShakeSession = case b of
895-
ShouldWait ->
896-
do
897-
waitMVar <- newEmptyMVar
898-
-- submit at the head of the queue,
899-
-- prefer restart request over any pending actions
900-
void $ submitWorkAtHead rts $ Left $
901-
toDyn $ ShakeRestartArgs vfs reason acts ioActionBetweenShakeSession rts 1 [waitMVar]
902-
-- Wait until the restart is done
903-
takeMVar waitMVar
904-
ShouldNotWait ->
905-
void $ submitWorkAtHead rts $ Left $
906-
toDyn $ ShakeRestartArgs vfs reason acts ioActionBetweenShakeSession rts 1 []
907-
892+
shakeRestart :: ShakeControlQueue -> VFSModified -> String -> [DelayedAction ()] -> IO [Key] -> IO ()
893+
shakeRestart rts vfs reason acts ioActionBetweenShakeSession = do
894+
waitMVar <- newEmptyMVar
895+
-- submit at the head of the queue,
896+
-- prefer restart request over any pending actions
897+
void $ submitWorkAtHead rts $ Left $
898+
toDyn $ ShakeRestartArgs vfs reason acts ioActionBetweenShakeSession rts 1 [waitMVar]
899+
-- Wait until the restart is done
900+
takeMVar waitMVar
908901

909902
dynShakeRestart :: Dynamic -> ShakeRestartArgs
910903
dynShakeRestart dy = case fromDynamic dy of

hls-plugin-api/src/Ide/Types.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module Ide.Types
4242
, installSigUsr1Handler
4343
, lookupCommandProvider
4444
, ResolveFunction
45-
, mkResolveHandler, ShouldWait(..)
45+
, mkResolveHandler
4646
)
4747
where
4848

@@ -1302,6 +1302,3 @@ installSigUsr1Handler h = void $ installHandler sigUSR1 (Catch h) Nothing
13021302
resolve handlers for the same method, than our assumptions that we never have
13031303
two responses break, and behavior is undefined.
13041304
-}
1305-
1306-
data ShouldWait = ShouldWait | ShouldNotWait
1307-
deriving Eq

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Then we restart the shake session, so that changes to our virtual files are actu
179179
-}
180180
restartCabalShakeSession :: ShakeExtras -> VFS.VFS -> NormalizedFilePath -> String -> IO [Key] -> IO ()
181181
restartCabalShakeSession shakeExtras vfs file actionMsg actionBetweenSession = do
182-
restartShakeSession shakeExtras ShouldNotWait (VFSModified vfs) (fromNormalizedFilePath file ++ " " ++ actionMsg) [] $ do
182+
restartShakeSession shakeExtras (VFSModified vfs) (fromNormalizedFilePath file ++ " " ++ actionMsg) [] $ do
183183
keys <- actionBetweenSession
184184
return (toKey GetModificationTime file:keys)
185185

@@ -188,7 +188,7 @@ restartCabalShakeSession shakeExtras vfs file actionMsg actionBetweenSession = d
188188
-- rule to get re-run if the file changes on disk.
189189
restartCabalShakeSessionPhysical :: ShakeExtras -> VFS.VFS -> NormalizedFilePath -> String -> IO [Key] -> IO ()
190190
restartCabalShakeSessionPhysical shakeExtras vfs file actionMsg actionBetweenSession = do
191-
restartShakeSession shakeExtras ShouldNotWait (VFSModified vfs) (fromNormalizedFilePath file ++ " " ++ actionMsg) [] $ do
191+
restartShakeSession shakeExtras (VFSModified vfs) (fromNormalizedFilePath file ++ " " ++ actionMsg) [] $ do
192192
keys <- actionBetweenSession
193193
return (toKey GetModificationTime file:toKey GetPhysicalModificationTime file:keys)
194194

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Handlers.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import Data.String (IsString)
4141
import Data.Text (Text)
4242
import qualified Data.Text as T
4343
import qualified Data.Text.Utf16.Rope.Mixed as Rope
44-
import Development.IDE.Core.FileStore (getUriContents, setSomethingModifiedWait)
44+
import Development.IDE.Core.FileStore (getUriContents, setSomethingModified)
4545
import Development.IDE.Core.Rules (IdeState,
4646
runAction)
4747
import Development.IDE.Core.Shake (use_, uses_, VFSModified (VFSUnmodified), useWithSeparateFingerprintRule_)
@@ -214,11 +214,11 @@ runEvalCmd recorder plId st mtoken EvalParams{..} =
214214

215215
-- enable codegen for the module which we need to evaluate.
216216
final_hscEnv <- liftIO $ bracket_
217-
(setSomethingModifiedWait VFSUnmodified st "Eval" $ do
217+
(setSomethingModified VFSUnmodified st "Eval" $ do
218218
queueForEvaluation st nfp
219219
return [toKey IsEvaluating nfp]
220220
)
221-
(setSomethingModifiedWait VFSUnmodified st "Eval" $ do
221+
(setSomethingModified VFSUnmodified st "Eval" $ do
222222
unqueueForEvaluation st nfp
223223
return [toKey IsEvaluating nfp]
224224
)

scripts/flaky-test-patterns.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# open close
55
# non local variable
66
# Notification Handlers
7-
# bidirectional module dependency with hs-boot
7+
bidirectional module dependency with hs-boot
88

99
# InternalError over InvalidParams
1010
# ghcide restarts shake session on config changes:
@@ -19,7 +19,7 @@
1919
# hls-class-plugin-tests::Creates a placeholder for fmap
2020
# hls-rename-plugin-tests::Rename
2121
# th-linking-test-unboxed
22-
update syntax error
22+
# update syntax error
2323
# iface-error-test-1
2424

2525
# update syntax error

0 commit comments

Comments
 (0)