QmlProjectManager: Respect import paths when checking the uri

When checking if an uri in a qmldir file is valid,
the cmake generator did not take the importPaths given in
the qmlproject into account. This is now fixed.

Change-Id: I403665f0c9c57bd41f644cd7c7e19349820b1824
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Knud Dollereder
2024-06-27 16:40:58 +02:00
parent 5036c1813d
commit db9ee194fb

View File

@@ -224,10 +224,20 @@ bool CMakeGenerator::ignore(const Utils::FilePath &path) const
bool CMakeGenerator::checkUri(const QString& uri, const Utils::FilePath &path) const
{
Utils::FilePath relative = path.relativeChildPath(m_root->dir);
const QList<QStringView> pathComponents = relative.pathView().split('/', Qt::SkipEmptyParts);
const QStringList uriComponents = uri.split('.', Qt::SkipEmptyParts);
QTC_ASSERT(buildSystem(), return false);
Utils::FilePath relative = path.relativeChildPath(m_root->dir);
QList<QStringView> pathComponents = relative.pathView().split('/', Qt::SkipEmptyParts);
for (const auto& import : buildSystem()->importPaths()) {
Utils::FilePath importPath = Utils::FilePath::fromUserInput(import);
for (const auto& component : importPath.pathView().split('/', Qt::SkipEmptyParts)) {
if (component == pathComponents.first())
pathComponents.pop_front();
}
}
const QStringList uriComponents = uri.split('.', Qt::SkipEmptyParts);
if (pathComponents.size() == uriComponents.size()) {
for (qsizetype i=0; i<pathComponents.size(); ++i) {
if (pathComponents[i] != uriComponents[i])