From 85609aff8e3bd09a68d7868ad6cf3158e261d713 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 3 Nov 2010 11:02:25 +0100 Subject: CppHighlighter: highlight macro references. Change-Id: I7c90957aa67e03a109af0a722160d4e1c759d716 Reviewed-by: Leandro Melo --- .../cpptools/cpphighlightingsupportinternal.cpp | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/plugins/cpptools/cpphighlightingsupportinternal.cpp') diff --git a/src/plugins/cpptools/cpphighlightingsupportinternal.cpp b/src/plugins/cpptools/cpphighlightingsupportinternal.cpp index f9cfcecaa7..4b62a06999 100644 --- a/src/plugins/cpptools/cpphighlightingsupportinternal.cpp +++ b/src/plugins/cpptools/cpphighlightingsupportinternal.cpp @@ -34,6 +34,10 @@ #include "cpphighlightingsupportinternal.h" #include +#include +#include +#include +#include using namespace CPlusPlus; using namespace CppTools; @@ -52,8 +56,32 @@ QFuture CppHighlightingSupportInternal::highlightin const Document::Ptr &doc, const Snapshot &snapshot) const { + //Get macro uses + QList macroUses; + foreach (Document::MacroUse macro, doc->macroUses()) { + const QString name = QString::fromUtf8(macro.macro().name()); + + //Filter out QtKeywords + if (isQtKeyword(QStringRef(&name))) + continue; + + //Filter out C++ keywords + SimpleLexer tokenize; + tokenize.setQtMocRunEnabled(false); + tokenize.setObjCEnabled(false); + const QList tokens = tokenize(name); + if (tokens.length() && (tokens.at(0).isKeyword() || tokens.at(0).isObjCAtKeyword())) + continue; + + int line, column; + editor()->convertPosition(macro.begin(), &line, &column); + ++column; //Highlighting starts at (column-1) --> compensate here + CheckSymbols::Use use(line, column, name.size(), SemanticInfo::MacroUse); + macroUses.append(use); + } + LookupContext context(doc, snapshot); - return CheckSymbols::go(doc, context); + return CheckSymbols::go(doc, context, macroUses); } CppHighlightingSupportInternalFactory::~CppHighlightingSupportInternalFactory() -- cgit v1.2.1