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 <QDir>
|
||||
#include <QDirIterator>
|
||||
|
||||
using namespace LanguageUtils;
|
||||
using namespace QmlJS::AST;
|
||||
@@ -385,8 +386,10 @@ Import LinkPrivate::importNonFile(const Document::Ptr &doc, const ImportInfo &im
|
||||
|
||||
if (!importFound) {
|
||||
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.
|
||||
if (QFile::exists(dir + "/app.qmltypes"))
|
||||
if (it.hasNext())
|
||||
importLibrary(doc, dir, &import);
|
||||
}
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include <utils/runextensions.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QMetaObject>
|
||||
@@ -781,13 +782,17 @@ static bool findNewQmlApplicationInPath(const QString &path,
|
||||
default: break;
|
||||
}
|
||||
|
||||
const QDir dir(path);
|
||||
const QLatin1String appQmltypes("app.qmltypes");
|
||||
QFile appQmltypesFile(dir.filePath(appQmltypes));
|
||||
if (!appQmltypesFile.exists())
|
||||
QString qmltypesFile;
|
||||
|
||||
QDir dir(path);
|
||||
QDirIterator it(path, QStringList { "*.qmltypes" }, QDir::Files);
|
||||
|
||||
if (!it.hasNext())
|
||||
return false;
|
||||
|
||||
LibraryInfo libraryInfo = LibraryInfo(QmlDirParser::TypeInfo(appQmltypes));
|
||||
qmltypesFile = it.next();
|
||||
|
||||
LibraryInfo libraryInfo = LibraryInfo(QmlDirParser::TypeInfo(qmltypesFile));
|
||||
const QString libraryPath = dir.absolutePath();
|
||||
newLibraries->insert(libraryPath);
|
||||
modelManager->updateLibraryInfo(path, libraryInfo);
|
||||
|
@@ -36,17 +36,12 @@
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace LanguageUtils;
|
||||
using namespace QmlJS;
|
||||
|
||||
static const QStringList qmltypesFileNames = {
|
||||
QLatin1String("plugins.qmltypes"),
|
||||
QLatin1String("app.qmltypes"),
|
||||
QLatin1String("lib.qmltypes")
|
||||
};
|
||||
|
||||
PluginDumper::PluginDumper(ModelManagerInterface *modelManager)
|
||||
: QObject(modelManager)
|
||||
, m_modelManager(modelManager)
|
||||
@@ -152,9 +147,12 @@ void PluginDumper::onLoadPluginTypes(const QString &libraryPath, const QString &
|
||||
plugin.importVersion = importVersion;
|
||||
|
||||
// add default qmltypes file if it exists
|
||||
for (const QString &qmltypesFileName : qmltypesFileNames) {
|
||||
const QString defaultQmltypesPath = makeAbsolute(qmltypesFileName, canonicalLibraryPath);
|
||||
if (!plugin.typeInfoPaths.contains(defaultQmltypesPath) && QFile::exists(defaultQmltypesPath))
|
||||
QDirIterator it(canonicalLibraryPath, QStringList { "*.qmltypes" }, QDir::Files);
|
||||
|
||||
while (it.hasNext()) {
|
||||
const QString defaultQmltypesPath = makeAbsolute(it.next(), canonicalLibraryPath);
|
||||
|
||||
if (!plugin.typeInfoPaths.contains(defaultQmltypesPath))
|
||||
plugin.typeInfoPaths += defaultQmltypesPath;
|
||||
}
|
||||
|
||||
@@ -405,11 +403,10 @@ QString PluginDumper::buildQmltypesPath(const QString &name) const
|
||||
if (path.isEmpty())
|
||||
return QString();
|
||||
|
||||
for (const QString &qmltypesFileName : qmltypesFileNames) {
|
||||
const QString filename = path + QLatin1Char('/') + qmltypesFileName;
|
||||
if (QFile::exists(filename))
|
||||
return filename;
|
||||
}
|
||||
QDirIterator it(path, QStringList { "*.qmltypes" }, QDir::Files);
|
||||
|
||||
if (it.hasNext())
|
||||
return it.next();
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
Reference in New Issue
Block a user