aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cpphoverhandler.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2017-10-23 15:53:57 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2017-10-25 06:20:15 +0000
commit9d1939799467ec900eee20b0c68b82d367aaaea7 (patch)
treed498e629fd6d3e86e5d672eded77f50150ae9ec9 /src/plugins/cppeditor/cpphoverhandler.cpp
parent4d90477e02be27e083c35f526cac5187fe39e4ed (diff)
CppEditor: Simplify CppHoverHandler::identifyMatch
Diagnostic tooltips for the built-in code model were determined with the help of editorWidget->extraSelectionTooltip(), which iterated over all extra selections. Rely on CppElementEvaluator::hasDiagnosis() instead, which looks only for the relevant selections of the category CodeWarningsSelection. This is not supposed to change any behavior. Change-Id: I7aea678b347a94a00610057180e305921234b580 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cpphoverhandler.cpp')
-rw-r--r--src/plugins/cppeditor/cpphoverhandler.cpp62
1 files changed, 30 insertions, 32 deletions
diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp
index dcb182435d..d480c12c61 100644
--- a/src/plugins/cppeditor/cpphoverhandler.cpp
+++ b/src/plugins/cppeditor/cpphoverhandler.cpp
@@ -99,39 +99,37 @@ void CppHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos)
if (editorDocumentProcessorHasDiagnosticAt(editorWidget, pos)) {
setPriority(Priority_Diagnostic);
m_positionForEditorDocumentProcessor = pos;
- } else if (!editorWidget->extraSelectionTooltip(pos).isEmpty()) {
- setToolTip(editorWidget->extraSelectionTooltip(pos));
- } else {
- QTextCursor tc(editorWidget->document());
- tc.setPosition(pos);
-
- CppElementEvaluator evaluator(editorWidget);
- evaluator.setTextCursor(tc);
- evaluator.execute();
- if (evaluator.hasDiagnosis()) {
- setToolTip(evaluator.diagnosis());
- setPriority(Priority_Diagnostic);
+ return;
+ }
+
+ QTextCursor tc(editorWidget->document());
+ tc.setPosition(pos);
+
+ CppElementEvaluator evaluator(editorWidget);
+ evaluator.setTextCursor(tc);
+ evaluator.execute();
+ if (evaluator.hasDiagnosis()) {
+ setToolTip(evaluator.diagnosis());
+ setPriority(Priority_Diagnostic);
+ } else if (evaluator.identifiedCppElement()) {
+ const QSharedPointer<CppElement> &cppElement = evaluator.cppElement();
+ if (priority() != Priority_Diagnostic) {
+ setToolTip(cppElement->tooltip);
+ setPriority(cppElement->tooltip.isEmpty() ? Priority_None : Priority_Tooltip);
}
- 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();
- 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));
- break;
- }
+ QStringList candidates = cppElement->helpIdCandidates;
+ candidates.removeDuplicates();
+ 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));
+ break;
}
}
}