diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-07-03 13:29:30 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-07-05 08:47:34 +0000 |
commit | 27479853584892585548b29eacea731252c274a8 (patch) | |
tree | a3e6f6793d52cf9b493b6ee81abaefe6d49222e2 /src/plugins/clangcodemodel | |
parent | 1a16caf221da6586f429a164656d89509398c625 (diff) | |
download | qt-creator-27479853584892585548b29eacea731252c274a8.tar.gz |
Clang: Gray out diagnostics on document change
When reparses take a while, this is helpful.
Change-Id: Ie2003a3d65b30d944d20fa19dd4161412182851c
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/clangcodemodel')
6 files changed, 42 insertions, 13 deletions
diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp index f8afaf6565..f5fe4d6368 100644 --- a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp +++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp @@ -41,6 +41,7 @@ #include <utils/fileutils.h> #include <utils/proxyaction.h> #include <utils/qtcassert.h> +#include <utils/theme/theme.h> #include <QFileInfo> #include <QTextBlock> @@ -347,6 +348,19 @@ ClangDiagnosticManager::diagnosticsAt(uint line, uint column) const return diagnostics; } +void ClangDiagnosticManager::invalidateDiagnostics() +{ + if (m_diagnosticsInvalidated) + return; + + m_diagnosticsInvalidated = true; + for (ClangTextMark *textMark : m_clangTextMarks) { + textMark->setColor(::Utils::Theme::Color::IconsDisabledColor); + textMark->updateIcon(/*valid=*/ false); + textMark->updateMarker(); + } +} + void ClangDiagnosticManager::clearDiagnosticsWithFixIts() { m_fixItdiagnostics.clear(); @@ -364,6 +378,7 @@ void ClangDiagnosticManager::generateEditorSelections() void ClangDiagnosticManager::processNewDiagnostics( const QVector<ClangBackEnd::DiagnosticContainer> &allDiagnostics) { + m_diagnosticsInvalidated = false; filterDiagnostics(allDiagnostics); generateTextMarks(); diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.h b/src/plugins/clangcodemodel/clangdiagnosticmanager.h index 1da92c8605..e22cd933d5 100644 --- a/src/plugins/clangcodemodel/clangdiagnosticmanager.h +++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.h @@ -58,6 +58,7 @@ public: bool hasDiagnosticsAt(uint line, uint column) const; QVector<ClangBackEnd::DiagnosticContainer> diagnosticsAt(uint line, uint column) const; + void invalidateDiagnostics(); void clearDiagnosticsWithFixIts(); private: @@ -80,6 +81,7 @@ private: QList<QTextEdit::ExtraSelection> m_extraSelections; TextEditor::RefactorMarkers m_fixItAvailableMarkers; std::vector<ClangTextMark *> m_clangTextMarks; + bool m_diagnosticsInvalidated = false; }; } // namespace Internal diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index 800d4baf0e..848de72ebc 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -281,6 +281,11 @@ void ClangEditorDocumentProcessor::editorDocumentTimerRestarted() m_updateTranslationUnitTimer.stop(); // Wait for the next call to run(). } +void ClangEditorDocumentProcessor::invalidateDiagnostics() +{ + m_diagnosticManager.invalidateDiagnostics(); +} + void ClangEditorDocumentProcessor::setParserConfig( const CppTools::BaseEditorDocumentParser::Configuration config) { diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.h b/src/plugins/clangcodemodel/clangeditordocumentprocessor.h index cdee5b7d86..da6872fa3d 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.h +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.h @@ -77,6 +77,7 @@ public: TextEditor::QuickFixOperations extraRefactoringOperations(const TextEditor::AssistInterface &assistInterface) override; + void invalidateDiagnostics() override; bool hasDiagnosticsAt(uint line, uint column) const override; void addDiagnosticToolTipToLayout(uint line, uint column, QLayout *target) const override; diff --git a/src/plugins/clangcodemodel/clangtextmark.cpp b/src/plugins/clangcodemodel/clangtextmark.cpp index 1e53bce06e..b8d69a722e 100644 --- a/src/plugins/clangcodemodel/clangtextmark.cpp +++ b/src/plugins/clangcodemodel/clangtextmark.cpp @@ -78,23 +78,29 @@ ClangTextMark::ClangTextMark(const QString &fileName, : QApplication::translate("Clang Code Model Marks", "Code Model Error")); setPriority(warning ? TextEditor::TextMark::NormalPriority : TextEditor::TextMark::HighPriority); - setIcon(diagnostic.severity()); + updateIcon(); setLineAnnotation(diagnostic.text().toString()); } -void ClangTextMark::setIcon(ClangBackEnd::DiagnosticSeverity severity) +void ClangTextMark::updateIcon(bool valid) { - static const QIcon errorIcon = Utils::Icon({ - {QLatin1String(":/clangcodemodel/images/error.png"), Utils::Theme::IconsErrorColor} - }, Utils::Icon::Tint).icon(); - static const QIcon warningIcon = Utils::Icon({ - {QLatin1String(":/clangcodemodel/images/warning.png"), Utils::Theme::IconsWarningColor} - }, Utils::Icon::Tint).icon(); - - if (isWarningOrNote(severity)) - TextMark::setIcon(warningIcon); + static const QIcon errorIcon = Utils::Icon( + {{":/clangcodemodel/images/error.png", Utils::Theme::IconsErrorColor}}, + Utils::Icon::Tint).icon(); + static const QIcon warningIcon = Utils::Icon( + {{":/clangcodemodel/images/warning.png", Utils::Theme::IconsWarningColor}}, + Utils::Icon::Tint).icon(); + static const QIcon invalidErrorIcon = Utils::Icon( + {{":/clangcodemodel/images/error.png", Utils::Theme::IconsDisabledColor}}, + Utils::Icon::Tint).icon(); + static const QIcon invalidWarningIcon = Utils::Icon( + {{":/clangcodemodel/images/warning.png", Utils::Theme::IconsDisabledColor}}, + Utils::Icon::Tint).icon(); + + if (isWarningOrNote(m_diagnostic.severity())) + setIcon(valid ? warningIcon : invalidWarningIcon); else - TextMark::setIcon(errorIcon); + setIcon(valid ? errorIcon : invalidErrorIcon); } bool ClangTextMark::addToolTipContent(QLayout *target) const diff --git a/src/plugins/clangcodemodel/clangtextmark.h b/src/plugins/clangcodemodel/clangtextmark.h index f1a1b9078b..0342fd1a62 100644 --- a/src/plugins/clangcodemodel/clangtextmark.h +++ b/src/plugins/clangcodemodel/clangtextmark.h @@ -43,8 +43,8 @@ public: const ClangBackEnd::DiagnosticContainer &diagnostic, const RemovedFromEditorHandler &removedHandler); + void updateIcon(bool valid = true); private: - void setIcon(ClangBackEnd::DiagnosticSeverity severity); bool addToolTipContent(QLayout *target) const override; void removedFromEditor() override; |