Serenity Operating System
1/*
2 * Copyright (c) 2021, Itamar S. <itamar8910@gmail.com>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include "ProjectDeclarations.h"
8
9HackStudio::ProjectDeclarations& HackStudio::ProjectDeclarations::the()
10{
11 static ProjectDeclarations s_instance;
12 return s_instance;
13}
14void HackStudio::ProjectDeclarations::set_declared_symbols(DeprecatedString const& filename, Vector<CodeComprehension::Declaration> const& declarations)
15{
16 m_document_to_declarations.set(filename, declarations);
17 if (on_update)
18 on_update();
19}
20
21Optional<GUI::Icon> HackStudio::ProjectDeclarations::get_icon_for(CodeComprehension::DeclarationType type)
22{
23 static GUI::Icon struct_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Struct.png"sv).release_value_but_fixme_should_propagate_errors());
24 static GUI::Icon class_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Class.png"sv).release_value_but_fixme_should_propagate_errors());
25 static GUI::Icon function_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Function.png"sv).release_value_but_fixme_should_propagate_errors());
26 static GUI::Icon variable_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Variable.png"sv).release_value_but_fixme_should_propagate_errors());
27 static GUI::Icon preprocessor_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Preprocessor.png"sv).release_value_but_fixme_should_propagate_errors());
28 static GUI::Icon member_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Member.png"sv).release_value_but_fixme_should_propagate_errors());
29 static GUI::Icon namespace_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Namespace.png"sv).release_value_but_fixme_should_propagate_errors());
30 switch (type) {
31 case CodeComprehension::DeclarationType::Struct:
32 return struct_icon;
33 case CodeComprehension::DeclarationType::Class:
34 return class_icon;
35 case CodeComprehension::DeclarationType::Function:
36 return function_icon;
37 case CodeComprehension::DeclarationType::Variable:
38 return variable_icon;
39 case CodeComprehension::DeclarationType::PreprocessorDefinition:
40 return preprocessor_icon;
41 case CodeComprehension::DeclarationType::Member:
42 return member_icon;
43 case CodeComprehension::DeclarationType::Namespace:
44 return namespace_icon;
45 default:
46 return {};
47 }
48}