#pragma once
#include <memory>
#include "./base/events.hpp"
#include "./base/event_bus.hpp"
#include "./detail/symbol/repository/system.hpp"
#include "./detail/symbol/repository/workspace.hpp"
#include "./detail/symbol/repository/editing.hpp"

namespace lsp::service
{
    class Symbol
    {
    public:
        explicit Symbol(std::shared_ptr<EventBus> event_bus);
        ~Symbol();

        // === 加载符号 ===
        void LoadSystemSymbols(const std::string& folder);
        void LoadWorkspaceSymbols(const std::string& folder);
        void ReloadWorkspaceSymbols(const std::string& folder);

        const symbol::repository::System& SystemRepo() const;
        const symbol::repository::Workspace& WorkspaceRepo() const;
        const symbol::repository::Editing& EditingRepo() const;

    private:
        void OnDocumentParsed(const events::DocumentParsed& event);
        void OnDocumentReparsed(const events::DocumentReparsed& event);
        void OnDocumentClosed(const events::DocumentClosed& event);

    private:
        symbol::repository::System system_repo_;
        symbol::repository::Workspace workspace_repo_;
        symbol::repository::Editing editing_repo_;

        std::shared_ptr<EventBus> event_bus_;
    };
}
