forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/5.0'
Conflicts: src/plugins/autotest/testresultdelegate.cpp Change-Id: If172206f231fc2a9f4a672cd2e6eaeaea4988c96
This commit is contained in:
@@ -1372,12 +1372,13 @@ void ClangdClient::findLocalUsages(TextEditor::TextDocument *document, const QTe
|
||||
void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverResponse,
|
||||
const DocumentUri &uri)
|
||||
{
|
||||
// Macros aren't locatable via the AST, so parse the formatted string.
|
||||
if (const Utils::optional<Hover> result = hoverResponse.result()) {
|
||||
const HoverContent content = result->content();
|
||||
const MarkupContent * const markup = Utils::get_if<MarkupContent>(&content);
|
||||
if (markup) {
|
||||
const QString markupString = markup->content();
|
||||
|
||||
// Macros aren't locatable via the AST, so parse the formatted string.
|
||||
static const QString magicMacroPrefix = "### macro `";
|
||||
if (markupString.startsWith(magicMacroPrefix)) {
|
||||
const int nameStart = magicMacroPrefix.length();
|
||||
@@ -1389,6 +1390,19 @@ void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverR
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Is it the file path for an include directive?
|
||||
QString cleanString = markupString;
|
||||
cleanString.remove('`');
|
||||
const QStringList lines = cleanString.trimmed().split('\n');
|
||||
if (!lines.isEmpty()) {
|
||||
const auto filePath = Utils::FilePath::fromUserInput(lines.last().simplified());
|
||||
if (filePath.exists()) {
|
||||
d->setHelpItemForTooltip(hoverResponse.id(), filePath.fileName(),
|
||||
HelpItem::Brief);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -606,8 +606,10 @@ void ClangdTestTooltips::test()
|
||||
QCOMPARE(editor->document(), doc);
|
||||
QVERIFY(editor->editorWidget());
|
||||
|
||||
if (QLatin1String(QTest::currentDataTag()) == QLatin1String("IncludeDirective"))
|
||||
if (client()->versionNumber() < QVersionNumber(14)
|
||||
&& QLatin1String(QTest::currentDataTag()) == QLatin1String("IncludeDirective")) {
|
||||
QSKIP("FIXME: clangd sends empty or no hover data for includes");
|
||||
}
|
||||
|
||||
QTimer timer;
|
||||
timer.setSingleShot(true);
|
||||
@@ -633,7 +635,6 @@ void ClangdTestTooltips::test()
|
||||
QEXPECT_FAIL("TypeName_ResolveTemplateTypeAlias", "typedef already resolved in AST", Abort);
|
||||
QCOMPARE(int(helpItem.category()), expectedCategory);
|
||||
QEXPECT_FAIL("TemplateClassQualified", "Additional look-up needed?", Abort);
|
||||
QEXPECT_FAIL("AutoTypeTemplate", "Additional look-up needed?", Abort);
|
||||
QCOMPARE(helpItem.helpIds(), expectedIds);
|
||||
QCOMPARE(helpItem.docMark(), expectedMark);
|
||||
}
|
||||
|
||||
@@ -43,5 +43,6 @@
|
||||
<file>tooltips/tooltips.pro</file>
|
||||
<file>highlighting/highlighting.cpp</file>
|
||||
<file>highlighting/highlighting.pro</file>
|
||||
<file>tooltips/subdir/tooltipinfo.h</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#define MACRO_FROM_HEADER(x) x + \
|
||||
x + \
|
||||
x
|
||||
@@ -1,3 +1,4 @@
|
||||
TEMPLATE = app
|
||||
CONFIG -= qt
|
||||
SOURCES = tooltips.cpp
|
||||
INCLUDEPATH += subdir
|
||||
|
||||
Reference in New Issue
Block a user