Introduced a backwards scanner for finding expression under cursor

The backwards scanner lazily tokenizes strings. This optimizes the
common case where scanning one or two lines is enough while at the same
time we extended the limit from 5 to 10 lines.

Reviewed-by: Roberto Raggi
This commit is contained in:
Thorbjørn Lindeijer
2009-05-27 14:32:09 +02:00
parent b93c9ce347
commit 878bc07201
3 changed files with 112 additions and 80 deletions

View File

@@ -41,6 +41,7 @@ QT_END_NAMESPACE
namespace CPlusPlus {
class BackwardsScanner;
class SimpleToken;
class CPLUSPLUS_EXPORT ExpressionUnderCursor
@@ -53,13 +54,8 @@ public:
int startOfFunctionCall(const QTextCursor &cursor);
private:
void init(const QTextCursor &cursor,
QList<SimpleToken> *tokens,
QString *text,
int *startPosition = 0);
int startOfMatchingBrace(const QList<SimpleToken> &tk, int index);
int startOfExpression(const QList<SimpleToken> &tk, int index);
int startOfMatchingBrace(BackwardsScanner &tk, int index);
int startOfExpression(BackwardsScanner &tk, int index);
int previousBlockState(const QTextBlock &block);
bool isAccessToken(const SimpleToken &tk);