Commit cb9cc8dc authored by Leandro Melo's avatar Leandro Melo

C++ editor: Better control to stop the semantic highlighter

Done-by: Roberto Raggi
Reviewed-by: Leandro Melo
Reviewed-by: mae
parent 3c8ff2be
......@@ -2182,6 +2182,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
const QByteArray preprocessedCode = snapshot.preprocessedCode(source.code, source.fileName);
doc = snapshot.documentFromSource(preprocessedCode, source.fileName);
doc->control()->setTopLevelDeclarationProcessor(this);
doc->check();
#if 0
......
......@@ -73,7 +73,7 @@ namespace Internal {
class CPPEditor;
class SemanticHighlighter: public QThread
class SemanticHighlighter: public QThread, CPlusPlus::TopLevelDeclarationProcessor
{
Q_OBJECT
......@@ -81,6 +81,8 @@ public:
SemanticHighlighter(QObject *parent = 0);
virtual ~SemanticHighlighter();
virtual bool processDeclaration(CPlusPlus::DeclarationAST *) { return m_done; }
void abort();
struct Source
......
......@@ -244,6 +244,7 @@ public:
, objcRetainId(0)
, objcCopyId(0)
, objcNonatomicId(0)
, processor(0)
{}
~Data()
......@@ -531,6 +532,7 @@ public:
const Identifier *objcRetainId;
const Identifier *objcCopyId;
const Identifier *objcNonatomicId;
TopLevelDeclarationProcessor *processor;
};
Control::Control()
......@@ -809,3 +811,13 @@ void Control::squeeze()
{
d->numericLiterals.reset();
}
TopLevelDeclarationProcessor *Control::topLevelDeclarationProcessor() const
{
return d->processor;
}
void Control::setTopLevelDeclarationProcessor(CPlusPlus::TopLevelDeclarationProcessor *processor)
{
d->processor = processor;
}
......@@ -54,10 +54,18 @@
#define CPLUSPLUS_CONTROL_H
#include "CPlusPlusForwardDeclarations.h"
#include "ASTfwd.h"
#include "Names.h"
namespace CPlusPlus {
class CPLUSPLUS_EXPORT TopLevelDeclarationProcessor
{
public:
virtual ~TopLevelDeclarationProcessor() {}
virtual bool processDeclaration(DeclarationAST *ast) = 0;
};
class CPLUSPLUS_EXPORT Control
{
public:
......@@ -67,6 +75,9 @@ public:
TranslationUnit *translationUnit() const;
TranslationUnit *switchTranslationUnit(TranslationUnit *unit);
TopLevelDeclarationProcessor *topLevelDeclarationProcessor() const;
void setTopLevelDeclarationProcessor(TopLevelDeclarationProcessor *processor);
DiagnosticClient *diagnosticClient() const;
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
......
......@@ -566,6 +566,12 @@ bool Parser::parseTranslationUnit(TranslationUnitAST *&node)
skipUntilDeclaration();
}
if (TopLevelDeclarationProcessor *processor = _control->topLevelDeclarationProcessor()) {
if (processor->processDeclaration(declaration))
break;
}
_templateArgumentList.clear();
}
......@@ -6032,3 +6038,4 @@ void Parser::fatal(unsigned index, const char *format, ...)
va_end(ap);
va_end(args);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment