/* * Copyright (c) 2021, Itamar S. * Copyright (c) 2024, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include "DeclarationsModel.h" #include #include #include #include #include #include namespace HackStudio { class ProjectDeclarations { AK_MAKE_NONCOPYABLE(ProjectDeclarations); public: static ProjectDeclarations& the(); template void for_each_declared_symbol(Func); void set_declared_symbols(ByteString const& filename, Vector const&); DeclarationsModel& declarations_model() { return m_declarations_model; } void update_declarations_model(); static Optional get_icon_for(CodeComprehension::DeclarationType); Function on_update = nullptr; private: ProjectDeclarations(); HashMap> m_document_to_declarations; NonnullRefPtr m_declarations_model; }; template void ProjectDeclarations::for_each_declared_symbol(Func f) { for (auto& item : m_document_to_declarations) { for (auto& decl : item.value) { f(decl); } } } }