forked from qt-creator/qt-creator
QmlJS: Don't warn user about imports if static info is available
Don't underline the import if a qmldump fails, but the typeinfo is available via a .qmltypes file. That should allow users to 'fix' qmldump issues by shipping a .qmltypes file. Reviewed-by: Erik Verbruggen
This commit is contained in:
@@ -1970,6 +1970,7 @@ const Value *Function::invoke(const Activation *activation) const
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
QHash<QString, FakeMetaObject::ConstPtr> CppQmlTypesLoader::builtinObjects;
|
QHash<QString, FakeMetaObject::ConstPtr> CppQmlTypesLoader::builtinObjects;
|
||||||
|
QHash<QString, QList<LanguageUtils::ComponentVersion> > CppQmlTypesLoader::builtinPackages;
|
||||||
|
|
||||||
QStringList CppQmlTypesLoader::loadQmlTypes(const QFileInfoList &qmlTypeFiles)
|
QStringList CppQmlTypesLoader::loadQmlTypes(const QFileInfoList &qmlTypeFiles)
|
||||||
{
|
{
|
||||||
@@ -1997,6 +1998,17 @@ QStringList CppQmlTypesLoader::loadQmlTypes(const QFileInfoList &qmlTypeFiles)
|
|||||||
builtinObjects.unite(newObjects);
|
builtinObjects.unite(newObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QHash<QString, LanguageUtils::FakeMetaObject::ConstPtr>::const_iterator iter
|
||||||
|
= builtinObjects.constBegin();
|
||||||
|
for (; iter != builtinObjects.constEnd(); iter++) {
|
||||||
|
foreach (const FakeMetaObject::Export &exp, iter.value().data()->exports()) {
|
||||||
|
QList<LanguageUtils::ComponentVersion> versions = builtinPackages.value(exp.package);
|
||||||
|
if (!versions.contains(exp.version)) {
|
||||||
|
versions.append(exp.version);
|
||||||
|
builtinPackages.insert(exp.package, versions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return errorMsgs;
|
return errorMsgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -600,7 +600,9 @@ class QMLJS_EXPORT CppQmlTypesLoader
|
|||||||
public:
|
public:
|
||||||
/** \return an empty list when successful, error messages otherwise. */
|
/** \return an empty list when successful, error messages otherwise. */
|
||||||
static QStringList loadQmlTypes(const QFileInfoList &xmlFiles);
|
static QStringList loadQmlTypes(const QFileInfoList &xmlFiles);
|
||||||
|
|
||||||
static QHash<QString, LanguageUtils::FakeMetaObject::ConstPtr> builtinObjects;
|
static QHash<QString, LanguageUtils::FakeMetaObject::ConstPtr> builtinObjects;
|
||||||
|
static QHash<QString, QList<LanguageUtils::ComponentVersion> > builtinPackages;
|
||||||
|
|
||||||
// parses the xml string and fills the newObjects map
|
// parses the xml string and fills the newObjects map
|
||||||
static QString parseQmlTypeDescriptions(const QByteArray &xml,
|
static QString parseQmlTypeDescriptions(const QByteArray &xml,
|
||||||
|
@@ -347,8 +347,16 @@ bool Link::importLibrary(Document::Ptr doc, Interpreter::ObjectValue *import,
|
|||||||
tr("Library contains C++ plugins, type dump is in progress."));
|
tr("Library contains C++ plugins, type dump is in progress."));
|
||||||
}
|
}
|
||||||
} else if (libraryInfo.dumpStatus() == LibraryInfo::DumpError) {
|
} else if (libraryInfo.dumpStatus() == LibraryInfo::DumpError) {
|
||||||
if (errorLoc.isValid()) {
|
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
|
||||||
error(doc, errorLoc, libraryInfo.dumpError());
|
|
||||||
|
// Only underline import if package/version isn't described in .qmltypes anyway
|
||||||
|
const QmlJS::ModelManagerInterface::BuiltinPackagesHash builtinPackages
|
||||||
|
= modelManager->builtinPackages();
|
||||||
|
const QString packageName = importInfo.name().replace(QDir::separator(), QLatin1Char('.'));
|
||||||
|
if (!builtinPackages.value(packageName).contains(importInfo.version())) {
|
||||||
|
if (errorLoc.isValid()) {
|
||||||
|
error(doc, errorLoc, libraryInfo.dumpError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QList<QmlObjectValue *> loadedObjects =
|
QList<QmlObjectValue *> loadedObjects =
|
||||||
|
@@ -110,6 +110,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef QHash<QString, QList<LanguageUtils::FakeMetaObject::ConstPtr> > CppQmlTypeHash;
|
typedef QHash<QString, QList<LanguageUtils::FakeMetaObject::ConstPtr> > CppQmlTypeHash;
|
||||||
|
typedef QHash<QString, QList<LanguageUtils::ComponentVersion> > BuiltinPackagesHash;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModelManagerInterface(QObject *parent = 0);
|
ModelManagerInterface(QObject *parent = 0);
|
||||||
@@ -135,6 +136,7 @@ public:
|
|||||||
const QString &importUri, const QString &importVersion) = 0;
|
const QString &importUri, const QString &importVersion) = 0;
|
||||||
|
|
||||||
virtual CppQmlTypeHash cppQmlTypes() const = 0;
|
virtual CppQmlTypeHash cppQmlTypes() const = 0;
|
||||||
|
virtual BuiltinPackagesHash builtinPackages() const = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void documentUpdated(QmlJS::Document::Ptr doc);
|
void documentUpdated(QmlJS::Document::Ptr doc);
|
||||||
|
@@ -640,3 +640,8 @@ ModelManagerInterface::CppQmlTypeHash ModelManager::cppQmlTypes() const
|
|||||||
QMutexLocker locker(&m_cppTypesMutex);
|
QMutexLocker locker(&m_cppTypesMutex);
|
||||||
return m_cppTypes;
|
return m_cppTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModelManagerInterface::BuiltinPackagesHash ModelManager::builtinPackages() const
|
||||||
|
{
|
||||||
|
return Interpreter::CppQmlTypesLoader::builtinPackages;
|
||||||
|
}
|
||||||
|
@@ -87,6 +87,7 @@ public:
|
|||||||
const QString &importUri, const QString &importVersion);
|
const QString &importUri, const QString &importVersion);
|
||||||
|
|
||||||
virtual CppQmlTypeHash cppQmlTypes() const;
|
virtual CppQmlTypeHash cppQmlTypes() const;
|
||||||
|
virtual BuiltinPackagesHash builtinPackages() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void projectPathChanged(const QString &projectPath);
|
void projectPathChanged(const QString &projectPath);
|
||||||
|
Reference in New Issue
Block a user