CppEditor: Fix build with Qt < 5.14

Change-Id: Ie08a7c0d19fff60b91b1855f7177813776542ef4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-06-19 10:23:29 +02:00
parent 38a156c5a4
commit 176fbc1698

View File

@@ -366,7 +366,7 @@ void CppHighlighter::highlightWord(QStringRef word, int position, int length)
}
}
bool CppHighlighter::highlightRawStringLiteral(const QStringView &text, const Token &tk)
bool CppHighlighter::highlightRawStringLiteral(const QStringView &_text, const Token &tk)
{
// Step one: Does the lexer think this is a raw string literal?
switch (tk.kind()) {
@@ -380,6 +380,9 @@ bool CppHighlighter::highlightRawStringLiteral(const QStringView &text, const To
return false;
}
// TODO: Remove on upgrade to Qt >= 5.14.
const QString text = _text.toString();
// Step two: Find all the components. Bail out if we don't have a complete,
// well-formed raw string literal.
const int rOffset = text.indexOf(QLatin1String("R\""), tk.utf16charsBegin());
@@ -403,7 +406,7 @@ bool CppHighlighter::highlightRawStringLiteral(const QStringView &text, const To
const QTextCharFormat delimiterFormat = formatForCategory(C_KEYWORD);
const int stringOffset = delimiterOffset + delimiter.length() + 1;
setFormat(tk.utf16charsBegin(), stringOffset, delimiterFormat);
setFormatWithSpaces(text.toString(), stringOffset, endDelimiterOffset - stringOffset - 1,
setFormatWithSpaces(text, stringOffset, endDelimiterOffset - stringOffset - 1,
formatForCategory(C_STRING));
setFormat(endDelimiterOffset - 1, delimiter.length() + 2, delimiterFormat);
return true;