diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-01-25 15:51:36 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2019-01-21 10:30:03 +0000 |
commit | 6c10d36f8776900f75f16ae26a127e4771eda1e6 (patch) | |
tree | e2932ae96fd5a2ca0e3d84a5ef818bf16704fb36 /src/plugins/cpptools/cpphoverhandler.cpp | |
parent | 2d8bc0e509a5dbb7314ea12eeb7a28acc13d82cd (diff) | |
download | qt-creator-6c10d36f8776900f75f16ae26a127e4771eda1e6.tar.gz |
Try harder to get context help in presence of diagnostics
- even if there are diagnostics still try to retrieve symbol info
and help
- fall back to text based keyword extraction in case code model
info fails
- if both a code model tool tip (e.g. function signature or type)
and help are available, show both
Task-number: QTCREATORBUG-15959
Change-Id: Id85a223c24849ead1b25d63776d64a7da1cc73ef
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cpphoverhandler.cpp')
-rw-r--r-- | src/plugins/cpptools/cpphoverhandler.cpp | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/src/plugins/cpptools/cpphoverhandler.cpp b/src/plugins/cpptools/cpphoverhandler.cpp index 3969065ff7..752f50725b 100644 --- a/src/plugins/cpptools/cpphoverhandler.cpp +++ b/src/plugins/cpptools/cpphoverhandler.cpp @@ -30,6 +30,7 @@ #include <coreplugin/helpmanager.h> #include <texteditor/texteditor.h> +#include <utils/optional.h> #include <utils/textutils.h> #include <utils/executeondestruction.h> @@ -78,47 +79,31 @@ void CppHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, Rep CppElementEvaluator evaluator(editorWidget); evaluator.setTextCursor(tc); evaluator.execute(); + QString tip; if (evaluator.hasDiagnosis()) { - setToolTip(evaluator.diagnosis()); + tip += evaluator.diagnosis(); setPriority(Priority_Diagnostic); - } else if (evaluator.identifiedCppElement()) { + } + if (evaluator.identifiedCppElement()) { const QSharedPointer<CppElement> &cppElement = evaluator.cppElement(); - if (priority() != Priority_Diagnostic) { - setToolTip(cppElement->tooltip); - setPriority(cppElement->tooltip.isEmpty() ? Priority_None : Priority_Tooltip); - } QStringList candidates = cppElement->helpIdCandidates; candidates.removeDuplicates(); + Utils::optional<HelpItem> helpItem; foreach (const QString &helpId, candidates) { if (helpId.isEmpty()) continue; - const QMap<QString, QUrl> helpLinks = HelpManager::linksForIdentifier(helpId); if (!helpLinks.isEmpty()) { - setLastHelpItemIdentified(HelpItem(helpId, - cppElement->helpMark, - cppElement->helpCategory, - helpLinks)); + helpItem.emplace(helpId, cppElement->helpMark, cppElement->helpCategory, helpLinks); break; } } + if (helpItem) + setLastHelpItemIdentified(helpItem.value()); // tool tip appended by decorateToolTip + else + tip += cppElement->tooltip; } -} - -void CppHoverHandler::decorateToolTip() -{ - if (Qt::mightBeRichText(toolTip())) - setToolTip(toolTip().toHtmlEscaped()); - - if (priority() == Priority_Diagnostic) - return; - - const HelpItem &help = lastHelpItemIdentified(); - if (help.isValid()) { - const QString text = tooltipTextForHelpItem(help); - if (!text.isEmpty()) - setToolTip(text); - } + setToolTip(tip); } } // namespace CppTools |