From b6fd3c1a75566501725d0d6c2607dcb098eaed13 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Tue, 4 Jun 2019 17:17:05 +0200 Subject: [PATCH] Remove use of `managed` for starting the scenario service (#1508) Ironically `managed` didn't turn out to make our code more manageable and we ended up mostly using it in very isolated places only to then immediately convert it back to bracket-style functions using `with`. This PR also removes the use of `managed` from the GcpLogger which was the only other place where we are using it and it finally kills the rather silly logic that starting up the scenario service was tied to having an event logger. --- src/Development/IDE/State/Service.hs | 5 ++--- src/Development/IDE/Types/LSP.hs | 3 --- test/Demo.hs | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Development/IDE/State/Service.hs b/src/Development/IDE/State/Service.hs index 618a48b3..9cbc6ec0 100644 --- a/src/Development/IDE/State/Service.hs +++ b/src/Development/IDE/State/Service.hs @@ -24,7 +24,6 @@ import Control.Monad.Except import Development.IDE.Types.Options (IdeOptions(..)) import Development.IDE.State.FileStore import qualified Development.IDE.Logger as Logger -import Data.Maybe import Data.Set (Set) import qualified Data.Set as Set import Development.IDE.Functions.GHCError @@ -70,14 +69,14 @@ unsafeClearDiagnostics = unsafeClearAllDiagnostics -- | Initialise the Compiler Service. initialise :: Rules () - -> Maybe (Event -> IO ()) + -> (Event -> IO ()) -> Logger.Handle -> IdeOptions -> VFSHandle -> IO IdeState initialise mainRule toDiags logger options vfs = shakeOpen - (fromMaybe (const $ pure ()) toDiags) + toDiags logger (setProfiling options $ shakeOptions { shakeThreads = optThreads options diff --git a/src/Development/IDE/Types/LSP.hs b/src/Development/IDE/Types/LSP.hs index 9885a7ea..26e45cbd 100644 --- a/src/Development/IDE/Types/LSP.hs +++ b/src/Development/IDE/Types/LSP.hs @@ -52,7 +52,4 @@ data Event | EventFileValidation Int Int -- ^ @EventFileValidation finishedValidations totalValidations @ -- How many validations have we finished of how many total. - | EventFatalError !T.Text - -- ^ @EventFatalError reason@: A fatal error occurred in the compiler and - -- the compiler cannot continue. deriving Show diff --git a/test/Demo.hs b/test/Demo.hs index fba5aebd..d11c9c7d 100644 --- a/test/Demo.hs +++ b/test/Demo.hs @@ -42,7 +42,7 @@ main = do vfs <- makeVFSHandle ide <- initialise mainRule - (Just $ showEvent lock) + (showEvent lock) (makeOneHandle $ withLock lock . T.putStrLn) IdeOptions {optPreprocessor = (,) []