Introduced token caching to prevent repetetive tokenizing.

Also removed TokenUnderCursor as it's functionality is in the token cache.

Reviewed-by: ckamm
This commit is contained in:
Erik Verbruggen
2010-06-07 13:06:21 +02:00
parent 2e10016210
commit e42ca194c5
25 changed files with 273 additions and 242 deletions

View File

@@ -30,6 +30,7 @@
#include "ExpressionUnderCursor.h"
#include "SimpleLexer.h"
#include "BackwardsScanner.h"
#include "TokenCache.h"
#include <Token.h>
#include <QTextCursor>
@@ -37,8 +38,8 @@
using namespace CPlusPlus;
ExpressionUnderCursor::ExpressionUnderCursor()
: _jumpedComma(false)
ExpressionUnderCursor::ExpressionUnderCursor(TokenCache *tokenCache)
: _tokenCache(tokenCache), _jumpedComma(false)
{ }
ExpressionUnderCursor::~ExpressionUnderCursor()
@@ -218,7 +219,7 @@ bool ExpressionUnderCursor::isAccessToken(const SimpleToken &tk)
QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
{
BackwardsScanner scanner(cursor);
BackwardsScanner scanner(_tokenCache, cursor);
_jumpedComma = false;
@@ -232,7 +233,7 @@ QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) const
{
BackwardsScanner scanner(cursor);
BackwardsScanner scanner(_tokenCache, cursor);
int index = scanner.startToken();