| Copyright | (C) 2023 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
DAP.Adaptor
Description
Synopsis
- setBody :: ToJSON value => value -> Adaptor app request ()
- setField :: ToJSON value => Key -> value -> Adaptor app request ()
- sendSuccesfulEmptyResponse :: Adaptor app Request ()
- sendSuccesfulResponse :: Adaptor app Request () -> Adaptor app Request ()
- sendErrorResponse :: ErrorMessage -> Maybe Message -> Adaptor app Request ()
- sendSuccesfulEvent :: EventType -> Adaptor app request () -> Adaptor app request ()
- sendReverseRequest :: ReverseCommand -> Adaptor app Request ()
- sendRunInTerminalReverseRequest :: RunInTerminalRequestArguments -> Adaptor app Request ()
- getServerCapabilities :: Adaptor app request Capabilities
- withConnectionLock :: IO () -> Adaptor app request ()
- getArguments :: (Show value, FromJSON value) => Adaptor app Request value
- getRequestSeqNum :: Adaptor app Request Seq
- getReverseRequestResponseBody :: (Show value, FromJSON value) => ReverseRequestResponse -> Adaptor app r value
- registerNewDebugSession :: SessionId -> app -> [(Adaptor app () () -> IO ()) -> IO ()] -> Adaptor app request ()
- updateDebugSession :: (app -> app) -> Adaptor app request ()
- getDebugSession :: Adaptor a r a
- getDebugSessionId :: Adaptor app request SessionId
- destroyDebugSession :: Adaptor app request ()
- sendError :: ErrorMessage -> Maybe Message -> Adaptor app request a
- logWarn :: Text -> Adaptor app request ()
- logError :: Text -> Adaptor app request ()
- logInfo :: Text -> Adaptor app request ()
- logger :: LogAction IO DAPLog -> Level -> SockAddr -> Maybe DebugStatus -> Text -> IO ()
- debugMessage :: DebugStatus -> ByteString -> Adaptor app request ()
- send :: Adaptor app Request () -> Adaptor app Request ()
- sendRaw :: ToJSON value => value -> Adaptor app request ()
- runAdaptorWith :: AdaptorLocal app request -> AdaptorState -> Adaptor app request () -> IO ()
- runAdaptor :: AdaptorLocal app Request -> AdaptorState -> Adaptor app Request () -> IO ()
- withRequest :: Request -> Adaptor app Request a -> Adaptor app r a
- getHandle :: Adaptor app r Handle
Message Construction
Response
sendSuccesfulEmptyResponse :: Adaptor app Request () Source #
sendErrorResponse :: ErrorMessage -> Maybe Message -> Adaptor app Request () Source #
Sends unsuccessful response Only used internally within the Server module
Events
sendSuccesfulEvent :: EventType -> Adaptor app request () -> Adaptor app request () Source #
Sends successful event
Reverse Requests
sendReverseRequest :: ReverseCommand -> Adaptor app Request () Source #
Write reverse request to Handle
sendRunInTerminalReverseRequest :: RunInTerminalRequestArguments -> Adaptor app Request () Source #
Send runInTerminal reverse request
Server
getServerCapabilities :: Adaptor app request Capabilities Source #
withConnectionLock :: IO () -> Adaptor app request () Source #
Request Arguments
getArguments :: (Show value, FromJSON value) => Adaptor app Request value Source #
Attempt to parse arguments from the Request
getReverseRequestResponseBody :: (Show value, FromJSON value) => ReverseRequestResponse -> Adaptor app r value Source #
Attempt to parse arguments from a ReverseRequestResponse (not in env)
Debug Session
registerNewDebugSession Source #
Arguments
| :: SessionId | |
| -> app | |
| -> [(Adaptor app () () -> IO ()) -> IO ()] | Actions to run debugger (operates in a forked thread that gets killed when disconnect is set)
Long running operation, meant to be used as a sink for
the debugger to emit events and for the adaptor to forward to the editor
This function should be in a This event handler thread also takes an argument that allows any child thread to execute events on behalf of the DAP server (in 'Adaptor app ()'). This function should always be used when sending events to the editor from the debugger (or from any forked thread).
registerNewDebugSession sessionId appState $ loadDebugger : [\withAdaptor ->
forever $ getDebuggerOutput >>= \output -> do
withAdaptor $ sendOutputEvent defaultOutputEvent { outputEventOutput = output }
] |
| -> Adaptor app request () |
updateDebugSession :: (app -> app) -> Adaptor app request () Source #
getDebugSession :: Adaptor a r a Source #
getDebugSessionId :: Adaptor app request SessionId Source #
destroyDebugSession :: Adaptor app request () Source #
Whenever a debug Session ends (cleanly or otherwise) this function will remove the local debugger communication state from the global state
Error handling
sendError :: ErrorMessage -> Maybe Message -> Adaptor app request a Source #
Raises an error
Meant abort the current reqeust / response cycle, prematurely sending an ErrorResponse
https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_ErrorResponse
Logging
logger :: LogAction IO DAPLog -> Level -> SockAddr -> Maybe DebugStatus -> Text -> IO () Source #
Meant for external consumption
debugMessage :: DebugStatus -> ByteString -> Adaptor app request () Source #
Meant for internal consumption, used to signify a message has been SENT from the server
Internal use
send :: Adaptor app Request () -> Adaptor app Request () Source #
Function for constructing a payload and writing bytes to a socket.
This function takes care of incrementing sequence numbers
and setting fields automatically that are required for response messages.
i.e. "request_seq" and "command".
We also have to be sure to reset the message payload
sendRaw :: ToJSON value => value -> Adaptor app request () Source #
sendRaw (internal use only)
Sends a raw JSON payload to the editor. No "seq", "type" or "command" fields are set.
The message is still encoded with the ProtocolMessage Header, byte count, and CRLF.
Internal function used to execute actions on behalf of the DAP server
runAdaptorWith :: AdaptorLocal app request -> AdaptorState -> Adaptor app request () -> IO () Source #
Evaluates Adaptor action by using and updating the state in the MVar
runAdaptor :: AdaptorLocal app Request -> AdaptorState -> Adaptor app Request () -> IO () Source #
Utility for evaluating a monad transformer stack