summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2011-04-12 09:14:31 +0200
committerKai Koehne <kai.koehne@nokia.com>2011-04-12 11:27:17 +0200
commit3e07024e10012856892291294a861aaaeb33d5f0 (patch)
tree995c35e9e38f6d81811a91d1a08c482d6c1f3669
parentf19669e66118f2b4a17f755c5f4c799e1dfff480 (diff)
downloadqt-creator-3e07024e10012856892291294a861aaaeb33d5f0.tar.gz
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
-rw-r--r--src/libs/qmljs/qmljsinterpreter.cpp12
-rw-r--r--src/libs/qmljs/qmljsinterpreter.h2
-rw-r--r--src/libs/qmljs/qmljslink.cpp12
-rw-r--r--src/libs/qmljs/qmljsmodelmanagerinterface.h2
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp5
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.h1
6 files changed, 32 insertions, 2 deletions
diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp
index b3f11d2b20..65e3b3cd10 100644
--- a/src/libs/qmljs/qmljsinterpreter.cpp
+++ b/src/libs/qmljs/qmljsinterpreter.cpp
@@ -1970,6 +1970,7 @@ const Value *Function::invoke(const Activation *activation) const
////////////////////////////////////////////////////////////////////////////////
QHash<QString, FakeMetaObject::ConstPtr> CppQmlTypesLoader::builtinObjects;
+QHash<QString, QList<LanguageUtils::ComponentVersion> > CppQmlTypesLoader::builtinPackages;
QStringList CppQmlTypesLoader::loadQmlTypes(const QFileInfoList &qmlTypeFiles)
{
@@ -1997,6 +1998,17 @@ QStringList CppQmlTypesLoader::loadQmlTypes(const QFileInfoList &qmlTypeFiles)
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;
}
diff --git a/src/libs/qmljs/qmljsinterpreter.h b/src/libs/qmljs/qmljsinterpreter.h
index c45b4ae8d0..4e787e3688 100644
--- a/src/libs/qmljs/qmljsinterpreter.h
+++ b/src/libs/qmljs/qmljsinterpreter.h
@@ -600,7 +600,9 @@ class QMLJS_EXPORT CppQmlTypesLoader
public:
/** \return an empty list when successful, error messages otherwise. */
static QStringList loadQmlTypes(const QFileInfoList &xmlFiles);
+
static QHash<QString, LanguageUtils::FakeMetaObject::ConstPtr> builtinObjects;
+ static QHash<QString, QList<LanguageUtils::ComponentVersion> > builtinPackages;
// parses the xml string and fills the newObjects map
static QString parseQmlTypeDescriptions(const QByteArray &xml,
diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp
index a079b51753..cc5adbfb24 100644
--- a/src/libs/qmljs/qmljslink.cpp
+++ b/src/libs/qmljs/qmljslink.cpp
@@ -347,8 +347,16 @@ bool Link::importLibrary(Document::Ptr doc, Interpreter::ObjectValue *import,
tr("Library contains C++ plugins, type dump is in progress."));
}
} else if (libraryInfo.dumpStatus() == LibraryInfo::DumpError) {
- if (errorLoc.isValid()) {
- error(doc, errorLoc, libraryInfo.dumpError());
+ ModelManagerInterface *modelManager = ModelManagerInterface::instance();
+
+ // 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 {
QList<QmlObjectValue *> loadedObjects =
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h
index 1fa30b4196..680422eff6 100644
--- a/src/libs/qmljs/qmljsmodelmanagerinterface.h
+++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h
@@ -110,6 +110,7 @@ public:
};
typedef QHash<QString, QList<LanguageUtils::FakeMetaObject::ConstPtr> > CppQmlTypeHash;
+ typedef QHash<QString, QList<LanguageUtils::ComponentVersion> > BuiltinPackagesHash;
public:
ModelManagerInterface(QObject *parent = 0);
@@ -135,6 +136,7 @@ public:
const QString &importUri, const QString &importVersion) = 0;
virtual CppQmlTypeHash cppQmlTypes() const = 0;
+ virtual BuiltinPackagesHash builtinPackages() const = 0;
signals:
void documentUpdated(QmlJS::Document::Ptr doc);
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index d6a829b987..8142322c40 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -640,3 +640,8 @@ ModelManagerInterface::CppQmlTypeHash ModelManager::cppQmlTypes() const
QMutexLocker locker(&m_cppTypesMutex);
return m_cppTypes;
}
+
+ModelManagerInterface::BuiltinPackagesHash ModelManager::builtinPackages() const
+{
+ return Interpreter::CppQmlTypesLoader::builtinPackages;
+}
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.h b/src/plugins/qmljstools/qmljsmodelmanager.h
index 9adbb1ad03..84b9f5d7f6 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.h
+++ b/src/plugins/qmljstools/qmljsmodelmanager.h
@@ -87,6 +87,7 @@ public:
const QString &importUri, const QString &importVersion);
virtual CppQmlTypeHash cppQmlTypes() const;
+ virtual BuiltinPackagesHash builtinPackages() const;
Q_SIGNALS:
void projectPathChanged(const QString &projectPath);