Don't highlight operators as functions (#104)

* Don't highlight operators as functions

* address comments
This commit is contained in:
topisani 2017-12-01 17:08:19 +01:00 committed by GitHub
parent 63d2b5fa10
commit c4ada3e9df
5 changed files with 11 additions and 0 deletions

View File

@ -171,6 +171,8 @@ void EmitSemanticHighlighting(QueryDatabase* db,
QueryFunc* func = &db->funcs[sym.idx.idx];
if (!func->def)
continue; // applies to for loop
if (func->def->is_operator)
continue; // applies to for loop
is_type_member = func->def->declaring_type.has_value();
break;
}

View File

@ -1188,6 +1188,9 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
if (!is_template_specialization) {
func->def.short_name = decl->entityInfo->name;
// Set the |is_operator| flag to true if the function name starts with "operator"
func->def.is_operator = func->def.short_name.compare(0, 8, "operator") == 0;
// Build detailed name. The type desc looks like void (void *). We
// insert the qualified name before the first '('.
std::string qualified_name =

View File

@ -267,6 +267,9 @@ struct FuncDefDefinitionData {
// Functions that this function calls.
std::vector<FuncRef> callees;
// Used for semantic highlighting
bool is_operator = false;
FuncDefDefinitionData() {} // For reflection.
FuncDefDefinitionData(const std::string& usr) : usr(usr) {
// assert(usr.size() > 0);
@ -308,6 +311,7 @@ void Reflect(
REFLECT_MEMBER(base);
REFLECT_MEMBER(locals);
REFLECT_MEMBER(callees);
REFLECT_MEMBER(is_operator);
REFLECT_MEMBER_END();
}

View File

@ -50,6 +50,7 @@ optional<QueryFunc::DefUpdate> ToQuery(const IdMap& id_map,
result.base = id_map.ToQuery(func.base);
result.locals = id_map.ToQuery(func.locals);
result.callees = id_map.ToQuery(func.callees);
result.is_operator = func.is_operator;
return result;
}

View File

@ -118,6 +118,7 @@ template <typename TVisitor>
void Reflect(TVisitor& visitor, IndexFunc& value) {
REFLECT_MEMBER_START();
REFLECT_MEMBER2("id", value.id);
REFLECT_MEMBER2("is_operator", value.def.is_operator);
REFLECT_MEMBER2("usr", value.def.usr);
REFLECT_MEMBER2("short_name", value.def.short_name);
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);