forked from qt-creator/qt-creator
CppHighlighter: highlight macro references.
Change-Id: I7c90957aa67e03a109af0a722160d4e1c759d716 Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
This commit is contained in:
committed by
Leandro Melo
parent
85ce5aba62
commit
85609aff8e
@@ -33,7 +33,7 @@
|
||||
#include "cppchecksymbols.h"
|
||||
#include "cpplocalsymbols.h"
|
||||
|
||||
#include <cplusplus/Overview.h>
|
||||
#include <cplusplus/SimpleLexer.h>
|
||||
|
||||
#include <Names.h>
|
||||
#include <Literals.h>
|
||||
@@ -284,16 +284,21 @@ protected:
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
CheckSymbols::Future CheckSymbols::go(Document::Ptr doc, const LookupContext &context)
|
||||
static bool sortByLinePredicate(const CheckSymbols::Use &lhs, const CheckSymbols::Use &rhs)
|
||||
{
|
||||
return lhs.line < rhs.line;
|
||||
}
|
||||
|
||||
CheckSymbols::Future CheckSymbols::go(Document::Ptr doc, const LookupContext &context, const QList<CheckSymbols::Use> ¯oUses)
|
||||
{
|
||||
QTC_ASSERT(doc, return Future());
|
||||
|
||||
return (new CheckSymbols(doc, context))->start();
|
||||
return (new CheckSymbols(doc, context, macroUses))->start();
|
||||
}
|
||||
|
||||
CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context)
|
||||
CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context, const QList<CheckSymbols::Use> ¯oUses)
|
||||
: ASTVisitor(doc->translationUnit()), _doc(doc), _context(context)
|
||||
, _lineOfLastUsage(0)
|
||||
, _lineOfLastUsage(0), _macroUses(macroUses)
|
||||
{
|
||||
CollectSymbols collectTypes(doc, context.snapshot());
|
||||
|
||||
@@ -311,11 +316,13 @@ CheckSymbols::~CheckSymbols()
|
||||
|
||||
void CheckSymbols::run()
|
||||
{
|
||||
qSort(_macroUses.begin(), _macroUses.end(), sortByLinePredicate);
|
||||
_diagnosticMessages.clear();
|
||||
|
||||
if (! isCanceled()) {
|
||||
if (_doc->translationUnit()) {
|
||||
accept(_doc->translationUnit()->ast());
|
||||
_usages << QVector<Use>::fromList(_macroUses);
|
||||
flush();
|
||||
}
|
||||
}
|
||||
@@ -876,6 +883,9 @@ void CheckSymbols::addUse(const Use &use)
|
||||
}
|
||||
}
|
||||
|
||||
while (!_macroUses.isEmpty() && _macroUses.first().line <= use.line)
|
||||
_usages.append(_macroUses.takeFirst());
|
||||
|
||||
_lineOfLastUsage = qMax(_lineOfLastUsage, use.line);
|
||||
_usages.append(use);
|
||||
}
|
||||
@@ -1115,11 +1125,6 @@ bool CheckSymbols::maybeVirtualMethod(const Name *name) const
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool sortByLinePredicate(const CheckSymbols::Use &lhs, const CheckSymbols::Use &rhs)
|
||||
{
|
||||
return lhs.line < rhs.line;
|
||||
}
|
||||
|
||||
void CheckSymbols::flush()
|
||||
{
|
||||
_lineOfLastUsage = 0;
|
||||
|
Reference in New Issue
Block a user