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

@@ -199,9 +199,9 @@ ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
{
const Token &token = tokenAt(tokenIndex);
unsigned line, column;
cppDocument()->translationUnit()->getPosition(token.begin(), &line, &column);
cppDocument()->translationUnit()->getPosition(token.bytesBegin(), &line, &column);
const int start = document()->findBlockByNumber(line - 1).position() + column - 1;
return ChangeSet::Range(start, start + token.length());
return ChangeSet::Range(start, start + token.bytes());
}
ChangeSet::Range CppRefactoringFile::range(AST *ast) const
@@ -212,7 +212,7 @@ ChangeSet::Range CppRefactoringFile::range(AST *ast) const
int CppRefactoringFile::startOf(unsigned index) const
{
unsigned line, column;
cppDocument()->translationUnit()->getPosition(tokenAt(index).begin(), &line, &column);
cppDocument()->translationUnit()->getPosition(tokenAt(index).bytesBegin(), &line, &column);
return document()->findBlockByNumber(line - 1).position() + column - 1;
}
@@ -224,7 +224,7 @@ int CppRefactoringFile::startOf(const AST *ast) const
int CppRefactoringFile::endOf(unsigned index) const
{
unsigned line, column;
cppDocument()->translationUnit()->getPosition(tokenAt(index).end(), &line, &column);
cppDocument()->translationUnit()->getPosition(tokenAt(index).bytesEnd(), &line, &column);
return document()->findBlockByNumber(line - 1).position() + column - 1;
}
@@ -239,9 +239,9 @@ void CppRefactoringFile::startAndEndOf(unsigned index, int *start, int *end) con
{
unsigned line, column;
Token token(tokenAt(index));
cppDocument()->translationUnit()->getPosition(token.begin(), &line, &column);
cppDocument()->translationUnit()->getPosition(token.bytesBegin(), &line, &column);
*start = document()->findBlockByNumber(line - 1).position() + column - 1;
*end = *start + token.length();
*end = *start + token.bytes();
}
QString CppRefactoringFile::textOf(const AST *ast) const