Commit e1d1c9e6 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Fix highlighting and completion for property declarations.



When property declarations use a custom type such as

property Foo bar

we now
* highlight Foo as a QML type if it's found
* complete bar. as a Foo

Change-Id: I82c249646af19bfeb9f5a7a7692f0dc10b009835
Reviewed-by: default avatarLeandro Melo <leandro.melo@nokia.com>
parent 387d7a20
......@@ -1965,7 +1965,19 @@ const Value *ASTPropertyReference::value(ReferenceContext *referenceContext) con
return evaluator(_ast->statement);
}
return valueOwner()->defaultValueForBuiltinType(_ast->memberType.toString());
const QString memberType = _ast->memberType.toString();
const Value *builtin = valueOwner()->defaultValueForBuiltinType(memberType);
if (!builtin->asUndefinedValue())
return builtin;
if (_ast->typeModifier.isEmpty()) {
const Value *type = referenceContext->context()->lookupType(_doc, QStringList(memberType));
if (type)
return type;
}
return referenceContext->context()->valueOwner()->undefinedValue();
}
ASTSignal::ASTSignal(UiPublicMember *ast, const Document *doc, ValueOwner *valueOwner)
......
......@@ -305,6 +305,10 @@ protected:
bool visit(UiPublicMember *ast)
{
if (ast->typeToken.isValid() && !ast->memberType.isEmpty()) {
if (m_scopeChain.context()->lookupType(m_scopeChain.document().data(), QStringList(ast->memberType.toString())))
addUse(ast->typeToken, SemanticHighlighter::QmlTypeType);
}
if (ast->identifierToken.isValid())
addUse(ast->identifierToken, SemanticHighlighter::BindingNameType);
scopedAccept(ast, ast->statement);
......
Supports Markdown
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