forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user