forked from qt-creator/qt-creator
qmljs: (QString -> Utils::FilePath)++
convert more QString containing paths to Utils::FilePath Change-Id: I1219d7d147993e48cfa641dc9bea72ab38c90f51 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
committed by
Tim Jenssen
parent
0bb272d411
commit
fd89043de2
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "parser/qmljsast_p.h"
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QColor>
|
||||
@@ -256,8 +257,9 @@ const QStringList QmlJS::splitVersion(const QString &version)
|
||||
* \return The module paths if found, an empty string otherwise
|
||||
* \see qmlimportscanner in qtdeclarative/tools
|
||||
*/
|
||||
QStringList QmlJS::modulePaths(const QString &name, const QString &version,
|
||||
const QStringList &importPaths)
|
||||
QList<Utils::FilePath> QmlJS::modulePaths(const QString &name,
|
||||
const QString &version,
|
||||
const QList<Utils::FilePath> &importPaths)
|
||||
{
|
||||
Q_ASSERT(maybeModuleVersion(version));
|
||||
if (importPaths.isEmpty())
|
||||
@@ -267,27 +269,27 @@ QStringList QmlJS::modulePaths(const QString &name, const QString &version,
|
||||
const QStringList parts = name.split('.', Qt::SkipEmptyParts);
|
||||
auto mkpath = [](const QStringList &xs) -> QString { return xs.join(QLatin1Char('/')); };
|
||||
|
||||
QStringList result;
|
||||
QString candidate;
|
||||
QList<Utils::FilePath> result;
|
||||
Utils::FilePath candidate;
|
||||
|
||||
for (const QString &versionPart : splitVersion(sanitizedVersion)) {
|
||||
for (const QString &path : importPaths) {
|
||||
for (const Utils::FilePath &path : importPaths) {
|
||||
for (int i = parts.count() - 1; i >= 0; --i) {
|
||||
candidate = QDir::cleanPath(QString::fromLatin1("%1/%2.%3/%4")
|
||||
.arg(path,
|
||||
mkpath(parts.mid(0, i + 1)),
|
||||
versionPart,
|
||||
mkpath(parts.mid(i + 1))));
|
||||
if (QDir(candidate).exists())
|
||||
candidate = path.pathAppended(QString::fromLatin1("%2.%3/%4")
|
||||
.arg(mkpath(parts.mid(0, i + 1)),
|
||||
versionPart,
|
||||
mkpath(parts.mid(i + 1))))
|
||||
.cleanPath();
|
||||
if (candidate.exists())
|
||||
result << candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Version is empty
|
||||
for (const QString &path: importPaths) {
|
||||
candidate = QDir::cleanPath(QString::fromLatin1("%1/%2").arg(path, mkpath(parts)));
|
||||
if (QDir(candidate).exists())
|
||||
for (const Utils::FilePath &path : importPaths) {
|
||||
candidate = path.pathAppended(mkpath(parts)).cleanPath();
|
||||
if (candidate.exists())
|
||||
result << candidate;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user