Editor: Highlight background for whitespaces in strings and comments

The whitespaces are now highlighted with the same backgroundcolor as the characters.
Also added a test for the Lexer.

Task-number: QTCREATORBUG-5802

Change-Id: Ic1bcd8cfe30d6b8a0281b7963eaab310f972b9d2
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
David Schulz
2012-01-24 12:46:17 +01:00
committed by Roberto Raggi
parent 8c2bcd14da
commit e46a5579d3
3 changed files with 127 additions and 9 deletions

View File

@@ -157,10 +157,15 @@ void Lexer::scan(Token *tok)
void Lexer::scan_helper(Token *tok)
{
_Lagain:
_tokenStart = _currentChar;
tok->offset = _currentChar - _firstChar;
while (_yychar && std::isspace(_yychar)) {
if (_yychar == '\n') {
tok->f.joined = false;
tok->f.newline = true;
if (_state == State_MultiLineComment || _state == State_MultiLineDoxyComment)
break;
} else {
tok->f.whitespace = true;
}
@@ -170,12 +175,10 @@ void Lexer::scan_helper(Token *tok)
if (! _translationUnit)
tok->lineno = _currentLine;
_tokenStart = _currentChar;
tok->offset = _currentChar - _firstChar;
if (_state == State_MultiLineComment || _state == State_MultiLineDoxyComment) {
const int originalState = _state;
if (! _yychar) {
tok->f.kind = T_EOF_SYMBOL;
return;
@@ -204,6 +207,9 @@ void Lexer::scan_helper(Token *tok)
return; // done
}
_tokenStart = _currentChar;
tok->offset = _currentChar - _firstChar;
if (! _yychar) {
tok->f.kind = T_EOF_SYMBOL;
return;