C++: Clarify units of a Token

This will avoid confusion when later more length and indices methods are
added.

In Token:
    length() --> bytes()
    begin() --> bytesBegin()
    end() --> bytesEnd()

Change-Id: I244c69b022e239ee762b4114559e707f93ff344f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-12-13 18:41:15 +01:00
parent ba76baa65f
commit 126e69137a
32 changed files with 272 additions and 247 deletions

View File

@@ -87,7 +87,7 @@ const Token &BackwardsScanner::fetchToken(int tokenIndex)
QList<Token> adaptedTokens;
for (int i = 0; i < _tokens.size(); ++i) {
Token t = _tokens.at(i);
t.offset += + blockText.length() + 1;
t.byteOffset += + blockText.length() + 1;
adaptedTokens.append(t);
}
@@ -112,19 +112,19 @@ QString BackwardsScanner::text() const
QString BackwardsScanner::mid(int index) const
{
const Token &firstToken = _tokens.at(index + _offset);
return _text.mid(firstToken.begin());
return _text.mid(firstToken.bytesBegin());
}
QString BackwardsScanner::text(int index) const
{
const Token &firstToken = _tokens.at(index + _offset);
return _text.mid(firstToken.begin(), firstToken.length());
return _text.mid(firstToken.bytesBegin(), firstToken.bytes());
}
QStringRef BackwardsScanner::textRef(int index) const
{
const Token &firstToken = _tokens.at(index + _offset);
return _text.midRef(firstToken.begin(), firstToken.length());
return _text.midRef(firstToken.bytesBegin(), firstToken.bytes());
}
int BackwardsScanner::size() const
@@ -247,8 +247,8 @@ QString BackwardsScanner::indentationString(int index) const
{
const Token tokenAfterNewline = operator[](startOfLine(index + 1));
const int newlinePos = qMax(0, _text.lastIndexOf(QLatin1Char('\n'),
tokenAfterNewline.begin()));
return _text.mid(newlinePos, tokenAfterNewline.begin() - newlinePos);
tokenAfterNewline.bytesBegin()));
return _text.mid(newlinePos, tokenAfterNewline.bytesBegin() - newlinePos);
}