Skip to content

Commit 9b7b400

Browse files
committed
fix build
1 parent ebdfddb commit 9b7b400

2 files changed

Lines changed: 37 additions & 36 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ withWorkerQueue recorder title workerAction = ContT $ \mainAction -> do
8080
-- if we want to debug the exact location the worker swallows an async exception, we can
8181
-- temporarily comment out the `finally` clause.
8282
`finally` atomically (putTMVar b ())
83-
logWith log Debug (LogThreadEnding title)
84-
logWith log Debug (LogThreadEnded title)
83+
logWith recorder Debug (LogThreadEnding title)
84+
logWith recorder Debug (LogThreadEnded title)
8585
where
8686
writerThread q b =
8787
-- See above: check stop flag before dequeuing, exit if set, otherwise run next job.
@@ -96,9 +96,9 @@ withWorkerQueue recorder title workerAction = ContT $ \mainAction -> do
9696
case task of
9797
Exit -> return ()
9898
Task t -> do
99-
logWith log Debug $ LogSingleWorkStarting title
99+
logWith recorder Debug $ LogSingleWorkStarting title
100100
workerAction t
101-
logWith log Debug $ LogSingleWorkEnded title
101+
logWith recorder Debug $ LogSingleWorkEnded title
102102
writerThread q b
103103

104104

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

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ setupLSP recorder defaultRoot getHieDbLoc userHandlers getIdeState clientMsgVar
255255
, ctxGetHieDbLoc = getHieDbLoc
256256
, ctxGetIdeState = getIdeState
257257
, ctxUntilReactorStopSignal = untilReactorStopSignal
258-
, ctxconfirmReactorShutdown = confirmReactorShutdown
258+
, ctxConfirmReactorShutdown = confirmReactorShutdown
259259
, ctxForceShutdown = exit
260260
, ctxClearReqId = clearReqId
261261
, ctxWaitForCancel = waitForCancel
@@ -281,7 +281,7 @@ handleInit initParams env (TRequestMessage _ _ m params) = otTracedHandler "Init
281281
recorder = ctxRecorder initParams
282282
defaultRoot = ctxDefaultRoot initParams
283283
untilReactorStopSignal = ctxUntilReactorStopSignal initParams
284-
lifetimeConfirm = ctxconfirmReactorShutdown initParams
284+
lifetimeConfirm = ctxConfirmReactorShutdown initParams
285285
root <- case LSP.resRootPath env of
286286
Just lspRoot | lspRoot /= defaultRoot -> setCurrentDirectory lspRoot >> return lspRoot
287287
_ -> pure defaultRoot
@@ -290,38 +290,40 @@ handleInit initParams env (TRequestMessage _ _ m params) = otTracedHandler "Init
290290
logWith recorder Info $ LogRegisteringIdeConfig initConfig
291291
ideMVar <- newEmptyMVar
292292

293-
let
293+
let
294294
handleServerExceptionOrShutDown me = do
295295
-- shutdown shake
296296
tryReadMVar ideMVar >>= mapM_ shutdown
297-
case me of
298-
Left e -> do
299-
lifetimeConfirm "due to exception in reactor thread"
300-
logWith recorder Error $ LogReactorThreadException e
301-
ctxForceShutdown initParams
302-
_ -> do
303-
lifetimeConfirm "due to shutdown message"
304-
return ()
305-
306-
exceptionInHandler e = do
307-
logWith recorder Error $ LogReactorMessageActionException e
308-
309-
checkCancelled :: forall m . LspId m -> IO () -> (TResponseError m -> IO ()) -> IO ()
310-
checkCancelled _id act k =
311-
let sid = SomeLspId _id
312-
in flip finally (ctxClearReqId initParams sid) $
313-
catch (do
314-
-- We could optimize this by first checking if the id
315-
-- is in the cancelled set. However, this is unlikely to be a
316-
-- bottleneck and the additional check might hide
317-
-- issues with async exceptions that need to be fixed.
318-
cancelOrRes <- race (ctxWaitForCancel initParams sid) act
319-
case cancelOrRes of
320-
Left () -> do
321-
logWith recorder Debug $ LogCancelledRequest sid
322-
k $ TResponseError (InL LSPErrorCodes_RequestCancelled) "" Nothing
323-
Right res -> pure res
324-
) $ \(e :: SomeException) -> do
297+
case me of
298+
Left e -> do
299+
lifetimeConfirm "due to exception in reactor thread"
300+
logWith recorder Error $ LogReactorThreadException e
301+
ctxForceShutdown initParams
302+
_ -> do
303+
lifetimeConfirm "due to shutdown message"
304+
return ()
305+
306+
exceptionInHandler e = do
307+
logWith recorder Error $ LogReactorMessageActionException e
308+
309+
checkCancelled :: forall m . LspId m -> IO () -> (TResponseError m -> IO ()) -> IO ()
310+
checkCancelled _id act k =
311+
let sid = SomeLspId _id
312+
in flip finally (ctxClearReqId initParams sid) $
313+
catch
314+
(do
315+
-- We could optimize this by first checking if the id
316+
-- is in the cancelled set. However, this is unlikely to be a
317+
-- bottleneck and the additional check might hide
318+
-- issues with async exceptions that need to be fixed.
319+
cancelOrRes <- race (ctxWaitForCancel initParams sid) act
320+
case cancelOrRes of
321+
Left () -> do
322+
logWith recorder Debug $ LogCancelledRequest sid
323+
k $ TResponseError (InL LSPErrorCodes_RequestCancelled) "" Nothing
324+
Right res -> pure res
325+
)
326+
$ \(e :: SomeException) -> do
325327
exceptionInHandler e
326328
k $ TResponseError (InR ErrorCodes_InternalError) (T.pack $ show e) Nothing
327329
_ <- flip forkFinally handleServerExceptionOrShutDown $ do
@@ -386,4 +388,3 @@ modifyOptions x = x{ LSP.optTextDocumentSync = Just $ tweakTDS origTDS
386388
tweakTDS tds = tds{_openClose=Just True, _change=Just TextDocumentSyncKind_Incremental, _save=Just $ InR $ SaveOptions Nothing}
387389
origTDS = fromMaybe tdsDefault $ LSP.optTextDocumentSync x
388390
tdsDefault = TextDocumentSyncOptions Nothing Nothing Nothing Nothing Nothing
389-

0 commit comments

Comments
 (0)