aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsscope.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmlcompiler/qqmljsscope.cpp')
-rw-r--r--src/qmlcompiler/qqmljsscope.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsscope.cpp b/src/qmlcompiler/qqmljsscope.cpp
index 73a1da74ea..148c8c122e 100644
--- a/src/qmlcompiler/qqmljsscope.cpp
+++ b/src/qmlcompiler/qqmljsscope.cpp
@@ -41,6 +41,21 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QQmlJSScope
+ \internal
+ \brief Tracks the types for the QmlCompiler
+
+ QQmlJSScope tracks the types used in qml for the QmlCompiler.
+
+ Multiple QQmlJSScope objects might be created for the same conceptual type, except when reused
+ due to extensive caching. Two QQmlJSScope objects are considered equal when they are backed
+ by the same implementation, that is, they have the same internalName.
+ The qualifiedName of the QQmlJSScope for a type imported from multiple modules will contain the
+ name of one of the modules that imported it, which is not unique and might change depending
+ on the caching in .
+*/
+
using namespace Qt::StringLiterals;
void QQmlJSScope::reparent(const QQmlJSScope::Ptr &parentScope, const QQmlJSScope::Ptr &childScope)
@@ -781,6 +796,22 @@ bool QQmlJSScope::isNameDeferred(const QString &name) const
return isDeferred;
}
+QString QQmlJSScope::qualifiedNameFrom(const QString &moduleName, const QString &typeName,
+ const QTypeRevision &firstRevision,
+ const QTypeRevision &lastRevision)
+{
+ QString qualifiedName =
+ u"%1/%2 %3.%4"_s.arg(moduleName, typeName)
+ .arg(firstRevision.hasMajorVersion() ? firstRevision.majorVersion() : 0)
+ .arg(firstRevision.hasMinorVersion() ? firstRevision.minorVersion() : 0);
+ if (firstRevision != lastRevision) {
+ qualifiedName += u"-%1.%2"_s
+ .arg(lastRevision.hasMajorVersion() ? lastRevision.majorVersion() : 0)
+ .arg(lastRevision.hasMinorVersion() ? lastRevision.minorVersion() : 0);
+ }
+ return qualifiedName;
+}
+
void QQmlJSScope::setBaseTypeName(const QString &baseTypeName)
{
m_flags.setFlag(HasBaseTypeError, false);
@@ -915,6 +946,8 @@ bool QQmlJSScope::Export::isValid() const
void QDeferredFactory<QQmlJSScope>::populate(const QSharedPointer<QQmlJSScope> &scope) const
{
+ scope->setQualifiedName(m_qualifiedName);
+ scope->setModuleName(m_moduleName);
QQmlJSTypeReader typeReader(m_importer, m_filePath);
typeReader(scope);
m_importer->m_globalWarnings.append(typeReader.errors());