forked from qt-creator/qt-creator
Qml-C++: Find C++ qmlRegisterType calls and populate QML code model.
Reviewed-by: Erik Verbruggen
This commit is contained in:
@@ -1947,6 +1947,7 @@ const Value *Function::invoke(const Activation *activation) const
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QList<const FakeMetaObject *> CppQmlTypesLoader::builtinObjects;
|
||||
QList<const FakeMetaObject *> CppQmlTypesLoader::cppObjects;
|
||||
|
||||
QStringList CppQmlTypesLoader::load(const QFileInfoList &xmlFiles)
|
||||
{
|
||||
@@ -2440,6 +2441,7 @@ Engine::Engine()
|
||||
initializePrototypes();
|
||||
|
||||
_cppQmlTypes.load(this, CppQmlTypesLoader::builtinObjects);
|
||||
_cppQmlTypes.load(this, CppQmlTypesLoader::cppObjects);
|
||||
|
||||
// the 'Qt' object is dumped even though it is not exported
|
||||
// it contains useful information, in particular on enums - add the
|
||||
|
||||
@@ -593,6 +593,7 @@ public:
|
||||
/** \return an empty list when successful, error messages otherwise. */
|
||||
static QStringList load(const QFileInfoList &xmlFiles);
|
||||
static QList<const LanguageUtils::FakeMetaObject *> builtinObjects;
|
||||
static QList<const LanguageUtils::FakeMetaObject *> cppObjects;
|
||||
|
||||
// parses the xml string and fills the newObjects map
|
||||
static QString parseQmlTypeXml(const QByteArray &xml,
|
||||
|
||||
@@ -162,9 +162,26 @@ void Link::populateImportedTypes(TypeEnvironment *typeEnv, Document::Ptr doc)
|
||||
{
|
||||
Q_D(Link);
|
||||
|
||||
if (! (doc->qmlProgram() && doc->qmlProgram()->imports))
|
||||
if (! doc->qmlProgram())
|
||||
return;
|
||||
|
||||
// implicit imports: the <default> package is always available
|
||||
const QLatin1String defaultPackage("<default>");
|
||||
if (engine()->cppQmlTypes().hasPackage(defaultPackage)) {
|
||||
ImportInfo info(ImportInfo::LibraryImport, defaultPackage);
|
||||
ObjectValue *import = d->importCache.value(ImportCacheKey(info));
|
||||
if (!import) {
|
||||
import = new ObjectValue(engine());
|
||||
foreach (QmlObjectValue *object,
|
||||
engine()->cppQmlTypes().typesForImport(defaultPackage, ComponentVersion())) {
|
||||
import->setProperty(object->className(), object);
|
||||
}
|
||||
d->importCache.insert(ImportCacheKey(info), import);
|
||||
}
|
||||
typeEnv->addImport(import, info);
|
||||
}
|
||||
|
||||
|
||||
// implicit imports:
|
||||
// qml files in the same directory are available without explicit imports
|
||||
ImportInfo implcitImportInfo(ImportInfo::ImplicitDirectoryImport, doc->path());
|
||||
|
||||
Reference in New Issue
Block a user