diff --git a/src/clang_symbol_kind.h b/src/clang_symbol_kind.h new file mode 100644 index 00000000..5c433add --- /dev/null +++ b/src/clang_symbol_kind.h @@ -0,0 +1,46 @@ +#pragma once + +#include "serializer.h" + +#include + +// TODO Rename query.h:SymbolKind to another name +// clang/Index/IndexSymbol.h clang::index::SymbolKind +enum class ClangSymbolKind : uint8_t { + Unknown, + + Module = 1, + Namespace, + NamespaceAlias, + Macro, + + Enum = 5, + Struct, + Class, + Protocol, + Extension, + Union, + TypeAlias, + + Function = 12, + Variable, + Field, + EnumConstant, + + InstanceMethod = 16, + ClassMethod, + StaticMethod, + InstanceProperty, + ClassProperty, + StaticProperty, + + Constructor = 22, + Destructor, + ConversionFunction, + + Parameter = 25, + Using, +}; +MAKE_REFLECT_TYPE_PROXY(ClangSymbolKind, + std::underlying_type::type); + diff --git a/src/indexer.h b/src/indexer.h index a67e2452..1ecbe796 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -2,6 +2,7 @@ #include "clang_cursor.h" #include "clang_index.h" +#include "clang_symbol_kind.h" #include "clang_translation_unit.h" #include "clang_utils.h" #include "file_consumer.h" @@ -77,46 +78,6 @@ using IndexVarId = Id; struct IdCache; -// TODO Rename query.h:SymbolKind to another name -// clang/Index/IndexSymbol.h clang::index::SymbolKind -enum class ClangSymbolKind : uint8_t { - Unknown, - - Module = 1, - Namespace, - NamespaceAlias, - Macro, - - Enum = 5, - Struct, - Class, - Protocol, - Extension, - Union, - TypeAlias, - - Function = 12, - Variable, - Field, - EnumConstant, - - InstanceMethod = 16, - ClassMethod, - StaticMethod, - InstanceProperty, - ClassProperty, - StaticProperty, - - Constructor = 22, - Destructor, - ConversionFunction, - - Parameter = 25, - Using, -}; -MAKE_REFLECT_TYPE_PROXY(ClangSymbolKind, - std::underlying_type::type); - struct IndexFuncRef { // NOTE: id can be -1 if the function call is not coming from a function. IndexFuncId id; diff --git a/src/language_server_api.h b/src/language_server_api.h index 78ac5865..b65a4472 100644 --- a/src/language_server_api.h +++ b/src/language_server_api.h @@ -1,5 +1,6 @@ #pragma once +#include "clang_symbol_kind.h" #include "config.h" #include "ipc.h" #include "serializer.h" @@ -1086,7 +1087,7 @@ struct Out_CqueryPublishSemanticHighlighting int stableId = 0; // TODO Deprecate |type| in favor of fine-grained |kind|. SymbolType type = SymbolType::Type; - int kind; + ClangSymbolKind kind; bool isTypeMember = false; std::vector ranges; }; diff --git a/src/message_handler.cc b/src/message_handler.cc index efa250e4..eb69fb67 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -187,7 +187,7 @@ void EmitSemanticHighlighting(QueryDatabase* db, Out_CqueryPublishSemanticHighlighting::Symbol symbol; symbol.stableId = semantic_cache_for_file->GetStableId(sym.idx.kind, detailed_name); - symbol.kind = static_cast(kind); + symbol.kind = kind; symbol.type = map_symbol_kind_to_symbol_type(sym.idx.kind); symbol.isTypeMember = is_type_member; symbol.ranges.push_back(*loc);