X-Git-Url: http://git.lukelau.me/?p=lsp-test.git;a=blobdiff_plain;f=src%2FLanguage%2FHaskell%2FLSP%2FTest.hs;h=1b2e7ba867a6ebc4356b008e29a7c4ce53eee962;hp=7e87fcb3b915756b7057a71d0b511eb626b2b588;hb=f0a961503e19c2d281c3d6319df1096f5bf6cfcf;hpb=bd2ac7da01645dc111a6912be661bc13b7f9340f diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 7e87fcb..1b2e7ba 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -37,9 +37,8 @@ module Language.Haskell.LSP.Test , module Language.Haskell.LSP.Test.Parsing -- * Utilities -- | Quick helper functions for common tasks. - -- ** Lifecycle + -- ** Initialization , initializeResponse - , exitServer -- ** Documents , openDoc , openDoc' @@ -138,7 +137,6 @@ runSessionWithConfig :: SessionConfig -- ^ Configuration options for the session -> Session a -- ^ The session to run. -> IO a runSessionWithConfig config serverExe caps rootDir session = do - pid <- getCurrentProcessID absRootDir <- canonicalizePath rootDir @@ -149,8 +147,8 @@ runSessionWithConfig config serverExe caps rootDir session = do caps (Just TraceOff) Nothing - withServer serverExe (logStdErr config) $ \serverIn serverOut _ -> - runSessionWithHandles serverIn serverOut listenServer config caps rootDir exitServer $ do + withServer serverExe (logStdErr config) $ \serverIn serverOut serverProc -> + runSessionWithHandles serverIn serverOut serverProc listenServer config caps rootDir exitServer $ do -- Wrap the session around initialize and shutdown calls initRspMsg <- request Initialize initializeParams :: Session InitializeResponse @@ -168,6 +166,10 @@ runSessionWithConfig config serverExe caps rootDir session = do result <- session return result where + -- | Asks the server to shutdown and exit politely + exitServer :: Session () + exitServer = request_ Shutdown (Nothing :: Maybe Value) >> sendNotification Exit ExitParams + -- | Listens to the server output until the shutdown ack, -- makes sure it matches the record and signals any semaphores listenServer :: Handle -> SessionContext -> IO () @@ -575,7 +577,3 @@ getCodeLenses tId = do rsp <- request TextDocumentCodeLens (CodeLensParams tId) :: Session CodeLensResponse case getResponseResult rsp of List res -> pure res - --- | Exit the server after request its shutdown -exitServer :: Session() -exitServer = request_ Shutdown (Nothing :: Maybe Value) >> sendNotification Exit ExitParams