mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-16 13:48:04 +00:00
Add IndexLocation and add role to QueryLocation
IndexFuncRef should be deprecated in favor of IndexLocation
This commit is contained in:
parent
9b0256355e
commit
10c2843846
@ -67,6 +67,7 @@ enum class StorageClass : uint8_t {
|
||||
MAKE_REFLECT_TYPE_PROXY(StorageClass);
|
||||
|
||||
enum class SymbolRole : uint8_t {
|
||||
None = 0,
|
||||
Declaration = 1 << 0,
|
||||
Definition = 1 << 1,
|
||||
Reference = 1 << 2,
|
||||
|
@ -76,16 +76,25 @@ using IndexVarId = Id<IndexVar>;
|
||||
|
||||
struct IdCache;
|
||||
|
||||
struct IndexLocation {
|
||||
Range loc;
|
||||
Id<void> parent_id;
|
||||
SymbolKind parent_kind = SymbolKind::Invalid;
|
||||
SymbolRole role = SymbolRole::None;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(IndexLocation, loc, parent_id, parent_kind, role);
|
||||
|
||||
struct IndexFuncRef {
|
||||
// NOTE: id can be -1 if the function call is not coming from a function.
|
||||
IndexFuncId id;
|
||||
Range loc;
|
||||
IndexFuncId id;
|
||||
SymbolRole role = SymbolRole::None;
|
||||
bool is_implicit = false;
|
||||
|
||||
IndexFuncRef() {} // For serialization.
|
||||
|
||||
IndexFuncRef(IndexFuncId id, Range loc, bool is_implicit)
|
||||
: id(id), loc(loc), is_implicit(is_implicit) {}
|
||||
: loc(loc), id(id), is_implicit(is_implicit) {}
|
||||
IndexFuncRef(Range loc, bool is_implicit)
|
||||
: loc(loc), is_implicit(is_implicit) {}
|
||||
|
||||
|
@ -208,7 +208,7 @@ QueryFile::DefUpdate BuildFileDefUpdate(const IdMap& id_map, const IndexFile& in
|
||||
def.dependencies = indexed.dependencies;
|
||||
|
||||
// Convert enum to markdown compatible strings
|
||||
def.language = [indexed]() {
|
||||
def.language = [&indexed]() {
|
||||
switch (indexed.language) {
|
||||
case LanguageId::C:
|
||||
return "c";
|
||||
|
@ -48,11 +48,12 @@ void Reflect(TVisitor& visitor, WithGen<T>& value) {
|
||||
}
|
||||
|
||||
struct QueryLocation {
|
||||
QueryFileId path;
|
||||
Range range;
|
||||
QueryFileId path;
|
||||
SymbolRole role = SymbolRole::None;
|
||||
|
||||
QueryLocation() {} // Do not use, needed for reflect.
|
||||
QueryLocation(QueryFileId path, Range range) : path(path), range(range) {}
|
||||
QueryLocation(QueryFileId path, Range range) : range(range), path(path) {}
|
||||
|
||||
QueryLocation OffsetStartColumn(int16_t offset) const {
|
||||
QueryLocation result = *this;
|
||||
@ -72,8 +73,8 @@ struct QueryLocation {
|
||||
return range < o.range;
|
||||
}
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(QueryLocation, path, range);
|
||||
MAKE_HASHABLE(QueryLocation, t.path, t.range);
|
||||
MAKE_REFLECT_STRUCT(QueryLocation, range, path, role);
|
||||
MAKE_HASHABLE(QueryLocation, t.range, t.path);
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
|
Loading…
Reference in New Issue
Block a user