forked from qt-creator/qt-creator
QmlJSInterpreter: QML Plugin types
A Component in .qmltypes can have an array of exports which may differ in type names and versions. Consider the type names to be aliases and create a CppComponentValue for each of the alias corresponding to the best available version. Change-Id: I759ae0c68441e805b0502bf2d203c524bf1a7a7c Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
@@ -1365,19 +1365,20 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
|
|||||||
|
|
||||||
// make new exported objects
|
// make new exported objects
|
||||||
foreach (const FakeMetaObject::ConstPtr &fmo, _fakeMetaObjectsByPackage.value(package)) {
|
foreach (const FakeMetaObject::ConstPtr &fmo, _fakeMetaObjectsByPackage.value(package)) {
|
||||||
// find the highest-version export
|
// find the highest-version export for each alias
|
||||||
FakeMetaObject::Export bestExport;
|
QHash<QString, FakeMetaObject::Export> bestExports;
|
||||||
QList<QString> aliases;
|
|
||||||
foreach (const FakeMetaObject::Export &exp, fmo->exports()) {
|
foreach (const FakeMetaObject::Export &exp, fmo->exports()) {
|
||||||
// Store all aliases
|
|
||||||
if (!exp.type.isEmpty() && !aliases.contains(exp.type))
|
|
||||||
aliases.append(exp.type);
|
|
||||||
if (exp.package != package || (version.isValid() && exp.version > version))
|
if (exp.package != package || (version.isValid() && exp.version > version))
|
||||||
continue;
|
continue;
|
||||||
if (!bestExport.isValid() || exp.version > bestExport.version)
|
|
||||||
bestExport = exp;
|
if (bestExports.contains(exp.type)) {
|
||||||
|
if (exp.version > bestExports.value(exp.type).version)
|
||||||
|
bestExports.insert(exp.type, exp);
|
||||||
|
} else {
|
||||||
|
bestExports.insert(exp.type, exp);
|
||||||
}
|
}
|
||||||
if (!bestExport.isValid())
|
}
|
||||||
|
if (bestExports.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// if it already exists, skip
|
// if it already exists, skip
|
||||||
@@ -1385,6 +1386,7 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
|
|||||||
if (_objectsByQualifiedName.contains(key))
|
if (_objectsByQualifiedName.contains(key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
foreach (const FakeMetaObject::Export &bestExport, bestExports) {
|
||||||
QString name = bestExport.type;
|
QString name = bestExport.type;
|
||||||
bool exported = true;
|
bool exported = true;
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
@@ -1398,21 +1400,10 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
|
|||||||
|
|
||||||
// use package.cppname importversion as key
|
// use package.cppname importversion as key
|
||||||
_objectsByQualifiedName.insert(key, newComponent);
|
_objectsByQualifiedName.insert(key, newComponent);
|
||||||
|
|
||||||
// Create CppComponentValues for all the aliases
|
|
||||||
// TODO: Show warning for deprecated ones
|
|
||||||
aliases.removeOne(name);
|
|
||||||
QList<const CppComponentValue *> newComponents;
|
|
||||||
newComponents.append(newComponent);
|
|
||||||
foreach (const QString &alias, aliases) {
|
|
||||||
newComponents.append(new CppComponentValue(
|
|
||||||
fmo, alias, package, bestExport.version, version,
|
|
||||||
bestExport.metaObjectRevision, _valueOwner));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exported)
|
if (exported)
|
||||||
exportedObjects += newComponents;
|
exportedObjects += newComponent;
|
||||||
newObjects += newComponents;
|
newObjects += newComponent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set their prototypes, creating them if necessary
|
// set their prototypes, creating them if necessary
|
||||||
|
Reference in New Issue
Block a user