82
83
84
85
86
87
88
89
90
91
92
93
94
95
98 const QQmlJSScope::ConstPtr &scope,
const QQmlJSScope::ConstPtr &referrer,
99 QQmlJSScopesByIdOptions options, F &&callback)
const
101 Q_ASSERT(!scope.isNull());
104 const QString key = m_scopesById.key(scope);
109 possibleComponentRoots(
110 referrer, [&](
const QQmlJSScope::ConstPtr &referrerRoot,
111 QQmlJSScope::IsComponentRoot referrerConfidence) {
112 return possibleComponentRoots(
113 scope, [&](
const QQmlJSScope::ConstPtr &referredRoot,
114 QQmlJSScope::IsComponentRoot referredConfidence) {
115 if (isComponentVisible(referredRoot, referrerRoot, options)) {
118 if (callback(key, confidence(referrerConfidence, referredConfidence))
133
134
135
136
137
138
139 QString id(
const QQmlJSScope::ConstPtr &scope,
const QQmlJSScope::ConstPtr &referrer,
140 QQmlJSScopesByIdOptions options =
Default)
const
142 CertainCallback<QString> result;
143 const Success isCertain = possibleIds(scope, referrer, options, result);
147 Q_ASSERT(isCertain ==
Success::Yes || result.result.isEmpty());
149 return result.result;
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
170 const QString &id,
const QQmlJSScope::ConstPtr &referrer,
171 QQmlJSScopesByIdOptions options, F &&callback)
const
173 Q_ASSERT(!id.isEmpty());
176 const auto range = m_scopesById.equal_range(id);
177 for (
auto it = range.first; it != range.second; ++it) {
178 possibleComponentRoots(
179 *it, [&](
const QQmlJSScope::ConstPtr &referredRoot,
180 QQmlJSScope::IsComponentRoot referredConfidence) {
182 possibleComponentRoots(
183 referrer, [&](
const QQmlJSScope::ConstPtr &referrerRoot,
184 QQmlJSScope::IsComponentRoot referrerConfidence) {
186 if (!isComponentVisible(referredRoot, referrerRoot, options))
189 if (callback(*it, confidence(referrerConfidence, referredConfidence))
218
219
220
221
222
223
225 QQmlJSScopesByIdOptions options =
Default)
const
227 CertainCallback<QQmlJSScope::ConstPtr> result;
228 const Success isCertain = possibleScopes(id, referrer, options, result);
232 Q_ASSERT(isCertain ==
Success::Yes || result.result.isNull());
234 return result.result;
237 void insert(
const QString &id,
const QQmlJSScope::ConstPtr &scope)
239 Q_ASSERT(!id.isEmpty());
240 m_scopesById.insert(id, scope);
243 void clear() { m_scopesById.clear(); }
246
247
248
249
250
251
262 if (m_scopesById.size() == 0)
265 std::multimap<QQmlJSScope::ConstPtr, IdWithScope> componentRootsToIds;
266 for (
auto it = m_scopesById.cbegin(), end = m_scopesById.cend(); it != end; ++it) {
267 possibleComponentRoots(
269 [&it, &componentRootsToIds](
const QQmlJSScope::ConstPtr &componentRoot,
270 QQmlJSScope::IsComponentRoot) {
271 componentRootsToIds.insert({ componentRoot, { it.key(), it.value() } });
275 return componentRootsToIds;
280 static CallbackResult possibleComponentRoots(
const QQmlJSScope::ConstPtr &inner, F &&callback)
282 QQmlJSScope::ConstPtr scope = inner;
283 QQmlJSScope::IsComponentRoot maxConfidence = QQmlJSScope::IsComponentRoot::Yes;
285 switch (scope->componentRootStatus()) {
286 case QQmlJSScope::IsComponentRoot::Maybe:
287 if (callback(scope, QQmlJSScope::IsComponentRoot::Maybe)
294 maxConfidence = QQmlJSScope::IsComponentRoot::Maybe;
296 case QQmlJSScope::IsComponentRoot::No:
297 scope = scope->parentScope();
299 case QQmlJSScope::IsComponentRoot::Yes:
300 return callback(scope, maxConfidence);
308 QQmlJSScope::IsComponentRoot a, QQmlJSScope::IsComponentRoot b) {
310 case QQmlJSScope::IsComponentRoot::Yes:
311 return b == QQmlJSScope::IsComponentRoot::Yes
312 ? Confidence::Certain
313 : Confidence::Possible;
314 case QQmlJSScope::IsComponentRoot::Maybe:
323 bool isComponentVisible(
const QQmlJSScope::ConstPtr &observed,
324 const QQmlJSScope::ConstPtr &observer,
325 QQmlJSScopesByIdOptions options)
const
328 return observed == observer;
330 for (QQmlJSScope::ConstPtr scope = observer; scope; scope = scope->parentScope()) {
331 if (scope == observed)
338 QMultiHash<QString, QQmlJSScope::ConstPtr> m_scopesById;
339 bool m_componentsAreBound =
false;
340 bool m_signaturesAreEnforced =
true;
341 bool m_valueTypesAreAddressable =
false;