85
86
87
88
89
90
91
92
93
94
95
96
97
98
101 const QQmlJSScope::ConstPtr &scope,
const QQmlJSScope::ConstPtr &referrer,
102 QQmlJSScopesByIdOptions options, F &&callback)
const
104 Q_ASSERT(!scope.isNull());
107 const QString key = m_scopesById.key(scope);
112 possibleComponentRoots(
113 referrer, [&](
const QQmlJSScope::ConstPtr &referrerRoot,
114 QQmlJSScope::IsComponentRoot referrerConfidence) {
115 return possibleComponentRoots(
116 scope, [&](
const QQmlJSScope::ConstPtr &referredRoot,
117 QQmlJSScope::IsComponentRoot referredConfidence) {
118 if (isComponentVisible(referredRoot, referrerRoot, options)) {
121 if (callback(key, confidence(referrerConfidence, referredConfidence))
136
137
138
139
140
141
142 QString id(
const QQmlJSScope::ConstPtr &scope,
const QQmlJSScope::ConstPtr &referrer,
143 QQmlJSScopesByIdOptions options =
Default)
const
145 CertainCallback<QString> result;
146 const Success isCertain = possibleIds(scope, referrer, options, result);
150 Q_ASSERT(isCertain ==
Success::Yes || result.result.isEmpty());
152 return result.result;
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
173 const QString &id,
const QQmlJSScope::ConstPtr &referrer,
174 QQmlJSScopesByIdOptions options, F &&callback)
const
176 Q_ASSERT(!id.isEmpty());
179 const auto range = m_scopesById.equal_range(id);
180 for (
auto it = range.first; it != range.second; ++it) {
181 possibleComponentRoots(
182 *it, [&](
const QQmlJSScope::ConstPtr &referredRoot,
183 QQmlJSScope::IsComponentRoot referredConfidence) {
185 possibleComponentRoots(
186 referrer, [&](
const QQmlJSScope::ConstPtr &referrerRoot,
187 QQmlJSScope::IsComponentRoot referrerConfidence) {
189 if (!isComponentVisible(referredRoot, referrerRoot, options))
192 if (callback(*it, confidence(referrerConfidence, referredConfidence))
221
222
223
224
225
226
228 QQmlJSScopesByIdOptions options =
Default)
const
230 CertainCallback<QQmlJSScope::ConstPtr> result;
231 const Success isCertain = possibleScopes(id, referrer, options, result);
235 Q_ASSERT(isCertain ==
Success::Yes || result.result.isNull());
237 return result.result;
240 void insert(
const QString &id,
const QQmlJSScope::ConstPtr &scope)
242 Q_ASSERT(!id.isEmpty());
243 m_scopesById.insert(id, scope);
246 void clear() { m_scopesById.clear(); }
249
250
251
252
253
254
265 if (m_scopesById.size() == 0)
268 std::multimap<QQmlJSScope::ConstPtr, IdWithScope> componentRootsToIds;
269 for (
auto it = m_scopesById.cbegin(), end = m_scopesById.cend(); it != end; ++it) {
270 possibleComponentRoots(
272 [&it, &componentRootsToIds](
const QQmlJSScope::ConstPtr &componentRoot,
273 QQmlJSScope::IsComponentRoot) {
274 componentRootsToIds.insert({ componentRoot, { it.key(), it.value() } });
278 return componentRootsToIds;
283 static CallbackResult possibleComponentRoots(
const QQmlJSScope::ConstPtr &inner, F &&callback)
285 QQmlJSScope::ConstPtr scope = inner;
286 QQmlJSScope::IsComponentRoot maxConfidence = QQmlJSScope::IsComponentRoot::Yes;
288 switch (scope->componentRootStatus()) {
289 case QQmlJSScope::IsComponentRoot::Maybe:
290 if (callback(scope, QQmlJSScope::IsComponentRoot::Maybe)
297 maxConfidence = QQmlJSScope::IsComponentRoot::Maybe;
299 case QQmlJSScope::IsComponentRoot::No:
300 scope = scope->parentScope();
302 case QQmlJSScope::IsComponentRoot::Yes:
303 return callback(scope, maxConfidence);
311 QQmlJSScope::IsComponentRoot a, QQmlJSScope::IsComponentRoot b) {
313 case QQmlJSScope::IsComponentRoot::Yes:
314 return b == QQmlJSScope::IsComponentRoot::Yes
315 ? Confidence::Certain
316 : Confidence::Possible;
317 case QQmlJSScope::IsComponentRoot::Maybe:
326 bool isComponentVisible(
const QQmlJSScope::ConstPtr &observed,
327 const QQmlJSScope::ConstPtr &observer,
328 QQmlJSScopesByIdOptions options)
const
331 return observed == observer;
333 for (QQmlJSScope::ConstPtr scope = observer; scope; scope = scope->parentScope()) {
334 if (scope == observed)
341 QMultiHash<QString, QQmlJSScope::ConstPtr> m_scopesById;
342 bool m_componentsAreBound =
false;
343 bool m_signaturesAreEnforced =
true;
344 bool m_valueTypesAreAddressable =
false;
345 bool m_valueTypesAreAssertable =
false;