CppHighlighter: highlight macro references.

Change-Id: I7c90957aa67e03a109af0a722160d4e1c759d716
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
This commit is contained in:
Francois Ferrand
2010-11-03 11:02:25 +01:00
committed by Leandro Melo
parent 85ce5aba62
commit 85609aff8e
9 changed files with 101 additions and 61 deletions

View File

@@ -40,6 +40,7 @@
#include <QSet>
#include <QTextDocument>
#include <QTextCursor>
#include <QStringRef>
using namespace CPlusPlus;
@@ -131,5 +132,49 @@ bool isValidIdentifier(const QString &s)
return true;
}
bool isQtKeyword(const QStringRef &text)
{
switch (text.length()) {
case 4:
switch (text.at(0).toLatin1()) {
case 'e':
if (text == QLatin1String("emit"))
return true;
break;
case 'S':
if (text == QLatin1String("SLOT"))
return true;
break;
}
break;
case 5:
if (text.at(0) == QLatin1Char('s') && text == QLatin1String("slots"))
return true;
break;
case 6:
if (text.at(0) == QLatin1Char('S') && text == QLatin1String("SIGNAL"))
return true;
break;
case 7:
switch (text.at(0).toLatin1()) {
case 's':
if (text == QLatin1String("signals"))
return true;
break;
case 'f':
if (text == QLatin1String("foreach") || text == QLatin1String("forever"))
return true;
break;
}
break;
default:
break;
}
return false;
}
} // CppTools