break;
}
}
-
- if (!spell.isEmpty() && spell.at(0).isUpper())
- setFormat(token.offset, token.length, m_formats[TypeFormat]);
-
- if (index + 1 < tokens.size()) {
- bool maybeBinding = (index == 0 || checkStartOfBinding(tokens.at(index - 1)));
- bool maybeOnBinding = false;
- if (index > 0) {
- const Token &previousToken = tokens.at(index - 1);
- if (text.midRef(previousToken.offset, previousToken.length) == QLatin1String("on")) {
- maybeOnBinding = true;
- maybeBinding = false;
- }
- }
-
- if (maybeBinding || maybeOnBinding) {
- Token::Kind expectedTerminator = Token::Colon;
- if (maybeOnBinding)
- expectedTerminator = Token::LeftBrace;
-
- const int start = index;
-
- // put index on last identifier not followed by .identifier
- while (index + 2 < tokens.size() &&
- tokens.at(index + 1).is(Token::Dot) &&
- tokens.at(index + 2).is(Token::Identifier)) {
- index += 2;
- }
-
- if (index + 1 < tokens.size() && tokens.at(index + 1).is(expectedTerminator)) {
- // it's a binding.
- for (int i = start; i <= index; ++i) {
- const Token &tok = tokens.at(i);
- if (tok.kind == Token::Dot)
- continue;
- const QStringRef tokSpell = text.midRef(tok.offset, tok.length);
- if (!tokSpell.isEmpty() && tokSpell.at(0).isUpper()) {
- setFormat(tok.offset, tok.length, m_formats[TypeFormat]);
- } else {
- setFormat(tok.offset, tok.length, m_formats[FieldFormat]);
- }
- }
- break;
- } else {
- index = start;
- }
- }
- }
} break;
case Token::Delimiter:
#include <qmljs/qmljsevaluate.h>
#include <qmljs/qmljscontext.h>
#include <qmljs/qmljsbind.h>
+#include <qmljs/qmljscheck.h>
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <texteditor/syntaxhighlighter.h>
addUse(location, type);
}
+ void processTypeId(UiQualifiedId *typeId)
+ {
+ if (!typeId)
+ return;
+ if (m_scopeChain.context()->lookupType(m_scopeChain.document().data(), typeId))
+ addUse(fullLocationForQualifiedId(typeId), SemanticHighlighter::QmlTypeType);
+ }
+
+ void processBindingName(UiQualifiedId *localId)
+ {
+ if (!localId)
+ return;
+ addUse(fullLocationForQualifiedId(localId), SemanticHighlighter::BindingNameType);
+ }
+
bool visit(UiObjectDefinition *ast)
{
+ if (m_scopeChain.document()->bind()->isGroupedPropertyBinding(ast)) {
+ processBindingName(ast->qualifiedTypeNameId);
+ } else {
+ processTypeId(ast->qualifiedTypeNameId);
+ }
scopedAccept(ast, ast->initializer);
return false;
}
bool visit(UiObjectBinding *ast)
{
+ processTypeId(ast->qualifiedTypeNameId);
+ processBindingName(ast->qualifiedId);
scopedAccept(ast, ast->initializer);
return false;
}
bool visit(UiScriptBinding *ast)
{
+ processBindingName(ast->qualifiedId);
scopedAccept(ast, ast->statement);
return false;
}
+ bool visit(UiArrayBinding *ast)
+ {
+ processBindingName(ast->qualifiedId);
+ return true;
+ }
+
bool visit(UiPublicMember *ast)
{
+ if (ast->identifierToken.isValid())
+ addUse(ast->identifierToken, SemanticHighlighter::BindingNameType);
scopedAccept(ast, ast->statement);
return false;
}
m_formats[JsImportType] = fontSettings.toTextCharFormat(QLatin1String(TextEditor::Constants::C_JS_IMPORT_VAR));
m_formats[JsGlobalType] = fontSettings.toTextCharFormat(QLatin1String(TextEditor::Constants::C_JS_GLOBAL_VAR));
m_formats[LocalStateNameType] = fontSettings.toTextCharFormat(QLatin1String(TextEditor::Constants::C_QML_STATE_NAME));
+ m_formats[BindingNameType] = fontSettings.toTextCharFormat(QLatin1String(TextEditor::Constants::C_BINDING));
+ m_formats[FieldType] = fontSettings.toTextCharFormat(QLatin1String(TextEditor::Constants::C_FIELD));
}
int SemanticHighlighter::startRevision() const
JsScopeType, // var or function in local js scope
JsImportType, // name of js import
JsGlobalType, // in global scope
- LocalStateNameType // name of a state in the current file
+ LocalStateNameType, // name of a state in the current file
+ BindingNameType, // name on the left hand side of a binding
+ FieldType // member of an object
};
typedef TextEditor::SemanticHighlighter::Result Use;
const char * const C_JS_IMPORT_VAR = "JsImportVar";
const char * const C_JS_GLOBAL_VAR = "JsGlobalVar";
const char * const C_QML_STATE_NAME = "QmlStateName";
+const char * const C_BINDING = "Binding";
const char * const C_DISABLED_CODE = "DisabledCode";
virtualMethodFormatDescriptor.format().setItalic(true);
formatDescriptions.append(virtualMethodFormatDescriptor);
+ formatDescriptions.append(FormatDescription(QLatin1String(C_BINDING), tr("QML Binding"), Qt::darkRed));
+
Format qmlLocalNameFormat;
qmlLocalNameFormat.setItalic(true);
formatDescriptions.append(FormatDescription(QLatin1String(C_QML_LOCAL_ID), tr("QML Local Id"), qmlLocalNameFormat));