#pragma once
#include "./basic_types.hpp"

namespace lsp::protocol
{
    enum class ErrorCode : int
    {
        kParseError = -32700,
        kInvalidRequest = -32600,
        kMethodNotFound = -32601,
        kInvalidParams = -32602,
        kInternalError = -32603,

        kJsonrpcReservedErrorRangeStart = -32099,
        kServerNotInitialized = -32002,
        kUnknownErrorCode = -32001,
        kJsonrpcReservedErrorRangeEnd = -32000,
        kLspReservedErrorRangeStart = -32899,
        kRequestFailed = -32803,
        kServerCancelled = -32802,
        kContentModified = -32801,
        kRequestCancelled = -32800,
        kLspReservedErrorRangeEnd = -32800
    };

    struct Message
    {
        string jsonrpc = "2.0";
    };

    struct RequestMessage: Message
    {
        std::variant<integer, string> id;
        string method;
        std::optional<std::variant<LSPArray, LSPObject>> params;
    };

    struct ResponseError: Message
    {
        ErrorCode code;
        string message;
        std::optional<LSPAny> data;
    };

    struct ResponseMessage: Message
    {
        std::variant<integer, string> id;
        std::optional<LSPAny> result;
        std::optional<ResponseError> error;
    };

    struct NotificationMessage: Message
    {
        string method;
        std::optional<LSPAny> params;
    };

    struct CancelParams
    {
        std::variant<integer, string> id;
    };

}

