mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-16 21:58:08 +00:00
Filter out inside-out syntax and array types for variable hover
This commit is contained in:
parent
bf9150f58a
commit
dd84a85b75
@ -437,12 +437,22 @@ void SetVarDetail(IndexVar* var,
|
|||||||
} else {
|
} else {
|
||||||
def.detailed_name = std::move(type_name);
|
def.detailed_name = std::move(type_name);
|
||||||
ConcatTypeAndName(def.detailed_name, qualified_name);
|
ConcatTypeAndName(def.detailed_name, qualified_name);
|
||||||
const FileContents& fc = param->file_contents[db->path];
|
// The following check is used to skip inside-out syntax and array types
|
||||||
optional<int> spell_end = fc.ToOffset(cursor.get_spelling_range().end);
|
// which we can't display well.
|
||||||
optional<int> extent_end = fc.ToOffset(cursor.get_extent().end);
|
// For other types, append the textual initializer, bit field, constructor
|
||||||
if (extent_end && *spell_end < *extent_end)
|
// or whatever.
|
||||||
def.hover = def.detailed_name +
|
CXType deref = cx_type, next;
|
||||||
fc.content.substr(*spell_end, *extent_end - *spell_end);
|
while ((next = clang_getPointeeType(deref)).kind != CXType_Invalid)
|
||||||
|
deref = next;
|
||||||
|
if (clang_getResultType(deref).kind == CXType_Invalid &&
|
||||||
|
clang_getElementType(deref).kind == CXType_Invalid) {
|
||||||
|
const FileContents& fc = param->file_contents[db->path];
|
||||||
|
optional<int> spell_end = fc.ToOffset(cursor.get_spelling_range().end);
|
||||||
|
optional<int> extent_end = fc.ToOffset(cursor.get_extent().end);
|
||||||
|
if (extent_end && *spell_end < *extent_end)
|
||||||
|
def.hover = def.detailed_name +
|
||||||
|
fc.content.substr(*spell_end, *extent_end - *spell_end);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_first_seen) {
|
if (is_first_seen) {
|
||||||
|
Loading…
Reference in New Issue
Block a user