forked from qt-creator/qt-creator
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 <thomas.hartmann@qt.io>
This commit is contained in:
@@ -1709,6 +1709,7 @@ bool Check::visit(TypeOfExpression *ast)
|
|||||||
/// ### Maybe put this into the context as a helper function.
|
/// ### Maybe put this into the context as a helper function.
|
||||||
const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
|
const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!_importsOk)
|
if (!_importsOk)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -1716,6 +1717,17 @@ const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
|
|||||||
if (scopeObjects.isEmpty())
|
if (scopeObjects.isEmpty())
|
||||||
return 0;
|
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)
|
if (! id)
|
||||||
return 0; // ### error?
|
return 0; // ### error?
|
||||||
|
|
||||||
@@ -1728,12 +1740,7 @@ const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
|
|||||||
return 0; // ### should probably be a special value
|
return 0; // ### should probably be a special value
|
||||||
|
|
||||||
// attached properties
|
// attached properties
|
||||||
bool isAttachedProperty = false;
|
bool isAttachedProperty = getAttachedTypes(propertyName);
|
||||||
if (! propertyName.isEmpty() && propertyName[0].isUpper()) {
|
|
||||||
isAttachedProperty = true;
|
|
||||||
if (const ObjectValue *qmlTypes = _scopeChain.qmlTypes())
|
|
||||||
scopeObjects += qmlTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scopeObjects.isEmpty())
|
if (scopeObjects.isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1775,6 +1782,9 @@ const Value *Check::checkScopeObjectMember(const UiQualifiedId *id)
|
|||||||
|
|
||||||
idPart = idPart->next;
|
idPart = idPart->next;
|
||||||
propertyName = idPart->name.toString();
|
propertyName = idPart->name.toString();
|
||||||
|
isAttachedProperty = getAttachedTypes(propertyName);
|
||||||
|
if (isAttachedProperty)
|
||||||
|
return 0;
|
||||||
|
|
||||||
value = objectValue->lookupMember(propertyName, _context);
|
value = objectValue->lookupMember(propertyName, _context);
|
||||||
if (! value) {
|
if (! value) {
|
||||||
|
Reference in New Issue
Block a user