forked from qt-creator/qt-creator
CppEditor: Fix build with Qt < 5.14
Change-Id: Ie08a7c0d19fff60b91b1855f7177813776542ef4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -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?
|
// Step one: Does the lexer think this is a raw string literal?
|
||||||
switch (tk.kind()) {
|
switch (tk.kind()) {
|
||||||
@@ -380,6 +380,9 @@ bool CppHighlighter::highlightRawStringLiteral(const QStringView &text, const To
|
|||||||
return false;
|
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,
|
// Step two: Find all the components. Bail out if we don't have a complete,
|
||||||
// well-formed raw string literal.
|
// well-formed raw string literal.
|
||||||
const int rOffset = text.indexOf(QLatin1String("R\""), tk.utf16charsBegin());
|
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 QTextCharFormat delimiterFormat = formatForCategory(C_KEYWORD);
|
||||||
const int stringOffset = delimiterOffset + delimiter.length() + 1;
|
const int stringOffset = delimiterOffset + delimiter.length() + 1;
|
||||||
setFormat(tk.utf16charsBegin(), stringOffset, delimiterFormat);
|
setFormat(tk.utf16charsBegin(), stringOffset, delimiterFormat);
|
||||||
setFormatWithSpaces(text.toString(), stringOffset, endDelimiterOffset - stringOffset - 1,
|
setFormatWithSpaces(text, stringOffset, endDelimiterOffset - stringOffset - 1,
|
||||||
formatForCategory(C_STRING));
|
formatForCategory(C_STRING));
|
||||||
setFormat(endDelimiterOffset - 1, delimiter.length() + 2, delimiterFormat);
|
setFormat(endDelimiterOffset - 1, delimiter.length() + 2, delimiterFormat);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user