summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2018-05-09 13:37:51 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2018-05-14 09:04:42 +0000
commitf46fb39f3c77cb50701ee1fb1dc992c466cef300 (patch)
treec7c9b075584a07a3fb337a39cc53049a924221db /src
parente7123b140eb7e5d392542d087cdf5320336dec8a (diff)
downloadqt-creator-f46fb39f3c77cb50701ee1fb1dc992c466cef300.tar.gz
Clang: Reduce diagnostic visualization for non-project files further
We already avoided showing inline annotations for diagnostics in non-project files. But given many diagnostics the visualization is still quite noisy. E.g. consider opening not self-contained header files or files for which we do not have any project open, as it can happen if the debugger jumps to such a file. So leave only the text mark icon on the left and avoid all the rest: underlines and refactoring icons in the editor, marks in the scrollbar and task hub issues. Change-Id: I05245981b21b38be650489a006593922dcb6896d Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/clangcodemodel/clangdiagnosticmanager.cpp15
-rw-r--r--src/plugins/clangcodemodel/clangdiagnosticmanager.h4
-rw-r--r--src/plugins/clangcodemodel/clangtextmark.cpp9
-rw-r--r--src/plugins/clangcodemodel/clangtextmark.h2
4 files changed, 20 insertions, 10 deletions
diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
index f61fdb825d..78db10c80d 100644
--- a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
+++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
@@ -314,6 +314,9 @@ void ClangDiagnosticManager::generateFixItAvailableMarkers()
{
m_fixItAvailableMarkers.clear();
+ if (!m_fullVisualization)
+ return;
+
QSet<int> lineNumbersWithFixItMarker;
addFixItAvailableMarker(m_warningDiagnostics, lineNumbersWithFixItMarker);
addFixItAvailableMarker(m_errorDiagnostics, lineNumbersWithFixItMarker);
@@ -360,6 +363,9 @@ void ClangDiagnosticManager::clearTaskHubIssues()
void ClangDiagnosticManager::generateTaskHubIssues()
{
+ if (!m_fullVisualization)
+ return;
+
const QVector<ClangBackEnd::DiagnosticContainer> diagnostics = m_errorDiagnostics
+ m_warningDiagnostics;
for (const ClangBackEnd::DiagnosticContainer &diagnostic : diagnostics) {
@@ -431,16 +437,19 @@ void ClangDiagnosticManager::generateEditorSelections()
m_extraSelections.clear();
m_extraSelections.reserve(int(m_warningDiagnostics.size() + m_errorDiagnostics.size()));
+ if (!m_fullVisualization)
+ return;
+
addWarningSelections(m_warningDiagnostics, m_textDocument->document(), m_extraSelections);
addErrorSelections(m_errorDiagnostics, m_textDocument->document(), m_extraSelections);
}
void ClangDiagnosticManager::processNewDiagnostics(
const QVector<ClangBackEnd::DiagnosticContainer> &allDiagnostics,
- bool showTextMarkAnnotations)
+ bool fullVisualization)
{
m_diagnosticsInvalidated = false;
- m_showTextMarkAnnotations = showTextMarkAnnotations;
+ m_fullVisualization = fullVisualization;
filterDiagnostics(allDiagnostics);
generateEditorSelections();
@@ -478,7 +487,7 @@ void ClangDiagnosticManager::addClangTextMarks(
auto textMark = new ClangTextMark(::Utils::FileName::fromString(filePath()),
diagnostic,
onMarkRemoved,
- m_showTextMarkAnnotations);
+ m_fullVisualization);
m_clangTextMarks.push_back(textMark);
m_textDocument->addMark(textMark);
}
diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.h b/src/plugins/clangcodemodel/clangdiagnosticmanager.h
index c895735e8d..d0c31bf68b 100644
--- a/src/plugins/clangcodemodel/clangdiagnosticmanager.h
+++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.h
@@ -51,7 +51,7 @@ public:
~ClangDiagnosticManager();
void processNewDiagnostics(const QVector<ClangBackEnd::DiagnosticContainer> &allDiagnostics,
- bool showTextMarkAnnotations);
+ bool fullVisualization);
const QVector<ClangBackEnd::DiagnosticContainer> &diagnosticsWithFixIts() const;
QList<QTextEdit::ExtraSelection> takeExtraSelections();
@@ -88,7 +88,7 @@ private:
std::vector<ClangTextMark *> m_clangTextMarks;
bool m_firstDiagnostics = true;
bool m_diagnosticsInvalidated = false;
- bool m_showTextMarkAnnotations = false;
+ bool m_fullVisualization = false;
QTimer m_textMarkDelay;
};
diff --git a/src/plugins/clangcodemodel/clangtextmark.cpp b/src/plugins/clangcodemodel/clangtextmark.cpp
index 50db3f87cb..fbe08cb14d 100644
--- a/src/plugins/clangcodemodel/clangtextmark.cpp
+++ b/src/plugins/clangcodemodel/clangtextmark.cpp
@@ -68,7 +68,7 @@ static Core::Id categoryForSeverity(ClangBackEnd::DiagnosticSeverity severity)
ClangTextMark::ClangTextMark(const FileName &fileName,
const ClangBackEnd::DiagnosticContainer &diagnostic,
const RemovedFromEditorHandler &removedHandler,
- bool showLineAnnotations)
+ bool fullVisualization)
: TextEditor::TextMark(fileName,
int(diagnostic.location.line),
categoryForSeverity(diagnostic.severity))
@@ -76,15 +76,16 @@ ClangTextMark::ClangTextMark(const FileName &fileName,
, m_removedFromEditorHandler(removedHandler)
{
const bool warning = isWarningOrNote(diagnostic.severity);
- setColor(warning ? ::Utils::Theme::ClangCodeModel_Warning_TextMarkColor
- : ::Utils::Theme::ClangCodeModel_Error_TextMarkColor);
setDefaultToolTip(warning ? QApplication::translate("Clang Code Model Marks", "Code Model Warning")
: QApplication::translate("Clang Code Model Marks", "Code Model Error"));
setPriority(warning ? TextEditor::TextMark::NormalPriority
: TextEditor::TextMark::HighPriority);
updateIcon();
- if (showLineAnnotations)
+ if (fullVisualization) {
setLineAnnotation(Utils::diagnosticCategoryPrefixRemoved(diagnostic.text.toString()));
+ setColor(warning ? ::Utils::Theme::ClangCodeModel_Warning_TextMarkColor
+ : ::Utils::Theme::ClangCodeModel_Error_TextMarkColor);
+ }
}
void ClangTextMark::updateIcon(bool valid)
diff --git a/src/plugins/clangcodemodel/clangtextmark.h b/src/plugins/clangcodemodel/clangtextmark.h
index 6b7424ae91..1301cd200b 100644
--- a/src/plugins/clangcodemodel/clangtextmark.h
+++ b/src/plugins/clangcodemodel/clangtextmark.h
@@ -42,7 +42,7 @@ public:
ClangTextMark(const ::Utils::FileName &fileName,
const ClangBackEnd::DiagnosticContainer &diagnostic,
const RemovedFromEditorHandler &removedHandler,
- bool showLineAnnotations);
+ bool fullVisualization);
void updateIcon(bool valid = true);
private: