diff options
author | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-06-07 13:06:21 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-06-14 10:10:05 +0200 |
commit | e42ca194c53b8286447c7750feb8c7497c88e698 (patch) | |
tree | ab99d8feb411815c51f9d9a2b119aedd1a41244f /src/libs/cplusplus/MatchingText.cpp | |
parent | 2e1001621042a5704e504821fd5677733ffd9167 (diff) | |
download | qt-creator-e42ca194c53b8286447c7750feb8c7497c88e698.tar.gz |
Introduced token caching to prevent repetetive tokenizing.
Also removed TokenUnderCursor as it's functionality is in the token cache.
Reviewed-by: ckamm
Diffstat (limited to 'src/libs/cplusplus/MatchingText.cpp')
-rw-r--r-- | src/libs/cplusplus/MatchingText.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp index b0c5461f24..ed1b8c12b2 100644 --- a/src/libs/cplusplus/MatchingText.cpp +++ b/src/libs/cplusplus/MatchingText.cpp @@ -28,6 +28,7 @@ **************************************************************************/ #include "MatchingText.h" #include "BackwardsScanner.h" +#include "TokenCache.h" #include <Token.h> @@ -75,7 +76,8 @@ static bool isCompleteCharLiteral(const BackwardsScanner &tk, int index) return false; } -MatchingText::MatchingText() +MatchingText::MatchingText(TokenCache *tokenCache) + : _tokenCache(tokenCache) { } bool MatchingText::shouldInsertMatchingText(const QTextCursor &tc) @@ -151,7 +153,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri if (text.isEmpty() || !shouldInsertMatchingText(la)) return QString(); - BackwardsScanner tk(tc, textToProcess.left(*skippedChars), MAX_NUM_LINES); + BackwardsScanner tk(_tokenCache, tc, MAX_NUM_LINES, textToProcess.left(*skippedChars)); const int startToken = tk.startToken(); int index = startToken; @@ -211,7 +213,7 @@ bool MatchingText::shouldInsertNewline(const QTextCursor &tc) const QString MatchingText::insertParagraphSeparator(const QTextCursor &tc) const { - BackwardsScanner tk(tc, QString(), MAX_NUM_LINES); + BackwardsScanner tk(_tokenCache, tc, MAX_NUM_LINES); int index = tk.startToken(); if (tk[index - 1].isNot(T_LBRACE)) |