Don't use exitServer in Replay
authorLuke Lau <luke_lau@icloud.com>
Sat, 20 Jul 2019 19:51:41 +0000 (20:51 +0100)
committerLuke Lau <luke_lau@icloud.com>
Sat, 20 Jul 2019 19:51:41 +0000 (20:51 +0100)
It's not needed since the captured session should contain it anyway

src/Language/Haskell/LSP/Test.hs
src/Language/Haskell/LSP/Test/Replay.hs
src/Language/Haskell/LSP/Test/Session.hs

index 016abc22cb6b6ea6fb898db0264e3ce4da9594ff..1b2e7ba867a6ebc4356b008e29a7c4ce53eee962 100644 (file)
@@ -37,9 +37,8 @@ module Language.Haskell.LSP.Test
   , module Language.Haskell.LSP.Test.Parsing
   -- * Utilities
   -- | Quick helper functions for common tasks.
   , module Language.Haskell.LSP.Test.Parsing
   -- * Utilities
   -- | Quick helper functions for common tasks.
-  -- ** Lifecycle
+  -- ** Initialization
   , initializeResponse
   , initializeResponse
-  , exitServer
   -- ** Documents
   , openDoc
   , openDoc'
   -- ** 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
                      -> Session a -- ^ The session to run.
                      -> IO a
 runSessionWithConfig config serverExe caps rootDir session = do
-  
   pid <- getCurrentProcessID
   absRootDir <- canonicalizePath rootDir
 
   pid <- getCurrentProcessID
   absRootDir <- canonicalizePath rootDir
 
@@ -168,6 +166,10 @@ runSessionWithConfig config serverExe caps rootDir session = do
       result <- session
       return result
   where
       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 ()
   -- | 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
     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
index b20eb08f9cb6d3a7a005e82ca61ccf44806747e3..ac55e9e749008c575f8a5c50dafbbec70b15040d 100644 (file)
@@ -66,7 +66,7 @@ replaySession serverExe sessionDir = do
                             def
                             fullCaps
                             sessionDir
                             def
                             fullCaps
                             sessionDir
-                            exitServer
+                            (return ()) -- No finalizer cleanup
                             (sendMessages clientMsgs reqSema rspSema)
     takeMVar passSema
     killThread sessionThread
                             (sendMessages clientMsgs reqSema rspSema)
     takeMVar passSema
     killThread sessionThread
index bbfdf386ac167bd0f8ab5b9a277b754920aacf57..4d75d1defa541f07993874da444ed8d4cf08d0ff 100644 (file)
@@ -198,7 +198,6 @@ runSessionWithHandles :: Handle -- ^ Server in
                       -> Session a
                       -> IO a
 runSessionWithHandles serverIn serverOut serverProc serverHandler config caps rootDir exitServer session = do
                       -> Session a
                       -> IO a
 runSessionWithHandles serverIn serverOut serverProc serverHandler config caps rootDir exitServer session = do
-  
   absRootDir <- canonicalizePath rootDir
 
   hSetBuffering serverIn  NoBuffering
   absRootDir <- canonicalizePath rootDir
 
   hSetBuffering serverIn  NoBuffering