ClangCodeModel: Fix displaying diagnostics containing array operators

Fixes: QTCREATORBUG-31670
Change-Id: Ib0fa824d46d3e4297a0bdcfb66aef94e6e510a54
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2024-10-07 17:12:15 +02:00
parent b81a7eeb4a
commit 5a09ce5d53
2 changed files with 11 additions and 2 deletions

View File

@@ -105,9 +105,16 @@ FilePath currentCppEditorDocumentFilePath()
DiagnosticTextInfo::DiagnosticTextInfo(const QString &text) DiagnosticTextInfo::DiagnosticTextInfo(const QString &text)
: m_text(text) : m_text(text)
, m_squareBracketStartIndex(text.lastIndexOf('['))
{} {}
int DiagnosticTextInfo::getSquareBracketStartIndex() const
{
const int offset = m_text.lastIndexOf('[');
if (offset < m_text.length() - 1 && m_text.at(offset + 1) == ']')
return -1;
return offset;
}
QString DiagnosticTextInfo::textWithoutOption() const QString DiagnosticTextInfo::textWithoutOption() const
{ {
if (m_squareBracketStartIndex == -1) if (m_squareBracketStartIndex == -1)

View File

@@ -65,8 +65,10 @@ public:
static QString clazyCheckName(const QString &option); static QString clazyCheckName(const QString &option);
private: private:
int getSquareBracketStartIndex() const;
const QString m_text; const QString m_text;
const int m_squareBracketStartIndex; const int m_squareBracketStartIndex = getSquareBracketStartIndex();
}; };
class ClangSourceRange class ClangSourceRange