forked from qt-creator/qt-creator
C++: Fix unit-tests for MatchingText
BackwardScanner required more investigation and this is
the better fix than 413c66ec.
Change-Id: I651a7b416b549cc4a0e086873262d04409a7448e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -124,6 +124,11 @@ int BackwardsScanner::size() const
|
||||
return _tokens.size();
|
||||
}
|
||||
|
||||
int BackwardsScanner::offset() const
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
|
||||
int BackwardsScanner::startOfMatchingBrace(int index) const
|
||||
{
|
||||
const BackwardsScanner &tk = *this;
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
int startOfBlock(int index) const;
|
||||
|
||||
int size() const;
|
||||
int offset() const;
|
||||
|
||||
static int previousBlockState(const QTextBlock &block);
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ static bool isRecordLikeToken(const Token &token)
|
||||
|
||||
static bool isRecordLikeToken(const BackwardsScanner &tokens, int index)
|
||||
{
|
||||
if (index < tokens.size() - 1)
|
||||
if (index + tokens.offset() < tokens.size() - 1)
|
||||
return isRecordLikeToken(tokens[index]);
|
||||
return false;
|
||||
}
|
||||
@@ -347,7 +347,7 @@ static bool recordLikeMightFollowToken(const Token &token)
|
||||
|
||||
static bool isAfterRecordLikeDefinition(const BackwardsScanner &tokens, int index)
|
||||
{
|
||||
for (; index >= 0; --index) {
|
||||
for (;; --index) {
|
||||
if (recordLikeHasToFollowToken(tokens[index]))
|
||||
return isRecordLikeToken(tokens, index + 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user