mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-20 23:49:28 +00:00
Use cursor extents for is_implicit
function calls
cursor extents have larger ranges and less specific, thus making them overridable by more specific (with smaller range) symbols. Thus we do not need to hide them in query.cc:BuildFileDef For example, the left paren in `A a(3)` jumps to the constructor. the left paren in `A a = f()` jumps to the copy/move constructor.
This commit is contained in:
parent
95126bff61
commit
77e9ea1b77
@ -355,7 +355,7 @@ bool IsFunctionCallContext(CXCursorKind kind) {
|
||||
}
|
||||
|
||||
void OnIndexReference_Function(IndexFile* db,
|
||||
Range loc_spelling,
|
||||
Range loc,
|
||||
ClangCursor caller_cursor,
|
||||
IndexFuncId called_id,
|
||||
IndexFunc* called,
|
||||
@ -367,11 +367,11 @@ void OnIndexReference_Function(IndexFile* db,
|
||||
called = db->Resolve(called_id);
|
||||
|
||||
AddFuncRef(&caller->def.callees,
|
||||
IndexFuncRef(called->id, loc_spelling, is_implicit));
|
||||
IndexFuncRef(called->id, loc, is_implicit));
|
||||
AddFuncRef(&called->callers,
|
||||
IndexFuncRef(caller->id, loc_spelling, is_implicit));
|
||||
IndexFuncRef(caller->id, loc, is_implicit));
|
||||
} else {
|
||||
AddFuncRef(&called->callers, IndexFuncRef(loc_spelling, is_implicit));
|
||||
AddFuncRef(&called->callers, IndexFuncRef(loc, is_implicit));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1640,7 +1640,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
||||
// }
|
||||
|
||||
// TODO: search full history?
|
||||
Range loc_spelling = ResolveSpelling(ref->cursor);
|
||||
Range loc = ResolveSpelling(ref->cursor);
|
||||
|
||||
IndexFuncId called_id = db->ToFuncId(ref->referencedEntity->USR);
|
||||
IndexFunc* called = db->Resolve(called_id);
|
||||
@ -1661,7 +1661,12 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
||||
!CursorSpellingContainsString(ref->cursor, param->tu->cx_tu,
|
||||
called->def.short_name)));
|
||||
|
||||
OnIndexReference_Function(db, loc_spelling, ref->container->cursor,
|
||||
// Extents have larger ranges and thus less specific, and will be overriden
|
||||
// by other functions if exist.
|
||||
if (is_implicit)
|
||||
loc = ResolveExtent(ref->cursor);
|
||||
|
||||
OnIndexReference_Function(db, loc, ref->container->cursor,
|
||||
called_id, called, is_implicit);
|
||||
|
||||
// Checks if |str| starts with |start|. Ignores case.
|
||||
@ -1703,7 +1708,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
||||
if (ctor_usr) {
|
||||
IndexFunc* ctor = db->Resolve(db->ToFuncId(*ctor_usr));
|
||||
AddFuncRef(&ctor->callers,
|
||||
IndexFuncRef(loc_spelling, true /*is_implicit*/));
|
||||
IndexFuncRef(loc, true /*is_implicit*/));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,8 +221,8 @@ QueryFile::Def BuildFileDef(const IdMap& id_map, const IndexFile& indexed) {
|
||||
add_outline(id_map.ToSymbol(func.id), decl.spelling);
|
||||
}
|
||||
for (const IndexFuncRef& caller : func.callers) {
|
||||
if (caller.is_implicit)
|
||||
continue;
|
||||
// if (caller.is_implicit)
|
||||
// continue;
|
||||
add_all_symbols(id_map.ToSymbol(func.id), caller.loc);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user