forked from qt-creator/qt-creator
Recognize Q_* and QT_* as reserved keywords.
This commit is contained in:
@@ -359,16 +359,18 @@ void CppHighlighter::highlightLine(const QString &text, int position, int length
|
|||||||
void CppHighlighter::highlightWord(QStringRef word, int position, int length)
|
void CppHighlighter::highlightWord(QStringRef word, int position, int length)
|
||||||
{
|
{
|
||||||
// try to highlight Qt 'identifiers' like QObject and Q_PROPERTY
|
// try to highlight Qt 'identifiers' like QObject and Q_PROPERTY
|
||||||
// but don't highlight words like 'Query'
|
|
||||||
|
|
||||||
if (word.length() > 1 && word.at(0) == QLatin1Char('Q')) {
|
if (word.length() > 2 && word.at(0) == QLatin1Char('Q')) {
|
||||||
for (int i = 1; i < word.length(); ++i) {
|
if (word.at(1) == QLatin1Char('_') // Q_
|
||||||
const QChar &ch = word.at(i);
|
|| word.at(1) == QLatin1Char('T') && word.at(2) == QLatin1Char('_')) { // QT_
|
||||||
if (! (ch.isUpper() || ch == QLatin1Char('_')))
|
for (int i = 1; i < word.length(); ++i) {
|
||||||
return;
|
const QChar &ch = word.at(i);
|
||||||
|
if (! (ch.isUpper() || ch == QLatin1Char('_')))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setFormat(position, length, m_formats[CppTypeFormat]);
|
||||||
}
|
}
|
||||||
|
|
||||||
setFormat(position, length, m_formats[CppTypeFormat]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user