Module: Holistic::LanguageServer::Response

Extended by:
Response
Included in:
Response
Defined in:
lib/holistic/language_server/response.rb

Constant Summary collapse

Success =
::Data.define(:message_id, :result) do
  def encode
    encoded_payload = {
      "jsonrpc" => Protocol::JSONRPC_VERSION,
      "id"      => message_id,
      "result"  => result
    }.to_json

    "#{Protocol::CONTENT_LENGTH_HEADER}:#{encoded_payload.bytesize}#{Protocol::END_OF_HEADER}#{encoded_payload}"
  end
end
Error =
::Data.define(:message_id, :code, :message, :data) do
  def encode
    encoded_payload = {
      "jsonrpc" => Protocol::JSONRPC_VERSION,
      "id" => message_id,
      "error" => {
        "code" => code,
        "message" => message,
        "data" => data
      }
    }.to_json

    "#{Protocol::CONTENT_LENGTH_HEADER}:#{encoded_payload.bytesize}#{Protocol::END_OF_HEADER}#{encoded_payload}"
  end
end
Exit =
::Data.define
NotFound =
::Data.define
Drop =
::Data.define