diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-12-13 18:41:15 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-05-15 15:55:38 +0200 |
commit | 126e69137a7b3cfdf86832c2561f1dde311e9ad6 (patch) | |
tree | a884d65be6c50dfbd876091c295bfd0245f8f30d /src/libs | |
parent | ba76baa65fa9ad4d1f3154639be385c7b49dc1dd (diff) | |
download | qt-creator-126e69137a7b3cfdf86832c2561f1dde311e9ad6.tar.gz |
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>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/3rdparty/cplusplus/ASTVisitor.cpp | 4 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Bind.cpp | 94 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Lexer.cpp | 4 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Symbol.cpp | 2 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Token.cpp | 2 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Token.h | 34 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/TranslationUnit.cpp | 24 | ||||
-rw-r--r-- | src/libs/cplusplus/BackwardsScanner.cpp | 12 | ||||
-rw-r--r-- | src/libs/cplusplus/ExpressionUnderCursor.cpp | 2 | ||||
-rw-r--r-- | src/libs/cplusplus/FindUsages.cpp | 8 | ||||
-rw-r--r-- | src/libs/cplusplus/PPToken.cpp | 4 | ||||
-rw-r--r-- | src/libs/cplusplus/PPToken.h | 4 | ||||
-rw-r--r-- | src/libs/cplusplus/SimpleLexer.cpp | 6 | ||||
-rw-r--r-- | src/libs/cplusplus/pp-engine.cpp | 95 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsfindexportedcpptypes.cpp | 13 |
15 files changed, 158 insertions, 150 deletions
diff --git a/src/libs/3rdparty/cplusplus/ASTVisitor.cpp b/src/libs/3rdparty/cplusplus/ASTVisitor.cpp index 5aa1f2d52f..8fe4399673 100644 --- a/src/libs/3rdparty/cplusplus/ASTVisitor.cpp +++ b/src/libs/3rdparty/cplusplus/ASTVisitor.cpp @@ -86,7 +86,7 @@ void ASTVisitor::getTokenPosition(unsigned index, { translationUnit()->getTokenPosition(index, line, column, fileName); } void ASTVisitor::getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const -{ getPosition(tokenAt(index).begin(), line, column); } +{ getPosition(tokenAt(index).bytesBegin(), line, column); } void ASTVisitor::getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const -{ getPosition(tokenAt(index).end(), line, column); } +{ getPosition(tokenAt(index).bytesEnd(), line, column); } diff --git a/src/libs/3rdparty/cplusplus/Bind.cpp b/src/libs/3rdparty/cplusplus/Bind.cpp index a00bdc97c3..8abb3e4ce7 100644 --- a/src/libs/3rdparty/cplusplus/Bind.cpp +++ b/src/libs/3rdparty/cplusplus/Bind.cpp @@ -1094,8 +1094,8 @@ void Bind::lambdaDeclarator(LambdaDeclaratorAST *ast) Function *fun = control()->newFunction(0, 0); - fun->setStartOffset(tokenAt(ast->firstToken()).begin()); - fun->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + fun->setStartOffset(tokenAt(ast->firstToken()).bytesBegin()); + fun->setEndOffset(tokenAt(ast->lastToken() - 1).bytesEnd()); if (ast->trailing_return_type) _type = this->trailingReturnType(ast->trailing_return_type, _type); fun->setReturnType(_type); @@ -1192,8 +1192,8 @@ bool Bind::visit(CompoundStatementAST *ast) { Block *block = control()->newBlock(ast->firstToken()); unsigned startScopeToken = ast->lbrace_token ? ast->lbrace_token : ast->firstToken(); - block->setStartOffset(tokenAt(startScopeToken).end()); - block->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + block->setStartOffset(tokenAt(startScopeToken).bytesEnd()); + block->setEndOffset(tokenAt(ast->lastToken() - 1).bytesEnd()); ast->symbol = block; _scope->addMember(block); Scope *previousScope = switchScope(block); @@ -1235,8 +1235,8 @@ bool Bind::visit(ForeachStatementAST *ast) { Block *block = control()->newBlock(ast->firstToken()); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken(); - block->setStartOffset(tokenAt(startScopeToken).end()); - block->setEndOffset(tokenAt(ast->lastToken()).begin()); + block->setStartOffset(tokenAt(startScopeToken).bytesEnd()); + block->setEndOffset(tokenAt(ast->lastToken()).bytesBegin()); _scope->addMember(block); ast->symbol = block; @@ -1285,8 +1285,8 @@ bool Bind::visit(RangeBasedForStatementAST *ast) { Block *block = control()->newBlock(ast->firstToken()); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken(); - block->setStartOffset(tokenAt(startScopeToken).end()); - block->setEndOffset(tokenAt(ast->lastToken()).begin()); + block->setStartOffset(tokenAt(startScopeToken).bytesEnd()); + block->setEndOffset(tokenAt(ast->lastToken()).bytesBegin()); _scope->addMember(block); ast->symbol = block; @@ -1334,8 +1334,8 @@ bool Bind::visit(ForStatementAST *ast) { Block *block = control()->newBlock(ast->firstToken()); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken(); - block->setStartOffset(tokenAt(startScopeToken).end()); - block->setEndOffset(tokenAt(ast->lastToken()).begin()); + block->setStartOffset(tokenAt(startScopeToken).bytesEnd()); + block->setEndOffset(tokenAt(ast->lastToken()).bytesBegin()); _scope->addMember(block); ast->symbol = block; @@ -1354,8 +1354,8 @@ bool Bind::visit(IfStatementAST *ast) { Block *block = control()->newBlock(ast->firstToken()); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken(); - block->setStartOffset(tokenAt(startScopeToken).end()); - block->setEndOffset(tokenAt(ast->lastToken()).begin()); + block->setStartOffset(tokenAt(startScopeToken).bytesEnd()); + block->setEndOffset(tokenAt(ast->lastToken()).bytesBegin()); _scope->addMember(block); ast->symbol = block; @@ -1410,8 +1410,8 @@ bool Bind::visit(SwitchStatementAST *ast) { Block *block = control()->newBlock(ast->firstToken()); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken(); - block->setStartOffset(tokenAt(startScopeToken).end()); - block->setEndOffset(tokenAt(ast->lastToken()).begin()); + block->setStartOffset(tokenAt(startScopeToken).bytesEnd()); + block->setEndOffset(tokenAt(ast->lastToken()).bytesBegin()); _scope->addMember(block); ast->symbol = block; @@ -1436,8 +1436,8 @@ bool Bind::visit(CatchClauseAST *ast) { Block *block = control()->newBlock(ast->firstToken()); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken(); - block->setStartOffset(tokenAt(startScopeToken).end()); - block->setEndOffset(tokenAt(ast->lastToken()).begin()); + block->setStartOffset(tokenAt(startScopeToken).bytesEnd()); + block->setEndOffset(tokenAt(ast->lastToken()).bytesBegin()); _scope->addMember(block); ast->symbol = block; @@ -1453,8 +1453,8 @@ bool Bind::visit(WhileStatementAST *ast) { Block *block = control()->newBlock(ast->firstToken()); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken(); - block->setStartOffset(tokenAt(startScopeToken).end()); - block->setEndOffset(tokenAt(ast->lastToken()).begin()); + block->setStartOffset(tokenAt(startScopeToken).bytesEnd()); + block->setEndOffset(tokenAt(ast->lastToken()).bytesBegin()); _scope->addMember(block); ast->symbol = block; @@ -1469,8 +1469,8 @@ bool Bind::visit(ObjCFastEnumerationAST *ast) { Block *block = control()->newBlock(ast->firstToken()); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken(); - block->setStartOffset(tokenAt(startScopeToken).end()); - block->setEndOffset(tokenAt(ast->lastToken()).begin()); + block->setStartOffset(tokenAt(startScopeToken).bytesEnd()); + block->setEndOffset(tokenAt(ast->lastToken()).bytesBegin()); _scope->addMember(block); ast->symbol = block; @@ -2139,7 +2139,7 @@ bool Bind::visit(FunctionDefinitionAST *ast) if (fun) { setDeclSpecifiers(fun, declSpecifiers); - fun->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + fun->setEndOffset(tokenAt(ast->lastToken() - 1).bytesEnd()); if (_scope->isClass()) { fun->setVisibility(_visibility); @@ -2201,8 +2201,8 @@ bool Bind::visit(NamespaceAST *ast) } Namespace *ns = control()->newNamespace(sourceLocation, namespaceName); - ns->setStartOffset(tokenAt(sourceLocation).end()); // the scope starts after the namespace or the identifier token. - ns->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + ns->setStartOffset(tokenAt(sourceLocation).bytesEnd()); // the scope starts after the namespace or the identifier token. + ns->setEndOffset(tokenAt(ast->lastToken() - 1).bytesEnd()); ns->setInline(ast->inline_token != 0); ast->symbol = ns; _scope->addMember(ns); @@ -2261,8 +2261,8 @@ bool Bind::visit(ParameterDeclarationAST *ast) bool Bind::visit(TemplateDeclarationAST *ast) { Template *templ = control()->newTemplate(ast->firstToken(), 0); - templ->setStartOffset(tokenAt(ast->firstToken()).begin()); - templ->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + templ->setStartOffset(tokenAt(ast->firstToken()).bytesBegin()); + templ->setEndOffset(tokenAt(ast->lastToken() - 1).bytesEnd()); ast->symbol = templ; Scope *previousScope = switchScope(templ); @@ -2375,34 +2375,34 @@ unsigned Bind::calculateScopeStart(ObjCClassDeclarationAST *ast) const { if (ast->inst_vars_decl) if (unsigned pos = ast->inst_vars_decl->lbrace_token) - return tokenAt(pos).end(); + return tokenAt(pos).bytesEnd(); if (ast->protocol_refs) if (unsigned pos = ast->protocol_refs->lastToken()) - return tokenAt(pos - 1).end(); + return tokenAt(pos - 1).bytesEnd(); if (ast->superclass) if (unsigned pos = ast->superclass->lastToken()) - return tokenAt(pos - 1).end(); + return tokenAt(pos - 1).bytesEnd(); if (ast->colon_token) - return tokenAt(ast->colon_token).end(); + return tokenAt(ast->colon_token).bytesEnd(); if (ast->rparen_token) - return tokenAt(ast->rparen_token).end(); + return tokenAt(ast->rparen_token).bytesEnd(); if (ast->category_name) if (unsigned pos = ast->category_name->lastToken()) - return tokenAt(pos - 1).end(); + return tokenAt(pos - 1).bytesEnd(); if (ast->lparen_token) - return tokenAt(ast->lparen_token).end(); + return tokenAt(ast->lparen_token).bytesEnd(); if (ast->class_name) if (unsigned pos = ast->class_name->lastToken()) - return tokenAt(pos - 1).end(); + return tokenAt(pos - 1).bytesEnd(); - return tokenAt(ast->firstToken()).begin(); + return tokenAt(ast->firstToken()).bytesBegin(); } bool Bind::visit(ObjCClassDeclarationAST *ast) @@ -2420,7 +2420,7 @@ bool Bind::visit(ObjCClassDeclarationAST *ast) _scope->addMember(klass); klass->setStartOffset(calculateScopeStart(ast)); - klass->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + klass->setEndOffset(tokenAt(ast->lastToken() - 1).bytesEnd()); if (ast->interface_token) klass->setInterface(true); @@ -2479,12 +2479,12 @@ unsigned Bind::calculateScopeStart(ObjCProtocolDeclarationAST *ast) const { if (ast->protocol_refs) if (unsigned pos = ast->protocol_refs->lastToken()) - return tokenAt(pos - 1).end(); + return tokenAt(pos - 1).bytesEnd(); if (ast->name) if (unsigned pos = ast->name->lastToken()) - return tokenAt(pos - 1).end(); + return tokenAt(pos - 1).bytesEnd(); - return tokenAt(ast->firstToken()).begin(); + return tokenAt(ast->firstToken()).bytesBegin(); } bool Bind::visit(ObjCProtocolDeclarationAST *ast) @@ -2499,7 +2499,7 @@ bool Bind::visit(ObjCProtocolDeclarationAST *ast) const unsigned sourceLocation = location(ast->name, ast->firstToken()); ObjCProtocol *protocol = control()->newObjCProtocol(sourceLocation, name); protocol->setStartOffset(calculateScopeStart(ast)); - protocol->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + protocol->setEndOffset(tokenAt(ast->lastToken() - 1).bytesEnd()); ast->symbol = protocol; _scope->addMember(protocol); @@ -2920,7 +2920,7 @@ bool Bind::visit(ClassSpecifierAST *ast) { // unsigned classkey_token = ast->classkey_token; unsigned sourceLocation = ast->firstToken(); - unsigned startScopeOffset = tokenAt(sourceLocation).end(); // at the end of the class key + unsigned startScopeOffset = tokenAt(sourceLocation).bytesEnd(); // at the end of the class key for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) { _type = this->specifier(it->value, _type); @@ -2930,12 +2930,12 @@ bool Bind::visit(ClassSpecifierAST *ast) if (ast->name && ! ast->name->asAnonymousName()) { sourceLocation = location(ast->name, sourceLocation); - startScopeOffset = tokenAt(sourceLocation).end(); // at the end of the class name + startScopeOffset = tokenAt(sourceLocation).bytesEnd(); // at the end of the class name if (QualifiedNameAST *q = ast->name->asQualifiedName()) { if (q->unqualified_name) { sourceLocation = q->unqualified_name->firstToken(); - startScopeOffset = tokenAt(q->unqualified_name->lastToken() - 1).end(); // at the end of the unqualified name + startScopeOffset = tokenAt(q->unqualified_name->lastToken() - 1).bytesEnd(); // at the end of the unqualified name } } @@ -2944,7 +2944,7 @@ bool Bind::visit(ClassSpecifierAST *ast) Class *klass = control()->newClass(sourceLocation, className); klass->setStartOffset(startScopeOffset); - klass->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + klass->setEndOffset(tokenAt(ast->lastToken() - 1).bytesEnd()); _scope->addMember(klass); if (_scope->isClass()) @@ -3003,8 +3003,8 @@ bool Bind::visit(EnumSpecifierAST *ast) const Name *enumName = this->name(ast->name); Enum *e = control()->newEnum(sourceLocation, enumName); - e->setStartOffset(tokenAt(sourceLocation).end()); // at the end of the enum or identifier token. - e->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + e->setStartOffset(tokenAt(sourceLocation).bytesEnd()); // at the end of the enum or identifier token. + e->setEndOffset(tokenAt(ast->lastToken() - 1).bytesEnd()); if (ast->key_token) e->setScoped(true); ast->symbol = e; @@ -3126,8 +3126,8 @@ bool Bind::visit(NestedDeclaratorAST *ast) bool Bind::visit(FunctionDeclaratorAST *ast) { Function *fun = control()->newFunction(0, 0); - fun->setStartOffset(tokenAt(ast->firstToken()).begin()); - fun->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + fun->setStartOffset(tokenAt(ast->firstToken()).bytesBegin()); + fun->setEndOffset(tokenAt(ast->lastToken() - 1).bytesEnd()); if (ast->trailing_return_type) _type = this->trailingReturnType(ast->trailing_return_type, _type); fun->setReturnType(_type); diff --git a/src/libs/3rdparty/cplusplus/Lexer.cpp b/src/libs/3rdparty/cplusplus/Lexer.cpp index c1cec4a756..f2729fa531 100644 --- a/src/libs/3rdparty/cplusplus/Lexer.cpp +++ b/src/libs/3rdparty/cplusplus/Lexer.cpp @@ -108,7 +108,7 @@ void Lexer::scan(Token *tok) { tok->reset(); scan_helper(tok); - tok->f.length = _currentChar - _tokenStart; + tok->f.bytes = _currentChar - _tokenStart; } void Lexer::scan_helper(Token *tok) @@ -141,7 +141,7 @@ void Lexer::scan_helper(Token *tok) tok->lineno = _currentLine; _tokenStart = _currentChar; - tok->offset = _currentChar - _firstChar; + tok->byteOffset = _currentChar - _firstChar; if (_yychar) { s._newlineExpected = false; diff --git a/src/libs/3rdparty/cplusplus/Symbol.cpp b/src/libs/3rdparty/cplusplus/Symbol.cpp index f3a86e6a8b..5c262b79f5 100644 --- a/src/libs/3rdparty/cplusplus/Symbol.cpp +++ b/src/libs/3rdparty/cplusplus/Symbol.cpp @@ -166,7 +166,7 @@ void Symbol::setSourceLocation(unsigned sourceLocation, TranslationUnit *transla if (translationUnit) { const Token &tk = translationUnit->tokenAt(sourceLocation); _isGenerated = tk.generated(); - translationUnit->getPosition(tk.begin(), &_line, &_column, &_fileId); + translationUnit->getPosition(tk.bytesBegin(), &_line, &_column, &_fileId); } else { _isGenerated = false; _line = 0; diff --git a/src/libs/3rdparty/cplusplus/Token.cpp b/src/libs/3rdparty/cplusplus/Token.cpp index 1469edea7f..57e36c3ea5 100644 --- a/src/libs/3rdparty/cplusplus/Token.cpp +++ b/src/libs/3rdparty/cplusplus/Token.cpp @@ -84,7 +84,7 @@ const char *token_names[] = { void Token::reset() { flags = 0; - offset = 0; + byteOffset = 0; ptr = 0; } diff --git a/src/libs/3rdparty/cplusplus/Token.h b/src/libs/3rdparty/cplusplus/Token.h index 8889df0653..02d7f5ebe9 100644 --- a/src/libs/3rdparty/cplusplus/Token.h +++ b/src/libs/3rdparty/cplusplus/Token.h @@ -285,7 +285,7 @@ enum Kind { class CPLUSPLUS_EXPORT Token { public: - Token() : flags(0), offset(0), ptr(0) {} + Token() : flags(0), byteOffset(0), ptr(0) {} inline bool is(unsigned k) const { return f.kind == k; } inline bool isNot(unsigned k) const { return f.kind != k; } @@ -298,13 +298,13 @@ public: inline bool joined() const { return f.joined; } inline bool expanded() const { return f.expanded; } inline bool generated() const { return f.generated; } - inline unsigned length() const { return f.length; } + inline unsigned bytes() const { return f.bytes; } - inline unsigned begin() const - { return offset; } + inline unsigned bytesBegin() const + { return byteOffset; } - inline unsigned end() const - { return offset + f.length; } + inline unsigned bytesEnd() const + { return byteOffset + f.bytes; } inline bool isLiteral() const { return f.kind >= T_FIRST_LITERAL && f.kind <= T_LAST_LITERAL; } @@ -333,15 +333,15 @@ public: public: struct Flags { // The token kind. - unsigned kind : 8; + unsigned kind : 8; // The token starts a new line. - unsigned newline : 1; - // The token is preceded by whitespace(s). - unsigned whitespace : 1; + unsigned newline : 1; + // The token is preceeded by whitespace(s). + unsigned whitespace : 1; // The token is joined with the previous one. - unsigned joined : 1; + unsigned joined : 1; // The token originates from a macro expansion. - unsigned expanded : 1; + unsigned expanded : 1; // The token originates from a macro expansion and does not correspond to an // argument that went through substitution. Notice the example: // @@ -351,18 +351,18 @@ public: // After preprocessing we would expect the following tokens: 1 + 2; // Tokens '1', '+', '2', and ';' are all expanded. However only tokens '+' and ';' // are generated. - unsigned generated : 1; + unsigned generated : 1; // Unused... - unsigned pad : 3; - // The token length. - unsigned length : 16; + unsigned pad : 3; + // The token length in bytes. + unsigned bytes : 16; }; union { unsigned flags; Flags f; }; - unsigned offset; + unsigned byteOffset; union { void *ptr; diff --git a/src/libs/3rdparty/cplusplus/TranslationUnit.cpp b/src/libs/3rdparty/cplusplus/TranslationUnit.cpp index 226e25e44e..91d5101955 100644 --- a/src/libs/3rdparty/cplusplus/TranslationUnit.cpp +++ b/src/libs/3rdparty/cplusplus/TranslationUnit.cpp @@ -164,7 +164,7 @@ void TranslationUnit::tokenize() _Lrecognize: if (tk.is(T_POUND) && tk.newline()) { - unsigned offset = tk.begin(); + unsigned offset = tk.byteOffset; lex(&tk); if (! tk.newline() && tk.is(T_IDENTIFIER) && tk.identifier == expansionId) { @@ -264,7 +264,7 @@ void TranslationUnit::tokenize() currentExpanded = true; const std::pair<unsigned, unsigned> &p = lineColumn[lineColumnIdx]; if (p.first) - _expandedLineColumn.insert(std::make_pair(tk.begin(), p)); + _expandedLineColumn.insert(std::make_pair(tk.bytesBegin(), p)); else currentGenerated = true; @@ -382,17 +382,17 @@ void TranslationUnit::getTokenPosition(unsigned index, unsigned *line, unsigned *column, const StringLiteral **fileName) const -{ return getPosition(tokenAt(index).begin(), line, column, fileName); } +{ return getPosition(tokenAt(index).bytesBegin(), line, column, fileName); } void TranslationUnit::getTokenStartPosition(unsigned index, unsigned *line, unsigned *column, const StringLiteral **fileName) const -{ return getPosition(tokenAt(index).begin(), line, column, fileName); } +{ return getPosition(tokenAt(index).bytesBegin(), line, column, fileName); } void TranslationUnit::getTokenEndPosition(unsigned index, unsigned *line, unsigned *column, const StringLiteral **fileName) const -{ return getPosition(tokenAt(index).end(), line, column, fileName); } +{ return getPosition(tokenAt(index).bytesEnd(), line, column, fileName); } void TranslationUnit::getPosition(unsigned tokenOffset, unsigned *line, @@ -508,7 +508,7 @@ void TranslationUnit::fatal(unsigned index, const char *format, ...) unsigned TranslationUnit::findPreviousLineOffset(unsigned tokenIndex) const { - unsigned lineOffset = _lineOffsets[findLineNumber(tokenAt(tokenIndex).begin())]; + unsigned lineOffset = _lineOffsets[findLineNumber(tokenAt(tokenIndex).bytesBegin())]; return lineOffset; } @@ -521,21 +521,21 @@ bool TranslationUnit::maybeSplitGreaterGreaterToken(unsigned tokenIndex) return false; tok.f.kind = T_GREATER; - tok.f.length = 1; + tok.f.bytes = 1; Token newGreater; newGreater.f.kind = T_GREATER; newGreater.f.expanded = tok.expanded(); newGreater.f.generated = tok.generated(); - newGreater.f.length = 1; - newGreater.offset = tok.offset + 1; + newGreater.f.bytes = 1; + newGreater.byteOffset = tok.byteOffset + 1; _tokens->insert(_tokens->begin() + tokenIndex + 1, newGreater); - TokenLineColumn::const_iterator it = _expandedLineColumn.find(tok.begin()); + TokenLineColumn::const_iterator it = _expandedLineColumn.find(tok.bytesBegin()); if (it != _expandedLineColumn.end()) { const std::pair<unsigned, unsigned> newPosition(it->second.first, it->second.second + 1); - _expandedLineColumn.insert(std::make_pair(newGreater.begin(), newPosition)); + _expandedLineColumn.insert(std::make_pair(newGreater.bytesBegin(), newPosition)); } return true; @@ -551,7 +551,7 @@ void TranslationUnit::releaseTokensAndComments() void TranslationUnit::showErrorLine(unsigned index, unsigned column, FILE *out) { - unsigned lineOffset = _lineOffsets[findLineNumber(tokenAt(index).begin())]; + unsigned lineOffset = _lineOffsets[findLineNumber(tokenAt(index).bytesBegin())]; for (const char *cp = _firstSourceChar + lineOffset + 1; *cp && *cp != '\n'; ++cp) { fputc(*cp, out); } diff --git a/src/libs/cplusplus/BackwardsScanner.cpp b/src/libs/cplusplus/BackwardsScanner.cpp index ee7f03737a..a979c39eb1 100644 --- a/src/libs/cplusplus/BackwardsScanner.cpp +++ b/src/libs/cplusplus/BackwardsScanner.cpp @@ -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); } diff --git a/src/libs/cplusplus/ExpressionUnderCursor.cpp b/src/libs/cplusplus/ExpressionUnderCursor.cpp index fefb55347e..93176362be 100644 --- a/src/libs/cplusplus/ExpressionUnderCursor.cpp +++ b/src/libs/cplusplus/ExpressionUnderCursor.cpp @@ -266,7 +266,7 @@ int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) const if (tk.is(T_EOF_SYMBOL)) { break; } else if (tk.is(T_LPAREN)) { - return scanner.startPosition() + tk.begin(); + return scanner.startPosition() + tk.bytesBegin(); } else if (tk.is(T_RPAREN)) { int matchingBrace = scanner.startOfMatchingBrace(index); diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp index 383bd3dad7..91fa156c2f 100644 --- a/src/libs/cplusplus/FindUsages.cpp +++ b/src/libs/cplusplus/FindUsages.cpp @@ -140,7 +140,7 @@ void FindUsages::reportResult(unsigned tokenIndex, const QList<LookupItem> &cand QString FindUsages::matchingLine(const Token &tk) const { const char *beg = _source.constData(); - const char *cp = beg + tk.begin(); + const char *cp = beg + tk.bytesBegin(); for (; cp != beg - 1; --cp) { if (*cp == '\n') break; @@ -178,7 +178,7 @@ void FindUsages::reportResult(unsigned tokenIndex) if (col) --col; // adjust the column position. - const int len = tk.length(); + const int len = tk.bytes(); const Usage u(_doc->fileName(), lineText, line, col, len); _usages.append(u); @@ -259,8 +259,8 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const void FindUsages::checkExpression(unsigned startToken, unsigned endToken, Scope *scope) { - const unsigned begin = tokenAt(startToken).begin(); - const unsigned end = tokenAt(endToken).end(); + const unsigned begin = tokenAt(startToken).bytesBegin(); + const unsigned end = tokenAt(endToken).bytesEnd(); const QByteArray expression = _source.mid(begin, end - begin); // qDebug() << "*** check expression:" << expression; diff --git a/src/libs/cplusplus/PPToken.cpp b/src/libs/cplusplus/PPToken.cpp index 7b34c1ed35..fdfaacd2bd 100644 --- a/src/libs/cplusplus/PPToken.cpp +++ b/src/libs/cplusplus/PPToken.cpp @@ -55,8 +55,8 @@ int ByteArrayRef::count(char ch) const void Internal::PPToken::squeezeSource() { if (hasSource()) { - m_src = m_src.mid(offset, f.length); + m_src = m_src.mid(byteOffset, f.bytes); m_src.squeeze(); - offset = 0; + byteOffset = 0; } } diff --git a/src/libs/cplusplus/PPToken.h b/src/libs/cplusplus/PPToken.h index 1168fc90a4..fdb700d378 100644 --- a/src/libs/cplusplus/PPToken.h +++ b/src/libs/cplusplus/PPToken.h @@ -129,10 +129,10 @@ public: { return m_src.constData(); } const char *tokenStart() const - { return bufferStart() + offset; } + { return bufferStart() + byteOffset; } ByteArrayRef asByteArrayRef() const - { return ByteArrayRef(&m_src, offset, length()); } + { return ByteArrayRef(&m_src, byteOffset, bytes()); } private: QByteArray m_src; diff --git a/src/libs/cplusplus/SimpleLexer.cpp b/src/libs/cplusplus/SimpleLexer.cpp index 6ab2f4db91..26030ae09f 100644 --- a/src/libs/cplusplus/SimpleLexer.cpp +++ b/src/libs/cplusplus/SimpleLexer.cpp @@ -89,7 +89,7 @@ QList<Token> SimpleLexer::operator()(const QString &text, int state) break; } - QStringRef spell = text.midRef(tk.begin(), tk.length()); + QStringRef spell = text.midRef(tk.bytesBegin(), tk.bytes()); lex.setScanAngleStringLiteralTokens(false); if (tk.newline() && tk.is(T_POUND)) @@ -116,7 +116,7 @@ int SimpleLexer::tokenAt(const QList<Token> &tokens, unsigned offset) { for (int index = tokens.size() - 1; index >= 0; --index) { const Token &tk = tokens.at(index); - if (tk.begin() <= offset && tk.end() >= offset) + if (tk.bytesBegin() <= offset && tk.bytesEnd() >= offset) return index; } @@ -144,7 +144,7 @@ int SimpleLexer::tokenBefore(const QList<Token> &tokens, unsigned offset) { for (int index = tokens.size() - 1; index >= 0; --index) { const Token &tk = tokens.at(index); - if (tk.begin() <= offset) + if (tk.bytesBegin() <= offset) return index; } diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 942f3e5315..b32bb9dda4 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -303,7 +303,7 @@ public: : first(first), last(last) { // WARN: `last' must be a valid iterator. - trivial.offset = last->offset; + trivial.byteOffset = last->byteOffset; } inline operator bool() const @@ -384,12 +384,12 @@ protected: const char *tokenPosition() const { - return source.constData() + (*_lex)->offset; + return source.constData() + (*_lex)->byteOffset; } int tokenLength() const { - return (*_lex)->f.length; + return (*_lex)->f.bytes; } ByteArrayRef tokenSpell() const @@ -421,7 +421,7 @@ protected: ++(*_lex); if ((*_lex)->is(T_IDENTIFIER)) { _value.set_long(macroDefinition(tokenSpell(), - (*_lex)->offset, + (*_lex)->byteOffset, (*_lex)->lineno, env, client) != 0); ++(*_lex); @@ -429,7 +429,7 @@ protected: ++(*_lex); if ((*_lex)->is(T_IDENTIFIER)) { _value.set_long(macroDefinition(tokenSpell(), - (*_lex)->offset, + (*_lex)->byteOffset, (*_lex)->lineno, env, client) != 0); @@ -830,7 +830,7 @@ void Preprocessor::handleDefined(PPToken *tk) QByteArray result(1, '0'); const ByteArrayRef macroName = idToken.asByteArrayRef(); - if (macroDefinition(macroName, idToken.offset + m_state.m_offsetRef, + if (macroDefinition(macroName, idToken.byteOffset + m_state.m_offsetRef, idToken.lineno, m_env, m_client)) { result[0] = '1'; } @@ -881,7 +881,7 @@ _Lclassify: lex(tk); } while (isContinuationToken(*tk)); goto _Lclassify; - } else if (tk->is(T_IDENTIFIER) && !isQtReservedWord(tk->tokenStart(), tk->length())) { + } else if (tk->is(T_IDENTIFIER) && !isQtReservedWord(tk->tokenStart(), tk->bytes())) { m_state.updateIncludeGuardState(State::IncludeGuardStateHint_OtherToken); if (m_state.m_inCondition && tk->asByteArrayRef() == "defined") { handleDefined(tk); @@ -904,7 +904,7 @@ void Preprocessor::skipPreprocesorDirective(PPToken *tk) if (tk->isComment()) { synchronizeOutputLines(*tk); enforceSpacing(*tk, true); - currentOutputBuffer().append(tk->tokenStart(), tk->length()); + currentOutputBuffer().append(tk->tokenStart(), tk->bytes()); } lex(tk); } @@ -984,7 +984,7 @@ bool Preprocessor::handleIdentifier(PPToken *tk) if (!expandFunctionlikeMacros() // Still expand if this originally started with an object-like macro. && m_state.m_expansionStatus != Expanding) { - m_client->notifyMacroReference(m_state.m_offsetRef + idTk.offset, + m_client->notifyMacroReference(m_state.m_offsetRef + idTk.byteOffset, idTk.lineno, *macro); return false; @@ -1026,7 +1026,7 @@ bool Preprocessor::handleIdentifier(PPToken *tk) //### TODO: error message pushToken(tk); // If a previous marker was found, make sure to put it back. - if (oldMarkerTk.length()) + if (oldMarkerTk.bytes()) pushToken(&oldMarkerTk); *tk = idTk; return false; @@ -1044,13 +1044,13 @@ bool Preprocessor::handleIdentifier(PPToken *tk) } else { argRefs.push_back(MacroArgumentReference( - m_state.m_offsetRef + argTks.first().begin(), - argTks.last().begin() + argTks.last().length() - - argTks.first().begin())); + m_state.m_offsetRef + argTks.first().bytesBegin(), + argTks.last().bytesBegin() + argTks.last().bytes() + - argTks.first().bytesBegin())); } } - m_client->startExpandingMacro(m_state.m_offsetRef + idTk.offset, + m_client->startExpandingMacro(m_state.m_offsetRef + idTk.byteOffset, idTk.lineno, *macro, argRefs); @@ -1058,11 +1058,11 @@ bool Preprocessor::handleIdentifier(PPToken *tk) if (!handleFunctionLikeMacro(macro, body, allArgTks, baseLine)) { if (m_client && !idTk.expanded()) - m_client->stopExpandingMacro(idTk.offset, *macro); + m_client->stopExpandingMacro(idTk.byteOffset, *macro); return false; } } else if (m_client && !idTk.generated()) { - m_client->startExpandingMacro(m_state.m_offsetRef + idTk.offset, idTk.lineno, *macro); + m_client->startExpandingMacro(m_state.m_offsetRef + idTk.byteOffset, idTk.lineno, *macro); } if (body.isEmpty()) { @@ -1072,7 +1072,7 @@ bool Preprocessor::handleIdentifier(PPToken *tk) // This is not the most beautiful approach but it's quite reasonable. What we do here // is to create a fake identifier token which is only composed by whitespaces. It's // also not marked as expanded so it it can be treated as a regular token. - const QByteArray content(int(idTk.length() + computeDistance(idTk)), ' '); + const QByteArray content(int(idTk.bytes() + computeDistance(idTk)), ' '); PPToken fakeIdentifier = generateToken(T_IDENTIFIER, content.constData(), content.length(), idTk.lineno, false, false); @@ -1105,13 +1105,13 @@ bool Preprocessor::handleIdentifier(PPToken *tk) || m_state.m_expansionStatus == JustFinishedExpansion) { PPToken marker; marker.f.expanded = true; - marker.f.length = idTk.length(); - marker.offset = idTk.offset; + marker.f.bytes = idTk.bytes(); + marker.byteOffset = idTk.byteOffset; marker.lineno = idTk.lineno; body.prepend(marker); body.append(marker); m_state.setExpansionStatus(ReadyForExpansion); - } else if (oldMarkerTk.length() + } else if (oldMarkerTk.bytes() && (m_state.m_expansionStatus == ReadyForExpansion || m_state.m_expansionStatus == Expanding)) { body.append(oldMarkerTk); @@ -1122,7 +1122,7 @@ bool Preprocessor::handleIdentifier(PPToken *tk) m_state.pushTokenBuffer(body.begin(), body.end(), macro); if (m_client && !idTk.generated()) - m_client->stopExpandingMacro(idTk.offset, *macro); + m_client->stopExpandingMacro(idTk.byteOffset, *macro); return true; } @@ -1170,7 +1170,7 @@ bool Preprocessor::handleFunctionLikeMacro(const Macro *macro, lineno = t.lineno; else if (t.whitespace()) enclosedString.append(' '); - enclosedString.append(t.tokenStart(), t.length()); + enclosedString.append(t.tokenStart(), t.bytes()); } enclosedString.replace("\\", "\\\\"); enclosedString.replace("\"", "\\\""); @@ -1269,7 +1269,8 @@ void Preprocessor::trackExpansionCycles(PPToken *tk) // Offset and length of the macro invocation char chunk[40]; - qsnprintf(chunk, sizeof(chunk), "# expansion begin %d,%d", tk->offset, tk->length()); + qsnprintf(chunk, sizeof(chunk), "# expansion begin %d,%d", tk->byteOffset, + tk->bytes()); buffer.append(chunk); // Expanded tokens @@ -1437,7 +1438,7 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source, enforceSpacing(tk, macroExpanded); // Finally output the token. - currentOutputBuffer().append(tk.tokenStart(), tk.length()); + currentOutputBuffer().append(tk.tokenStart(), tk.bytes()); } while (tk.isNot(T_EOF_SYMBOL)); @@ -1512,7 +1513,8 @@ void Preprocessor::scanActualArgument(PPToken *tk, QVector<PPToken> *tokens) // expansion. We stick with GCC's approach which is to replace them by C style // comments (currently clang just gets rid of them) and transform internals */ // into *|. - QByteArray text = m_state.m_source.mid(tk->begin() + 2, tk->end() - tk->begin() - 2); + QByteArray text = m_state.m_source.mid(tk->bytesBegin() + 2, + tk->bytesEnd() - tk->bytesBegin() - 2); const QByteArray &comment = "/*" + text.replace("*/", "*|") + "*/"; tokens->append(generateToken(T_COMMENT, comment.constData(), comment.size(), @@ -1625,7 +1627,7 @@ void Preprocessor::handleIncludeDirective(PPToken *tk, bool includeNext) void Preprocessor::handleDefineDirective(PPToken *tk) { - const unsigned defineOffset = tk->offset; + const unsigned defineOffset = tk->byteOffset; lex(tk); // consume "define" token if (tk->isNot(T_IDENTIFIER)) @@ -1636,7 +1638,7 @@ void Preprocessor::handleDefineDirective(PPToken *tk) macro.setLine(tk->lineno); QByteArray macroName = tk->asByteArrayRef().toByteArray(); macro.setName(macroName); - macro.setOffset(tk->offset); + macro.setOffset(tk->byteOffset); PPToken idToken(*tk); @@ -1697,7 +1699,7 @@ void Preprocessor::handleDefineDirective(PPToken *tk) macroReference = m_env->resolve(tk->asByteArrayRef()); if (macroReference) { if (!macroReference->isFunctionLike()) { - m_client->notifyMacroReference(tk->offset, tk->lineno, *macroReference); + m_client->notifyMacroReference(tk->byteOffset, tk->lineno, *macroReference); macroReference = 0; } } @@ -1707,14 +1709,14 @@ void Preprocessor::handleDefineDirective(PPToken *tk) macroReference = 0; } - previousOffset = tk->offset; + previousOffset = tk->byteOffset; previousLine = tk->lineno; // Discard comments in macro definitions (keep comments flag doesn't apply here). if (tk->isComment()) { synchronizeOutputLines(*tk); enforceSpacing(*tk, true); - currentOutputBuffer().append(tk->tokenStart(), tk->length()); + currentOutputBuffer().append(tk->tokenStart(), tk->bytes()); } else { bodyTokens.push_back(*tk); } @@ -1741,8 +1743,8 @@ void Preprocessor::handleDefineDirective(PPToken *tk) macro.setDefinition(macroId, bodyTokens); } else if (!bodyTokens.isEmpty()) { PPToken &firstBodyToken = bodyTokens[0]; - int start = firstBodyToken.offset; - int len = tk->offset - start; + int start = firstBodyToken.byteOffset; + int len = tk->byteOffset - start; QByteArray bodyText = firstBodyToken.source().mid(start, len).trimmed(); const int bodySize = bodyTokens.size(); @@ -1754,7 +1756,7 @@ void Preprocessor::handleDefineDirective(PPToken *tk) macro.setDefinition(bodyText, bodyTokens); } - macro.setLength(tk->offset - defineOffset); + macro.setLength(tk->byteOffset - defineOffset); m_env->bind(macro); // qDebug() << "adding macro" << macro.name() << "defined at" << macro.fileName() << ":"<<macro.line(); @@ -1766,14 +1768,15 @@ void Preprocessor::handleDefineDirective(PPToken *tk) QByteArray Preprocessor::expand(PPToken *tk, PPToken *lastConditionToken) { unsigned line = tk->lineno; - unsigned begin = tk->begin(); + unsigned begin = tk->bytesBegin(); PPToken lastTk; while (isContinuationToken(*tk)) { lastTk = *tk; lex(tk); } // Gather the exact spelling of the content in the source. - QByteArray condition(m_state.m_source.mid(begin, lastTk.begin() + lastTk.length() - begin)); + QByteArray condition(m_state.m_source.mid(begin, lastTk.bytesBegin() + lastTk.bytes() + - begin)); // qDebug("*** Condition before: [%s]", condition.constData()); QByteArray result; @@ -1852,7 +1855,7 @@ void Preprocessor::handleElifDirective(PPToken *tk, const PPToken £Token) m_state.m_trueTest[m_state.m_ifLevel] = !startSkipping; m_state.m_skipping[m_state.m_ifLevel] = startSkipping; if (m_client && !startSkipping) - m_client->stopSkippingBlocks(poundToken.offset - 1); + m_client->stopSkippingBlocks(poundToken.byteOffset - 1); } } } @@ -1871,7 +1874,7 @@ void Preprocessor::handleElseDirective(PPToken *tk, const PPToken £Token) m_state.m_skipping[m_state.m_ifLevel] = startSkipping; if (m_client && wasSkipping && !startSkipping) - m_client->stopSkippingBlocks(poundToken.offset - 1); + m_client->stopSkippingBlocks(poundToken.byteOffset - 1); else if (m_client && !wasSkipping && startSkipping) startSkippingBlocks(poundToken); } @@ -1897,7 +1900,7 @@ void Preprocessor::handleEndIfDirective(PPToken *tk, const PPToken £Token) m_state.m_trueTest[m_state.m_ifLevel] = false; --m_state.m_ifLevel; if (m_client && wasSkipping && !m_state.m_skipping[m_state.m_ifLevel]) - m_client->stopSkippingBlocks(poundToken.offset - 1); + m_client->stopSkippingBlocks(poundToken.byteOffset - 1); if (m_state.m_ifLevel == 0) m_state.updateIncludeGuardState(State::IncludeGuardStateHint_Endif); @@ -1915,7 +1918,7 @@ void Preprocessor::handleIfDefDirective(bool checkUndefined, PPToken *tk) bool value = false; const ByteArrayRef macroName = tk->asByteArrayRef(); - if (Macro *macro = macroDefinition(macroName, tk->offset, tk->lineno, m_env, m_client)) { + if (Macro *macro = macroDefinition(macroName, tk->byteOffset, tk->lineno, m_env, m_client)) { value = true; // the macro is a feature constraint(e.g. QT_NO_XXX) @@ -1954,7 +1957,7 @@ void Preprocessor::handleUndefDirective(PPToken *tk) lex(tk); // consume "undef" token if (tk->is(T_IDENTIFIER)) { const ByteArrayRef macroName = tk->asByteArrayRef(); - const unsigned offset = tk->offset + m_state.m_offsetRef; + const unsigned offset = tk->byteOffset + m_state.m_offsetRef; // Track macro use if previously defined if (m_client) { if (const Macro *existingMacro = m_env->resolve(macroName)) @@ -2007,8 +2010,8 @@ PPToken Preprocessor::generateToken(enum Kind kind, else if (kind == T_NUMERIC_LITERAL) tk.number = m_state.m_lexer->control()->numericLiteral(m_scratchBuffer.constData() + pos, length); } - tk.offset = unsigned(pos); - tk.f.length = length; + tk.byteOffset = unsigned(pos); + tk.f.bytes = length; tk.f.generated = true; tk.f.expanded = true; tk.lineno = lineno; @@ -2019,9 +2022,9 @@ PPToken Preprocessor::generateToken(enum Kind kind, PPToken Preprocessor::generateConcatenated(const PPToken &leftTk, const PPToken &rightTk) { QByteArray newText; - newText.reserve(leftTk.length() + rightTk.length()); - newText.append(leftTk.tokenStart(), leftTk.length()); - newText.append(rightTk.tokenStart(), rightTk.length()); + newText.reserve(leftTk.bytes() + rightTk.bytes()); + newText.append(leftTk.tokenStart(), leftTk.bytes()); + newText.append(rightTk.tokenStart(), rightTk.bytes()); PPToken result = generateToken(T_IDENTIFIER, newText.constData(), newText.size(), leftTk.lineno, true); result.f.whitespace = leftTk.whitespace(); return result; @@ -2032,7 +2035,7 @@ void Preprocessor::startSkippingBlocks(const Preprocessor::PPToken &tk) const if (!m_client) return; - int iter = tk.end(); + int iter = tk.bytesEnd(); const QByteArray &txt = tk.source(); for (; iter < txt.size(); ++iter) { if (txt.at(iter) == '\n') { diff --git a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp index 7034ea64b9..ea7d9cf051 100644 --- a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp +++ b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp @@ -225,8 +225,10 @@ protected: // go through comments backwards to find the annotation closest to the call for (unsigned i = _doc->translationUnit()->commentCount(); i-- > 0; ) { const Token commentToken = _doc->translationUnit()->commentAt(i); - if (commentToken.begin() >= end.begin() || commentToken.end() <= begin.begin()) + if (commentToken.bytesBegin() >= end.bytesBegin() + || commentToken.bytesEnd() <= begin.bytesBegin()) { continue; + } const QString comment = stringOf(commentToken); if (uriAnnotation.indexIn(comment) != -1) { packageName = uriAnnotation.cap(1); @@ -274,7 +276,8 @@ protected: // and the expression const Token begin = translationUnit()->tokenAt(typeId->firstToken()); const Token last = translationUnit()->tokenAt(typeId->lastToken() - 1); - exportedType.typeExpression = QString::fromUtf8(_doc->utf8Source().mid(begin.begin(), last.end() - begin.begin())); + exportedType.typeExpression = QString::fromUtf8( + _doc->utf8Source().mid(begin.bytesBegin(), last.bytesEnd() - begin.bytesBegin())); _exportedTypes += exportedType; @@ -401,12 +404,14 @@ private: { const Token firstToken = translationUnit()->tokenAt(first); const Token lastToken = translationUnit()->tokenAt(last); - return QString::fromUtf8(_doc->utf8Source().mid(firstToken.begin(), lastToken.end() - firstToken.begin())); + return QString::fromUtf8( + _doc->utf8Source().mid(firstToken.bytesBegin(), + lastToken.bytesEnd() - firstToken.bytesBegin())); } QString stringOf(const Token &token) { - return QString::fromUtf8(_doc->utf8Source().mid(token.begin(), token.length())); + return QString::fromUtf8(_doc->utf8Source().mid(token.bytesBegin(), token.bytes())); } ExpressionAST *skipStringCall(ExpressionAST *exp) |