Moved the semantic highlighter in a QFuture.

This commit is contained in:
Roberto Raggi
2010-07-05 18:52:52 +02:00
parent eca8693ebd
commit 6d8ecb762f
6 changed files with 165 additions and 99 deletions

View File

@@ -36,25 +36,29 @@
#include <cplusplus/LookupContext.h>
#include <ASTVisitor.h>
#include <QtCore/QSet>
#include <QtCore/QFuture>
#include <QtCore/QtConcurrentRun>
namespace CPlusPlus {
class CheckUndefinedSymbols: protected ASTVisitor
{
public:
CheckUndefinedSymbols(TranslationUnit *unit, const LookupContext &context);
virtual ~CheckUndefinedSymbols();
QList<Document::DiagnosticMessage> operator()(AST *ast);
typedef CppEditor::Internal::SemanticInfo::Use Use;
QList<Use> typeUsages() const;
void runFunctor(QFutureInterface<Use> &future);
typedef QFuture<Use> Future;
static Future go(Document::Ptr doc, const LookupContext &context);
protected:
using ASTVisitor::visit;
using ASTVisitor::endVisit;
CheckUndefinedSymbols(Document::Ptr doc, const LookupContext &context);
bool warning(unsigned line, unsigned column, const QString &text, unsigned length = 0);
bool warning(AST *ast, const QString &text);
@@ -62,6 +66,9 @@ protected:
void checkNamespace(NameAST *name);
void addTypeUsage(ClassOrNamespace *b, NameAST *ast);
void addTypeUsage(const QList<Symbol *> &candidates, NameAST *ast);
void addTypeUsage(const Use &use);
virtual bool preVisit(AST *);
virtual bool visit(NamespaceAST *);
virtual bool visit(UsingDirectiveAST *);
@@ -83,13 +90,14 @@ protected:
Scope *findScope(AST *ast) const;
private:
Document::Ptr _doc;
LookupContext _context;
QString _fileName;
QList<Document::DiagnosticMessage> _diagnosticMessages;
QSet<QByteArray> _potentialTypes;
QList<ScopedSymbol *> _scopes;
QList<Use> _typeUsages;
QList<TemplateDeclarationAST *> _templateDeclarationStack;
QFutureInterface<Use> *_future;
};
} // end of namespace CPlusPlus