diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2024-04-19 12:52:19 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2024-04-23 20:33:38 +0200 |
commit | 0559256ddea974d43f971b05c62e61ad76437697 (patch) | |
tree | 73d3d06fe6b2ed73c76554be0b85fb00945d9023 /src | |
parent | 22a3ebbe438c2dd5e00dabbdb2819206849ea056 (diff) |
dom: load .ui.qml files in implicit import
Do not filter out .ui.qml files when loading .qml files from the
implicit import directory. Fix the regexp to also accept `.ui.qml` files
and make the regexp static.
Add a test.
This was discovered while trying to rename a .ui.qml file for the
renaming task.
Task-number: QTBUG-114993
Change-Id: I9de09b3e6c89e07dc9e73cacdf3ebe162771f2f8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qmldom/qqmldomexternalitems.cpp | 9 | ||||
-rw-r--r-- | src/qmldom/qqmldomexternalitems_p.h | 1 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/qmldom/qqmldomexternalitems.cpp b/src/qmldom/qqmldomexternalitems.cpp index 0ce3c9f5b4..6f48aa19e3 100644 --- a/src/qmldom/qqmldomexternalitems.cpp +++ b/src/qmldom/qqmldomexternalitems.cpp @@ -16,7 +16,6 @@ #include <QtCore/QDir> #include <QtCore/QScopeGuard> #include <QtCore/QFileInfo> -#include <QtCore/QRegularExpression> #include <QtCore/QRegularExpressionMatch> #include <algorithm> @@ -604,9 +603,11 @@ bool QmlDirectory::iterateDirectSubpaths(const DomItem &self, DirectVisitor visi bool QmlDirectory::addQmlFilePath(const QString &relativePath) { - QRegularExpression qmlFileRe(QRegularExpression::anchoredPattern( - uR"((?<compName>[a-zA-z0-9_]+)\.(?:qml|qmlannotation))")); - QRegularExpressionMatch m = qmlFileRe.match(relativePath); + static const QRegularExpression qmlFileRegularExpression{ + QRegularExpression::anchoredPattern( + uR"((?<compName>[a-zA-z0-9_]+)\.(?:qml|qmlannotation|ui\.qml))") + }; + QRegularExpressionMatch m = qmlFileRegularExpression.match(relativePath); if (m.hasMatch() && !m_qmlFiles.values(m.captured(u"compName")).contains(relativePath)) { m_qmlFiles.insert(m.captured(u"compName"), relativePath); Export e; diff --git a/src/qmldom/qqmldomexternalitems_p.h b/src/qmldom/qqmldomexternalitems_p.h index 6b88efeca4..1aa9d765cb 100644 --- a/src/qmldom/qqmldomexternalitems_p.h +++ b/src/qmldom/qqmldomexternalitems_p.h @@ -25,6 +25,7 @@ #include <QtQml/private/qqmldirparser_p.h> #include <QtQmlCompiler/private/qqmljstyperesolver_p.h> #include <QtCore/QMetaType> +#include <QtCore/qregularexpression.h> #include <limits> #include <memory> |