@@ -86,7 +86,6 @@ import Control.Monad.Extra
86
86
import Data.Time
87
87
import GHC.Generics
88
88
import System.IO.Unsafe
89
- import Numeric.Extra
90
89
import Language.Haskell.LSP.Types
91
90
import Data.Foldable (traverse_ )
92
91
@@ -177,15 +176,6 @@ instance Eq Key where
177
176
instance Hashable Key where
178
177
hashWithSalt salt (Key key) = hashWithSalt salt (typeOf key, key)
179
178
180
- -- | The result of an IDE operation. Warnings and errors are in the Diagnostic,
181
- -- and a value is in the Maybe. For operations that throw an error you
182
- -- expect a non-empty list of diagnostics, at least one of which is an error,
183
- -- and a Nothing. For operations that succeed you expect perhaps some warnings
184
- -- and a Just. For operations that depend on other failing operations you may
185
- -- get empty diagnostics and a Nothing, to indicate this phase throws no fresh
186
- -- errors but still failed.
187
- --
188
-
189
179
data Value v
190
180
= Succeeded TextDocumentVersion v
191
181
| Stale TextDocumentVersion v
@@ -260,15 +250,13 @@ data IdeState = IdeState
260
250
261
251
262
252
-- This is debugging code that generates a series of profiles, if the Boolean is true
263
- shakeRunDatabaseProfile :: Maybe FilePath -> ShakeDatabase -> [Action a ] -> IO ([a ], Maybe FilePath )
264
- shakeRunDatabaseProfile mbProfileDir shakeDb acts = do
265
- (time, (res,_)) <- duration $ shakeRunDatabase shakeDb acts
266
- proFile <- for mbProfileDir $ \ dir -> do
253
+ shakeDatabaseProfile :: Maybe FilePath -> ShakeDatabase -> IO (Maybe FilePath )
254
+ shakeDatabaseProfile mbProfileDir shakeDb =
255
+ for mbProfileDir $ \ dir -> do
267
256
count <- modifyVar profileCounter $ \ x -> let ! y = x+ 1 in return (y,y)
268
- let file = " ide-" ++ profileStartTime ++ " -" ++ takeEnd 5 (" 0000" ++ show count) ++ " - " ++ showDP 2 time <.> " html"
257
+ let file = " ide-" ++ profileStartTime ++ " -" ++ takeEnd 5 (" 0000" ++ show count) <.> " html"
269
258
shakeProfileDatabase shakeDb $ dir </> file
270
259
return (dir </> file)
271
- return (res, proFile)
272
260
273
261
{-# NOINLINE profileStartTime #-}
274
262
profileStartTime :: String
@@ -429,7 +417,13 @@ shakeRestart it@IdeState{shakeExtras=ShakeExtras{logger}, ..} systemActs =
429
417
shakeSession
430
418
(\ runner -> do
431
419
(stopTime,queue) <- duration (cancelShakeSession runner)
432
- logDebug logger $ T. pack $ " Restarting build session (aborting the previous one took " ++ showDuration stopTime ++ " )"
420
+ res <- shakeDatabaseProfile shakeProfileDir shakeDb
421
+ let profile = case res of
422
+ Just fp -> " , profile saved at " <> fp
423
+ _ -> " "
424
+ logDebug logger $ T. pack $
425
+ " Restarting build session (aborting the previous one took " ++
426
+ showDuration stopTime ++ profile ++ " )"
433
427
return queue
434
428
)
435
429
-- It is crucial to be masked here, otherwise we can get killed
@@ -483,19 +477,13 @@ newSession IdeState{shakeExtras=ShakeExtras{..}, ..} systemActs userActs = do
483
477
<* liftIO (cancel progressThread)
484
478
]
485
479
res <- try @ SomeException
486
- (restore $ shakeRunDatabaseProfile shakeProfileDir shakeDb systemActs')
480
+ (restore $ shakeRunDatabase shakeDb systemActs')
487
481
let res' = case res of
488
482
Left e -> " exception: " <> displayException e
489
483
Right _ -> " completed"
490
- profile = case res of
491
- Right (_, Just fp) ->
492
- let link = case filePathToUri' $ toNormalizedFilePath' fp of
493
- NormalizedUri _ x -> x
494
- in " , profile saved at " <> T. unpack link
495
- _ -> " "
496
484
-- Wrap up in a thread to avoid calling interruptible
497
485
-- operations inside the masked section
498
- let wrapUp = logDebug logger $ T. pack $ " Finishing build session(" ++ res' ++ profile ++ " )"
486
+ let wrapUp = logDebug logger $ T. pack $ " Finishing build session(" ++ res' ++ " )"
499
487
return wrapUp
500
488
501
489
-- Do the work in a background thread
0 commit comments