X-Git-Url: http://git.lukelau.me/?p=lsp-test.git;a=blobdiff_plain;f=src%2FLanguage%2FHaskell%2FLSP%2FTest.hs;h=64100a4ced2d3f606857374e57a2735fc7770158;hp=4cad784156477f23f4cefdb482de94764ac7d215;hb=a4c1143848809be8aed55403dc3187a256dcbe9b;hpb=fe5448266f5db772dd3f10be432cd56581bbcb40 diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 4cad784..64100a4 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -22,6 +22,7 @@ module Language.Haskell.LSP.Test , MonadSessionConfig(..) , SessionException(..) , anySessionException + , withTimeout -- * Sending , sendRequest , sendRequest_ @@ -31,12 +32,10 @@ module Language.Haskell.LSP.Test , sendNotification' , sendResponse -- * Receving + , message , anyRequest - , request , anyResponse - , response , anyNotification - , notification , anyMessage , loggingNotification , publishDiagnosticsNotification @@ -94,7 +93,7 @@ import Data.Default import qualified Data.HashMap.Strict as HashMap import qualified Data.Map as Map import Data.Maybe -import Language.Haskell.LSP.Types hiding (id, capabilities) +import Language.Haskell.LSP.Types hiding (id, capabilities, message) import qualified Language.Haskell.LSP.Types as LSP import Language.Haskell.LSP.Messages import Language.Haskell.LSP.VFS @@ -161,7 +160,7 @@ runSessionWithConfig config serverExe rootDir session = do reqMap <- readMVar $ requestMap context let msg = decodeFromServerMsg reqMap msgBytes - writeChan (messageChan context) msg + writeChan (messageChan context) (ServerMessage msg) listenServer serverOut context @@ -176,7 +175,7 @@ documentContents doc = do -- and returns the new content getDocumentEdit :: TextDocumentIdentifier -> Session T.Text getDocumentEdit doc = do - req <- request :: Session ApplyWorkspaceEditRequest + req <- message :: Session ApplyWorkspaceEditRequest unless (checkDocumentChanges req || checkChanges req) $ liftIO $ throw (IncorrectApplyEditRequestException (show req)) @@ -317,7 +316,7 @@ getDocUri file = do waitForDiagnostics :: Session [Diagnostic] waitForDiagnostics = do - diagsNot <- skipManyTill anyMessage notification :: Session PublishDiagnosticsNotification + diagsNot <- skipManyTill anyMessage message :: Session PublishDiagnosticsNotification let (List diags) = diagsNot ^. params . LSP.diagnostics return diags @@ -326,7 +325,7 @@ waitForDiagnostics = do -- returned. noDiagnostics :: Session () noDiagnostics = do - diagsNot <- notification :: Session PublishDiagnosticsNotification + diagsNot <- message :: Session PublishDiagnosticsNotification when (diagsNot ^. params . LSP.diagnostics /= List []) $ liftIO $ throw UnexpectedDiagnosticsException -- | Returns the symbols in a document. @@ -369,4 +368,4 @@ executeCodeAction action = do where handleEdit :: WorkspaceEdit -> Session () handleEdit e = let req = RequestMessage "" (IdInt 0) WorkspaceApplyEdit (ApplyWorkspaceEditParams e) - in processMessage (ReqApplyWorkspaceEdit req) + in updateState (ReqApplyWorkspaceEdit req)