Filter out inside-out syntax and array types for variable hover

This commit is contained in:
Fangrui Song 2018-01-17 00:17:04 -08:00
parent bf9150f58a
commit dd84a85b75

View File

@ -437,6 +437,15 @@ void SetVarDetail(IndexVar* var,
} else {
def.detailed_name = std::move(type_name);
ConcatTypeAndName(def.detailed_name, qualified_name);
// The following check is used to skip inside-out syntax and array types
// which we can't display well.
// For other types, append the textual initializer, bit field, constructor
// or whatever.
CXType deref = cx_type, next;
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);
@ -444,6 +453,7 @@ void SetVarDetail(IndexVar* var,
def.hover = def.detailed_name +
fc.content.substr(*spell_end, *extent_end - *spell_end);
}
}
if (is_first_seen) {
optional<IndexTypeId> var_type = ResolveToDeclarationType(db, cursor);