Types.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (c) 2022, Itamar S. <itamar8910@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/DeprecatedString.h>
  8. namespace CodeComprehension {
  9. enum class Language {
  10. Unspecified,
  11. Cpp,
  12. };
  13. struct AutocompleteResultEntry {
  14. DeprecatedString completion;
  15. size_t partial_input_length { 0 };
  16. // TODO: Actually assign the value of this field in more places (when applicable).
  17. Language language { Language::Unspecified };
  18. DeprecatedString display_text {};
  19. enum class HideAutocompleteAfterApplying {
  20. No,
  21. Yes,
  22. };
  23. HideAutocompleteAfterApplying hide_autocomplete_after_applying { HideAutocompleteAfterApplying::Yes };
  24. };
  25. struct ProjectLocation {
  26. DeprecatedString file;
  27. size_t line { 0 };
  28. size_t column { 0 };
  29. bool operator==(ProjectLocation const& other) const
  30. {
  31. return file == other.file && line == other.line && column == other.column;
  32. }
  33. };
  34. enum class DeclarationType {
  35. Function,
  36. Struct,
  37. Class,
  38. Variable,
  39. PreprocessorDefinition,
  40. Namespace,
  41. Member,
  42. };
  43. struct Declaration {
  44. DeprecatedString name;
  45. ProjectLocation position;
  46. DeclarationType type;
  47. DeprecatedString scope;
  48. bool operator==(Declaration const& other) const
  49. {
  50. return name == other.name && position == other.position && type == other.type && scope == other.scope;
  51. }
  52. };
  53. #define FOR_EACH_SEMANTIC_TYPE \
  54. __SEMANTIC(Unknown) \
  55. __SEMANTIC(Regular) \
  56. __SEMANTIC(Keyword) \
  57. __SEMANTIC(Type) \
  58. __SEMANTIC(Identifier) \
  59. __SEMANTIC(String) \
  60. __SEMANTIC(Number) \
  61. __SEMANTIC(IncludePath) \
  62. __SEMANTIC(PreprocessorStatement) \
  63. __SEMANTIC(Comment) \
  64. __SEMANTIC(Whitespace) \
  65. __SEMANTIC(Function) \
  66. __SEMANTIC(Variable) \
  67. __SEMANTIC(CustomType) \
  68. __SEMANTIC(Namespace) \
  69. __SEMANTIC(Member) \
  70. __SEMANTIC(Parameter) \
  71. __SEMANTIC(PreprocessorMacro)
  72. struct TokenInfo {
  73. enum class SemanticType : u32 {
  74. #define __SEMANTIC(x) x,
  75. FOR_EACH_SEMANTIC_TYPE
  76. #undef __SEMANTIC
  77. } type { SemanticType::Unknown };
  78. size_t start_line { 0 };
  79. size_t start_column { 0 };
  80. size_t end_line { 0 };
  81. size_t end_column { 0 };
  82. static constexpr char const* type_to_string(SemanticType t)
  83. {
  84. switch (t) {
  85. #define __SEMANTIC(x) \
  86. case SemanticType::x: \
  87. return #x;
  88. FOR_EACH_SEMANTIC_TYPE
  89. #undef __SEMANTIC
  90. }
  91. VERIFY_NOT_REACHED();
  92. }
  93. };
  94. struct TodoEntry {
  95. DeprecatedString content;
  96. DeprecatedString filename;
  97. size_t line { 0 };
  98. size_t column { 0 };
  99. };
  100. }