forked from qt-creator/qt-creator
qmljs: Do not use app.qmltypes and lib.qmltypes anymore
Task-number: QTBUG-82710 Change-Id: I876ec2b8e2b668a239248511b0fbd58389098de6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include <utils/qrcparser.h>
|
#include <utils/qrcparser.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QDirIterator>
|
||||||
|
|
||||||
using namespace LanguageUtils;
|
using namespace LanguageUtils;
|
||||||
using namespace QmlJS::AST;
|
using namespace QmlJS::AST;
|
||||||
@@ -385,8 +386,10 @@ Import LinkPrivate::importNonFile(const Document::Ptr &doc, const ImportInfo &im
|
|||||||
|
|
||||||
if (!importFound) {
|
if (!importFound) {
|
||||||
for (const QString &dir : qAsConst(m_applicationDirectories)) {
|
for (const QString &dir : qAsConst(m_applicationDirectories)) {
|
||||||
|
QDirIterator it(dir, QStringList { "*.qmltypes" }, QDir::Files);
|
||||||
|
|
||||||
// This adds the types to the C++ types, to be found below if applicable.
|
// This adds the types to the C++ types, to be found below if applicable.
|
||||||
if (QFile::exists(dir + "/app.qmltypes"))
|
if (it.hasNext())
|
||||||
importLibrary(doc, dir, &import);
|
importLibrary(doc, dir, &import);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include <utils/runextensions.h>
|
#include <utils/runextensions.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QDirIterator>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
@@ -781,13 +782,17 @@ static bool findNewQmlApplicationInPath(const QString &path,
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDir dir(path);
|
QString qmltypesFile;
|
||||||
const QLatin1String appQmltypes("app.qmltypes");
|
|
||||||
QFile appQmltypesFile(dir.filePath(appQmltypes));
|
QDir dir(path);
|
||||||
if (!appQmltypesFile.exists())
|
QDirIterator it(path, QStringList { "*.qmltypes" }, QDir::Files);
|
||||||
|
|
||||||
|
if (!it.hasNext())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LibraryInfo libraryInfo = LibraryInfo(QmlDirParser::TypeInfo(appQmltypes));
|
qmltypesFile = it.next();
|
||||||
|
|
||||||
|
LibraryInfo libraryInfo = LibraryInfo(QmlDirParser::TypeInfo(qmltypesFile));
|
||||||
const QString libraryPath = dir.absolutePath();
|
const QString libraryPath = dir.absolutePath();
|
||||||
newLibraries->insert(libraryPath);
|
newLibraries->insert(libraryPath);
|
||||||
modelManager->updateLibraryInfo(path, libraryInfo);
|
modelManager->updateLibraryInfo(path, libraryInfo);
|
||||||
|
@@ -36,17 +36,12 @@
|
|||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QDirIterator>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
using namespace LanguageUtils;
|
using namespace LanguageUtils;
|
||||||
using namespace QmlJS;
|
using namespace QmlJS;
|
||||||
|
|
||||||
static const QStringList qmltypesFileNames = {
|
|
||||||
QLatin1String("plugins.qmltypes"),
|
|
||||||
QLatin1String("app.qmltypes"),
|
|
||||||
QLatin1String("lib.qmltypes")
|
|
||||||
};
|
|
||||||
|
|
||||||
PluginDumper::PluginDumper(ModelManagerInterface *modelManager)
|
PluginDumper::PluginDumper(ModelManagerInterface *modelManager)
|
||||||
: QObject(modelManager)
|
: QObject(modelManager)
|
||||||
, m_modelManager(modelManager)
|
, m_modelManager(modelManager)
|
||||||
@@ -152,9 +147,12 @@ void PluginDumper::onLoadPluginTypes(const QString &libraryPath, const QString &
|
|||||||
plugin.importVersion = importVersion;
|
plugin.importVersion = importVersion;
|
||||||
|
|
||||||
// add default qmltypes file if it exists
|
// add default qmltypes file if it exists
|
||||||
for (const QString &qmltypesFileName : qmltypesFileNames) {
|
QDirIterator it(canonicalLibraryPath, QStringList { "*.qmltypes" }, QDir::Files);
|
||||||
const QString defaultQmltypesPath = makeAbsolute(qmltypesFileName, canonicalLibraryPath);
|
|
||||||
if (!plugin.typeInfoPaths.contains(defaultQmltypesPath) && QFile::exists(defaultQmltypesPath))
|
while (it.hasNext()) {
|
||||||
|
const QString defaultQmltypesPath = makeAbsolute(it.next(), canonicalLibraryPath);
|
||||||
|
|
||||||
|
if (!plugin.typeInfoPaths.contains(defaultQmltypesPath))
|
||||||
plugin.typeInfoPaths += defaultQmltypesPath;
|
plugin.typeInfoPaths += defaultQmltypesPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,11 +403,10 @@ QString PluginDumper::buildQmltypesPath(const QString &name) const
|
|||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
for (const QString &qmltypesFileName : qmltypesFileNames) {
|
QDirIterator it(path, QStringList { "*.qmltypes" }, QDir::Files);
|
||||||
const QString filename = path + QLatin1Char('/') + qmltypesFileName;
|
|
||||||
if (QFile::exists(filename))
|
if (it.hasNext())
|
||||||
return filename;
|
return it.next();
|
||||||
}
|
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user