X-Git-Url: http://git.lukelau.me/?p=lsp-test.git;a=blobdiff_plain;f=src%2FLanguage%2FHaskell%2FLSP%2FTest.hs;h=8da170c0d4fe6e984e2d21ffcd05dab6a79cfbc3;hp=d3b1b65e4c5a7b9c2e9e5190897852e87a2ec018;hb=0f8b9d328f4d950ff0a2e1c3b5aed593b21c2d3a;hpb=ea5db1975df3a208798ce2c44dc71fb8123fabd3 diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index d3b1b65..8da170c 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -16,8 +16,12 @@ module Language.Haskell.LSP.Test -- * Sessions runSession , runSessionWithHandles - , runSessionWithCapabilities + , runSessionWithConfig , Session + , SessionConfig(..) + , MonadSessionConfig(..) + , SessionException(..) + , anySessionException -- * Sending , sendRequest , sendNotification @@ -74,12 +78,12 @@ import qualified Data.ByteString.Lazy.Char8 as B import Data.Default import qualified Data.Map as Map import Data.Maybe -import Language.Haskell.LSP.Types -import qualified Language.Haskell.LSP.Types as LSP (error, id) -import Language.Haskell.LSP.TH.ClientCapabilities +import Language.Haskell.LSP.Types hiding (id, capabilities) +import qualified Language.Haskell.LSP.Types as LSP import Language.Haskell.LSP.VFS import Language.Haskell.LSP.Test.Compat import Language.Haskell.LSP.Test.Decoding +import Language.Haskell.LSP.Test.Exceptions import Language.Haskell.LSP.Test.Parsing import Language.Haskell.LSP.Test.Session import Language.Haskell.LSP.Test.Server @@ -93,15 +97,15 @@ runSession :: String -- ^ The command to run the server. -> FilePath -- ^ The filepath to the root directory for the session. -> Session a -- ^ The session to run. -> IO a -runSession = runSessionWithCapabilities def +runSession = runSessionWithConfig def -- | Starts a new sesion with a client with the specified capabilities. -runSessionWithCapabilities :: ClientCapabilities -- ^ The capabilities the client should have. +runSessionWithConfig :: SessionConfig -- ^ The capabilities the client should have. -> String -- ^ The command to run the server. -> FilePath -- ^ The filepath to the root directory for the session. -> Session a -- ^ The session to run. -> IO a -runSessionWithCapabilities caps serverExe rootDir session = do +runSessionWithConfig config serverExe rootDir session = do pid <- getProcessID absRootDir <- canonicalizePath rootDir @@ -109,10 +113,11 @@ runSessionWithCapabilities caps serverExe rootDir session = do (Just $ T.pack absRootDir) (Just $ filePathToUri absRootDir) Nothing - caps + (capabilities config) (Just TraceOff) - withServer serverExe $ \serverIn serverOut _ -> runSessionWithHandles serverIn serverOut listenServer rootDir $ do + withServer serverExe $ \serverIn serverOut _ -> + runSessionWithHandles serverIn serverOut listenServer config rootDir $ do -- Wrap the session around initialize and shutdown calls sendRequest Initialize initializeParams