Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmldomtop_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef DOMTOP_H
5#define DOMTOP_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qqmldomitem_p.h"
19#include "qqmldomelements_p.h"
21
22#include <QtCore/QQueue>
23#include <QtCore/QString>
24#include <QtCore/QDateTime>
25
26#include <QtCore/QCborValue>
27#include <QtCore/QCborMap>
28
29#include <memory>
30#include <optional>
31
33
34using namespace Qt::Literals::StringLiterals;
35
36namespace QQmlJS {
37namespace Dom {
38
39class QMLDOM_EXPORT ExternalItemPairBase: public OwningItem { // all access should have the lock of the DomUniverse containing this
41public:
42 constexpr static DomType kindValue = DomType::ExternalItemPair;
43 DomType kind() const final override { return kindValue; }
46 const QDateTime &currentExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC),
47 int derivedFrom = 0,
48 const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
49 : OwningItem(derivedFrom, lastDataUpdateAt),
50 validExposedAt(validExposedAt),
51 currentExposedAt(currentExposedAt)
52 {}
54 OwningItem(o), validExposedAt(o.validExposedAt), currentExposedAt(o.currentExposedAt)
55 {}
56 virtual std::shared_ptr<ExternalOwningItem> validItem() const = 0;
57 virtual DomItem validItem(const DomItem &self) const = 0;
58 virtual std::shared_ptr<ExternalOwningItem> currentItem() const = 0;
59 virtual DomItem currentItem(const DomItem &self) const = 0;
60
61 QString canonicalFilePath(const DomItem &) const final override;
62 Path canonicalPath(const DomItem &self) const final override;
63 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const final override;
64 DomItem field(const DomItem &self, QStringView name) const final override
65 {
66 return OwningItem::field(self, name);
67 }
68
69 bool currentIsValid() const;
70
71 std::shared_ptr<ExternalItemPairBase> makeCopy(const DomItem &self) const
72 {
73 return std::static_pointer_cast<ExternalItemPairBase>(doCopy(self));
74 }
75
76 QDateTime lastDataUpdateAt() const final override
77 {
78 if (currentItem())
79 return currentItem()->lastDataUpdateAt();
80 return ExternalItemPairBase::lastDataUpdateAt();
81 }
82
83 void refreshedDataAt(QDateTime tNew) final override
84 {
85 if (currentItem())
86 currentItem()->refreshedDataAt(tNew);
87 return OwningItem::refreshedDataAt(tNew);
88 }
89
90 friend class DomUniverse;
91
94};
95
96template<class T>
98{ // all access should have the lock of the DomUniverse containing this
99protected:
100 std::shared_ptr<OwningItem> doCopy(const DomItem &) const override
101 {
102 return std::make_shared<ExternalItemPair>(*this);
103 }
104
105public:
106 constexpr static DomType kindValue = DomType::ExternalItemPair;
107 friend class DomUniverse;
109 const std::shared_ptr<T> &valid = {}, const std::shared_ptr<T> &current = {},
110 const QDateTime &validExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC),
111 const QDateTime &currentExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC),
112 int derivedFrom = 0,
113 const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
114 : ExternalItemPairBase(validExposedAt, currentExposedAt, derivedFrom, lastDataUpdateAt),
115 valid(valid),
116 current(current)
117 {}
119 ExternalItemPairBase(o), valid(o.valid), current(o.current)
120 {
121 }
122 std::shared_ptr<ExternalOwningItem> validItem() const override { return valid; }
123 DomItem validItem(const DomItem &self) const override { return self.copy(valid); }
124 std::shared_ptr<ExternalOwningItem> currentItem() const override { return current; }
125 DomItem currentItem(const DomItem &self) const override { return self.copy(current); }
126 std::shared_ptr<ExternalItemPair> makeCopy(const DomItem &self) const
127 {
128 return std::static_pointer_cast<ExternalItemPair>(doCopy(self));
129 }
130
131 std::shared_ptr<T> valid;
132 std::shared_ptr<T> current;
133};
134
136public:
137 DomTop(QMap<QString, OwnerT> extraOwningItems = {}, int derivedFrom = 0)
138 : OwningItem(derivedFrom), m_extraOwningItems(extraOwningItems)
139 {}
140 DomTop(const DomTop &o):
142 {
143 QMap<QString, OwnerT> items = o.extraOwningItems();
144 {
145 QMutexLocker l(mutex());
146 m_extraOwningItems = items;
147 }
148 }
150
151 virtual Path canonicalPath() const = 0;
152
153 Path canonicalPath(const DomItem &) const override;
154 DomItem containingObject(const DomItem &) const override;
155 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override;
156 template<typename T>
157 void setExtraOwningItem(const QString &fieldName, const std::shared_ptr<T> &item)
158 {
159 QMutexLocker l(mutex());
160 if (!item)
161 m_extraOwningItems.remove(fieldName);
162 else
163 m_extraOwningItems.insert(fieldName, item);
164 }
165
166 void clearExtraOwningItems();
167 QMap<QString, OwnerT> extraOwningItems() const;
168
169private:
170 QMap<QString, OwnerT> m_extraOwningItems;
171};
172
173class QMLDOM_EXPORT DomUniverse final : public DomTop,
174 public std::enable_shared_from_this<DomUniverse>
175{
178protected:
179 std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override;
180
181public:
182 constexpr static DomType kindValue = DomType::DomUniverse;
183 DomType kind() const override { return kindValue; }
184
185 static ErrorGroups myErrors();
186
187 DomUniverse(const QString &universeName);
188 DomUniverse(const DomUniverse &) = delete;
189 static std::shared_ptr<DomUniverse> guaranteeUniverse(const std::shared_ptr<DomUniverse> &univ);
190 static DomItem create(const QString &universeName);
191
192 Path canonicalPath() const override;
193 using DomTop::canonicalPath;
194 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override;
195 std::shared_ptr<DomUniverse> makeCopy(const DomItem &self) const
196 {
197 return std::static_pointer_cast<DomUniverse>(doCopy(self));
198 }
199
200 // Helper structure reflecting the change in the map once loading && parsing is completed
201 // formerItem - DomItem representing value (ExternalItemPair) existing in the map before the
202 // loading && parsing. Might be empty (if didn't exist / failure) or equal to currentItem
203 // currentItem - DomItem representing current map value
209
210 LoadResult loadFile(const FileToLoad &file, DomType fileType,
211 DomCreationOptions creationOptions = {});
212
213 void removePath(const QString &dir);
214
215 std::shared_ptr<ExternalItemPair<GlobalScope>> globalScopeWithName(const QString &name) const
216 {
217 QMutexLocker l(mutex());
218 return m_globalScopeWithName.value(name);
219 }
220
221 std::shared_ptr<ExternalItemPair<GlobalScope>> ensureGlobalScopeWithName(const QString &name)
222 {
223 if (auto current = globalScopeWithName(name))
224 return current;
225 auto newScope = std::make_shared<GlobalScope>(name);
226 auto newValue = std::make_shared<ExternalItemPair<GlobalScope>>(
227 newScope, newScope);
228 QMutexLocker l(mutex());
229 if (auto current = m_globalScopeWithName.value(name))
230 return current;
231 m_globalScopeWithName.insert(name, newValue);
232 return newValue;
233 }
234
235 QSet<QString> globalScopeNames() const
236 {
237 QMap<QString, std::shared_ptr<ExternalItemPair<GlobalScope>>> map;
238 {
239 QMutexLocker l(mutex());
240 map = m_globalScopeWithName;
241 }
242 return QSet<QString>(map.keyBegin(), map.keyEnd());
243 }
244
245 std::shared_ptr<ExternalItemPair<QmlDirectory>> qmlDirectoryWithPath(const QString &path) const
246 {
247 QMutexLocker l(mutex());
248 return m_qmlDirectoryWithPath.value(path);
249 }
250 QSet<QString> qmlDirectoryPaths() const
251 {
252 QMap<QString, std::shared_ptr<ExternalItemPair<QmlDirectory>>> map;
253 {
254 QMutexLocker l(mutex());
255 map = m_qmlDirectoryWithPath;
256 }
257 return QSet<QString>(map.keyBegin(), map.keyEnd());
258 }
259
260 std::shared_ptr<ExternalItemPair<QmldirFile>> qmldirFileWithPath(const QString &path) const
261 {
262 QMutexLocker l(mutex());
263 return m_qmldirFileWithPath.value(path);
264 }
265 QSet<QString> qmldirFilePaths() const
266 {
267 QMap<QString, std::shared_ptr<ExternalItemPair<QmldirFile>>> map;
268 {
269 QMutexLocker l(mutex());
270 map = m_qmldirFileWithPath;
271 }
272 return QSet<QString>(map.keyBegin(), map.keyEnd());
273 }
274
275 std::shared_ptr<ExternalItemPair<QmlFile>> qmlFileWithPath(const QString &path) const
276 {
277 QMutexLocker l(mutex());
278 return m_qmlFileWithPath.value(path);
279 }
280 QSet<QString> qmlFilePaths() const
281 {
282 QMap<QString, std::shared_ptr<ExternalItemPair<QmlFile>>> map;
283 {
284 QMutexLocker l(mutex());
285 map = m_qmlFileWithPath;
286 }
287 return QSet<QString>(map.keyBegin(), map.keyEnd());
288 }
289
290 std::shared_ptr<ExternalItemPair<JsFile>> jsFileWithPath(const QString &path) const
291 {
292 QMutexLocker l(mutex());
293 return m_jsFileWithPath.value(path);
294 }
295 QSet<QString> jsFilePaths() const
296 {
297 QMap<QString, std::shared_ptr<ExternalItemPair<JsFile>>> map;
298 {
299 QMutexLocker l(mutex());
300 map = m_jsFileWithPath;
301 }
302 return QSet<QString>(map.keyBegin(), map.keyEnd());
303 }
304
305 std::shared_ptr<ExternalItemPair<QmltypesFile>> qmltypesFileWithPath(const QString &path) const
306 {
307 QMutexLocker l(mutex());
308 return m_qmltypesFileWithPath.value(path);
309 }
310 QSet<QString> qmltypesFilePaths() const
311 {
312 QMap<QString, std::shared_ptr<ExternalItemPair<QmltypesFile>>> map;
313 {
314 QMutexLocker l(mutex());
315 map = m_qmltypesFileWithPath;
316 }
317 return QSet<QString>(map.keyBegin(), map.keyEnd());
318 }
319
320 QString name() const {
321 return m_name;
322 }
323
324private:
325 struct ContentWithDate
326 {
327 QString content;
329 };
330 // contains either Content with the timestamp when it was read or an Error
331 using ReadResult = std::variant<ContentWithDate, ErrorMessage>;
332 ReadResult readFileContent(const QString &canonicalPath) const;
333
334 LoadResult load(const ContentWithDate &codeWithDate, const FileToLoad &file, DomType fType,
335 DomCreationOptions creationOptions = {});
336
337 // contains either Content to be parsed or LoadResult if loading / parsing is not needed
338 using PreloadResult = std::variant<ContentWithDate, LoadResult>;
339 PreloadResult preload(const DomItem &univ, const FileToLoad &file, DomType fType) const;
340
341 std::shared_ptr<QmlFile> parseQmlFile(const QString &code, const FileToLoad &file,
342 const QDateTime &contentDate,
343 DomCreationOptions creationOptions);
344 std::shared_ptr<JsFile> parseJsFile(const QString &code, const FileToLoad &file,
345 const QDateTime &contentDate);
346 std::shared_ptr<ExternalItemPairBase> getPathValueOrNull(DomType fType,
347 const QString &path) const;
348 std::optional<DomItem> getItemIfMostRecent(const DomItem &univ, DomType fType,
349 const QString &path) const;
350 std::optional<DomItem> getItemIfHasSameCode(const DomItem &univ, DomType fType,
351 const QString &canonicalPath,
352 const ContentWithDate &codeWithDate) const;
353 static bool valueHasMostRecentItem(const ExternalItemPairBase *value,
354 const QDateTime &lastModified);
355 static bool valueHasSameContent(const ExternalItemPairBase *value, const QString &content);
356
357 // TODO better name / consider proper public get/set
358 template <typename T>
359 QMap<QString, std::shared_ptr<ExternalItemPair<T>>> &getMutableRefToMap()
360 {
361 Q_ASSERT(!mutex()->tryLock());
362 if constexpr (std::is_same_v<T, QmlDirectory>) {
363 return m_qmlDirectoryWithPath;
364 }
365 if constexpr (std::is_same_v<T, QmldirFile>) {
366 return m_qmldirFileWithPath;
367 }
368 if constexpr (std::is_same_v<T, QmlFile>) {
369 return m_qmlFileWithPath;
370 }
371 if constexpr (std::is_same_v<T, JsFile>) {
372 return m_jsFileWithPath;
373 }
374 if constexpr (std::is_same_v<T, QmltypesFile>) {
375 return m_qmltypesFileWithPath;
376 }
377 if constexpr (std::is_same_v<T, GlobalScope>) {
378 return m_globalScopeWithName;
379 }
380 Q_UNREACHABLE();
381 }
382
383 // Inserts or updates an entry reflecting ExternalItem in the corresponding map
384 // Returns a pair of:
385 // - current ExternalItemPair, current value in the map (might be empty, or equal to curValue)
386 // - new current ExternalItemPair, value in the map after after the execution of this function
387 template <typename T>
388 QPair<std::shared_ptr<ExternalItemPair<T>>, std::shared_ptr<ExternalItemPair<T>>>
389 insertOrUpdateEntry(std::shared_ptr<T> newItem)
390 {
391 std::shared_ptr<ExternalItemPair<T>> curValue;
392 std::shared_ptr<ExternalItemPair<T>> newCurValue;
393 QString canonicalPath = newItem->canonicalFilePath();
395 {
396 QMutexLocker l(mutex());
397 auto &map = getMutableRefToMap<T>();
398 auto it = map.find(canonicalPath);
399 if (it != map.cend() && (*it) && (*it)->current) {
400 curValue = *it;
401 if (valueHasSameContent(curValue.get(), newItem->code())) {
402 // value in the map has same content as newItem, a.k.a. most recent
403 newCurValue = curValue;
404 if (newCurValue->current->lastDataUpdateAt() < newItem->lastDataUpdateAt()) {
405 // update timestamp in the current, as if its content was refreshed by
406 // NewItem
407 newCurValue->current->refreshedDataAt(newItem->lastDataUpdateAt());
408 }
409 } else if (curValue->current->lastDataUpdateAt() > newItem->lastDataUpdateAt()) {
410 // value in the map is more recent than newItem, nothing to update
411 newCurValue = curValue;
412 } else {
413 // perform update with newItem
414 curValue->current = std::move(newItem);
415 curValue->currentExposedAt = now;
416 if (curValue->current->isValid()) {
417 curValue->valid = curValue->current;
418 curValue->validExposedAt = std::move(now);
419 }
420 newCurValue = curValue;
421 }
422 } else {
423 // not found / invalid, just insert
424 newCurValue = std::make_shared<ExternalItemPair<T>>(
425 (newItem->isValid() ? newItem : std::shared_ptr<T>()), newItem, now, now);
426 map.insert(canonicalPath, newCurValue);
427 }
428 }
429 return qMakePair(curValue, newCurValue);
430 }
431
432 // Inserts or updates an entry reflecting ExternalItem in the corresponding map
433 // returns LoadResult reflecting the change made to the map
434 template <typename T>
435 LoadResult insertOrUpdateExternalItem(std::shared_ptr<T> extItem)
436 {
437 auto change = insertOrUpdateEntry<T>(std::move(extItem));
438 DomItem univ(shared_from_this());
439 return { univ.copy(change.first), univ.copy(change.second) };
440 }
441
442private:
443 QString m_name;
444 QMap<QString, std::shared_ptr<ExternalItemPair<GlobalScope>>> m_globalScopeWithName;
445 QMap<QString, std::shared_ptr<ExternalItemPair<QmlDirectory>>> m_qmlDirectoryWithPath;
446 QMap<QString, std::shared_ptr<ExternalItemPair<QmldirFile>>> m_qmldirFileWithPath;
447 QMap<QString, std::shared_ptr<ExternalItemPair<QmlFile>>> m_qmlFileWithPath;
448 QMap<QString, std::shared_ptr<ExternalItemPair<JsFile>>> m_jsFileWithPath;
449 QMap<QString, std::shared_ptr<ExternalItemPair<QmltypesFile>>> m_qmltypesFileWithPath;
450};
451
454public:
455 constexpr static DomType kindValue = DomType::ExternalItemInfo;
456 DomType kind() const final override { return kindValue; }
458 const Path &canonicalPath,
459 const QDateTime &currentExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC),
460 int derivedFrom = 0,
461 const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
462 : OwningItem(derivedFrom, lastDataUpdateAt),
463 m_canonicalPath(canonicalPath),
464 m_currentExposedAt(currentExposedAt)
465 {}
467
468 virtual std::shared_ptr<ExternalOwningItem> currentItem() const = 0;
469 virtual DomItem currentItem(const DomItem &) const = 0;
470
471 QString canonicalFilePath(const DomItem &) const final override;
472 Path canonicalPath() const { return m_canonicalPath; }
473 Path canonicalPath(const DomItem &) const final override { return canonicalPath(); }
474 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const final override;
475 DomItem field(const DomItem &self, QStringView name) const final override
476 {
477 return OwningItem::field(self, name);
478 }
479
480 int currentRevision(const DomItem &self) const;
481 int lastRevision(const DomItem &self) const;
482 int lastValidRevision(const DomItem &self) const;
483
484 std::shared_ptr<ExternalItemInfoBase> makeCopy(const DomItem &self) const
485 {
486 return std::static_pointer_cast<ExternalItemInfoBase>(doCopy(self));
487 }
488
489 QDateTime lastDataUpdateAt() const final override
490 {
491 if (currentItem())
492 return currentItem()->lastDataUpdateAt();
493 return OwningItem::lastDataUpdateAt();
494 }
495
496 void refreshedDataAt(QDateTime tNew) final override
497 {
498 if (currentItem())
499 currentItem()->refreshedDataAt(tNew);
500 return OwningItem::refreshedDataAt(tNew);
501 }
502
504 QMutexLocker l(mutex());
505 if (!m_logicalFilePaths.contains(path))
506 m_logicalFilePaths.append(path);
507 }
508
510 QMutexLocker l(mutex()); // should not be needed, as it should not change...
511 return m_currentExposedAt;
512 }
513
515 QMutexLocker l(mutex()); // should not be needed, as it should not change...
516 m_currentExposedAt = d;
517 }
518
519
521 QMutexLocker l(mutex());
522 return m_logicalFilePaths;
523 }
524
525 private:
526 friend class DomEnvironment;
527 Path m_canonicalPath;
528 QDateTime m_currentExposedAt;
529 QStringList m_logicalFilePaths;
530};
531
532template<typename T>
534{
535protected:
536 std::shared_ptr<OwningItem> doCopy(const DomItem &) const override
537 {
538 return std::make_shared<ExternalItemInfo>(*this);
539 }
540
541public:
557
558 std::shared_ptr<ExternalItemInfo> makeCopy(const DomItem &self) const
559 {
560 return std::static_pointer_cast<ExternalItemInfo>(doCopy(self));
561 }
562
563 std::shared_ptr<ExternalOwningItem> currentItem() const override {
564 return current;
565 }
566 DomItem currentItem(const DomItem &self) const override { return self.copy(current); }
567
568 std::shared_ptr<T> current;
569};
570
572{ // internal, should be cleaned, but nobody should use this...
573public:
574 bool operator==(Dependency const &o) const
575 {
576 return uri == o.uri && version.majorVersion == o.version.majorVersion
577 && version.minorVersion == o.version.minorVersion && filePath == o.filePath;
578 }
579 QString uri; // either dotted uri or file:, http: https: uri
581 QString filePath; // for file deps
583};
584
586{
588
589protected:
590 std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override;
591
592public:
593 constexpr static DomType kindValue = DomType::LoadInfo;
594 DomType kind() const override { return kindValue; }
595
596 enum class Status {
597 NotStarted, // dependencies non checked yet
598 Starting, // adding deps
599 InProgress, // waiting for all deps to be loaded
600 CallingCallbacks, // calling callbacks
601 Done // fully loaded
602 };
603
604 LoadInfo(const Path &elPath = Path(), Status status = Status::NotStarted, int nLoaded = 0,
605 int derivedFrom = 0,
606 const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
607 : OwningItem(derivedFrom, lastDataUpdateAt),
608 m_elementCanonicalPath(elPath),
609 m_status(status),
610 m_nLoaded(nLoaded)
611 {
612 }
613 LoadInfo(const LoadInfo &o) : OwningItem(o), m_elementCanonicalPath(o.elementCanonicalPath())
614 {
615 {
616 QMutexLocker l(o.mutex());
617 m_status = o.m_status;
618 m_nLoaded = o.m_nLoaded;
619 m_toDo = o.m_toDo;
620 m_inProgress = o.m_inProgress;
621 m_endCallbacks = o.m_endCallbacks;
622 }
623 }
624
625 Path canonicalPath(const DomItem &self) const override;
626
627 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override;
628 std::shared_ptr<LoadInfo> makeCopy(const DomItem &self) const
629 {
630 return std::static_pointer_cast<LoadInfo>(doCopy(self));
631 }
632 void addError(const DomItem &self, ErrorMessage &&msg) override
633 {
634 self.path(elementCanonicalPath()).addError(std::move(msg));
635 }
636
637 void addEndCallback(const DomItem &self, std::function<void(Path, const DomItem &, const DomItem &)> callback);
638
639 void advanceLoad(const DomItem &self);
640 void finishedLoadingDep(const DomItem &self, const Dependency &d);
641 void execEnd(const DomItem &self);
642
644 {
645 QMutexLocker l(mutex());
646 return m_status;
647 }
648
649 int nLoaded() const
650 {
651 QMutexLocker l(mutex());
652 return m_nLoaded;
653 }
654
656 {
657 QMutexLocker l(mutex()); // we should never change this, remove lock?
658 return m_elementCanonicalPath;
659 }
660
661 int nNotDone() const
662 {
663 QMutexLocker l(mutex());
664 return m_toDo.size() + m_inProgress.size();
665 }
666
667 QList<Dependency> inProgress() const
668 {
669 QMutexLocker l(mutex());
670 return m_inProgress;
671 }
672
673 QList<Dependency> toDo() const
674 {
675 QMutexLocker l(mutex());
676 return m_toDo;
677 }
678
679 int nCallbacks() const
680 {
681 QMutexLocker l(mutex());
682 return m_endCallbacks.size();
683 }
684
685private:
686 void doAddDependencies(const DomItem &self);
687 void addDependency(const DomItem &self, const Dependency &dep);
688
689 Path m_elementCanonicalPath;
690 Status m_status;
691 int m_nLoaded;
692 QQueue<Dependency> m_toDo;
693 QList<Dependency> m_inProgress;
694 QList<std::function<void(Path, const DomItem &, const DomItem &)>> m_endCallbacks;
695};
696
698
700
702{
704public:
705 enum class Cached { None, First, All };
706 Q_ENUM(Cached)
707
708 static RefCacheEntry forPath(const DomItem &el, const Path &canonicalPath);
709 static bool addForPath(const DomItem &el, const Path &canonicalPath, const RefCacheEntry &entry,
710 AddOption addOption = AddOption::KeepExisting);
711
712 Cached cached = Cached::None;
713 QList<Path> canonicalPaths;
714};
715
717 public std::enable_shared_from_this<DomEnvironment>
718{
721protected:
722 std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override;
723
724public:
725 enum class Option {
726 Default = 0x0,
727 KeepValid = 0x1, // if there is a previous valid version, use that instead of the latest
728 Exported = 0x2, // the current environment is accessible by multiple threads, one should only modify whole OwningItems, and in general load and do other operations in other (Child) environments
729 NoReload = 0x4, // never reload something that was already loaded by the parent environment
730 WeakLoad = 0x8, // load only the names of the available types, not the types (qml files) themselves
731 SingleThreaded = 0x10, // do all operations in a single thread
732 NoDependencies = 0x20 // will not load dependencies (useful when editing)
733 };
736
737 static ErrorGroups myErrors();
738 constexpr static DomType kindValue = DomType::DomEnvironment;
739 DomType kind() const override;
740
741 Path canonicalPath() const override;
742 using DomTop::canonicalPath;
743 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override;
744 DomItem field(const DomItem &self, QStringView name) const final override;
745
746 std::shared_ptr<DomEnvironment> makeCopy(const DomItem &self) const;
747
748 void loadFile(const FileToLoad &file, const Callback &callback,
749 std::optional<DomType> fileType = std::optional<DomType>(),
750 const ErrorHandler &h = nullptr /* used only in loadPendingDependencies*/);
751 void loadBuiltins(const Callback &callback = nullptr, const ErrorHandler &h = nullptr);
752 void loadModuleDependency(const QString &uri, Version v, const Callback &callback = nullptr,
753 const ErrorHandler & = nullptr);
754
755 void removePath(const QString &path);
756
757 std::shared_ptr<DomUniverse> universe() const;
758
759 QSet<QString> moduleIndexUris(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const;
760 QSet<int> moduleIndexMajorVersions(const DomItem &self, const QString &uri,
761 EnvLookup lookup = EnvLookup::Normal) const;
762 std::shared_ptr<ModuleIndex> moduleIndexWithUri(const DomItem &self, const QString &uri, int majorVersion,
763 EnvLookup lookup, Changeable changeable,
764 const ErrorHandler &errorHandler = nullptr);
765 std::shared_ptr<ModuleIndex> moduleIndexWithUri(const DomItem &self, const QString &uri, int majorVersion,
766 EnvLookup lookup = EnvLookup::Normal) const;
767 std::shared_ptr<ExternalItemInfo<QmlDirectory>>
768 qmlDirectoryWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const;
769 QSet<QString> qmlDirectoryPaths(const DomItem &self, EnvLookup options = EnvLookup::Normal) const;
770 std::shared_ptr<ExternalItemInfo<QmldirFile>>
771 qmldirFileWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const;
772 QSet<QString> qmldirFilePaths(const DomItem &self, EnvLookup options = EnvLookup::Normal) const;
773 std::shared_ptr<ExternalItemInfoBase>
774 qmlDirWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const;
775 QSet<QString> qmlDirPaths(const DomItem &self, EnvLookup options = EnvLookup::Normal) const;
776 std::shared_ptr<ExternalItemInfo<QmlFile>>
777 qmlFileWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const;
778 QSet<QString> qmlFilePaths(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const;
779 std::shared_ptr<ExternalItemInfo<JsFile>>
780 jsFileWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const;
781 QSet<QString> jsFilePaths(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const;
782 std::shared_ptr<ExternalItemInfo<QmltypesFile>>
783 qmltypesFileWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const;
784 QSet<QString> qmltypesFilePaths(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const;
785 std::shared_ptr<ExternalItemInfo<GlobalScope>>
786 globalScopeWithName(const DomItem &self, const QString &name, EnvLookup lookup = EnvLookup::Normal) const;
787 std::shared_ptr<ExternalItemInfo<GlobalScope>>
788 ensureGlobalScopeWithName(const DomItem &self, const QString &name, EnvLookup lookup = EnvLookup::Normal);
789 QSet<QString> globalScopeNames(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const;
790
791 explicit DomEnvironment(const QStringList &loadPaths, Options options = Option::SingleThreaded,
792 DomCreationOptions domCreationOptions = None,
793 const std::shared_ptr<DomUniverse> &universe = nullptr);
794 explicit DomEnvironment(const std::shared_ptr<DomEnvironment> &parent,
795 const QStringList &loadPaths, Options options = Option::SingleThreaded,
796 DomCreationOptions domCreationOptions = None);
798 static std::shared_ptr<DomEnvironment>
799 create(const QStringList &loadPaths, Options options = Option::SingleThreaded,
800 DomCreationOptions creationOptions = DomCreationOption::None,
801 const DomItem &universe = DomItem::empty);
802
803 // TODO AddOption can easily be removed later. KeepExisting option only used in one
804 // place which will be removed in https://codereview.qt-project.org/c/qt/qtdeclarative/+/523217
805 void addQmlFile(const std::shared_ptr<QmlFile> &file,
806 AddOption option = AddOption::KeepExisting);
807 void addQmlDirectory(const std::shared_ptr<QmlDirectory> &file,
808 AddOption option = AddOption::KeepExisting);
809 void addQmldirFile(const std::shared_ptr<QmldirFile> &file,
810 AddOption option = AddOption::KeepExisting);
811 void addQmltypesFile(const std::shared_ptr<QmltypesFile> &file,
812 AddOption option = AddOption::KeepExisting);
813 void addJsFile(const std::shared_ptr<JsFile> &file, AddOption option = AddOption::KeepExisting);
814 void addGlobalScope(const std::shared_ptr<GlobalScope> &file,
815 AddOption option = AddOption::KeepExisting);
816
817 bool commitToBase(
818 const DomItem &self, const std::shared_ptr<DomEnvironment> &validEnv = nullptr);
819
820 void addDependenciesToLoad(const Path &path);
821 void addLoadInfo(
822 const DomItem &self, const std::shared_ptr<LoadInfo> &loadInfo);
823 std::shared_ptr<LoadInfo> loadInfo(const Path &path) const;
824 QList<Path> loadInfoPaths() const;
825 QHash<Path, std::shared_ptr<LoadInfo>> loadInfos() const;
826 void loadPendingDependencies();
827 bool finishLoadingDependencies(int waitMSec = 30000);
828 void addWorkForLoadInfo(const Path &elementCanonicalPath);
829
830 Options options() const;
831
832 std::shared_ptr<DomEnvironment> base() const;
833
834 QStringList loadPaths() const;
835 QStringList qmldirFiles() const;
836
837 QString globalScopeName() const;
838
839 static QList<Import> defaultImplicitImports();
840 QList<Import> implicitImports() const;
841
842 void addAllLoadedCallback(const DomItem &self, Callback c);
843
844 void clearReferenceCache();
845 void setLoadPaths(const QStringList &v);
846
847 // Helper structure reflecting the change in the map once loading / fetching is completed
848 // formerItem - DomItem representing value (ExternalItemInfo) existing in the map before the
849 // loading && parsing. Might be empty (if didn't exist / failure) or equal to currentItem
850 // currentItem - DomItem representing current map value
856 // TODO(QTBUG-121171)
857 template <typename T>
858 LoadResult insertOrUpdateExternalItemInfo(const QString &path, std::shared_ptr<T> extItem)
859 {
860 // maybe in the next revision this all can be just substituted by the addExternalItem
861 DomItem env(shared_from_this());
862 // try to fetch from the current env.
863 if (auto curValue = lookup<T>(path, EnvLookup::NoBase)) {
864 // found in the "initial" env
865 return { env.copy(curValue), env.copy(curValue) };
866 }
867 std::shared_ptr<ExternalItemInfo<T>> newCurValue;
868 // try to fetch from the base env
869 auto valueInBase = lookup<T>(path, EnvLookup::BaseOnly);
870 if (!valueInBase) {
871 // Nothing found. Just create an externalItemInfo which will be inserted
872 newCurValue = std::make_shared<ExternalItemInfo<T>>(std::move(extItem),
874 } else {
875 // prepare updated value as a copy of the value from the Base to be inserted
876 newCurValue = valueInBase->makeCopy(env);
877 if (newCurValue->current != extItem) {
878 newCurValue->current = std::move(extItem);
879 newCurValue->setCurrentExposedAt(QDateTime::currentDateTimeUtc());
880 }
881 }
882 // Before inserting new or updated value, check one more time, if ItemInfo is already
883 // present
884 // lookup<> can't be used here because of the data-race
885 {
886 QMutexLocker l(mutex());
887 auto &map = getMutableRefToMap<T>();
888 const auto &it = map.find(path);
889 if (it != map.end())
890 return { env.copy(*it), env.copy(*it) };
891 // otherwise insert
892 map.insert(path, newCurValue);
893 }
894 return { env.copy(valueInBase), env.copy(newCurValue) };
895 }
896
897 template <typename T>
898 void addExternalItemInfo(const DomItem &newExtItem, const Callback &loadCallback,
899 const Callback &endCallback)
900 {
901 // get either Valid "file" from the ExternalItemPair or the current (wip) "file"
902 std::shared_ptr<T> newItemPtr;
903 if (options() & DomEnvironment::Option::KeepValid)
904 newItemPtr = newExtItem.field(Fields::validItem).ownerAs<T>();
905 if (!newItemPtr)
906 newItemPtr = newExtItem.field(Fields::currentItem).ownerAs<T>();
907 Q_ASSERT(newItemPtr && "envCallbackForFile reached without current file");
908
909 auto loadResult = insertOrUpdateExternalItemInfo(newExtItem.canonicalFilePath(),
910 std::move(newItemPtr));
911 Path p = loadResult.currentItem.canonicalPath();
912 {
913 auto depLoad = qScopeGuard([p, this, endCallback] {
914 addDependenciesToLoad(p);
915 // add EndCallback to the queue, which should be called once all dependencies are
916 // loaded
917 if (endCallback) {
918 DomItem env = DomItem(shared_from_this());
919 addAllLoadedCallback(
920 env, [p, endCallback](Path, const DomItem &, const DomItem &env) {
921 DomItem el = env.path(p);
922 endCallback(p, el, el);
923 });
924 }
925 });
926 // call loadCallback
927 if (loadCallback) {
928 loadCallback(p, loadResult.formerItem, loadResult.currentItem);
929 }
930 }
931 }
932 void populateFromQmlFile(MutableDomItem &&qmlFile);
933 DomCreationOptions domCreationOptions() const { return m_domCreationOptions; }
934
935private:
936 friend class RefCacheEntry;
937
938 void loadFile(const FileToLoad &file, const Callback &loadCallback, const Callback &endCallback,
939 std::optional<DomType> fileType = std::optional<DomType>(),
940 const ErrorHandler &h = nullptr);
941
942 void loadModuleDependency(const DomItem &self, const QString &uri, Version v,
943 Callback loadCallback = nullptr, Callback endCallback = nullptr,
944 const ErrorHandler & = nullptr);
945
946 template <typename T>
947 QSet<QString> getStrings(function_ref<QSet<QString>()> getBase, const QMap<QString, T> &selfMap,
948 EnvLookup lookup) const;
949
950 template <typename T>
951 const QMap<QString, std::shared_ptr<ExternalItemInfo<T>>> &getConstRefToMap() const
952 {
953 Q_ASSERT(!mutex()->tryLock());
954 if constexpr (std::is_same_v<T, GlobalScope>) {
955 return m_globalScopeWithName;
956 }
957 if constexpr (std::is_same_v<T, QmlDirectory>) {
958 return m_qmlDirectoryWithPath;
959 }
960 if constexpr (std::is_same_v<T, QmldirFile>) {
961 return m_qmldirFileWithPath;
962 }
963 if constexpr (std::is_same_v<T, QmlFile>) {
964 return m_qmlFileWithPath;
965 }
966 if constexpr (std::is_same_v<T, JsFile>) {
967 return m_jsFileWithPath;
968 }
969 if constexpr (std::is_same_v<T, QmltypesFile>) {
970 return m_qmltypesFileWithPath;
971 }
972 Q_UNREACHABLE();
973 }
974
975 template <typename T>
976 std::shared_ptr<ExternalItemInfo<T>> lookup(const QString &path, EnvLookup options) const
977 {
978 if (options != EnvLookup::BaseOnly) {
979 QMutexLocker l(mutex());
980 const auto &map = getConstRefToMap<T>();
981 const auto &it = map.find(path);
982 if (it != map.end())
983 return *it;
984 }
985 if (options != EnvLookup::NoBase && m_base)
986 return m_base->lookup<T>(path, options);
987 return {};
988 }
989
990 template <typename T>
991 QMap<QString, std::shared_ptr<ExternalItemInfo<T>>> &getMutableRefToMap()
992 {
993 Q_ASSERT(!mutex()->tryLock());
994 if constexpr (std::is_same_v<T, QmlDirectory>) {
995 return m_qmlDirectoryWithPath;
996 }
997 if constexpr (std::is_same_v<T, QmldirFile>) {
998 return m_qmldirFileWithPath;
999 }
1000 if constexpr (std::is_same_v<T, QmlFile>) {
1001 return m_qmlFileWithPath;
1002 }
1003 if constexpr (std::is_same_v<T, JsFile>) {
1004 return m_jsFileWithPath;
1005 }
1006 if constexpr (std::is_same_v<T, QmltypesFile>) {
1007 return m_qmltypesFileWithPath;
1008 }
1009 if constexpr (std::is_same_v<T, GlobalScope>) {
1010 return m_globalScopeWithName;
1011 }
1012 Q_UNREACHABLE();
1013 }
1014
1015 template <typename T>
1016 void addExternalItem(std::shared_ptr<T> file, QString key, AddOption option)
1017 {
1018 if (!file)
1019 return;
1020
1021 auto eInfo = std::make_shared<ExternalItemInfo<T>>(file, QDateTime::currentDateTimeUtc());
1022 // Lookup helper can't be used here, because it introduces data-race otherwise
1023 // (other modifications might happen between the lookup and the insert)
1024 QMutexLocker l(mutex());
1025 auto &map = getMutableRefToMap<T>();
1026 const auto &it = map.find(key);
1027 if (it != map.end() && option == AddOption::KeepExisting)
1028 return;
1029 map.insert(key, eInfo);
1030 }
1031
1032 using FetchResult =
1033 QPair<std::shared_ptr<ExternalItemInfoBase>, std::shared_ptr<ExternalItemInfoBase>>;
1034 // This function tries to get an Info object about the ExternalItem from the current env
1035 // and depending on the result and options tries to fetch it from the Parent env,
1036 // saving a copy with an updated timestamp
1037 template <typename T>
1038 FetchResult fetchFileFromEnvs(const FileToLoad &file)
1039 {
1040 const auto &path = file.canonicalPath();
1041 // lookup only in the current env
1042 if (auto value = lookup<T>(path, EnvLookup::NoBase)) {
1043 return qMakePair(value, value);
1044 }
1045 // try to find the file in the base(parent) Env and insert if found
1046 if (options() & Option::NoReload) {
1047 if (auto baseV = lookup<T>(path, EnvLookup::BaseOnly)) {
1048 // Watch out! QTBUG-121171
1049 // It's possible between the lookup and creation of curVal, baseV && baseV->current
1050 // might have changed
1051 // Prepare a value to be inserted as copy of the value from Base
1052 auto curV = std::make_shared<ExternalItemInfo<T>>(
1053 baseV->current, QDateTime::currentDateTimeUtc(), baseV->revision(),
1054 baseV->lastDataUpdateAt());
1055 // Lookup one more time if the value was already inserted to the current env
1056 // Lookup can't be used here because of the data-race
1057 {
1058 QMutexLocker l(mutex());
1059 auto &map = getMutableRefToMap<T>();
1060 const auto &it = map.find(path);
1061 if (it != map.end())
1062 return qMakePair(*it, *it);
1063 // otherwise insert
1064 map.insert(path, curV);
1065 }
1066 return qMakePair(baseV, curV);
1067 }
1068 }
1069 return qMakePair(nullptr, nullptr);
1070 }
1071
1072 Callback getLoadCallbackFor(DomType fileType, const Callback &loadCallback);
1073
1074 std::shared_ptr<ModuleIndex> lookupModuleInEnv(const QString &uri, int majorVersion) const;
1075 // ModuleLookupResult contains the ModuleIndex pointer, and an indicator whether it was found
1076 // in m_base or in m_moduleIndexWithUri
1077 struct ModuleLookupResult {
1078 enum Origin : bool {FromBase, FromGlobal};
1079 std::shared_ptr<ModuleIndex> module;
1080 Origin fromBase = FromGlobal;
1081 };
1082 // helper function used by the moduleIndexWithUri methods
1083 ModuleLookupResult moduleIndexWithUriHelper(const DomItem &self, const QString &uri, int majorVersion,
1084 EnvLookup lookup = EnvLookup::Normal) const;
1085
1086 const Options m_options;
1087 const std::shared_ptr<DomEnvironment> m_base;
1088 std::shared_ptr<DomEnvironment> m_lastValidBase;
1089 const std::shared_ptr<DomUniverse> m_universe;
1090 QStringList m_loadPaths; // paths for qml
1091 QString m_globalScopeName;
1092 QMap<QString, QMap<int, std::shared_ptr<ModuleIndex>>> m_moduleIndexWithUri;
1093 QMap<QString, std::shared_ptr<ExternalItemInfo<GlobalScope>>> m_globalScopeWithName;
1094 QMap<QString, std::shared_ptr<ExternalItemInfo<QmlDirectory>>> m_qmlDirectoryWithPath;
1095 QMap<QString, std::shared_ptr<ExternalItemInfo<QmldirFile>>> m_qmldirFileWithPath;
1096 QMap<QString, std::shared_ptr<ExternalItemInfo<QmlFile>>> m_qmlFileWithPath;
1097 QMap<QString, std::shared_ptr<ExternalItemInfo<JsFile>>> m_jsFileWithPath;
1098 QMap<QString, std::shared_ptr<ExternalItemInfo<QmltypesFile>>> m_qmltypesFileWithPath;
1099 QQueue<Path> m_loadsWithWork;
1100 QQueue<Path> m_inProgress;
1101 QHash<Path, std::shared_ptr<LoadInfo>> m_loadInfos;
1102 QList<Import> m_implicitImports;
1103 QList<Callback> m_allLoadedCallback;
1104 QHash<Path, RefCacheEntry> m_referenceCache;
1105 DomCreationOptions m_domCreationOptions;
1106
1107 struct SemanticAnalysis
1108 {
1109 SemanticAnalysis(const QStringList &loadPaths);
1110 void setLoadPaths(const QStringList &loadPaths);
1111
1112 std::shared_ptr<QQmlJSResourceFileMapper> m_mapper;
1113 std::shared_ptr<QQmlJSImporter> m_importer;
1114 };
1115 std::optional<SemanticAnalysis> m_semanticAnalysis;
1116 SemanticAnalysis &semanticAnalysis();
1117};
1118Q_DECLARE_OPERATORS_FOR_FLAGS(DomEnvironment::Options)
1119
1120} // end namespace Dom
1121} // end namespace QQmlJS
1123#endif // DOMTOP_H
\inmodule QtCore\reentrant
Definition qdatetime.h:283
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)
static QDateTime currentDateTimeUtc()
\inmodule QtCore
Definition qhash.h:820
Definition qlist.h:75
iterator insert(const Key &key, const T &value)
Definition qmap.h:688
const_iterator cend() const
Definition qmap.h:605
iterator find(const Key &key)
Definition qmap.h:641
iterator end()
Definition qmap.h:602
key_iterator keyBegin() const
Definition qmap.h:606
key_iterator keyEnd() const
Definition qmap.h:607
\inmodule QtCore
Definition qmutex.h:313
bool operator==(Dependency const &o) const
Represents a consistent set of types organized in modules, it is the top level of the DOM.
LoadResult insertOrUpdateExternalItemInfo(const QString &path, std::shared_ptr< T > extItem)
void addExternalItemInfo(const DomItem &newExtItem, const Callback &loadCallback, const Callback &endCallback)
DomCreationOptions domCreationOptions() const
function< void(const Path &, const DomItem &, const DomItem &)> Callback
DomItem path(const Path &p, const ErrorHandler &h=&defaultErrorHandler) const
DomItem copy(const Owner &owner, const Path &ownerPath, const T &base) const
DomTop(QMap< QString, OwnerT > extraOwningItems={}, int derivedFrom=0)
virtual Path canonicalPath() const =0
DomTop(const DomTop &o)
DomItem::Callback Callback
void setExtraOwningItem(const QString &fieldName, const std::shared_ptr< T > &item)
Represents a set of parsed/loaded modules libraries and a plugins.
QSet< QString > globalScopeNames() const
std::shared_ptr< ExternalItemPair< GlobalScope > > ensureGlobalScopeWithName(const QString &name)
std::shared_ptr< ExternalItemPair< JsFile > > jsFileWithPath(const QString &path) const
QSet< QString > qmltypesFilePaths() const
std::shared_ptr< ExternalItemPair< QmldirFile > > qmldirFileWithPath(const QString &path) const
DomUniverse(const DomUniverse &)=delete
std::shared_ptr< ExternalItemPair< GlobalScope > > globalScopeWithName(const QString &name) const
std::shared_ptr< ExternalItemPair< QmlFile > > qmlFileWithPath(const QString &path) const
QSet< QString > qmlDirectoryPaths() const
QSet< QString > jsFilePaths() const
std::shared_ptr< ExternalItemPair< QmltypesFile > > qmltypesFileWithPath(const QString &path) const
QSet< QString > qmldirFilePaths() const
std::shared_ptr< ExternalItemPair< QmlDirectory > > qmlDirectoryWithPath(const QString &path) const
DomType kind() const override
std::shared_ptr< DomUniverse > makeCopy(const DomItem &self) const
QSet< QString > qmlFilePaths() const
Represents a set of tags grouping a set of related error messages.
Represents an error message connected to the dom.
ExternalItemInfoBase(const ExternalItemInfoBase &o)=default
void setCurrentExposedAt(QDateTime d)
std::shared_ptr< ExternalItemInfoBase > makeCopy(const DomItem &self) const
DomType kind() const final override
ExternalItemInfoBase(const Path &canonicalPath, const QDateTime &currentExposedAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), int derivedFrom=0, const QDateTime &lastDataUpdateAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
QStringList logicalFilePaths() const
virtual std::shared_ptr< ExternalOwningItem > currentItem() const =0
DomItem field(const DomItem &self, QStringView name) const final override
Path canonicalPath(const DomItem &) const final override
void refreshedDataAt(QDateTime tNew) final override
virtual DomItem currentItem(const DomItem &) const =0
void ensureLogicalFilePath(const QString &path)
QDateTime lastDataUpdateAt() const final override
std::shared_ptr< OwningItem > doCopy(const DomItem &) const override
static constexpr DomType kindValue
ExternalItemInfo(const std::shared_ptr< T > &current=std::shared_ptr< T >(), const QDateTime &currentExposedAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), int derivedFrom=0, const QDateTime &lastDataUpdateAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
std::shared_ptr< T > current
ExternalItemInfo(const QString &canonicalPath)
std::shared_ptr< ExternalItemInfo > makeCopy(const DomItem &self) const
DomItem currentItem(const DomItem &self) const override
ExternalItemInfo(const ExternalItemInfo &o)
std::shared_ptr< ExternalOwningItem > currentItem() const override
ExternalItemPairBase(const ExternalItemPairBase &o)
DomType kind() const final override
void refreshedDataAt(QDateTime tNew) final override
virtual DomItem validItem(const DomItem &self) const =0
ExternalItemPairBase(const QDateTime &validExposedAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), const QDateTime &currentExposedAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), int derivedFrom=0, const QDateTime &lastDataUpdateAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
QDateTime lastDataUpdateAt() const final override
std::shared_ptr< ExternalItemPairBase > makeCopy(const DomItem &self) const
virtual std::shared_ptr< ExternalOwningItem > currentItem() const =0
virtual std::shared_ptr< ExternalOwningItem > validItem() const =0
virtual DomItem currentItem(const DomItem &self) const =0
DomItem field(const DomItem &self, QStringView name) const final override
std::shared_ptr< T > valid
std::shared_ptr< T > current
std::shared_ptr< OwningItem > doCopy(const DomItem &) const override
std::shared_ptr< ExternalOwningItem > validItem() const override
DomItem validItem(const DomItem &self) const override
DomItem currentItem(const DomItem &self) const override
ExternalItemPair(const ExternalItemPair &o)
ExternalItemPair(const std::shared_ptr< T > &valid={}, const std::shared_ptr< T > &current={}, const QDateTime &validExposedAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), const QDateTime &currentExposedAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), int derivedFrom=0, const QDateTime &lastDataUpdateAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
std::shared_ptr< ExternalOwningItem > currentItem() const override
std::shared_ptr< ExternalItemPair > makeCopy(const DomItem &self) const
Status status() const
void addError(const DomItem &self, ErrorMessage &&msg) override
DomType kind() const override
LoadInfo(const Path &elPath=Path(), Status status=Status::NotStarted, int nLoaded=0, int derivedFrom=0, const QDateTime &lastDataUpdateAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
Path elementCanonicalPath() const
QList< Dependency > toDo() const
std::shared_ptr< LoadInfo > makeCopy(const DomItem &self) const
LoadInfo(const LoadInfo &o)
QList< Dependency > inProgress() const
A QmlFile, when loaded in a DomEnvironment that has the DomCreationOption::WithSemanticAnalysis,...
Definition qset.h:18
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QMap< QString, QString > map
[6]
p1 load("image.bmp")
QDate date
[1]
QSet< QString >::iterator it
std::function< void(const ErrorMessage &)> ErrorHandler
Combined button and popup list for selecting options.
SharedPointerFileDialogOptions m_options
#define Q_DECLARE_TR_FUNCTIONS(context)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
@ None
Definition qhash.cpp:531
GLsizei const GLfloat * v
[13]
GLuint64 key
GLuint name
GLfloat GLfloat GLfloat GLfloat h
const GLubyte * c
GLuint entry
GLsizei const GLchar *const * path
GLfloat GLfloat p
[1]
GLuint GLenum option
QT_BEGIN_NAMESPACE constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
Definition qpair.h:19
#define QMLDOM_EXPORT
QQmlJS::Dom::DomItem DomItem
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
Definition qscopeguard.h:60
static QT_BEGIN_NAMESPACE const uint Default
Definition qsplitter_p.h:27
static QString canonicalPath(const QString &rootPath)
static FileType fileType(const QFileInfo &fi)
#define Q_ENUM(x)
#define Q_GADGET
static const uint base
Definition qurlidna.cpp:20
#define explicit
QFile file
[0]
mutex tryLock(deadline.remainingTime())
[4]
QMutex mutex
[2]
QString dir
[11]
QGraphicsItem * item
QList< QTreeWidgetItem * > items
view create()
QStringView el
void readFileContent(QStringList *content, const QString &url, Predicate filter)