forked from qt-creator/qt-creator
Clang: Fix tooltip for pointer to class
Detect and dereference pointer to get to the correct class. Fixes: QTCREATORBUG-21523 Change-Id: I679778b2cfbbce4466294dabdee096686f53f095 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -425,14 +425,24 @@ ToolTipInfo ToolTipInfoCollector::qDocInfo(const Cursor &cursor) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor.kind() == CXCursor_VarDecl || cursor.kind() == CXCursor_FieldDecl) {
|
if (cursor.kind() == CXCursor_VarDecl || cursor.kind() == CXCursor_ParmDecl
|
||||||
result.qdocMark = typeName(cursor.type());
|
|| cursor.kind() == CXCursor_FieldDecl) {
|
||||||
// maybe template instantiation
|
// maybe template instantiation
|
||||||
if (cursor.type().kind() == CXType_Unexposed && cursor.type().canonical().kind() == CXType_Record) {
|
if (cursor.type().kind() == CXType_Unexposed && cursor.type().canonical().kind() == CXType_Record) {
|
||||||
result.qdocIdCandidates = qDocIdCandidates(cursor.type().canonical().declaration());
|
result.qdocIdCandidates = qDocIdCandidates(cursor.type().canonical().declaration());
|
||||||
|
result.qdocMark = typeName(cursor.type());
|
||||||
result.qdocCategory = ToolTipInfo::ClassOrNamespace;
|
result.qdocCategory = ToolTipInfo::ClassOrNamespace;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Type type = cursor.type();
|
||||||
|
while (type.pointeeType().isValid())
|
||||||
|
type = type.pointeeType();
|
||||||
|
|
||||||
|
const Cursor typeCursor = type.declaration();
|
||||||
|
result.qdocIdCandidates = qDocIdCandidates(typeCursor);
|
||||||
|
result.qdocCategory = qdocCategory(typeCursor);
|
||||||
|
result.qdocMark = typeName(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Handle also RValueReference()
|
// TODO: Handle also RValueReference()
|
||||||
|
@@ -584,6 +584,18 @@ TEST_F(ToolTipInfo, AutoTypeBuiltin)
|
|||||||
ASSERT_THAT(actual.text, Utf8StringLiteral("int"));
|
ASSERT_THAT(actual.text, Utf8StringLiteral("int"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ToolTipInfo, PointerToPointerToClass)
|
||||||
|
{
|
||||||
|
::ToolTipInfo expected(Utf8StringLiteral("Nuu **"));
|
||||||
|
expected.qdocIdCandidates = {Utf8StringLiteral("Nuu")};
|
||||||
|
expected.qdocMark = Utf8StringLiteral("Nuu");
|
||||||
|
expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace;
|
||||||
|
|
||||||
|
const ::ToolTipInfo actual = tooltip(200, 12);
|
||||||
|
|
||||||
|
ASSERT_THAT(actual, IsToolTip(expected));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Test for qdoc entries, too.
|
// TODO: Test for qdoc entries, too.
|
||||||
TEST_F(ToolTipInfo, AutoTypeEnum)
|
TEST_F(ToolTipInfo, AutoTypeEnum)
|
||||||
{
|
{
|
||||||
|
@@ -194,3 +194,8 @@ void constructor()
|
|||||||
ExplicitCon();
|
ExplicitCon();
|
||||||
ExplicitCon(2);
|
ExplicitCon(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Nuu **pointers(Nuu **p1)
|
||||||
|
{
|
||||||
|
return p1;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user