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

extern "C" {
#include <tree_sitter/api.h>
}

namespace lsp::service::document
{
    class TextDocument
    {
    public:
        explicit TextDocument(const protocol::TextDocumentItem& item);

        void ApplyChange(const protocol::TextDocumentContentChangeEvent& change);
        void SetVersion(protocol::integer version);

        const protocol::string& GetContent() const;
        const protocol::DocumentUri& GetUri() const;
        protocol::integer GetVersion() const;

    private:
        static bool IsFullDocumentUpdate(const protocol::TextDocumentContentChangeEvent& change, const protocol::string& current_content);

        protocol::TextDocumentItem item_;
    };
}
