aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2022-09-22 15:18:38 +0200
committerSami Shalayel <sami.shalayel@qt.io>2022-10-31 15:10:53 +0200
commitbfdf1bf797baa96af1ee800c7d6ef40816ced953 (patch)
tree3767f53513a199301a18380ee5ae2ec8c559bbab /tools
parent728270a0cb8f652ffe4bf0da623583674e6f9357 (diff)
qmltc: support inline components from different qml files
Make qmltc aware that inline components can be shared between files such that it does not complain about not finding them. Typical usage are `MyOtherFile.MyInlineComponent {}` and `ModuleName.MyOtherFile.MyInlineComponent {}` for an an inline component called MyInlineComponent defined in MyOtherFile.qml, maybe also in a module called ModuleName. Make QQmlJSScope::findType() aware that inline components exists (and potentially that they might also appear in namespaced types). They can also be "imported" or reexported from basetypes and/or deeply nested in some children scopes. Also make it public so that qqmljsimportvisitor can use it when processing property types. Added some tests testing both notations (with and without the qualifed module name). Also add a test to see if there is no confusion between the enums and the inline components (due to their very similar notations). Fixes: QTBUG-106592 Change-Id: I8f2d4790729902ffa664fd0eb1b7c3279af8ddca Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmltc/qmltcvisitor.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/qmltc/qmltcvisitor.cpp b/tools/qmltc/qmltcvisitor.cpp
index a5050b3bde..3143316652 100644
--- a/tools/qmltc/qmltcvisitor.cpp
+++ b/tools/qmltc/qmltcvisitor.cpp
@@ -188,7 +188,7 @@ bool QmltcVisitor::visit(QQmlJS::AST::UiObjectDefinition *object)
if (!QQmlJSImportVisitor::visit(object))
return false;
- if (processingRoot) {
+ if (processingRoot || m_currentScope->isInlineComponent()) {
Q_ASSERT(rootScopeIsValid());
setRootFilePath();
}
@@ -796,9 +796,12 @@ void QmltcVisitor::checkForNamingCollisionsWithCpp(const QQmlJSScope::ConstPtr &
// this information in QQmlJSMetaPropertyBinding currently
}
+/*! \internal
+ * Sets the file paths for the document and the inline components roots.
+ */
void QmltcVisitor::setRootFilePath()
{
- const QString filePath = m_exportedRootScope->filePath();
+ const QString filePath = m_currentScope->filePath();
if (filePath.endsWith(u".h")) // assume the correct path is set
return;
Q_ASSERT(filePath.endsWith(u".qml"_s));
@@ -816,7 +819,7 @@ void QmltcVisitor::setRootFilePath()
return;
}
// NB: get the file name to avoid prefixes
- m_exportedRootScope->setFilePath(QFileInfo(*firstHeader).fileName());
+ m_currentScope->setFilePath(QFileInfo(*firstHeader).fileName());
}
QString QmltcVisitor::sourceDirectoryPath(const QString &path)