mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 23:55:08 +00:00
Role : uint8_t -> uint16_t; Add Read,Write to Role (#if CINDEX_VERSION >= 48)
Fix textDocument/documentSymbol
This commit is contained in:
parent
8a939389d8
commit
de1e350c59
@ -66,24 +66,25 @@ enum class StorageClass : uint8_t {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_TYPE_PROXY(StorageClass);
|
MAKE_REFLECT_TYPE_PROXY(StorageClass);
|
||||||
|
|
||||||
enum class Role : uint8_t {
|
enum class Role : uint16_t {
|
||||||
None = 0,
|
None = 0,
|
||||||
Declaration = 1 << 0,
|
Declaration = 1 << 0,
|
||||||
Definition = 1 << 1,
|
Definition = 1 << 1,
|
||||||
Reference = 1 << 2,
|
Reference = 1 << 2,
|
||||||
Implicit = 1 << 3,
|
Read = 1 << 3,
|
||||||
|
Write = 1 << 4,
|
||||||
ChildOf = 1 << 4,
|
Call = 1 << 5,
|
||||||
BaseOf = 1 << 5,
|
Dynamic = 1 << 6,
|
||||||
Call = 1 << 6,
|
Address = 1 << 7,
|
||||||
|
Implicit = 1 << 8,
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_TYPE_PROXY(Role);
|
MAKE_REFLECT_TYPE_PROXY(Role);
|
||||||
MAKE_ENUM_HASHABLE(Role);
|
MAKE_ENUM_HASHABLE(Role);
|
||||||
|
|
||||||
inline uint8_t operator&(Role lhs, Role rhs) {
|
inline uint16_t operator&(Role lhs, Role rhs) {
|
||||||
return uint8_t(lhs) & uint8_t(rhs);
|
return uint16_t(lhs) & uint16_t(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Role operator|(Role lhs, Role rhs) {
|
inline Role operator|(Role lhs, Role rhs) {
|
||||||
return Role(uint8_t(lhs) | uint8_t(rhs));
|
return Role(uint16_t(lhs) | uint16_t(rhs));
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
#if CINDEX_VERSION >= 47
|
#if CINDEX_VERSION >= 47
|
||||||
#define CINDEX_HAVE_PRETTY 1
|
#define CINDEX_HAVE_PRETTY 1
|
||||||
#endif
|
#endif
|
||||||
|
#if CINDEX_VERSION >= 48
|
||||||
|
#define CINDEX_HAVE_ROLE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -53,6 +56,14 @@ bool IsScopeSemanticContainer(CXCursorKind kind) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Role GetRole(const CXIdxEntityRefInfo* ref_info, Role role) {
|
||||||
|
#if CINDEX_HAVE_ROLE
|
||||||
|
return static_cast<Role>(static_cast<int>(ref_info->role));
|
||||||
|
#else
|
||||||
|
return role;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
SymbolKind GetSymbolKind(CXCursorKind kind) {
|
SymbolKind GetSymbolKind(CXCursorKind kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
default:
|
default:
|
||||||
@ -1999,7 +2010,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
|||||||
var->def.kind = ClangSymbolKind::Parameter;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2056,7 +2067,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
|||||||
|
|
||||||
OnIndexReference_Function(
|
OnIndexReference_Function(
|
||||||
db, loc, ref->container->cursor, called_id,
|
db, loc, ref->container->cursor, called_id,
|
||||||
Role::Call |
|
GetRole(ref, Role::Call) |
|
||||||
(is_implicit ? Role::Implicit : Role::None));
|
(is_implicit ? Role::Implicit : Role::None));
|
||||||
|
|
||||||
// Checks if |str| starts with |start|. Ignores case.
|
// Checks if |str| starts with |start|. Ignores case.
|
||||||
|
@ -30,8 +30,10 @@ struct TextDocumentDocumentSymbolHandler
|
|||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
|
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
|
QueryFileId file_id;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
request->params.textDocument.uri.GetPath(), &file)) {
|
request->params.textDocument.uri.GetPath(), &file,
|
||||||
|
&file_id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +43,10 @@ struct TextDocumentDocumentSymbolHandler
|
|||||||
if (!info)
|
if (!info)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
optional<lsLocation> location = GetLsLocation(db, working_files, sym);
|
// FIXME
|
||||||
|
Use use(sym);
|
||||||
|
use.file = file_id;
|
||||||
|
optional<lsLocation> location = GetLsLocation(db, working_files, use);
|
||||||
if (!location)
|
if (!location)
|
||||||
continue;
|
continue;
|
||||||
info->location = *location;
|
info->location = *location;
|
||||||
|
@ -25,12 +25,21 @@ void Reflect(Writer& visitor, uint8_t& value) {
|
|||||||
visitor.Int(value);
|
visitor.Int(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reflect(Reader& visitor, int16_t& value) {
|
void Reflect(Reader& visitor, short& value) {
|
||||||
if (!visitor.IsInt())
|
if (!visitor.IsInt())
|
||||||
throw std::invalid_argument("int16_t");
|
throw std::invalid_argument("short");
|
||||||
value = (int16_t)visitor.GetInt();
|
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);
|
visitor.Int(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,8 +128,11 @@ struct IndexFile;
|
|||||||
void Reflect(Reader& visitor, uint8_t& value);
|
void Reflect(Reader& visitor, uint8_t& value);
|
||||||
void Reflect(Writer& visitor, uint8_t& value);
|
void Reflect(Writer& visitor, uint8_t& value);
|
||||||
|
|
||||||
void Reflect(Reader& visitor, int16_t& value);
|
void Reflect(Reader& visitor, short& value);
|
||||||
void Reflect(Writer& visitor, int16_t& 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(Reader& visitor, int& value);
|
||||||
void Reflect(Writer& visitor, int& value);
|
void Reflect(Writer& visitor, int& value);
|
||||||
|
Loading…
Reference in New Issue
Block a user