Be less aggressive about indexing potential lambdas

This commit is contained in:
Jacob Dufault 2017-12-12 09:49:52 -08:00
parent 48a7ec73eb
commit 1467526bad

View File

@ -1394,24 +1394,31 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
IndexVarId var_id = db->ToVarId(referenced.get_usr()); IndexVarId var_id = db->ToVarId(referenced.get_usr());
IndexVar* var = db->Resolve(var_id); IndexVar* var = db->Resolve(var_id);
// Lambda paramaters are not processed by OnIndexDeclaration and // Lambda paramaters are not processed by OnIndexDeclaration and
// may not have a short_name yet. // may not have a short_name yet. Note that we only process the lambda
// parameter as a definition if it is in the same file as the reference,
// as lambdas cannot be split across files.
if (var->def.short_name.empty()) { if (var->def.short_name.empty()) {
// TODO Some of the logic here duplicates CXIdxEntity_Variable branch of CXFile referenced_file;
// OnIndexDeclaration. Range spelling = ResolveSpelling(referenced.cx_cursor, &referenced_file);
// But there `decl` is of type CXIdxDeclInfo and has more information, if (file == referenced_file) {
// thus not easy to reuse the code. var->def.definition_spelling = spelling;
var->def.short_name = referenced.get_spelling(); var->def.definition_extent = ResolveExtent(referenced.cx_cursor);
std::string type_name = ToString(
clang_getTypeSpelling(clang_getCursorType(referenced.cx_cursor))); // TODO Some of the logic here duplicates CXIdxEntity_Variable branch of
var->def.detailed_name = type_name + " " + var->def.short_name; // OnIndexDeclaration.
var->def.is_local = false; // But there `decl` is of type CXIdxDeclInfo and has more information,
var->def.definition_spelling = ResolveSpelling(referenced.cx_cursor); // thus not easy to reuse the code.
var->def.definition_extent = ResolveSpelling(referenced.cx_cursor); var->def.short_name = referenced.get_spelling();
UniqueAdd(var->uses, ResolveSpelling(referenced.cx_cursor)); std::string type_name = ToString(
AddDeclInitializerUsages(db, referenced.cx_cursor); clang_getTypeSpelling(clang_getCursorType(referenced.cx_cursor)));
// TODO Use proper semantic_container and lexical_container. var->def.detailed_name = type_name + " " + var->def.short_name;
AddDeclTypeUsages(db, referenced.cx_cursor, nullptr, nullptr); var->def.is_local = false;
// TODO Other logic in OnIndexDeclaration may need to be adapted. UniqueAdd(var->uses, ResolveSpelling(referenced.cx_cursor));
AddDeclInitializerUsages(db, referenced.cx_cursor);
// TODO Use proper semantic_container and lexical_container.
AddDeclTypeUsages(db, referenced.cx_cursor, nullptr, nullptr);
// TODO Other logic in OnIndexDeclaration may need to be adapted.
}
} }
UniqueAdd(var->uses, loc_spelling); UniqueAdd(var->uses, loc_spelling);
break; break;