forked from qt-creator/qt-creator
QmlJS: Scan app.qmltypes and lib.qmltypes for type information
app.qmltypes is being added as a new convention to Qt 5.15. These files are to be found next to application binaries, and contain the QML types those application register themselves, in contrast to QML types registered from plugins loaded via the regular import mechanism. lib.qmltypes works the same way, in principle, for libraries. This change only adds it to the possible names for qmltypes files, though. Change-Id: I1d7c5835c8c3e988d214c5cdb949ca677b48dfc5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -111,6 +111,7 @@ private:
|
||||
Snapshot m_snapshot;
|
||||
ValueOwner *m_valueOwner = nullptr;
|
||||
QStringList m_importPaths;
|
||||
QStringList m_applicationDirectories;
|
||||
LibraryInfo m_builtins;
|
||||
ViewerContext m_vContext;
|
||||
|
||||
@@ -140,6 +141,7 @@ Link::Link(const Snapshot &snapshot, const ViewerContext &vContext, const Librar
|
||||
d->m_valueOwner = new ValueOwner;
|
||||
d->m_snapshot = snapshot;
|
||||
d->m_importPaths = vContext.paths;
|
||||
d->m_applicationDirectories = vContext.applicationDirectories;
|
||||
d->m_builtins = builtins;
|
||||
d->m_vContext = vContext;
|
||||
|
||||
@@ -381,6 +383,14 @@ Import LinkPrivate::importNonFile(const Document::Ptr &doc, const ImportInfo &im
|
||||
QString libraryPath = modulePath(packageName, version.toString(), m_importPaths);
|
||||
bool importFound = !libraryPath.isEmpty() && importLibrary(doc, libraryPath, &import);
|
||||
|
||||
if (!importFound) {
|
||||
for (const QString &dir : qAsConst(m_applicationDirectories)) {
|
||||
// This adds the types to the C++ types, to be found below if applicable.
|
||||
if (QFile::exists(dir + "/app.qmltypes"))
|
||||
importLibrary(doc, dir, &import);
|
||||
}
|
||||
}
|
||||
|
||||
// if there are cpp-based types for this package, use them too
|
||||
if (m_valueOwner->cppQmlTypes().hasModule(packageName)) {
|
||||
importFound = true;
|
||||
|
||||
Reference in New Issue
Block a user