, module Language.Haskell.LSP.Test.Parsing
-- * Utilities
-- | Quick helper functions for common tasks.
- -- ** Lifecycle
+ -- ** Initialization
, initializeResponse
- , exitServer
-- ** Documents
, openDoc
, openDoc'
-> Session a -- ^ The session to run.
-> IO a
runSessionWithConfig config serverExe caps rootDir session = do
-
pid <- getCurrentProcessID
absRootDir <- canonicalizePath rootDir
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
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 ()
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