public class DebugMessageTypeAdapter
extends org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter
DebugMessageTypeAdapter
provides an adapter that maps Debug
Server Protocol style JSON to/from LSP4J's JSONRPC implementation. The Debug
Server Protocol (DSP) has its own message format that is quite similar to
JSON-RPC 2.0. The DSP is defined in a JSON
schema in the VS Code Debug Adapter. This section documents how LSP4J's
jsonrpc classes maps to the Debug Protocol, using some extensions in the DSP
code to the lsp4j's Message
s.
"ProtocolMessage": { // implemented byMessage
"type": "object", "description": "Base class of requests, responses, and events.", "properties": { "seq": { // implemented by (depending on type, with conversion to/from String): //IdentifiableMessage.getId()
, or //DebugNotificationMessage.getId()
or //DebugResponseMessage.getResponseId()
"type": "integer", "description": "Sequence number." }, "type": { // implicit in type of subclass ofMessage
"type": "string", "description": "Message type.", "_enum": [ "request", "response", "event" ] } }, "required": [ "seq", "type" ] }, "Request": { // implemented byDebugRequestMessage
"allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, { "type": "object", "description": "A client or server-initiated request.", "properties": { "type": { // implicit by being of typeDebugRequestMessage
"type": "string", "enum": [ "request" ] }, "command": { // implemented byRequestMessage.getMethod()
"type": "string", "description": "The command to execute." }, "arguments": { // implemented byRequestMessage.getParams()
"type": [ "array", "boolean", "integer", "null", "number" , "object", "string" ], "description": "Object containing arguments for the command." } }, "required": [ "type", "command" ] }] }, "Event": { // implemented byDebugNotificationMessage
"allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, { "type": "object", "description": "Server-initiated event.", "properties": { "type": { // implicit by being of typeDebugNotificationMessage
"type": "string", "enum": [ "event" ] }, "event": { // implemented byNotificationMessage.getMethod()
"type": "string", "description": "Type of event." }, "body": { // implemented byNotificationMessage.getParams()
"type": [ "array", "boolean", "integer", "null", "number" , "object", "string" ], "description": "Event-specific information." } }, "required": [ "type", "event" ] }] }, "Response": { // implemented byDebugResponseMessage
"allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, { "type": "object", "description": "Response to a request.", "properties": { "type": { // implicit by being of typeDebugResponseMessage
"type": "string", "enum": [ "response" ] }, "request_seq": { // implemented byIdentifiableMessage.getId()
"type": "integer", "description": "Sequence number of the corresponding request." }, "success": { // implemented byResponseMessage.getError()
== null "type": "boolean", "description": "Outcome of the request." }, "command": { // implemented byDebugResponseMessage.getMethod()
"type": "string", "description": "The command requested." }, "message": { // implemented byResponseError.getMessage()
"type": "string", "description": "Contains error message if success == false." }, "body": { // implemented byResponseMessage.getResult()
for success andResponseError.getData()
for error "type": [ "array", "boolean", "integer", "null", "number" , "object", "string" ], "description": "Contains request result if success is true and optional error details if success is false." } }, "required": [ "type", "request_seq", "success", "command" ] }] },
Modifier and Type | Class and Description |
---|---|
static class |
DebugMessageTypeAdapter.Factory |
Constructor and Description |
---|
DebugMessageTypeAdapter(org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler handler,
com.google.gson.Gson gson) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
parseBody(com.google.gson.stream.JsonReader in,
java.lang.String messageType,
int request_seq,
java.lang.String method,
java.lang.Boolean success)
Convert the json input into the body object corresponding to the type of
message.
|
protected java.lang.Object |
parseBody(java.lang.Object rawBody,
java.lang.String messageType,
int request_seq,
java.lang.String method,
java.lang.Boolean success)
Convert the JsonElement into the body object corresponding to the type of
message.
|
org.eclipse.lsp4j.jsonrpc.messages.Message |
read(com.google.gson.stream.JsonReader in) |
void |
write(com.google.gson.stream.JsonWriter out,
org.eclipse.lsp4j.jsonrpc.messages.Message message) |
createMessage, fromJson, fromJson, getParameterTypes, isNull, isNullOrVoidType, parseParams, parseParams, parseResult, parseResult, writeId, writeNullValue
public DebugMessageTypeAdapter(org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler handler, com.google.gson.Gson gson)
public org.eclipse.lsp4j.jsonrpc.messages.Message read(com.google.gson.stream.JsonReader in) throws java.io.IOException
read
in class org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter
java.io.IOException
protected java.lang.Object parseBody(com.google.gson.stream.JsonReader in, java.lang.String messageType, int request_seq, java.lang.String method, java.lang.Boolean success) throws java.io.IOException
parseBody(Object, String, int, String, Boolean)
on
the return value of this call for a second chance conversion.in
- json input to read frommessageType
- message type if knownrequest_seq
- seq id of request message if knownmethod
- event/method being calledsuccess
- if success of a response is knownjava.io.IOException
protected java.lang.Object parseBody(java.lang.Object rawBody, java.lang.String messageType, int request_seq, java.lang.String method, java.lang.Boolean success)
rawBody
- json element to read frommessageType
- message type if knownrequest_seq
- seq id of request message if knownmethod
- event/method being calledsuccess
- if success of a response is knownpublic void write(com.google.gson.stream.JsonWriter out, org.eclipse.lsp4j.jsonrpc.messages.Message message) throws java.io.IOException
write
in class org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter
java.io.IOException