mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-31 18:00:26 +00:00
Fix goto def when implicit functions are called.
Don't import the implicit functions into the 'all symbols' structure. This fixes symbol lookup.
This commit is contained in:
parent
2e4c5474da
commit
ee90938b28
@ -87,13 +87,15 @@ struct IndexFuncRef {
|
|||||||
IndexFuncRef(Range loc, bool is_implicit) : id(IndexFuncId((size_t)-1)), loc(loc), is_implicit(is_implicit) {}
|
IndexFuncRef(Range loc, bool is_implicit) : id(IndexFuncId((size_t)-1)), loc(loc), is_implicit(is_implicit) {}
|
||||||
|
|
||||||
inline bool operator==(const IndexFuncRef& other) {
|
inline bool operator==(const IndexFuncRef& other) {
|
||||||
return id == other.id && loc == other.loc;
|
return id == other.id && loc == other.loc && is_implicit == other.is_implicit;
|
||||||
}
|
}
|
||||||
inline bool operator!=(const IndexFuncRef& other) { return !(*this == other); }
|
inline bool operator!=(const IndexFuncRef& other) { return !(*this == other); }
|
||||||
inline bool operator<(const IndexFuncRef& other) const {
|
inline bool operator<(const IndexFuncRef& other) const {
|
||||||
if (id < other.id)
|
if (id < other.id)
|
||||||
return true;
|
return true;
|
||||||
return id == other.id && loc < other.loc;
|
if (id == other.id && loc < other.loc)
|
||||||
|
return true;
|
||||||
|
return id == other.id && loc == other.loc && is_implicit < other.is_implicit;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -205,8 +205,10 @@ QueryFile::Def BuildFileDef(const IdMap& id_map, const IndexFile& indexed) {
|
|||||||
add_all_symbols(id_map.ToSymbol(func.id), decl);
|
add_all_symbols(id_map.ToSymbol(func.id), decl);
|
||||||
add_outline(id_map.ToSymbol(func.id), decl);
|
add_outline(id_map.ToSymbol(func.id), decl);
|
||||||
}
|
}
|
||||||
for (const IndexFuncRef& caller : func.callers)
|
for (const IndexFuncRef& caller : func.callers) {
|
||||||
|
if (caller.is_implicit) continue;
|
||||||
add_all_symbols(id_map.ToSymbol(func.id), caller.loc);
|
add_all_symbols(id_map.ToSymbol(func.id), caller.loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (const IndexVar& var : indexed.vars) {
|
for (const IndexVar& var : indexed.vars) {
|
||||||
if (var.def.definition_spelling.has_value())
|
if (var.def.definition_spelling.has_value())
|
||||||
@ -339,7 +341,7 @@ QueryVarId IdMap::ToQuery(IndexVarId id) const {
|
|||||||
return QueryVarId(cached_var_ids_.find(id)->second);
|
return QueryVarId(cached_var_ids_.find(id)->second);
|
||||||
}
|
}
|
||||||
QueryFuncRef IdMap::ToQuery(IndexFuncRef ref) const {
|
QueryFuncRef IdMap::ToQuery(IndexFuncRef ref) const {
|
||||||
return QueryFuncRef(ToQuery(ref.id), ToQuery(ref.loc));
|
return QueryFuncRef(ToQuery(ref.id), ToQuery(ref.loc), ref.is_implicit);
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<QueryLocation> IdMap::ToQuery(optional<Range> range) const {
|
optional<QueryLocation> IdMap::ToQuery(optional<Range> range) const {
|
||||||
|
23
src/query.h
23
src/query.h
@ -100,31 +100,26 @@ struct SymbolRef {
|
|||||||
MAKE_REFLECT_STRUCT(SymbolRef, idx, loc);
|
MAKE_REFLECT_STRUCT(SymbolRef, idx, loc);
|
||||||
|
|
||||||
struct QueryFuncRef {
|
struct QueryFuncRef {
|
||||||
QueryFuncId id() const {
|
QueryFuncId id;
|
||||||
assert(has_id());
|
|
||||||
return id_;
|
|
||||||
}
|
|
||||||
bool has_id() const {
|
|
||||||
return id_.id != -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryFuncId id_;
|
|
||||||
QueryLocation loc;
|
QueryLocation loc;
|
||||||
|
bool is_implicit = false;
|
||||||
|
|
||||||
QueryFuncRef() {} // Do not use, needed for reflect.
|
QueryFuncRef() {} // Do not use, needed for reflect.
|
||||||
QueryFuncRef(QueryFuncId id, QueryLocation loc) : id_(id), loc(loc) {}
|
QueryFuncRef(QueryFuncId id, QueryLocation loc, bool is_implicit) : id(id), loc(loc), is_implicit(is_implicit) {}
|
||||||
|
|
||||||
bool operator==(const QueryFuncRef& that) const {
|
bool operator==(const QueryFuncRef& that) const {
|
||||||
return id_ == that.id_ && loc == that.loc;
|
return id == that.id && loc == that.loc && is_implicit == that.is_implicit;
|
||||||
}
|
}
|
||||||
bool operator!=(const QueryFuncRef& that) const { return !(*this == that); }
|
bool operator!=(const QueryFuncRef& that) const { return !(*this == that); }
|
||||||
bool operator<(const QueryFuncRef& that) const {
|
bool operator<(const QueryFuncRef& that) const {
|
||||||
if (id_ < that.id_)
|
if (id < that.id)
|
||||||
return true;
|
return true;
|
||||||
return id_ == that.id_ && loc.range.start < that.loc.range.start;
|
if (id == that.id && loc.range.start < that.loc.range.start)
|
||||||
|
return true;
|
||||||
|
return id == that.id && loc.range.start == that.loc.range.start && is_implicit < that.is_implicit;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(QueryFuncRef, id_, loc);
|
MAKE_REFLECT_STRUCT(QueryFuncRef, id, loc, is_implicit);
|
||||||
|
|
||||||
// There are two sources of reindex updates: the (single) definition of a
|
// There are two sources of reindex updates: the (single) definition of a
|
||||||
// symbol has changed, or one of many users of the symbol has changed.
|
// symbol has changed, or one of many users of the symbol has changed.
|
||||||
|
Loading…
Reference in New Issue
Block a user