forked from qt-creator/qt-creator
Introduced MacroResolver.
This commit is contained in:
@@ -432,6 +432,7 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
|
|||||||
Document::Ptr previousDoc = snapshot.value(fileName);
|
Document::Ptr previousDoc = snapshot.value(fileName);
|
||||||
if (previousDoc) {
|
if (previousDoc) {
|
||||||
Control *control = previousDoc->control();
|
Control *control = previousDoc->control();
|
||||||
|
previousDoc->control();
|
||||||
Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size());
|
Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size());
|
||||||
if (! id)
|
if (! id)
|
||||||
continue; // skip this document, it's not using symbolId.
|
continue; // skip this document, it's not using symbolId.
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ class Semantic;
|
|||||||
class Control;
|
class Control;
|
||||||
class MemoryPool;
|
class MemoryPool;
|
||||||
class DiagnosticClient;
|
class DiagnosticClient;
|
||||||
|
class MacroResolver;
|
||||||
|
|
||||||
class Identifier;
|
class Identifier;
|
||||||
class Literal;
|
class Literal;
|
||||||
|
|||||||
@@ -59,6 +59,12 @@
|
|||||||
|
|
||||||
CPLUSPLUS_BEGIN_NAMESPACE
|
CPLUSPLUS_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
MacroResolver::MacroResolver()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
MacroResolver::~MacroResolver()
|
||||||
|
{ }
|
||||||
|
|
||||||
template <typename _Iterator>
|
template <typename _Iterator>
|
||||||
static void delete_map_entries(_Iterator first, _Iterator last)
|
static void delete_map_entries(_Iterator first, _Iterator last)
|
||||||
{
|
{
|
||||||
@@ -87,7 +93,8 @@ public:
|
|||||||
Data(Control *control)
|
Data(Control *control)
|
||||||
: control(control),
|
: control(control),
|
||||||
translationUnit(0),
|
translationUnit(0),
|
||||||
diagnosticClient(0)
|
diagnosticClient(0),
|
||||||
|
macroResolver(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
~Data()
|
~Data()
|
||||||
@@ -516,6 +523,7 @@ public:
|
|||||||
Control *control;
|
Control *control;
|
||||||
TranslationUnit *translationUnit;
|
TranslationUnit *translationUnit;
|
||||||
DiagnosticClient *diagnosticClient;
|
DiagnosticClient *diagnosticClient;
|
||||||
|
MacroResolver *macroResolver;
|
||||||
LiteralTable<Identifier> identifiers;
|
LiteralTable<Identifier> identifiers;
|
||||||
LiteralTable<StringLiteral> stringLiterals;
|
LiteralTable<StringLiteral> stringLiterals;
|
||||||
LiteralTable<NumericLiteral> numericLiterals;
|
LiteralTable<NumericLiteral> numericLiterals;
|
||||||
@@ -576,6 +584,12 @@ TranslationUnit *Control::switchTranslationUnit(TranslationUnit *unit)
|
|||||||
return previousTranslationUnit;
|
return previousTranslationUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MacroResolver *Control::macroResolver() const
|
||||||
|
{ return d->macroResolver; }
|
||||||
|
|
||||||
|
void Control::setMacroResolver(MacroResolver *macroResolver)
|
||||||
|
{ d->macroResolver = macroResolver; }
|
||||||
|
|
||||||
DiagnosticClient *Control::diagnosticClient() const
|
DiagnosticClient *Control::diagnosticClient() const
|
||||||
{ return d->diagnosticClient; }
|
{ return d->diagnosticClient; }
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,18 @@
|
|||||||
CPLUSPLUS_BEGIN_HEADER
|
CPLUSPLUS_BEGIN_HEADER
|
||||||
CPLUSPLUS_BEGIN_NAMESPACE
|
CPLUSPLUS_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class CPLUSPLUS_EXPORT MacroResolver
|
||||||
|
{
|
||||||
|
MacroResolver(const MacroResolver &other);
|
||||||
|
void operator = (const MacroResolver &other);
|
||||||
|
|
||||||
|
public:
|
||||||
|
MacroResolver();
|
||||||
|
virtual ~MacroResolver();
|
||||||
|
|
||||||
|
virtual bool isMacro(TranslationUnit *unit, unsigned tokenIndex) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class CPLUSPLUS_EXPORT Control
|
class CPLUSPLUS_EXPORT Control
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -64,6 +76,9 @@ public:
|
|||||||
TranslationUnit *translationUnit() const;
|
TranslationUnit *translationUnit() const;
|
||||||
TranslationUnit *switchTranslationUnit(TranslationUnit *unit);
|
TranslationUnit *switchTranslationUnit(TranslationUnit *unit);
|
||||||
|
|
||||||
|
MacroResolver *macroResolver() const;
|
||||||
|
void setMacroResolver(MacroResolver *macroResolver);
|
||||||
|
|
||||||
DiagnosticClient *diagnosticClient() const;
|
DiagnosticClient *diagnosticClient() const;
|
||||||
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
|
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
|
||||||
|
|
||||||
|
|||||||
@@ -244,6 +244,14 @@ void Parser::match(int kind, unsigned *token)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Parser::isMacro(unsigned tokenIndex) const
|
||||||
|
{
|
||||||
|
if (MacroResolver *r = _control->macroResolver())
|
||||||
|
return r->isMacro(_translationUnit, tokenIndex);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Parser::parseClassOrNamespaceName(NameAST *&node)
|
bool Parser::parseClassOrNamespaceName(NameAST *&node)
|
||||||
{
|
{
|
||||||
if (LA() == T_IDENTIFIER) {
|
if (LA() == T_IDENTIFIER) {
|
||||||
|
|||||||
@@ -286,6 +286,8 @@ private:
|
|||||||
inline void rewind(unsigned cursor)
|
inline void rewind(unsigned cursor)
|
||||||
{ _tokenIndex = cursor; }
|
{ _tokenIndex = cursor; }
|
||||||
|
|
||||||
|
bool isMacro(unsigned tokenIndex) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TranslationUnit *_translationUnit;
|
TranslationUnit *_translationUnit;
|
||||||
Control *_control;
|
Control *_control;
|
||||||
|
|||||||
Reference in New Issue
Block a user