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 Messages.
"ProtocolMessage": { // implemented by Message
"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 of Message
"type": "string",
"description": "Message type.",
"_enum": [ "request", "response", "event" ]
}
},
"required": [ "seq", "type" ]
},
"Request": { // implemented by DebugRequestMessage
"allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, {
"type": "object",
"description": "A client or server-initiated request.",
"properties": {
"type": { // implicit by being of type DebugRequestMessage
"type": "string",
"enum": [ "request" ]
},
"command": { // implemented by RequestMessage.getMethod()
"type": "string",
"description": "The command to execute."
},
"arguments": { // implemented by RequestMessage.getParams()
"type": [ "array", "boolean", "integer", "null", "number" , "object", "string" ],
"description": "Object containing arguments for the command."
}
},
"required": [ "type", "command" ]
}]
},
"Event": { // implemented by DebugNotificationMessage
"allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, {
"type": "object",
"description": "Server-initiated event.",
"properties": {
"type": { // implicit by being of type DebugNotificationMessage
"type": "string",
"enum": [ "event" ]
},
"event": { // implemented by NotificationMessage.getMethod()
"type": "string",
"description": "Type of event."
},
"body": { // implemented by NotificationMessage.getParams()
"type": [ "array", "boolean", "integer", "null", "number" , "object", "string" ],
"description": "Event-specific information."
}
},
"required": [ "type", "event" ]
}]
},
"Response": { // implemented by DebugResponseMessage
"allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, {
"type": "object",
"description": "Response to a request.",
"properties": {
"type": { // implicit by being of type DebugResponseMessage
"type": "string",
"enum": [ "response" ]
},
"request_seq": { // implemented by IdentifiableMessage.getId()
"type": "integer",
"description": "Sequence number of the corresponding request."
},
"success": { // implemented by ResponseMessage.getError() == null
"type": "boolean",
"description": "Outcome of the request."
},
"command": { // implemented by DebugResponseMessage.getMethod()
"type": "string",
"description": "The command requested."
},
"message": { // implemented by ResponseError.getMessage()
"type": "string",
"description": "Contains error message if success == false."
},
"body": { // implemented by ResponseMessage.getResult() for success and ResponseError.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, writeNullValuepublic 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.MessageTypeAdapterjava.io.IOExceptionprotected 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.IOExceptionprotected 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.MessageTypeAdapterjava.io.IOException