2021-04-09 08:49:48 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Itamar S. <itamar8910@gmail.com>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-09 08:49:48 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
#include <AK/ByteString.h>
|
2021-04-09 08:49:48 +03:00
|
|
|
#include <AK/Function.h>
|
|
|
|
#include <AK/HashMap.h>
|
|
|
|
#include <AK/Noncopyable.h>
|
|
|
|
#include <LibGUI/AutocompleteProvider.h>
|
|
|
|
#include <LibGUI/Icon.h>
|
|
|
|
|
|
|
|
namespace HackStudio {
|
|
|
|
|
|
|
|
class ProjectDeclarations {
|
|
|
|
AK_MAKE_NONCOPYABLE(ProjectDeclarations);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static ProjectDeclarations& the();
|
|
|
|
template<typename Func>
|
|
|
|
void for_each_declared_symbol(Func);
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
void set_declared_symbols(ByteString const& filename, Vector<CodeComprehension::Declaration> const&);
|
2021-04-09 08:49:48 +03:00
|
|
|
|
2022-05-14 17:09:24 +03:00
|
|
|
static Optional<GUI::Icon> get_icon_for(CodeComprehension::DeclarationType);
|
2021-04-09 08:49:48 +03:00
|
|
|
|
|
|
|
Function<void()> on_update = nullptr;
|
|
|
|
|
|
|
|
private:
|
|
|
|
ProjectDeclarations() = default;
|
2023-12-16 17:49:34 +03:30
|
|
|
HashMap<ByteString, Vector<CodeComprehension::Declaration>> m_document_to_declarations;
|
2021-04-09 08:49:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Func>
|
|
|
|
void ProjectDeclarations::for_each_declared_symbol(Func f)
|
|
|
|
{
|
|
|
|
for (auto& item : m_document_to_declarations) {
|
|
|
|
for (auto& decl : item.value) {
|
|
|
|
f(decl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|