C++: Store token kind as lexer state

... when needed

Change-Id: I32a1649c87e1fa42da80eff5003b2f5714062064
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Orgad Shaneh
2014-01-18 19:51:57 +02:00
committed by Orgad Shaneh
parent 25ab1199cd
commit a309b3cfe6
4 changed files with 19 additions and 25 deletions

View File

@@ -66,7 +66,7 @@ CppHighlighter::CppHighlighter(QTextDocument *document) :
void CppHighlighter::highlightBlock(const QString &text)
{
const int previousState = previousBlockState();
int state = 0, initialBraceDepth = 0;
int state = T_EOF_SYMBOL, initialBraceDepth = 0;
if (previousState != -1) {
state = previousState & 0xff;
initialBraceDepth = previousState >> 8;
@@ -96,9 +96,9 @@ void CppHighlighter::highlightBlock(const QString &text)
setCurrentBlockState(previousState);
BaseTextDocumentLayout::clearParentheses(currentBlock());
if (text.length()) {// the empty line can still contain whitespace
if (initialState == Lexer::State_MultiLineComment)
if (initialState == T_COMMENT)
highlightLine(text, 0, text.length(), formatForCategory(CppCommentFormat));
else if (initialState == Lexer::State_MultiLineDoxyComment)
else if (initialState == T_DOXY_COMMENT)
highlightLine(text, 0, text.length(), formatForCategory(CppDoxygenCommentFormat));
else
setFormat(0, text.length(), formatForCategory(CppVisualWhitespace));