aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmlcompiler')
-rw-r--r--src/qmlcompiler/qqmljsscopesbyid_p.h23
-rw-r--r--src/qmlcompiler/qqmljstyperesolver.cpp7
-rw-r--r--src/qmlcompiler/qqmljstyperesolver_p.h6
3 files changed, 23 insertions, 13 deletions
diff --git a/src/qmlcompiler/qqmljsscopesbyid_p.h b/src/qmlcompiler/qqmljsscopesbyid_p.h
index ab97aeaccf..c9dca9ae34 100644
--- a/src/qmlcompiler/qqmljsscopesbyid_p.h
+++ b/src/qmlcompiler/qqmljsscopesbyid_p.h
@@ -22,6 +22,12 @@
QT_BEGIN_NAMESPACE
+enum QQmlJSScopesByIdOption: char {
+ Default = 0,
+ AssumeComponentsAreBound = 1,
+};
+Q_DECLARE_FLAGS(QQmlJSScopesByIdOptions, QQmlJSScopesByIdOption);
+
class QQmlJSScopesById
{
public:
@@ -34,11 +40,12 @@ public:
void setValueTypesAreAddressable(bool addressable) { m_valueTypesAreAddressable = addressable; }
bool valueTypesAreAddressable() const { return m_valueTypesAreAddressable; }
- QString id(const QQmlJSScope::ConstPtr &scope, const QQmlJSScope::ConstPtr &referrer) const
+ QString id(const QQmlJSScope::ConstPtr &scope, const QQmlJSScope::ConstPtr &referrer,
+ QQmlJSScopesByIdOptions options = Default) const
{
const QQmlJSScope::ConstPtr referrerRoot = componentRoot(referrer);
for (auto it = m_scopesById.begin(), end = m_scopesById.end(); it != end; ++it) {
- if (*it == scope && isComponentVisible(componentRoot(*it), referrerRoot))
+ if (*it == scope && isComponentVisible(componentRoot(*it), referrerRoot, options))
return it.key();
}
return QString();
@@ -49,7 +56,8 @@ public:
Returns the scope that has id \a id in the component to which \a referrer belongs to.
If no such scope exists, a null scope is returned.
*/
- QQmlJSScope::ConstPtr scope(const QString &id, const QQmlJSScope::ConstPtr &referrer) const
+ QQmlJSScope::ConstPtr scope(const QString &id, const QQmlJSScope::ConstPtr &referrer,
+ QQmlJSScopesByIdOptions options = Default) const
{
Q_ASSERT(!id.isEmpty());
const auto range = m_scopesById.equal_range(id);
@@ -58,7 +66,7 @@ public:
const QQmlJSScope::ConstPtr referrerRoot = componentRoot(referrer);
for (auto it = range.first; it != range.second; ++it) {
- if (isComponentVisible(componentRoot(*it), referrerRoot))
+ if (isComponentVisible(componentRoot(*it), referrerRoot, options))
return *it;
}
@@ -95,10 +103,11 @@ private:
return scope;
}
- bool isComponentVisible(
- const QQmlJSScope::ConstPtr &observed, const QQmlJSScope::ConstPtr &observer) const
+ bool isComponentVisible(const QQmlJSScope::ConstPtr &observed,
+ const QQmlJSScope::ConstPtr &observer,
+ QQmlJSScopesByIdOptions options) const
{
- if (!m_componentsAreBound)
+ if (!m_componentsAreBound && !options.testAnyFlag(AssumeComponentsAreBound))
return observed == observer;
for (QQmlJSScope::ConstPtr scope = observer; scope; scope = scope->parentScope()) {
diff --git a/src/qmlcompiler/qqmljstyperesolver.cpp b/src/qmlcompiler/qqmljstyperesolver.cpp
index 14f4436eac..7bd8138421 100644
--- a/src/qmlcompiler/qqmljstyperesolver.cpp
+++ b/src/qmlcompiler/qqmljstyperesolver.cpp
@@ -997,8 +997,9 @@ static bool isRevisionAllowed(int memberRevision, const QQmlJSScope::ConstPtr &s
return typeRevision.isValid() && typeRevision >= revision;
}
-QQmlJSRegisterContent QQmlJSTypeResolver::scopedType(
- const QQmlJSScope::ConstPtr &scope, const QString &name, int lookupIndex) const
+QQmlJSRegisterContent QQmlJSTypeResolver::scopedType(const QQmlJSScope::ConstPtr &scope,
+ const QString &name, int lookupIndex,
+ QQmlJSScopesByIdOptions options) const
{
const auto isAssignedToDefaultProperty = [this](const QQmlJSScope::ConstPtr &parent,
const QQmlJSScope::ConstPtr &child) {
@@ -1017,7 +1018,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::scopedType(
return false;
};
- if (QQmlJSScope::ConstPtr identified = m_objectsById.scope(name, scope)) {
+ if (QQmlJSScope::ConstPtr identified = m_objectsById.scope(name, scope, options)) {
return QQmlJSRegisterContent::create(storedType(identified), identified, lookupIndex,
QQmlJSRegisterContent::ObjectById, scope);
}
diff --git a/src/qmlcompiler/qqmljstyperesolver_p.h b/src/qmlcompiler/qqmljstyperesolver_p.h
index 47f82afe7e..5d740ded13 100644
--- a/src/qmlcompiler/qqmljstyperesolver_p.h
+++ b/src/qmlcompiler/qqmljstyperesolver_p.h
@@ -120,9 +120,9 @@ public:
QQmlJSRegisterContent builtinType(const QQmlJSScope::ConstPtr &type) const;
QQmlJSRegisterContent globalType(const QQmlJSScope::ConstPtr &type) const;
- QQmlJSRegisterContent scopedType(
- const QQmlJSScope::ConstPtr &scope, const QString &name,
- int lookupIndex = QQmlJSRegisterContent::InvalidLookupIndex) const;
+ QQmlJSRegisterContent scopedType(const QQmlJSScope::ConstPtr &scope, const QString &name,
+ int lookupIndex = QQmlJSRegisterContent::InvalidLookupIndex,
+ QQmlJSScopesByIdOptions options = Default) const;
QQmlJSRegisterContent memberType(
const QQmlJSRegisterContent &type, const QString &name,
int lookupIndex = QQmlJSRegisterContent::InvalidLookupIndex) const;