ProjectDeclarations.cpp 2.3 KB

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