+-- | An internal version of 'runSession' that allows for a custom handler to listen to the server.
+-- It also does not automatically send initialize and exit messages.
+runSessionWithHandler :: (Handle -> Session ())
+ -> FilePath
+ -> FilePath
+ -> Session a
+ -> IO a
+runSessionWithHandler serverHandler serverExe rootDir session = do
+ absRootDir <- canonicalizePath rootDir
+
+ (Just serverIn, Just serverOut, Nothing, serverProc) <- createProcess
+ (proc serverExe ["--lsp", "-d", "-l", "/tmp/hie-test.log"])
+ { std_in = CreatePipe, std_out = CreatePipe }
+
+ hSetBuffering serverIn NoBuffering
+ hSetBuffering serverOut NoBuffering
+
+ reqMap <- newMVar newRequestMap
+ messageChan <- newChan
+ meaninglessChan <- newChan
+
+ let context = SessionContext serverIn absRootDir messageChan reqMap
+ initState = SessionState (IdInt 9)
+
+ threadId <- forkIO $ void $ runSession' meaninglessChan context initState (serverHandler serverOut)
+ (result, _) <- runSession' messageChan context initState session