diff --git a/src/clang_symbol_kind.h b/src/clang_symbol_kind.h index 37f875c8..3138f615 100644 --- a/src/clang_symbol_kind.h +++ b/src/clang_symbol_kind.h @@ -66,24 +66,25 @@ enum class StorageClass : uint8_t { }; MAKE_REFLECT_TYPE_PROXY(StorageClass); -enum class Role : uint8_t { +enum class Role : uint16_t { None = 0, Declaration = 1 << 0, Definition = 1 << 1, Reference = 1 << 2, - Implicit = 1 << 3, - - ChildOf = 1 << 4, - BaseOf = 1 << 5, - Call = 1 << 6, + Read = 1 << 3, + Write = 1 << 4, + Call = 1 << 5, + Dynamic = 1 << 6, + Address = 1 << 7, + Implicit = 1 << 8, }; MAKE_REFLECT_TYPE_PROXY(Role); MAKE_ENUM_HASHABLE(Role); -inline uint8_t operator&(Role lhs, Role rhs) { - return uint8_t(lhs) & uint8_t(rhs); +inline uint16_t operator&(Role lhs, Role rhs) { + return uint16_t(lhs) & uint16_t(rhs); } inline Role operator|(Role lhs, Role rhs) { - return Role(uint8_t(lhs) | uint8_t(rhs)); + return Role(uint16_t(lhs) | uint16_t(rhs)); } diff --git a/src/indexer.cc b/src/indexer.cc index 020bb500..ca0141b4 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -21,6 +21,9 @@ #if CINDEX_VERSION >= 47 #define CINDEX_HAVE_PRETTY 1 #endif +#if CINDEX_VERSION >= 48 +#define CINDEX_HAVE_ROLE 1 +#endif namespace { @@ -53,6 +56,14 @@ bool IsScopeSemanticContainer(CXCursorKind kind) { } } +Role GetRole(const CXIdxEntityRefInfo* ref_info, Role role) { +#if CINDEX_HAVE_ROLE + return static_cast(static_cast(ref_info->role)); +#else + return role; +#endif +} + SymbolKind GetSymbolKind(CXCursorKind kind) { switch (kind) { default: @@ -1999,7 +2010,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { var->def.kind = ClangSymbolKind::Parameter; } } - UniqueAddUse(db, var->uses, loc, fromContainer(ref->container), Role::Reference); + UniqueAddUse(db, var->uses, loc, fromContainer(ref->container), GetRole(ref, Role::Reference)); break; } @@ -2056,7 +2067,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { OnIndexReference_Function( db, loc, ref->container->cursor, called_id, - Role::Call | + GetRole(ref, Role::Call) | (is_implicit ? Role::Implicit : Role::None)); // Checks if |str| starts with |start|. Ignores case. diff --git a/src/messages/text_document_document_symbol.cc b/src/messages/text_document_document_symbol.cc index 29e7a795..c8132b52 100644 --- a/src/messages/text_document_document_symbol.cc +++ b/src/messages/text_document_document_symbol.cc @@ -30,8 +30,10 @@ struct TextDocumentDocumentSymbolHandler out.id = request->id; QueryFile* file; + QueryFileId file_id; if (!FindFileOrFail(db, project, request->id, - request->params.textDocument.uri.GetPath(), &file)) { + request->params.textDocument.uri.GetPath(), &file, + &file_id)) { return; } @@ -41,7 +43,10 @@ struct TextDocumentDocumentSymbolHandler if (!info) continue; - optional location = GetLsLocation(db, working_files, sym); + // FIXME + Use use(sym); + use.file = file_id; + optional location = GetLsLocation(db, working_files, use); if (!location) continue; info->location = *location; diff --git a/src/serializer.cc b/src/serializer.cc index 953c2601..29f9324c 100644 --- a/src/serializer.cc +++ b/src/serializer.cc @@ -25,12 +25,21 @@ void Reflect(Writer& visitor, uint8_t& value) { visitor.Int(value); } -void Reflect(Reader& visitor, int16_t& value) { +void Reflect(Reader& visitor, short& value) { if (!visitor.IsInt()) - throw std::invalid_argument("int16_t"); - value = (int16_t)visitor.GetInt(); + throw std::invalid_argument("short"); + value = (short)visitor.GetInt(); } -void Reflect(Writer& visitor, int16_t& value) { +void Reflect(Writer& visitor, short& value) { + visitor.Int(value); +} + +void Reflect(Reader& visitor, unsigned short& value) { + if (!visitor.IsInt()) + throw std::invalid_argument("unsigned short"); + value = (unsigned short)visitor.GetInt(); +} +void Reflect(Writer& visitor, unsigned short& value) { visitor.Int(value); } diff --git a/src/serializer.h b/src/serializer.h index 89c3626d..bf967065 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -128,8 +128,11 @@ struct IndexFile; void Reflect(Reader& visitor, uint8_t& value); void Reflect(Writer& visitor, uint8_t& value); -void Reflect(Reader& visitor, int16_t& value); -void Reflect(Writer& visitor, int16_t& value); +void Reflect(Reader& visitor, short& value); +void Reflect(Writer& visitor, short& value); + +void Reflect(Reader& visitor, unsigned short& value); +void Reflect(Writer& visitor, unsigned short& value); void Reflect(Reader& visitor, int& value); void Reflect(Writer& visitor, int& value);