mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-19 15:10:47 +00:00
Use string_view for lsSymbolInformation
This commit is contained in:
parent
6d6c1639d0
commit
e259bb91d3
@ -1821,19 +1821,19 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
//
|
//
|
||||||
// To attribute the use of `x` in `e.x`, we use cursor extent `e.x`
|
// To attribute the use of `x` in `e.x`, we use cursor extent `e.x`
|
||||||
// minus cursor spelling `e` minus the period.
|
// minus cursor spelling `e` minus the period.
|
||||||
void CheckTypeDependentMemberRefExpr(Range& spell,
|
void CheckTypeDependentMemberRefExpr(Range* spell,
|
||||||
const ClangCursor& cursor,
|
const ClangCursor& cursor,
|
||||||
IndexParam* param,
|
IndexParam* param,
|
||||||
const IndexFile* db) {
|
const IndexFile* db) {
|
||||||
if (cursor.get_kind() == CXCursor_MemberRefExpr &&
|
if (cursor.get_kind() == CXCursor_MemberRefExpr &&
|
||||||
cursor.get_spelling().empty()) {
|
cursor.get_spelling().empty()) {
|
||||||
spell = cursor.get_extent().RemovePrefix(spell.end);
|
*spell = cursor.get_extent().RemovePrefix(spell->end);
|
||||||
const FileContents& fc = param->file_contents[db->path];
|
const FileContents& fc = param->file_contents[db->path];
|
||||||
optional<int> maybe_period = fc.ToOffset(spell.start);
|
optional<int> maybe_period = fc.ToOffset(spell->start);
|
||||||
if (maybe_period) {
|
if (maybe_period) {
|
||||||
int i = *maybe_period;
|
int i = *maybe_period;
|
||||||
if (fc.content[i] == '.')
|
if (fc.content[i] == '.')
|
||||||
spell.start.column++;
|
spell->start.column++;
|
||||||
// -> is likely unexposed.
|
// -> is likely unexposed.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1868,7 +1868,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
|||||||
case CXIdxEntity_Field: {
|
case CXIdxEntity_Field: {
|
||||||
ClangCursor ref_cursor(ref->cursor);
|
ClangCursor ref_cursor(ref->cursor);
|
||||||
Range loc = ref_cursor.get_spelling_range();
|
Range loc = ref_cursor.get_spelling_range();
|
||||||
CheckTypeDependentMemberRefExpr(loc, ref_cursor, param, db);
|
CheckTypeDependentMemberRefExpr(&loc, ref_cursor, param, db);
|
||||||
|
|
||||||
ClangCursor referenced = ref->referencedEntity->cursor;
|
ClangCursor referenced = ref->referencedEntity->cursor;
|
||||||
referenced = referenced.template_specialization_to_template_definition();
|
referenced = referenced.template_specialization_to_template_definition();
|
||||||
@ -1942,12 +1942,12 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
|||||||
// Extents have larger ranges and thus less specific, and will be
|
// Extents have larger ranges and thus less specific, and will be
|
||||||
// overriden by other functions if exist.
|
// overriden by other functions if exist.
|
||||||
//
|
//
|
||||||
// Type-dependent member ref expressions do not have useful spelling
|
// Type-dependent member access expressions do not have useful spelling
|
||||||
// ranges. See the comment above for the CXIdxEntity_Field case.
|
// ranges. See the comment above for the CXIdxEntity_Field case.
|
||||||
if (is_implicit)
|
if (is_implicit)
|
||||||
loc = ref_cursor.get_extent();
|
loc = ref_cursor.get_extent();
|
||||||
else
|
else
|
||||||
CheckTypeDependentMemberRefExpr(loc, ref_cursor, param, db);
|
CheckTypeDependentMemberRefExpr(&loc, ref_cursor, param, db);
|
||||||
|
|
||||||
OnIndexReference_Function(db, loc, ref->container->cursor, called_id,
|
OnIndexReference_Function(db, loc, ref->container->cursor, called_id,
|
||||||
called, is_implicit);
|
called, is_implicit);
|
||||||
|
@ -202,10 +202,10 @@ enum class lsSymbolKind : int {
|
|||||||
MAKE_REFLECT_TYPE_PROXY(lsSymbolKind);
|
MAKE_REFLECT_TYPE_PROXY(lsSymbolKind);
|
||||||
|
|
||||||
struct lsSymbolInformation {
|
struct lsSymbolInformation {
|
||||||
std::string name;
|
std::string_view name;
|
||||||
lsSymbolKind kind;
|
lsSymbolKind kind;
|
||||||
lsLocation location;
|
lsLocation location;
|
||||||
std::string containerName;
|
std::string_view containerName;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsSymbolInformation, name, kind, location, containerName);
|
MAKE_REFLECT_STRUCT(lsSymbolInformation, name, kind, location, containerName);
|
||||||
|
|
||||||
|
@ -439,8 +439,10 @@ optional<lsSymbolInformation> GetSymbolInfo(QueryDatabase* db,
|
|||||||
return nullopt;
|
return nullopt;
|
||||||
|
|
||||||
lsSymbolInformation info;
|
lsSymbolInformation info;
|
||||||
info.name =
|
if (use_short_name)
|
||||||
use_short_name ? std::string(type.def->ShortName()) : type.def->detailed_name;
|
info.name = type.def->ShortName();
|
||||||
|
else
|
||||||
|
info.name = type.def->detailed_name;
|
||||||
if (type.def->detailed_name != type.def->ShortName())
|
if (type.def->detailed_name != type.def->ShortName())
|
||||||
info.containerName = type.def->detailed_name;
|
info.containerName = type.def->detailed_name;
|
||||||
// TODO ClangSymbolKind -> lsSymbolKind
|
// TODO ClangSymbolKind -> lsSymbolKind
|
||||||
@ -460,8 +462,10 @@ optional<lsSymbolInformation> GetSymbolInfo(QueryDatabase* db,
|
|||||||
return nullopt;
|
return nullopt;
|
||||||
|
|
||||||
lsSymbolInformation info;
|
lsSymbolInformation info;
|
||||||
info.name =
|
if (use_short_name)
|
||||||
use_short_name ? std::string(func.def->ShortName()) : func.def->detailed_name;
|
info.name = func.def->ShortName();
|
||||||
|
else
|
||||||
|
info.name = func.def->detailed_name;
|
||||||
info.containerName = func.def->detailed_name;
|
info.containerName = func.def->detailed_name;
|
||||||
info.kind = lsSymbolKind::Function;
|
info.kind = lsSymbolKind::Function;
|
||||||
|
|
||||||
@ -479,7 +483,10 @@ optional<lsSymbolInformation> GetSymbolInfo(QueryDatabase* db,
|
|||||||
return nullopt;
|
return nullopt;
|
||||||
|
|
||||||
lsSymbolInformation info;
|
lsSymbolInformation info;
|
||||||
info.name = use_short_name ? std::string(var.def->ShortName()) : var.def->detailed_name;
|
if (use_short_name)
|
||||||
|
info.name = var.def->ShortName();
|
||||||
|
else
|
||||||
|
info.name = var.def->detailed_name;
|
||||||
info.containerName = var.def->detailed_name;
|
info.containerName = var.def->detailed_name;
|
||||||
info.kind = lsSymbolKind::Variable;
|
info.kind = lsSymbolKind::Variable;
|
||||||
return info;
|
return info;
|
||||||
|
Loading…
Reference in New Issue
Block a user