diff options
author | Francois Ferrand <thetypz@gmail.com> | 2010-11-03 11:02:25 +0100 |
---|---|---|
committer | Leandro Melo <leandro.melo@nokia.com> | 2012-04-13 02:07:37 +0200 |
commit | 85609aff8e3bd09a68d7868ad6cf3158e261d713 (patch) | |
tree | 9a09fa06d8277f779b3a4471974f34558f632256 /src/plugins/cpptools/cpphighlightingsupportinternal.cpp | |
parent | 85ce5aba6211385785476164ab95b37140e5b20d (diff) | |
download | qt-creator-85609aff8e3bd09a68d7868ad6cf3158e261d713.tar.gz |
CppHighlighter: highlight macro references.
Change-Id: I7c90957aa67e03a109af0a722160d4e1c759d716
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
Diffstat (limited to 'src/plugins/cpptools/cpphighlightingsupportinternal.cpp')
-rw-r--r-- | src/plugins/cpptools/cpphighlightingsupportinternal.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
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 <cplusplus/LookupContext.h> +#include <cplusplus/SimpleLexer.h> +#include <cplusplus/Token.h> +#include <cpptools/cpptoolsreuse.h> +#include <texteditor/itexteditor.h> using namespace CPlusPlus; using namespace CppTools; @@ -52,8 +56,32 @@ QFuture<CppHighlightingSupport::Use> CppHighlightingSupportInternal::highlightin const Document::Ptr &doc, const Snapshot &snapshot) const { + //Get macro uses + QList<CheckSymbols::Use> 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<Token> 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() |