forked from qt-creator/qt-creator
Clang: Make diagnostic tooltips consistent
Fix that triggering a diagnostic tooltip from the diagnostic location/range itself (underlined text) did not show the icon on the left and the actions/toolbuttons on the right in the tooltip. Instead of showing the tooltip content itself, request the tooltip for the corresponding text mark to get the extra decoration and actions. Change-Id: I5e94aca117a761f7a798d4f4b33db6e386e54d84 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -210,36 +210,6 @@ bool isDiagnosticAtLocation(const ClangBackEnd::DiagnosticContainer &diagnostic,
|
||||
return isDiagnosticRelatedToLocation(diagnostic, {cursorRange}, line, column);
|
||||
}
|
||||
|
||||
QVector<ClangBackEnd::DiagnosticContainer>
|
||||
filteredDiagnosticsAtLocation(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
||||
uint line,
|
||||
uint column,
|
||||
QTextDocument *textDocument)
|
||||
{
|
||||
QVector<ClangBackEnd::DiagnosticContainer> filteredDiagnostics;
|
||||
|
||||
foreach (const auto &diagnostic, diagnostics) {
|
||||
if (isDiagnosticAtLocation(diagnostic, line, column, textDocument))
|
||||
filteredDiagnostics.append(diagnostic);
|
||||
}
|
||||
|
||||
return filteredDiagnostics;
|
||||
}
|
||||
|
||||
bool editorDocumentProcessorHasDiagnosticAt(
|
||||
const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
||||
uint line,
|
||||
uint column,
|
||||
QTextDocument *textDocument)
|
||||
{
|
||||
foreach (const auto &diagnostic, diagnostics) {
|
||||
if (isDiagnosticAtLocation(diagnostic, line, column, textDocument))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextCursor cursorAtLastPositionOfLine(QTextDocument *textDocument, int lineNumber)
|
||||
{
|
||||
const QTextBlock textBlock = textDocument->findBlockByNumber(lineNumber - 1);
|
||||
@@ -399,24 +369,16 @@ TextEditor::RefactorMarkers ClangDiagnosticManager::takeFixItAvailableMarkers()
|
||||
return fixItAvailableMarkers;
|
||||
}
|
||||
|
||||
bool ClangDiagnosticManager::hasDiagnosticsAt(uint line, uint column) const
|
||||
TextEditor::TextMarks ClangDiagnosticManager::diagnosticTextMarksAt(uint line, uint column) const
|
||||
{
|
||||
QTextDocument *textDocument = m_textDocument->document();
|
||||
QList<TextEditor::TextMark *> textMarks;
|
||||
|
||||
return editorDocumentProcessorHasDiagnosticAt(m_errorDiagnostics, line, column, textDocument)
|
||||
|| editorDocumentProcessorHasDiagnosticAt(m_warningDiagnostics, line, column, textDocument);
|
||||
}
|
||||
for (ClangTextMark *textMark : m_clangTextMarks) {
|
||||
if (isDiagnosticAtLocation(textMark->diagnostic(), line, column, m_textDocument->document()))
|
||||
textMarks << textMark;
|
||||
}
|
||||
|
||||
QVector<ClangBackEnd::DiagnosticContainer>
|
||||
ClangDiagnosticManager::diagnosticsAt(uint line, uint column) const
|
||||
{
|
||||
QTextDocument *textDocument = m_textDocument->document();
|
||||
|
||||
QVector<ClangBackEnd::DiagnosticContainer> diagnostics;
|
||||
diagnostics += filteredDiagnosticsAtLocation(m_errorDiagnostics, line, column, textDocument);
|
||||
diagnostics += filteredDiagnosticsAtLocation(m_warningDiagnostics, line, column, textDocument);
|
||||
|
||||
return diagnostics;
|
||||
return textMarks;
|
||||
}
|
||||
|
||||
void ClangDiagnosticManager::invalidateDiagnostics()
|
||||
|
||||
Reference in New Issue
Block a user