mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 15:45:08 +00:00
Strip scope qualifiers of detailed_name in $cquery/memberHierarchy{Initial,Expand}
This commit is contained in:
parent
bfcab88090
commit
dc18f04759
@ -516,7 +516,7 @@ void SetTypeName(IndexType* type,
|
|||||||
// type->def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor);
|
// type->def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor);
|
||||||
type->def.detailed_name =
|
type->def.detailed_name =
|
||||||
param->ns.QualifiedName(container ? container : &parent, name);
|
param->ns.QualifiedName(container ? container : &parent, name);
|
||||||
auto idx = type->def.detailed_name.find(name);
|
auto idx = type->def.detailed_name.rfind(name);
|
||||||
assert(idx != std::string::npos);
|
assert(idx != std::string::npos);
|
||||||
type->def.short_name_offset = idx;
|
type->def.short_name_offset = idx;
|
||||||
type->def.short_name_size = strlen(name);
|
type->def.short_name_size = strlen(name);
|
||||||
@ -631,7 +631,8 @@ void SetVarDetail(IndexVar* var,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// FIXME QualifiedName should return index
|
// FIXME QualifiedName should return index
|
||||||
auto idx = def.detailed_name.find(short_name.begin(), 0, short_name.size());
|
auto idx = def.detailed_name.rfind(short_name.begin(), std::string::npos,
|
||||||
|
short_name.size());
|
||||||
assert(idx != std::string::npos);
|
assert(idx != std::string::npos);
|
||||||
def.short_name_offset = idx;
|
def.short_name_offset = idx;
|
||||||
def.short_name_size = short_name.size();
|
def.short_name_size = short_name.size();
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <optional.h>
|
#include <optional.h>
|
||||||
#include <string_view.h>
|
#include <string_view.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -375,6 +376,15 @@ struct VarDefDefinitionData {
|
|||||||
return std::string_view(detailed_name.c_str() + short_name_offset,
|
return std::string_view(detailed_name.c_str() + short_name_offset,
|
||||||
short_name_size);
|
short_name_size);
|
||||||
}
|
}
|
||||||
|
std::string DetailedName(bool qualified) const {
|
||||||
|
if (qualified)
|
||||||
|
return detailed_name;
|
||||||
|
int i = short_name_offset;
|
||||||
|
while (i && (isalnum(detailed_name[i - 1]) || detailed_name[i - 1] == '_' ||
|
||||||
|
detailed_name[i - 1] == ':'))
|
||||||
|
i--;
|
||||||
|
return detailed_name.substr(0, i) + detailed_name.substr(short_name_offset);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename TVisitor, typename Family>
|
template <typename TVisitor, typename Family>
|
||||||
|
@ -42,7 +42,7 @@ struct Out_CqueryMemberHierarchy
|
|||||||
struct Entry {
|
struct Entry {
|
||||||
QueryTypeId id;
|
QueryTypeId id;
|
||||||
std::string_view name;
|
std::string_view name;
|
||||||
std::string_view fieldName;
|
std::string fieldName;
|
||||||
lsLocation location;
|
lsLocation location;
|
||||||
// For unexpanded nodes, this is an upper bound because some entities may be
|
// For unexpanded nodes, this is an upper bound because some entities may be
|
||||||
// undefined. If it is 0, there are no members.
|
// undefined. If it is 0, there are no members.
|
||||||
@ -116,9 +116,9 @@ void Expand(MessageHandler* m,
|
|||||||
Out_CqueryMemberHierarchy::Entry entry1;
|
Out_CqueryMemberHierarchy::Entry entry1;
|
||||||
entry1.id = def1->type ? *def1->type : QueryTypeId();
|
entry1.id = def1->type ? *def1->type : QueryTypeId();
|
||||||
if (detailed_name)
|
if (detailed_name)
|
||||||
entry1.fieldName = def1->detailed_name;
|
entry1.fieldName = def1->DetailedName(false);
|
||||||
else
|
else
|
||||||
entry1.fieldName = def1->ShortName();
|
entry1.fieldName = std::string(def1->ShortName());
|
||||||
Expand(m, &entry1, detailed_name, levels - 1);
|
Expand(m, &entry1, detailed_name, levels - 1);
|
||||||
entry->children.push_back(std::move(entry1));
|
entry->children.push_back(std::move(entry1));
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user