forked from qt-creator/qt-creator
C++: Use Utils::transform() in BackwardsScanner
Change-Id: Iec2c2db7afd8e5fe463a32c6b5167592cdd7617c Reviewed-by: Laurent Montel <laurent.montel@kdab.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
01b2ed7904
commit
2f8c2d8864
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include <cplusplus/Token.h>
|
#include <cplusplus/Token.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
|
|
||||||
@@ -75,12 +77,11 @@ const Token &BackwardsScanner::fetchToken(int tokenIndex)
|
|||||||
_text.prepend(QLatin1Char('\n'));
|
_text.prepend(QLatin1Char('\n'));
|
||||||
_text.prepend(blockText);
|
_text.prepend(blockText);
|
||||||
|
|
||||||
Tokens adaptedTokens;
|
const int offset = blockText.length() + 1;
|
||||||
for (int i = 0; i < _tokens.size(); ++i) {
|
const Tokens adaptedTokens = Utils::transform(_tokens, [offset](Token token) {
|
||||||
Token t = _tokens.at(i);
|
token.utf16charOffset += unsigned(offset);
|
||||||
t.utf16charOffset += blockText.length() + 1;
|
return token;
|
||||||
adaptedTokens.append(t);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
_tokens = _tokenize(blockText, previousBlockState(_block));
|
_tokens = _tokenize(blockText, previousBlockState(_block));
|
||||||
_offset += _tokens.size();
|
_offset += _tokens.size();
|
||||||
|
|||||||
Reference in New Issue
Block a user