Commit 65b2edbd authored by Marco Benelli's avatar Marco Benelli

qmljs: better handling of attached properties

Attached properties used to cause false positives in the highlighter,
because when using qualified ids, only the first part was checked as
candidate for being at attached property.

Task-number: QTCREATORBUG-18707
Change-Id: I6b1b569bc1766325decbc5d100c16a4e0dc3634f
Reviewed-by: Thomas Hartmann's avatarThomas Hartmann <thomas.hartmann@qt.io>
parent 5457a2b5
......@@ -1709,6 +1709,7 @@ bool Check::visit(TypeOfExpression *ast)
/// ### Maybe put this into the context as a helper function.
const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
{
if (!_importsOk)
return 0;
......@@ -1716,6 +1717,17 @@ const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
if (scopeObjects.isEmpty())
return 0;
const auto getAttachedTypes = [this, &scopeObjects](const QString &propertyName) {
bool isAttachedProperty = false;
if (! propertyName.isEmpty() && propertyName[0].isUpper()) {
isAttachedProperty = true;
if (const ObjectValue *qmlTypes = _scopeChain.qmlTypes())
scopeObjects += qmlTypes;
}
return isAttachedProperty;
};
if (! id)
return 0; // ### error?
......@@ -1728,12 +1740,7 @@ const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
return 0; // ### should probably be a special value
// attached properties
bool isAttachedProperty = false;
if (! propertyName.isEmpty() && propertyName[0].isUpper()) {
isAttachedProperty = true;
if (const ObjectValue *qmlTypes = _scopeChain.qmlTypes())
scopeObjects += qmlTypes;
}
bool isAttachedProperty = getAttachedTypes(propertyName);
if (scopeObjects.isEmpty())
return 0;
......@@ -1775,6 +1782,9 @@ const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
idPart = idPart->next;
propertyName = idPart->name.toString();
isAttachedProperty = getAttachedTypes(propertyName);
if (isAttachedProperty)
return 0;
value = objectValue->lookupMember(propertyName, _context);
if (! value) {
......
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