forked from qt-creator/qt-creator
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:
@@ -356,7 +356,7 @@ bool CheckSymbols::warning(AST *ast, const QString &text)
|
||||
const Token &firstToken = tokenAt(ast->firstToken());
|
||||
const Token &lastToken = tokenAt(ast->lastToken() - 1);
|
||||
|
||||
const unsigned length = lastToken.end() - firstToken.begin();
|
||||
const unsigned length = lastToken.bytesEnd() - firstToken.bytesBegin();
|
||||
unsigned line = 1, column = 1;
|
||||
getTokenStartPosition(ast->firstToken(), &line, &column);
|
||||
|
||||
@@ -476,7 +476,7 @@ bool CheckSymbols::visit(NamespaceAST *ast)
|
||||
if (!tok.generated()) {
|
||||
unsigned line, column;
|
||||
getTokenStartPosition(ast->identifier_token, &line, &column);
|
||||
Result use(line, column, tok.length(), CppHighlightingSupport::TypeUse);
|
||||
Result use(line, column, tok.bytes(), CppHighlightingSupport::TypeUse);
|
||||
addUse(use);
|
||||
}
|
||||
}
|
||||
@@ -568,7 +568,8 @@ bool CheckSymbols::visit(MemberAccessAST *ast)
|
||||
if (_potentialFields.contains(id)) {
|
||||
const Token start = tokenAt(ast->firstToken());
|
||||
const Token end = tokenAt(ast->lastToken() - 1);
|
||||
const QByteArray expression = _doc->utf8Source().mid(start.begin(), end.end() - start.begin());
|
||||
const QByteArray expression = _doc->utf8Source()
|
||||
.mid(start.bytesBegin(), end.bytesEnd() - start.bytesBegin());
|
||||
|
||||
const QList<LookupItem> candidates =
|
||||
typeOfExpression(expression, enclosingScope(), TypeOfExpression::Preprocess);
|
||||
@@ -705,7 +706,8 @@ QByteArray CheckSymbols::textOf(AST *ast) const
|
||||
{
|
||||
const Token start = tokenAt(ast->firstToken());
|
||||
const Token end = tokenAt(ast->lastToken() - 1);
|
||||
const QByteArray text = _doc->utf8Source().mid(start.begin(), end.end() - start.begin());
|
||||
const QByteArray text = _doc->utf8Source().mid(start.bytesBegin(),
|
||||
end.bytesEnd() - start.bytesBegin());
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -724,8 +726,10 @@ void CheckSymbols::checkNamespace(NameAST *name)
|
||||
}
|
||||
}
|
||||
|
||||
const unsigned length = tokenAt(name->lastToken() - 1).end() - tokenAt(name->firstToken()).begin();
|
||||
warning(line, column, QCoreApplication::translate("CPlusPlus::CheckSymbols", "Expected a namespace-name"), length);
|
||||
const unsigned length = tokenAt(name->lastToken() - 1).bytesEnd()
|
||||
- tokenAt(name->firstToken()).bytesBegin();
|
||||
warning(line, column, QCoreApplication::translate("CPlusPlus::CheckSymbols",
|
||||
"Expected a namespace-name"), length);
|
||||
}
|
||||
|
||||
bool CheckSymbols::hasVirtualDestructor(Class *klass) const
|
||||
@@ -1112,7 +1116,7 @@ void CheckSymbols::addUse(unsigned tokenIndex, Kind kind)
|
||||
|
||||
unsigned line, column;
|
||||
getTokenStartPosition(tokenIndex, &line, &column);
|
||||
const unsigned length = tok.length();
|
||||
const unsigned length = tok.bytes();
|
||||
|
||||
const Result use(line, column, length, kind);
|
||||
addUse(use);
|
||||
@@ -1149,7 +1153,7 @@ void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast)
|
||||
|
||||
unsigned line, column;
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.length();
|
||||
const unsigned length = tok.bytes();
|
||||
const Result use(line, column, length, CppHighlightingSupport::TypeUse);
|
||||
addUse(use);
|
||||
}
|
||||
@@ -1190,7 +1194,7 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
|
||||
|
||||
unsigned line, column;
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.length();
|
||||
const unsigned length = tok.bytes();
|
||||
|
||||
Kind kind = CppHighlightingSupport::TypeUse;
|
||||
if (c->enclosingEnum() != 0)
|
||||
@@ -1232,7 +1236,7 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
|
||||
|
||||
unsigned line, column;
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.length();
|
||||
const unsigned length = tok.bytes();
|
||||
|
||||
const Result use(line, column, length, CppHighlightingSupport::FieldUse);
|
||||
addUse(use);
|
||||
@@ -1316,7 +1320,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
|
||||
|
||||
unsigned line, column;
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.length();
|
||||
const unsigned length = tok.bytes();
|
||||
|
||||
// Add a diagnostic message if argument count does not match
|
||||
if (matchType == Match_TooFewArgs)
|
||||
|
||||
Reference in New Issue
Block a user