projects
/
lsp-test.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Install JS language server
[lsp-test.git]
/
src
/
Language
/
Haskell
/
LSP
/
Test
/
Decoding.hs
diff --git
a/src/Language/Haskell/LSP/Test/Decoding.hs
b/src/Language/Haskell/LSP/Test/Decoding.hs
index 2cbc41c07354f9c10f81ab902379085e52d5ed72..af91928695d73df098cb4054abaae82632d3a845 100644
(file)
--- a/
src/Language/Haskell/LSP/Test/Decoding.hs
+++ b/
src/Language/Haskell/LSP/Test/Decoding.hs
@@
-32,7
+32,7
@@
getNextMessage :: Handle -> IO B.ByteString
getNextMessage h = do
headers <- getHeaders h
case read . init <$> lookup "Content-Length" headers of
getNextMessage h = do
headers <- getHeaders h
case read . init <$> lookup "Content-Length" headers of
- Nothing ->
error "Couldn't read Content-Length header"
+ Nothing ->
throw NoContentLengthHeader
Just size -> B.hGet h size
addHeader :: B.ByteString -> B.ByteString
Just size -> B.hGet h size
addHeader :: B.ByteString -> B.ByteString
@@
-123,7
+123,7
@@
matchResponseMsgType req = case req of
decodeFromServerMsg :: RequestMap -> B.ByteString -> FromServerMessage
decodeFromServerMsg reqMap bytes =
decodeFromServerMsg :: RequestMap -> B.ByteString -> FromServerMessage
decodeFromServerMsg reqMap bytes =
- case HM.lookup "method"
(fromJust $ decode bytes :: Object)
of
+ case HM.lookup "method"
obj
of
Just methodStr -> case fromJSON methodStr of
Success method -> case method of
-- We can work out the type of the message
Just methodStr -> case fromJSON methodStr of
Success method -> case method of
-- We can work out the type of the message
@@
-131,6
+131,9
@@
decodeFromServerMsg reqMap bytes =
WindowShowMessage -> NotShowMessage $ fromJust $ decode bytes
WindowLogMessage -> NotLogMessage $ fromJust $ decode bytes
CancelRequestServer -> NotCancelRequestFromServer $ fromJust $ decode bytes
WindowShowMessage -> NotShowMessage $ fromJust $ decode bytes
WindowLogMessage -> NotLogMessage $ fromJust $ decode bytes
CancelRequestServer -> NotCancelRequestFromServer $ fromJust $ decode bytes
+ WindowProgressStart -> NotProgressStart $ fromJust $ decode bytes
+ WindowProgressReport -> NotProgressReport $ fromJust $ decode bytes
+ WindowProgressDone -> NotProgressDone $ fromJust $ decode bytes
TelemetryEvent -> NotTelemetry $ fromJust $ decode bytes
WindowShowMessageRequest -> ReqShowMessage $ fromJust $ decode bytes
ClientRegisterCapability -> ReqRegisterCapability $ fromJust $ decode bytes
TelemetryEvent -> NotTelemetry $ fromJust $ decode bytes
WindowShowMessageRequest -> ReqShowMessage $ fromJust $ decode bytes
ClientRegisterCapability -> ReqRegisterCapability $ fromJust $ decode bytes
@@
-138,6
+141,10
@@
decodeFromServerMsg reqMap bytes =
WorkspaceApplyEdit -> ReqApplyWorkspaceEdit $ fromJust $ decode bytes
WorkspaceWorkspaceFolders -> error "ReqWorkspaceFolders not supported yet"
WorkspaceConfiguration -> error "ReqWorkspaceConfiguration not supported yet"
WorkspaceApplyEdit -> ReqApplyWorkspaceEdit $ fromJust $ decode bytes
WorkspaceWorkspaceFolders -> error "ReqWorkspaceFolders not supported yet"
WorkspaceConfiguration -> error "ReqWorkspaceConfiguration not supported yet"
+ CustomServerMethod _
+ | "id" `HM.member` obj && "method" `HM.member` obj -> ReqCustomServer $ fromJust $ decode bytes
+ | "id" `HM.member` obj -> RspCustomServer $ fromJust $ decode bytes
+ | otherwise -> NotCustomServer $ fromJust $ decode bytes
Error e -> error e
Error e -> error e
@@
-146,3
+153,4
@@
decodeFromServerMsg reqMap bytes =
Just req -> matchResponseMsgType req bytes -- try to decode it to more specific type
Nothing -> error "Couldn't match up response with request"
Nothing -> error "Couldn't decode message"
Just req -> matchResponseMsgType req bytes -- try to decode it to more specific type
Nothing -> error "Couldn't match up response with request"
Nothing -> error "Couldn't decode message"
+ where obj = fromJust $ decode bytes :: Object