From 4f1d5ce19655450c2e7c23f5583116fa559d6724 Mon Sep 17 00:00:00 2001 From: Christian Kamm <christian.d.kamm@nokia.com> Date: Wed, 7 Apr 2010 08:49:09 +0200 Subject: [PATCH] QmlJSEditor: Highlight 'A on B {' correctly. * Add 'on' qml-keyword. * Highlight the last identifier before 'on' as a type. Task-number: QTCREATORBUG-893 Reviewed-by: Erik Verbruggen --- src/plugins/qmljseditor/qmljshighlighter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmljseditor/qmljshighlighter.cpp b/src/plugins/qmljseditor/qmljshighlighter.cpp index 6ce661db5d4..a4dc4f05c09 100644 --- a/src/plugins/qmljseditor/qmljshighlighter.cpp +++ b/src/plugins/qmljseditor/qmljshighlighter.cpp @@ -146,7 +146,10 @@ void Highlighter::highlightBlock(const QString &text) } if (index + 1 < tokens.size()) { - if (tokens.at(index + 1).is(Token::LeftBrace) && text.at(token.offset).isUpper()) { + const Token &nextToken = tokens.at(index + 1); + if (text.at(token.offset).isUpper() + && (nextToken.is(Token::LeftBrace) + || text.midRef(nextToken.offset, nextToken.length) == QLatin1String("on"))) { setFormat(token.offset, token.length, m_formats[TypeFormat]); } else if (index == 0 || checkStartOfBinding(tokens.at(index - 1))) { const int start = index; @@ -240,6 +243,8 @@ bool Highlighter::maybeQmlKeyword(const QStringRef &text) const return true; } else if (ch == QLatin1Char('i') && text == QLatin1String("import")) { return true; + } else if (ch == QLatin1Char('o') && text == QLatin1String("on")) { + return true; } else { return false; } -- GitLab