Serenity Operating System
at master 47 lines 1.1 kB view raw
1/* 2 * Copyright (c) 2021, Itamar S. <itamar8910@gmail.com> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/DeprecatedString.h> 10#include <AK/Function.h> 11#include <AK/HashMap.h> 12#include <AK/Noncopyable.h> 13#include <LibGUI/AutocompleteProvider.h> 14#include <LibGUI/Icon.h> 15 16namespace HackStudio { 17 18class ProjectDeclarations { 19 AK_MAKE_NONCOPYABLE(ProjectDeclarations); 20 21public: 22 static ProjectDeclarations& the(); 23 template<typename Func> 24 void for_each_declared_symbol(Func); 25 26 void set_declared_symbols(DeprecatedString const& filename, Vector<CodeComprehension::Declaration> const&); 27 28 static Optional<GUI::Icon> get_icon_for(CodeComprehension::DeclarationType); 29 30 Function<void()> on_update = nullptr; 31 32private: 33 ProjectDeclarations() = default; 34 HashMap<DeprecatedString, Vector<CodeComprehension::Declaration>> m_document_to_declarations; 35}; 36 37template<typename Func> 38void ProjectDeclarations::for_each_declared_symbol(Func f) 39{ 40 for (auto& item : m_document_to_declarations) { 41 for (auto& decl : item.value) { 42 f(decl); 43 } 44 } 45} 46 47}