diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-01-18 16:04:27 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-01-22 12:33:21 +0000 |
commit | 608e7ec2459e3ce30a51fd9b58cd93a0e5384973 (patch) | |
tree | b04784c68d986b431333966d429465620a2b0afd /tests | |
parent | 4db7fd064f747ef115da15f8800ae3b57d4e1ca1 (diff) |
Clang: Fix tooltips for constructors
Constructors were not handled yet, so the tooltip for e.g. the
"QString()" constructor was "void ()".
Also, since the help system has problems with overloads, show the
function signature as clang sees it and provide a help system query that
will show the documentation for the class instead of the wrong overload.
Change-Id: Idc0cf9dce6a50c323e6fd945f277c7816b0f9b34
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unittest/clangtooltipinfo-test.cpp | 42 | ||||
-rw-r--r-- | tests/unit/unittest/data/tooltipinfo.cpp | 16 |
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/unit/unittest/clangtooltipinfo-test.cpp b/tests/unit/unittest/clangtooltipinfo-test.cpp index acaa3e18d7..c796932092 100644 --- a/tests/unit/unittest/clangtooltipinfo-test.cpp +++ b/tests/unit/unittest/clangtooltipinfo-test.cpp @@ -614,6 +614,48 @@ TEST_F(ToolTipInfo, AutoTypeClassTemplateType) ASSERT_THAT(actual.text(), Utf8StringLiteral("Zii<int>")); } +TEST_F(ToolTipInfo, DISABLED_WITHOUT_PRETTYDECL_PATCH(Function_DefaultConstructor)) +{ + const ::ToolTipInfo actual = tooltip(193, 5); + + ASSERT_THAT(actual.text(), Utf8StringLiteral("inline constexpr Con::Con() noexcept")); +} + +TEST_F(ToolTipInfo, DISABLED_WITHOUT_PRETTYDECL_PATCH(Function_ExplicitDefaultConstructor)) +{ + const ::ToolTipInfo actual = tooltip(194, 5); + + ASSERT_THAT(actual.text(), Utf8StringLiteral("ExplicitCon::ExplicitCon() noexcept = default")); +} + +TEST_F(ToolTipInfo, DISABLED_WITHOUT_PRETTYDECL_PATCH(Function_CustomConstructor)) +{ + const ::ToolTipInfo actual = tooltip(195, 5); + + ASSERT_THAT(actual.text(), Utf8StringLiteral("ExplicitCon::ExplicitCon(int m)")); +} + +// Overloads are problematic for the help system since the data base has not +// enough information about them. At least for constructors we can improve +// the situation a bit - provide a help system query that: +// 1) will not lead to the replacement of the constructor signature as +// clang sees it with the wrong overload documentation +// (signature + main help sentence). That's the qdocCategory=Unknown +// part. +// 2) finds the documentation for the class instead of the overload, +// so F1 will go to the class documentation. +TEST_F(ToolTipInfo, Function_ConstructorQDoc) +{ + ::ToolTipInfo expected; + expected.setQdocIdCandidates({Utf8StringLiteral("Con")}); + expected.setQdocMark(Utf8StringLiteral("Con")); + expected.setQdocCategory(::ToolTipInfo::Unknown); + + const ::ToolTipInfo actual = tooltip(193, 5); + + ASSERT_THAT(actual, IsQdocToolTip(expected)); +} + std::unique_ptr<Data> ToolTipInfo::d; void ToolTipInfo::SetUpTestCase() diff --git a/tests/unit/unittest/data/tooltipinfo.cpp b/tests/unit/unittest/data/tooltipinfo.cpp index 1945577b63..266d86bc47 100644 --- a/tests/unit/unittest/data/tooltipinfo.cpp +++ b/tests/unit/unittest/data/tooltipinfo.cpp @@ -178,3 +178,19 @@ void autoTypes() auto c = Bar(); (void)c; auto d = Zii<int>(); (void)d; } + + + + +struct Con {}; +struct ExplicitCon { + ExplicitCon() = default; + ExplicitCon(int m) :member(m) {} + int member; +}; +void constructor() +{ + Con(); + ExplicitCon(); + ExplicitCon(2); +} |