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

namespace lsp::protocol
{
    enum class ErrorCodes : int
    {
        ParseError = -32700,
        InvalidRequest = -32600,
        MethodNotFound = -32601,
        InvalidParams = -32602,
        InternalError = -32603,

        JsonrpcReservedErrorRangeStart = -32099,
        ServerNotInitialized = -32002,
        UnknownErrorCode = -32001,
        JsonrpcReservedErrorRangeEnd = -32000,
        LspReservedErrorRangeStart = -32899,
        RequestFailed = -32803,
        ServerCancelled = -32802,
        ContentModified = -32801,
        RequestCancelled = -32800,
        LspReservedErrorRangeEnd = -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
    {
        ErrorCodes 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;
    };

}

