forked from qt-creator/qt-creator
CppEditor: fix highlighter tests
amends 9091c99429
Change-Id: Iaa64d51aa0dad1d63c88a51bfa55afa2367e65ed
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -621,8 +621,9 @@ void CppHighlighterTest::test()
|
||||
const QChar c = m_doc.characterAt(pos);
|
||||
if (c == QChar::ParagraphSeparator)
|
||||
continue;
|
||||
const QTextCharFormat expectedFormat = c.isSpace()
|
||||
? whitespacified(formatForStyle) : formatForStyle;
|
||||
const QTextCharFormat expectedFormat = asSyntaxHighlight(
|
||||
c.isSpace() ? whitespacified(formatForStyle) : formatForStyle);
|
||||
|
||||
const QTextCharFormat actualFormat = getActualFormat(pos);
|
||||
if (actualFormat != expectedFormat) {
|
||||
int posLine;
|
||||
|
@@ -869,6 +869,13 @@ QTextCharFormat SyntaxHighlighter::whitespacified(const QTextCharFormat &fmt)
|
||||
return format;
|
||||
}
|
||||
|
||||
QTextCharFormat SyntaxHighlighter::asSyntaxHighlight(const QTextCharFormat &fmt)
|
||||
{
|
||||
QTextCharFormat format = fmt;
|
||||
format.setProperty(SyntaxHighlight, true);
|
||||
return format;
|
||||
}
|
||||
|
||||
void SyntaxHighlighter::highlightBlock(const QString &text)
|
||||
{
|
||||
formatSpaces(text);
|
||||
|
@@ -62,6 +62,7 @@ protected:
|
||||
void setTextFormatCategories(int count, std::function<TextStyle(int)> formatMapping);
|
||||
QTextCharFormat formatForCategory(int categoryIndex) const;
|
||||
QTextCharFormat whitespacified(const QTextCharFormat &fmt);
|
||||
QTextCharFormat asSyntaxHighlight(const QTextCharFormat &fmt);
|
||||
|
||||
// implement in subclasses
|
||||
// default implementation highlights whitespace
|
||||
|
Reference in New Issue
Block a user