qmllint: Support aliases to lists
Previously when resolving aliases all types of additional type information from the target was not copied over into the alias (writability, whether the property is a list etc.). The alias should now accurately reflect the original property's type information. Change-Id: I15078071716590f6a0e6262b8ad40ee946fe7da5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
614c7ac21d
commit
47a1b9faba
|
@ -137,6 +137,7 @@ void QQmlJSImportVisitor::resolveAliases()
|
|||
|
||||
QStringList components = property.typeName().split(u'.');
|
||||
QQmlJSScope::ConstPtr type;
|
||||
QQmlJSMetaProperty targetProperty;
|
||||
|
||||
// The first component has to be an ID. Find the object it refers to.
|
||||
const auto it = m_scopesById.find(components.takeFirst());
|
||||
|
@ -153,6 +154,7 @@ void QQmlJSImportVisitor::resolveAliases()
|
|||
if (!target.type() && target.isAlias())
|
||||
doRequeue = true;
|
||||
type = target.type();
|
||||
targetProperty = target;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,6 +165,11 @@ void QQmlJSImportVisitor::resolveAliases()
|
|||
.arg(property.propertyName()), Log_Alias, object->sourceLocation());
|
||||
} else {
|
||||
property.setType(type);
|
||||
// Copy additional property information from target
|
||||
property.setIsList(targetProperty.isList());
|
||||
property.setIsWritable(targetProperty.isWritable());
|
||||
property.setIsPointer(targetProperty.isPointer());
|
||||
|
||||
if (const QString internalName = type->internalName(); !internalName.isEmpty())
|
||||
property.setTypeName(internalName);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
import QtQuick 2.15
|
||||
|
||||
Item {
|
||||
Item { id: item }
|
||||
|
||||
default property alias content: item.children
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import QtQuick 2.15
|
||||
|
||||
AliasListType {
|
||||
Item {}
|
||||
Item {}
|
||||
}
|
|
@ -748,6 +748,7 @@ void TestQmllint::cleanQmlCode_data()
|
|||
QTest::newRow("QtQuick.Window 2.1") << QStringLiteral("qtquickWindow21.qml");
|
||||
QTest::newRow("attachedTypeIndirect") << QStringLiteral("attachedTypeIndirect.qml");
|
||||
QTest::newRow("objectArray") << QStringLiteral("objectArray.qml");
|
||||
QTest::newRow("aliasToList") << QStringLiteral("aliasToList.qml");
|
||||
}
|
||||
|
||||
void TestQmllint::cleanQmlCode()
|
||||
|
|
Loading…
Reference in New Issue