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/TokenCache.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/libs/cplusplus/TokenCache.h (limited to 'src/libs/cplusplus/TokenCache.h') diff --git a/src/libs/cplusplus/TokenCache.h b/src/libs/cplusplus/TokenCache.h new file mode 100644 index 0000000000..0e75e08d73 --- /dev/null +++ b/src/libs/cplusplus/TokenCache.h @@ -0,0 +1,39 @@ +#ifndef TOKENCACHE_H +#define TOKENCACHE_H + +#include +#include + +#include +#include + +#include +#include +#include + +namespace CPlusPlus { + +class CPLUSPLUS_EXPORT TokenCache +{ +public: + TokenCache(); + + void setDocument(QTextDocument *doc); + + QList tokensForBlock(const QTextBlock &block) const; + CPlusPlus::SimpleToken tokenUnderCursor(const QTextCursor &cursor) const; + + QString text(const QTextBlock &block, int tokenIndex) const; + + static int previousBlockState(const QTextBlock &block); + +private: + QTextDocument *m_doc; + + mutable int m_revision; + mutable QHash > m_tokensByBlock; +}; + +} // namespace CPlusPlus + +#endif // TOKENCACHE_H -- cgit v1.2.1