Commit 4f1d5ce1 authored by Christian Kamm's avatar Christian Kamm
Browse files

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
parent b610cc94
...@@ -146,7 +146,10 @@ void Highlighter::highlightBlock(const QString &text) ...@@ -146,7 +146,10 @@ void Highlighter::highlightBlock(const QString &text)
} }
if (index + 1 < tokens.size()) { 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]); setFormat(token.offset, token.length, m_formats[TypeFormat]);
} else if (index == 0 || checkStartOfBinding(tokens.at(index - 1))) { } else if (index == 0 || checkStartOfBinding(tokens.at(index - 1))) {
const int start = index; const int start = index;
...@@ -240,6 +243,8 @@ bool Highlighter::maybeQmlKeyword(const QStringRef &text) const ...@@ -240,6 +243,8 @@ bool Highlighter::maybeQmlKeyword(const QStringRef &text) const
return true; return true;
} else if (ch == QLatin1Char('i') && text == QLatin1String("import")) { } else if (ch == QLatin1Char('i') && text == QLatin1String("import")) {
return true; return true;
} else if (ch == QLatin1Char('o') && text == QLatin1String("on")) {
return true;
} else { } else {
return false; return false;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment