From e42ca194c53b8286447c7750feb8c7497c88e698 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 7 Jun 2010 13:06:21 +0200 Subject: Introduced token caching to prevent repetetive tokenizing. Also removed TokenUnderCursor as it's functionality is in the token cache. Reviewed-by: ckamm --- src/libs/cplusplus/BackwardsScanner.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/libs/cplusplus/BackwardsScanner.h') diff --git a/src/libs/cplusplus/BackwardsScanner.h b/src/libs/cplusplus/BackwardsScanner.h index cca06db75c..25b7bd3289 100644 --- a/src/libs/cplusplus/BackwardsScanner.h +++ b/src/libs/cplusplus/BackwardsScanner.h @@ -36,16 +36,18 @@ namespace CPlusPlus { +class TokenCache; + class CPLUSPLUS_EXPORT BackwardsScanner { enum { MAX_BLOCK_COUNT = 10 }; public: - BackwardsScanner(const QTextCursor &cursor, - const QString &suffix = QString(), - int maxBlockCount = MAX_BLOCK_COUNT); + BackwardsScanner(TokenCache *cache, + const QTextCursor &cursor, + int maxBlockCount = MAX_BLOCK_COUNT, + const QString &suffix = QString()); - int state() const; int startToken() const; int startPosition() const; @@ -67,20 +69,18 @@ public: int startOfMatchingBrace(int index) const; int startOfBlock(int index) const; - static int previousBlockState(const QTextBlock &block); - int size() const; private: const SimpleToken &fetchToken(int tokenIndex); private: + TokenCache *_tokenCache; QList _tokens; int _offset; int _blocksTokenized; QTextBlock _block; QString _text; - SimpleLexer _tokenize; int _maxBlockCount; int _startToken; }; -- cgit v1.2.1