Make implicit calls spanning one more column to the left/right

This is hacky but useful. e.g. textDocument/definition on the space/semicolon in `A a;` or `return 42;` will take you to the constructor.
This commit is contained in:
Fangrui Song 2018-01-02 16:30:03 -08:00
parent c157445ef3
commit 3e1a068c19

View File

@ -230,9 +230,17 @@ 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;
add_all_symbols(id_map.ToSymbol(func.id), caller.loc);
// Make ranges of implicit function calls larger (spanning one more column
// to the left/right). This is hacky but useful. e.g.
// textDocument/definition on the space/semicolon in `A a;` or `return 42;`
// will take you to the constructor.
Range range = caller.loc;
if (caller.is_implicit) {
if (range.start.column > 1)
range.start.column--;
range.end.column++;
}
add_all_symbols(id_map.ToSymbol(func.id), range);
}
}
for (const IndexVar& var : indexed.vars) {