Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant
4
5#ifndef DOMTOP_H
6#define DOMTOP_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qqmldomitem_p.h"
22
23#include <QtCore/QQueue>
24#include <QtCore/QString>
25#include <QtCore/QDateTime>
26
27#include <QtCore/QCborValue>
28#include <QtCore/QCborMap>
29
30#include <memory>
31#include <optional>
32
33QT_BEGIN_NAMESPACE
34
35using namespace Qt::Literals::StringLiterals;
36
37namespace QQmlJS {
38namespace Dom {
39
40class QMLDOM_EXPORT ExternalItemPairBase: public OwningItem { // all access should have the lock of the DomUniverse containing this
42public:
44 DomType kind() const final override { return kindValue; }
46 const QDateTime &validExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC),
47 const QDateTime &currentExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC),
48 int derivedFrom = 0,
49 const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
50 : OwningItem(derivedFrom, lastDataUpdateAt),
53 {}
57 virtual std::shared_ptr<ExternalOwningItem> validItem() const = 0;
58 virtual DomItem validItem(const DomItem &self) const = 0;
59 virtual std::shared_ptr<ExternalOwningItem> currentItem() const = 0;
60 virtual DomItem currentItem(const DomItem &self) const = 0;
61
62 QString canonicalFilePath(const DomItem &) const final override;
63 Path canonicalPath(const DomItem &self) const final override;
64 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const final override;
65 DomItem field(const DomItem &self, FieldName name) const final override
66 {
67 return OwningItem::field(self, name);
68 }
69
70 bool currentIsValid() const;
71
72 std::shared_ptr<ExternalItemPairBase> makeCopy(const DomItem &self) const
73 {
74 return std::static_pointer_cast<ExternalItemPairBase>(doCopy(self));
75 }
76
77 QDateTime lastDataUpdateAt() const final override
78 {
79 if (currentItem())
80 return currentItem()->lastDataUpdateAt();
81 return ExternalItemPairBase::lastDataUpdateAt();
82 }
83
84 void refreshedDataAt(QDateTime tNew) final override
85 {
86 if (currentItem())
87 currentItem()->refreshedDataAt(tNew);
88 return OwningItem::refreshedDataAt(tNew);
89 }
90
91 friend class DomUniverse;
92
95};
96
97template<class T>
98class QMLDOM_EXPORT ExternalItemPair final : public ExternalItemPairBase
99{ // all access should have the lock of the DomUniverse containing this
100protected:
101 std::shared_ptr<OwningItem> doCopy(const DomItem &) const override
102 {
103 return std::make_shared<ExternalItemPair>(*this);
104 }
105
106public:
108 friend class DomUniverse;
110 const std::shared_ptr<T> &valid = {}, const std::shared_ptr<T> &current = {},
111 const QDateTime &validExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC),
112 const QDateTime &currentExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC),
113 int derivedFrom = 0,
114 const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
115 : ExternalItemPairBase(validExposedAt, currentExposedAt, derivedFrom, lastDataUpdateAt),
116 valid(valid),
117 current(current)
118 {}
119 ExternalItemPair(const ExternalItemPair &o):
121 {
122 }
123 std::shared_ptr<ExternalOwningItem> validItem() const override { return valid; }
124 DomItem validItem(const DomItem &self) const override { return self.copy(valid); }
125 std::shared_ptr<ExternalOwningItem> currentItem() const override { return current; }
126 DomItem currentItem(const DomItem &self) const override { return self.copy(current); }
127 std::shared_ptr<ExternalItemPair> makeCopy(const DomItem &self) const
128 {
129 return std::static_pointer_cast<ExternalItemPair>(doCopy(self));
130 }
131
132 std::shared_ptr<T> valid;
133 std::shared_ptr<T> current;
134};
135
137public:
138 DomTop(int derivedFrom = 0) : OwningItem(derivedFrom) {}
139 DomTop(const DomTop &o) : OwningItem(o) {}
141
142 virtual Path canonicalPath() const = 0;
143
144 Path canonicalPath(const DomItem &) const override;
145 DomItem containingObject(const DomItem &) const override;
146 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override;
147};
148
149class QMLDOM_EXPORT DomUniverse final : public DomTop,
150 public std::enable_shared_from_this<DomUniverse>
151{
152 Q_GADGET
153 Q_DECLARE_TR_FUNCTIONS(DomUniverse);
154protected:
155 std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override;
156
157public:
159 DomType kind() const override { return kindValue; }
160
161 static ErrorGroups myErrors();
162
163 DomUniverse(const QString &universeName);
164 DomUniverse(const DomUniverse &) = delete;
165 static std::shared_ptr<DomUniverse> guaranteeUniverse(const std::shared_ptr<DomUniverse> &univ);
166 static DomItem create(const QString &universeName);
167
168 Path canonicalPath() const override;
169 using DomTop::canonicalPath;
170 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override;
171 std::shared_ptr<DomUniverse> makeCopy(const DomItem &self) const
172 {
173 return std::static_pointer_cast<DomUniverse>(doCopy(self));
174 }
175
176 // Helper structure reflecting the change in the map once loading && parsing is completed
177 // formerItem - DomItem representing value (ExternalItemPair) existing in the map before the
178 // loading && parsing. Might be empty (if didn't exist / failure) or equal to currentItem
179 // currentItem - DomItem representing current map value
185
186 LoadResult loadFile(const FileToLoad &file, DomType fileType,
187 DomCreationOption creationOption = {});
188
189 void removePath(const QString &dir);
190
191 std::shared_ptr<ExternalItemPair<QmlFile>> qmlFileWithPath(const QString &path) const
192 {
193 QMutexLocker l(mutex());
194 return m_qmlFileWithPath.value(path);
195 }
197 {
198 QMap<QString, std::shared_ptr<ExternalItemPair<QmlFile>>> map;
199 {
200 QMutexLocker l(mutex());
201 map = m_qmlFileWithPath;
202 }
203 return QSet<QString>(map.keyBegin(), map.keyEnd());
204 }
205
206 std::shared_ptr<ExternalItemPair<JsFile>> jsFileWithPath(const QString &path) const
207 {
208 QMutexLocker l(mutex());
209 return m_jsFileWithPath.value(path);
210 }
212 {
213 QMap<QString, std::shared_ptr<ExternalItemPair<JsFile>>> map;
214 {
215 QMutexLocker l(mutex());
216 map = m_jsFileWithPath;
217 }
218 return QSet<QString>(map.keyBegin(), map.keyEnd());
219 }
220
221 QString name() const {
222 return m_name;
223 }
224
225private:
226 struct ContentWithDate
227 {
228 QString content;
229 QDateTime date;
230 };
231 // contains either Content with the timestamp when it was read or an Error
232 using ReadResult = std::variant<ContentWithDate, ErrorMessage>;
233 ReadResult readFileContent(const QString &canonicalPath) const;
234
235 LoadResult load(const ContentWithDate &codeWithDate, const FileToLoad &file, DomType fType,
236 DomCreationOption creationOption = {});
237
238 // contains either Content to be parsed or LoadResult if loading / parsing is not needed
239 using PreloadResult = std::variant<ContentWithDate, LoadResult>;
240 PreloadResult preload(const DomItem &univ, const FileToLoad &file, DomType fType) const;
241
242 std::shared_ptr<QmlFile> parseQmlFile(const QString &code, const FileToLoad &file,
243 const QDateTime &contentDate,
244 DomCreationOption creationOption);
245 std::shared_ptr<JsFile> parseJsFile(const QString &code, const FileToLoad &file,
246 const QDateTime &contentDate);
247 std::shared_ptr<ExternalItemPairBase> getPathValueOrNull(DomType fType,
248 const QString &path) const;
249 std::optional<DomItem> getItemIfMostRecent(const DomItem &univ, DomType fType,
250 const QString &path) const;
251 std::optional<DomItem> getItemIfHasSameCode(const DomItem &univ, DomType fType,
252 const QString &canonicalPath,
253 const ContentWithDate &codeWithDate) const;
254 static bool valueHasMostRecentItem(const ExternalItemPairBase *value,
255 const QDateTime &lastModified);
256 static bool valueHasSameContent(const ExternalItemPairBase *value, const QString &content);
257
258 // TODO better name / consider proper public get/set
259 template <typename T>
260 QMap<QString, std::shared_ptr<ExternalItemPair<T>>> &getMutableRefToMap()
261 {
262 Q_ASSERT(!mutex()->tryLock());
263 if constexpr (std::is_same_v<T, QmlFile>) {
264 return m_qmlFileWithPath;
265 }
266 if constexpr (std::is_same_v<T, JsFile>) {
267 return m_jsFileWithPath;
268 }
269 Q_UNREACHABLE();
270 }
271
272 // Inserts or updates an entry reflecting ExternalItem in the corresponding map
273 // Returns a pair of:
274 // - current ExternalItemPair, current value in the map (might be empty, or equal to curValue)
275 // - new current ExternalItemPair, value in the map after after the execution of this function
276 template <typename T>
277 std::pair<std::shared_ptr<ExternalItemPair<T>>, std::shared_ptr<ExternalItemPair<T>>>
278 insertOrUpdateEntry(std::shared_ptr<T> newItem)
279 {
280 std::shared_ptr<ExternalItemPair<T>> curValue;
281 std::shared_ptr<ExternalItemPair<T>> newCurValue;
282 QString canonicalPath = newItem->canonicalFilePath();
283 QDateTime now = QDateTime::currentDateTimeUtc();
284 {
285 QMutexLocker l(mutex());
286 auto &map = getMutableRefToMap<T>();
287 auto it = map.find(canonicalPath);
288 if (it != map.cend() && (*it) && (*it)->current) {
289 curValue = *it;
290 if (valueHasSameContent(curValue.get(), newItem->code())) {
291 // value in the map has same content as newItem, a.k.a. most recent
292 newCurValue = curValue;
293 if (newCurValue->current->lastDataUpdateAt() < newItem->lastDataUpdateAt()) {
294 // update timestamp in the current, as if its content was refreshed by
295 // NewItem
296 newCurValue->current->refreshedDataAt(newItem->lastDataUpdateAt());
297 }
298 } else if (curValue->current->lastDataUpdateAt() > newItem->lastDataUpdateAt()) {
299 // value in the map is more recent than newItem, nothing to update
300 newCurValue = curValue;
301 } else {
302 // perform update with newItem
303 curValue->current = std::move(newItem);
304 curValue->currentExposedAt = now;
305 if (curValue->current->isValid()) {
306 curValue->valid = curValue->current;
307 curValue->validExposedAt = std::move(now);
308 }
309 newCurValue = curValue;
310 }
311 } else {
312 // not found / invalid, just insert
313 newCurValue = std::make_shared<ExternalItemPair<T>>(
314 (newItem->isValid() ? newItem : std::shared_ptr<T>()), newItem, now, now);
315 map.insert(canonicalPath, newCurValue);
316 }
317 }
318 return std::make_pair(curValue, newCurValue);
319 }
320
321 // Inserts or updates an entry reflecting ExternalItem in the corresponding map
322 // returns LoadResult reflecting the change made to the map
323 template <typename T>
324 LoadResult insertOrUpdateExternalItem(std::shared_ptr<T> extItem)
325 {
326 auto change = insertOrUpdateEntry<T>(std::move(extItem));
327 DomItem univ(shared_from_this());
328 return { univ.copy(change.first), univ.copy(change.second) };
329 }
330
331private:
332 QString m_name;
333 QMap<QString, std::shared_ptr<ExternalItemPair<QmlFile>>> m_qmlFileWithPath;
334 QMap<QString, std::shared_ptr<ExternalItemPair<JsFile>>> m_jsFileWithPath;
335};
336
339public:
341 DomType kind() const final override { return kindValue; }
343 const Path &canonicalPath,
344 const QDateTime &currentExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC),
345 int derivedFrom = 0,
346 const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
347 : OwningItem(derivedFrom, lastDataUpdateAt),
350 {}
352
353 virtual std::shared_ptr<ExternalOwningItem> currentItem() const = 0;
354 virtual DomItem currentItem(const DomItem &) const = 0;
355
356 QString canonicalFilePath(const DomItem &) const final override;
357 Path canonicalPath() const { return m_canonicalPath; }
358 Path canonicalPath(const DomItem &) const final override { return canonicalPath(); }
359 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const final override;
360 DomItem field(const DomItem &self, FieldName name) const final override
361 {
362 return OwningItem::field(self, name);
363 }
364
365 int currentRevision(const DomItem &self) const;
366 int lastRevision(const DomItem &self) const;
367 int lastValidRevision(const DomItem &self) const;
368
369 std::shared_ptr<ExternalItemInfoBase> makeCopy(const DomItem &self) const
370 {
371 return std::static_pointer_cast<ExternalItemInfoBase>(doCopy(self));
372 }
373
374 QDateTime lastDataUpdateAt() const final override
375 {
376 if (currentItem())
377 return currentItem()->lastDataUpdateAt();
378 return OwningItem::lastDataUpdateAt();
379 }
380
381 void refreshedDataAt(QDateTime tNew) final override
382 {
383 if (currentItem())
384 currentItem()->refreshedDataAt(tNew);
385 return OwningItem::refreshedDataAt(tNew);
386 }
387
388 void ensureLogicalFilePath(const QString &path) {
389 QMutexLocker l(mutex());
390 if (!m_logicalFilePaths.contains(path))
391 m_logicalFilePaths.append(path);
392 }
393
395 QMutexLocker l(mutex()); // should not be needed, as it should not change...
396 return m_currentExposedAt;
397 }
398
399 void setCurrentExposedAt(QDateTime d) {
400 QMutexLocker l(mutex()); // should not be needed, as it should not change...
401 m_currentExposedAt = d;
402 }
403
404
406 QMutexLocker l(mutex());
407 return m_logicalFilePaths;
408 }
409
410 private:
411 friend class DomEnvironment;
412 Path m_canonicalPath;
413 QDateTime m_currentExposedAt;
414 QStringList m_logicalFilePaths;
415};
416
417template<typename T>
418class ExternalItemInfo final : public ExternalItemInfoBase
419{
420protected:
421 std::shared_ptr<OwningItem> doCopy(const DomItem &) const override
422 {
423 return std::make_shared<ExternalItemInfo>(*this);
424 }
425
426public:
429 const std::shared_ptr<T> &current = std::shared_ptr<T>(),
430 const QDateTime &currentExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC),
431 int derivedFrom = 0,
432 const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
433 : ExternalItemInfoBase(current->canonicalPath().dropTail(), currentExposedAt, derivedFrom,
434 lastDataUpdateAt),
435 current(current)
436 {}
437 ExternalItemInfo(const QString &canonicalPath) : current(new T(canonicalPath)) { }
438 ExternalItemInfo(const ExternalItemInfo &o):
440 {
441 }
442
443 std::shared_ptr<ExternalItemInfo> makeCopy(const DomItem &self) const
444 {
445 return std::static_pointer_cast<ExternalItemInfo>(doCopy(self));
446 }
447
448 std::shared_ptr<ExternalOwningItem> currentItem() const override {
449 return current;
450 }
451 DomItem currentItem(const DomItem &self) const override { return self.copy(current); }
452
453 std::shared_ptr<T> current;
454};
455
457{ // internal, should be cleaned, but nobody should use this...
458public:
459 bool operator==(Dependency const &o) const
460 {
461 return uri == o.uri && version.majorVersion == o.version.majorVersion
462 && version.minorVersion == o.version.minorVersion && filePath == o.filePath;
463 }
464 QString uri; // either dotted uri or file:, http: https: uri
466 QString filePath; // for file deps
468};
469
470class QMLDOM_EXPORT LoadInfo final : public OwningItem
471{
472 Q_DECLARE_TR_FUNCTIONS(LoadInfo);
473
474protected:
475 std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override;
476
477public:
479 DomType kind() const override { return kindValue; }
480
481 enum class Status {
482 NotStarted, // dependencies non checked yet
483 Starting, // adding deps
484 InProgress, // waiting for all deps to be loaded
485 CallingCallbacks, // calling callbacks
486 Done // fully loaded
487 };
488
489 LoadInfo(const Path &elPath = Path(), Status status = Status::NotStarted, int nLoaded = 0,
490 int derivedFrom = 0,
491 const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
492 : OwningItem(derivedFrom, lastDataUpdateAt),
494 m_status(status),
495 m_nLoaded(nLoaded)
496 {
497 }
499 {
500 {
501 QMutexLocker l(o.mutex());
502 m_status = o.m_status;
503 m_nLoaded = o.m_nLoaded;
504 m_toDo = o.m_toDo;
505 m_inProgress = o.m_inProgress;
506 m_endCallbacks = o.m_endCallbacks;
507 }
508 }
509
510 Path canonicalPath(const DomItem &self) const override;
511
512 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override;
513 std::shared_ptr<LoadInfo> makeCopy(const DomItem &self) const
514 {
515 return std::static_pointer_cast<LoadInfo>(doCopy(self));
516 }
517 void addError(const DomItem &self, ErrorMessage &&msg) override
518 {
520 }
521
522 void addEndCallback(const DomItem &self, std::function<void(Path, const DomItem &, const DomItem &)> callback);
523
524 void advanceLoad(const DomItem &self);
525 void finishedLoadingDep(const DomItem &self, const Dependency &d);
526 void execEnd(const DomItem &self);
527
529 {
530 QMutexLocker l(mutex());
531 return m_status;
532 }
533
534 int nLoaded() const
535 {
536 QMutexLocker l(mutex());
537 return m_nLoaded;
538 }
539
541 {
542 QMutexLocker l(mutex()); // we should never change this, remove lock?
543 return m_elementCanonicalPath;
544 }
545
546 int nNotDone() const
547 {
548 QMutexLocker l(mutex());
549 return m_toDo.size() + m_inProgress.size();
550 }
551
553 {
554 QMutexLocker l(mutex());
555 return m_inProgress;
556 }
557
559 {
560 QMutexLocker l(mutex());
561 return m_toDo;
562 }
563
564 int nCallbacks() const
565 {
566 QMutexLocker l(mutex());
567 return m_endCallbacks.size();
568 }
569
570private:
571 void doAddDependencies(const DomItem &self);
572 void addDependency(const DomItem &self, const Dependency &dep);
573
574 Path m_elementCanonicalPath;
575 Status m_status;
576 int m_nLoaded;
577 QQueue<Dependency> m_toDo;
578 QList<Dependency> m_inProgress;
579 QList<std::function<void(Path, const DomItem &, const DomItem &)>> m_endCallbacks;
580};
581
583
585
587{
589public:
590 enum class Cached { None, First, All };
591 Q_ENUM(Cached)
592
593 static RefCacheEntry forPath(const DomItem &el, const Path &canonicalPath);
594 static bool addForPath(const DomItem &el, const Path &canonicalPath, const RefCacheEntry &entry,
596
599};
600
601class QMLDOM_EXPORT DomEnvironment final : public DomTop,
602 public std::enable_shared_from_this<DomEnvironment>
603{
604 Q_GADGET
605 Q_DECLARE_TR_FUNCTIONS(DomEnvironment);
606protected:
607 std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override;
608
609private:
610 struct TypeReader
611 {
612 TypeReader(const std::weak_ptr<DomEnvironment> &env, const QStringList &importPaths)
613 : m_env(env), m_importPaths(importPaths)
614 {
615 }
616
617 std::weak_ptr<DomEnvironment> m_env;
618 QStringList m_importPaths;
619
620 void operator()(QQmlJSImporter *importer, const QString &filePath,
621 const QSharedPointer<QQmlJSScope> &scopeToPopulate);
622 };
623
624public:
625 enum class Option {
626 Default = 0x0,
627 KeepValid = 0x1, // if there is a previous valid version, use that instead of the latest
628 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
629 NoReload = 0x4, // never reload something that was already loaded by the parent environment
630 WeakLoad = 0x8, // load only the names of the available types, not the types (qml files) themselves
631 SingleThreaded = 0x10, // do all operations in a single thread
632 NoDependencies = 0x20 // will not load dependencies (useful when editing)
633 };
634 Q_ENUM(Option)
635 Q_DECLARE_FLAGS(Options, Option);
636
637 static ErrorGroups myErrors();
639 DomType kind() const override;
640
641 Path canonicalPath() const override;
642 using DomTop::canonicalPath;
643 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override;
644 DomItem field(const DomItem &self, FieldName name) const final override;
645
646 std::shared_ptr<DomEnvironment> makeCopy(const DomItem &self) const;
647
648 bool hasFile(const QString &filePath) const;
649 void loadFile(const FileToLoad &file, const Callback &callback,
650 std::optional<DomType> fileType = std::optional<DomType>(),
651 const ErrorHandler &h = nullptr /* used only in loadPendingDependencies*/);
652
653 void removePath(const QString &path);
654
655 std::shared_ptr<DomUniverse> universe() const;
656
658 QSet<int> moduleIndexMajorVersions(const DomItem &self, const QString &uri,
659 EnvLookup lookup = EnvLookup::Normal) const;
660 std::shared_ptr<ExternalItemInfoBase>
661 qmlDirWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const;
662 std::shared_ptr<ExternalItemInfo<QmlFile>>
663 qmlFileWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const;
664 QSet<QString> qmlFilePaths(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const;
665 std::shared_ptr<ExternalItemInfo<JsFile>>
666 jsFileWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const;
667 QSet<QString> jsFilePaths(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const;
668
669 explicit DomEnvironment(const QStringList &loadPaths, Options options = Option::SingleThreaded,
670 DomCreationOption domCreationOption = Default,
671 const std::shared_ptr<DomUniverse> &universe = nullptr);
672 explicit DomEnvironment(const std::shared_ptr<DomEnvironment> &parent,
673 const QStringList &loadPaths, Options options = Option::SingleThreaded,
674 DomCreationOption domCreationOption = Default);
675 DomEnvironment(const DomEnvironment &o) = delete;
676 static std::shared_ptr<DomEnvironment>
677 create(const QStringList &loadPaths, Options options = Option::SingleThreaded,
679 const DomItem &universe = DomItem::empty);
680
681 // TODO AddOption can easily be removed later. KeepExisting option only used in one
682 // place which will be removed in https://codereview.qt-project.org/c/qt/qtdeclarative/+/523217
683 void addQmlFile(const std::shared_ptr<QmlFile> &file,
685 void addJsFile(const std::shared_ptr<JsFile> &file, AddOption option = AddOption::KeepExisting);
686
687 bool commitToBase(
688 const DomItem &self, const std::shared_ptr<DomEnvironment> &validEnv = nullptr);
689
690 void addDependenciesToLoad(const Path &path);
691 void addLoadInfo(
692 const DomItem &self, const std::shared_ptr<LoadInfo> &loadInfo);
693 std::shared_ptr<LoadInfo> loadInfo(const Path &path) const;
694 QList<Path> loadInfoPaths() const;
697 bool finishLoadingDependencies(int waitMSec = 30000);
698 void addWorkForLoadInfo(const Path &elementCanonicalPath);
699
700 Options options() const;
701
702 std::shared_ptr<DomEnvironment> base() const;
703
704 QStringList loadPaths() const;
705
708
709 void addAllLoadedCallback(const DomItem &self, Callback c);
710
711 void clearReferenceCache();
712 void setLoadPaths(const QStringList &v);
713 void setResourceFiles(const QStringList &v);
714
715 // Helper structure reflecting the change in the map once loading / fetching is completed
716 // formerItem - DomItem representing value (ExternalItemInfo) existing in the map before the
717 // loading && parsing. Might be empty (if didn't exist / failure) or equal to currentItem
718 // currentItem - DomItem representing current map value
724 // TODO(QTBUG-121171)
725 template <typename T>
726 LoadResult insertOrUpdateExternalItemInfo(const QString &path, std::shared_ptr<T> extItem)
727 {
728 // maybe in the next revision this all can be just substituted by the addExternalItem
729 DomItem env(shared_from_this());
730 // try to fetch from the current env.
731 if (auto curValue = lookup<T>(path, EnvLookup::NoBase)) {
732 // found in the "initial" env
733 return { env.copy(curValue), env.copy(curValue) };
734 }
735 std::shared_ptr<ExternalItemInfo<T>> newCurValue;
736 // try to fetch from the base env
737 auto valueInBase = lookup<T>(path, EnvLookup::BaseOnly);
738 if (!valueInBase) {
739 // Nothing found. Just create an externalItemInfo which will be inserted
740 newCurValue = std::make_shared<ExternalItemInfo<T>>(std::move(extItem),
741 QDateTime::currentDateTimeUtc());
742 } else {
743 // prepare updated value as a copy of the value from the Base to be inserted
744 newCurValue = valueInBase->makeCopy(env);
745 if (newCurValue->current != extItem) {
746 newCurValue->current = std::move(extItem);
747 newCurValue->setCurrentExposedAt(QDateTime::currentDateTimeUtc());
748 }
749 }
750 // Before inserting new or updated value, check one more time, if ItemInfo is already
751 // present
752 // lookup<> can't be used here because of the data-race
753 {
754 QMutexLocker l(mutex());
755 auto &map = getMutableRefToMap<T>();
756 const auto &it = map.find(path);
757 if (it != map.end())
758 return { env.copy(*it), env.copy(*it) };
759 // otherwise insert
760 map.insert(path, newCurValue);
761 }
762 return { env.copy(valueInBase), env.copy(newCurValue) };
763 }
764
765 template <typename T>
766 void addExternalItemInfo(const DomItem &newExtItem, const Callback &loadCallback,
767 const Callback &endCallback)
768 {
769 // get either Valid "file" from the ExternalItemPair or the current (wip) "file"
770 std::shared_ptr<T> newItemPtr;
771 if (options() & DomEnvironment::Option::KeepValid)
772 newItemPtr = newExtItem.field(Fields::validItem).ownerAs<T>();
773 if (!newItemPtr)
774 newItemPtr = newExtItem.field(Fields::currentItem).ownerAs<T>();
775 Q_ASSERT(newItemPtr && "envCallbackForFile reached without current file");
776
777 auto loadResult = insertOrUpdateExternalItemInfo(newExtItem.canonicalFilePath(),
778 std::move(newItemPtr));
779 Path p = loadResult.currentItem.canonicalPath();
780 {
781 auto depLoad = qScopeGuard([p, this, endCallback] {
782 addDependenciesToLoad(p);
783 // add EndCallback to the queue, which should be called once all dependencies are
784 // loaded
785 if (endCallback) {
786 DomItem env = DomItem(shared_from_this());
787 addAllLoadedCallback(
788 env, [p, endCallback](Path, const DomItem &, const DomItem &env) {
789 DomItem el = env.path(p);
790 endCallback(p, el, el);
791 });
792 }
793 });
794 // call loadCallback
795 if (loadCallback) {
796 loadCallback(p, loadResult.formerItem, loadResult.currentItem);
797 }
798 }
799 }
800 void populateFromQmlFile(MutableDomItem &&qmlFile);
801 DomCreationOption domCreationOption() const { return m_domCreationOption; }
802
803private:
804 friend class RefCacheEntry;
805
806 void loadFile(const FileToLoad &file, const Callback &loadCallback, const Callback &endCallback,
807 std::optional<DomType> fileType = std::optional<DomType>(),
808 const ErrorHandler &h = nullptr);
809
810 template <typename T>
811 QSet<QString> getStrings(function_ref<QSet<QString>()> getBase, const QMap<QString, T> &selfMap,
812 EnvLookup lookup) const;
813
814 template <typename T>
815 const QMap<QString, std::shared_ptr<ExternalItemInfo<T>>> &getConstRefToMap() const
816 {
817 Q_ASSERT(!mutex()->tryLock());
818 if constexpr (std::is_same_v<T, QmlFile>) {
819 return m_qmlFileWithPath;
820 }
821 if constexpr (std::is_same_v<T, JsFile>) {
822 return m_jsFileWithPath;
823 }
824 Q_UNREACHABLE();
825 }
826
827 template <typename T>
828 std::shared_ptr<ExternalItemInfo<T>> lookup(const QString &path, EnvLookup options) const
829 {
830 if (options != EnvLookup::BaseOnly) {
831 QMutexLocker l(mutex());
832 const auto &map = getConstRefToMap<T>();
833 const auto &it = map.find(path);
834 if (it != map.end())
835 return *it;
836 }
837 if (options != EnvLookup::NoBase && m_base)
838 return m_base->lookup<T>(path, options);
839 return {};
840 }
841
842 template <typename T>
843 QMap<QString, std::shared_ptr<ExternalItemInfo<T>>> &getMutableRefToMap()
844 {
845 Q_ASSERT(!mutex()->tryLock());
846 if constexpr (std::is_same_v<T, QmlFile>) {
847 return m_qmlFileWithPath;
848 }
849 if constexpr (std::is_same_v<T, JsFile>) {
850 return m_jsFileWithPath;
851 }
852 Q_UNREACHABLE();
853 }
854
855 template <typename T>
856 void addExternalItem(std::shared_ptr<T> file, QString key, AddOption option)
857 {
858 if (!file)
859 return;
860
861 auto eInfo = std::make_shared<ExternalItemInfo<T>>(file, QDateTime::currentDateTimeUtc());
862 // Lookup helper can't be used here, because it introduces data-race otherwise
863 // (other modifications might happen between the lookup and the insert)
864 QMutexLocker l(mutex());
865 auto &map = getMutableRefToMap<T>();
866 const auto &it = map.find(key);
867 if (it != map.end() && option == AddOption::KeepExisting)
868 return;
869 map.insert(key, eInfo);
870 }
871
872 using FetchResult =
873 std::pair<std::shared_ptr<ExternalItemInfoBase>, std::shared_ptr<ExternalItemInfoBase>>;
874 // This function tries to get an Info object about the ExternalItem from the current env
875 // and depending on the result and options tries to fetch it from the Parent env,
876 // saving a copy with an updated timestamp
877 template <typename T>
878 FetchResult fetchFileFromEnvs(const FileToLoad &file)
879 {
880 const auto &path = file.canonicalPath();
881 // lookup only in the current env
882 if (auto value = lookup<T>(path, EnvLookup::NoBase)) {
883 return std::make_pair(value, value);
884 }
885 // try to find the file in the base(parent) Env and insert if found
886 if (options() & Option::NoReload) {
887 if (auto baseV = lookup<T>(path, EnvLookup::BaseOnly)) {
888 // Watch out! QTBUG-121171
889 // It's possible between the lookup and creation of curVal, baseV && baseV->current
890 // might have changed
891 // Prepare a value to be inserted as copy of the value from Base
892 auto curV = std::make_shared<ExternalItemInfo<T>>(
893 baseV->current, QDateTime::currentDateTimeUtc(), baseV->revision(),
894 baseV->lastDataUpdateAt());
895 // Lookup one more time if the value was already inserted to the current env
896 // Lookup can't be used here because of the data-race
897 {
898 QMutexLocker l(mutex());
899 auto &map = getMutableRefToMap<T>();
900 const auto &it = map.find(path);
901 if (it != map.end())
902 return std::make_pair(*it, *it);
903 // otherwise insert
904 map.insert(path, curV);
905 }
906 return std::make_pair(baseV, curV);
907 }
908 }
909 return std::make_pair(nullptr, nullptr);
910 }
911
912 struct SemanticAnalysis
913 {
914 SemanticAnalysis(const QStringList &loadPaths);
915 void updateLoadPaths(const QStringList &loadPaths);
916 void setResourceFiles(const QStringList &qrcFiles);
917
918 std::shared_ptr<QQmlJSResourceFileMapper> m_mapper;
919 std::shared_ptr<QQmlJSImporter> m_importer;
920 QStringList m_resourceFiles;
921 };
922
923public:
924 SemanticAnalysis semanticAnalysis();
925
926private:
927 SemanticAnalysis semanticAnalysisUnlocked();
928 SemanticAnalysis prepareSemanticAnalysisForFileLoading();
929
930 const Options m_options;
931 const std::shared_ptr<DomEnvironment> m_base;
932 std::shared_ptr<DomEnvironment> m_lastValidBase;
933 const std::shared_ptr<DomUniverse> m_universe;
934 QStringList m_loadPaths; // paths for qml
935 QStringList m_resourcePaths;
936 QMap<QString, std::shared_ptr<ExternalItemInfo<QmlFile>>> m_qmlFileWithPath;
937 QMap<QString, std::shared_ptr<ExternalItemInfo<JsFile>>> m_jsFileWithPath;
938 QQueue<Path> m_loadsWithWork;
939 QQueue<Path> m_inProgress;
940 QHash<Path, std::shared_ptr<LoadInfo>> m_loadInfos;
941 QList<Import> m_implicitImports;
942 QList<Callback> m_allLoadedCallback;
943 QHash<Path, RefCacheEntry> m_referenceCache;
944 DomCreationOption m_domCreationOption;
945
946 std::optional<SemanticAnalysis> m_semanticAnalysis;
947};
948Q_DECLARE_OPERATORS_FOR_FLAGS(DomEnvironment::Options)
949
950} // end namespace Dom
951} // end namespace QQmlJS
952QT_END_NAMESPACE
953#endif // DOMTOP_H
DomType kind() const override
Path canonicalPath(const DomItem &self) const override
const CommentedElement * commentForNode(AST::Node *n, CommentAnchor location) const
AstComments(const std::shared_ptr< Engine > &e)
std::pair< AST::Node *, CommentAnchor > CommentKey
AstComments(const AstComments &o)
std::shared_ptr< AstComments > makeCopy(const DomItem &self) const
std::shared_ptr< OwningItem > doCopy(const DomItem &) const override
static constexpr DomType kindValue
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
void setSemanticScope(const QQmlJSScope::ConstPtr &scope)
QQmlJSScope::ConstPtr m_semanticScope
void updatePathFromOwner(const Path &newPath)
QQmlJSScope::ConstPtr semanticScope() const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
Path addAnnotation(const Path &selfPathFromOwner, const QmlObject &annotation, QmlObject **aPtr=nullptr)
BindingValue(const QList< QmlObject > &l)
void updatePathFromOwner(const Path &newPath)
BindingValue(const std::shared_ptr< ScriptExpression > &o)
BindingValue(const BindingValue &o)
DomItem value(const DomItem &binding) const
BindingValue & operator=(const BindingValue &o)
BindingValue(const QmlObject &o)
void setValue(std::unique_ptr< BindingValue > &&value)
BindingType bindingType() const
std::shared_ptr< ScriptExpression > scriptExpressionValue() const
RegionComments & comments()
Binding & operator=(const Binding &)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const
void setBindingIdentifiers(const ScriptElementVariant &bindingIdentifiers)
Path addAnnotation(const Path &selfPathFromOwner, const QmlObject &a, QmlObject **aPtr=nullptr)
QList< QmlObject > annotations() const
void updatePathFromOwner(const Path &newPath)
static QString preCodeForName(QStringView n)
QmlObject const * objectValue() const
DomItem valueItem(const DomItem &self) const
QList< QmlObject > * arrayValue()
Binding(const Binding &o)
QList< QmlObject > const * arrayValue() const
static QString postCodeForName(QStringView)
void setAnnotations(const QList< QmlObject > &annotations)
Binding & operator=(Binding &&)=default
void writeOut(const DomItem &self, OutWriter &lw) const
Binding(const QString &m_name, const QString &scriptCode, BindingType bindingType=BindingType::Normal)
const RegionComments & comments() const
Binding(const QString &m_name, std::unique_ptr< BindingValue > &&value, BindingType bindingType=BindingType::Normal)
void writeOutValue(const DomItem &self, OutWriter &lw) const
Binding(const QString &m_name=QString())
static constexpr DomType kindValue
Binding(const QString &m_name, const QmlObject &value, BindingType bindingType=BindingType::Normal)
Binding(Binding &&o)=default
std::shared_ptr< ScriptExpression > scriptExpressionValue()
ScriptElementVariant bindingIdentifiers() const
BindingValueKind valueKind() const
Binding(const QString &m_name, const std::shared_ptr< ScriptExpression > &value, BindingType bindingType=BindingType::Normal)
CommentCollector(MutableDomItem item)
void collectComments(const std::shared_ptr< Engine > &engine, AST::Node *rootNode, const std::shared_ptr< AstComments > &astComments)
Collects and associates comments with javascript AST::Node pointers or with MutableDomItem.
Extracts various pieces and information out of a rawComment string.
QStringView postWhitespace() const
QStringView comment() const
QQmlJS::SourceLocation sourceLocation() const
QQmlJS::SourceLocation commentLocation
QStringView preWhitespace() const
Represents a comment.
static constexpr DomType kindValue
CommentType type() const
void write(OutWriter &lw) const
QQmlJS::SourceLocation sourceLocation() const
QStringView rawComment() const
Comment(QStringView c, const QQmlJS::SourceLocation &loc, int newlinesBefore=1, CommentType type=Pre)
friend bool operator==(const Comment &c1, const Comment &c2)
friend bool operator!=(const Comment &c1, const Comment &c2)
CommentInfo info() const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
Expose attributes to the Dom.
Comment(const QString &c, const QQmlJS::SourceLocation &loc, int newlinesBefore=1, CommentType type=Pre)
const RegionComments & comments() const
CommentableDomElement & operator=(const CommentableDomElement &o)=default
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
CommentableDomElement(const CommentableDomElement &o)
CommentableDomElement(const Path &pathFromOwner=Path())
Keeps the comment associated with an element.
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
friend bool operator!=(const CommentedElement &c1, const CommentedElement &c2)
void writePre(OutWriter &lw) const
QList< Comment > preComments() const
void writePost(OutWriter &lw) const
static constexpr DomType kindValue
friend bool operator==(const CommentedElement &c1, const CommentedElement &c2)
void addComment(const Comment &comment)
QList< Comment > postComments() const
void setIsSingleton(bool isSingleton)
void updatePathFromOwner(const Path &newPath) override
Component(const Path &pathFromOwner=Path())
void setIsComposite(bool isComposite)
Component & operator=(const Component &)=default
void setIsCreatable(bool isCreatable)
void setObjects(const QList< QmlObject > &objects)
const QMultiMap< QString, EnumDecl > & enumerations() const &
Component(const Component &o)=default
Path addObject(const QmlObject &object, QmlObject **oPtr=nullptr)
void setName(const QString &name)
Path attachedTypePath(const DomItem &) const
void setEnumerations(const QMultiMap< QString, EnumDecl > &enumerations)
DomItem field(const DomItem &self, FieldName name) const override
Path addEnumeration(const EnumDecl &enumeration, AddOption option=AddOption::Overwrite, EnumDecl **ePtr=nullptr)
void setAttachedTypeName(const QString &name)
bool iterateDirectSubpaths(const DomItem &, DirectVisitor) const override
QString attachedTypeName() const
Component(const QString &name)
void setAttachedTypePath(const Path &p)
const QList< QmlObject > & objects() const &
DomKind domKind() const override
QCborValue value() const override
quintptr id() const override
static constexpr DomType kindValue
DomType kind() const override
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
ConstantData & operator*()
ConstantData(const Path &pathFromOwner, const QCborValue &value)
const ConstantData & operator*() const
const ConstantData * operator->() const
ConstantData * operator->()
bool operator==(Dependency const &o) const
QString typeName() const
virtual DomType kind() const =0
virtual DomKind domKind() const
virtual Path canonicalPath(const DomItem &self) const =0
virtual Path pathFromOwner() const =0
virtual QList< QString > fields(const DomItem &self) const
virtual bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const =0
virtual index_type indexes(const DomItem &self) const
const DomBase * domBase() const
virtual DomItem containingObject(const DomItem &self) const
virtual void writeOut(const DomItem &self, OutWriter &lw) const
virtual QSet< QString > const keys(const DomItem &self) const
virtual quintptr id() const
virtual QCborValue value() const
virtual QString canonicalFilePath(const DomItem &self) const
virtual ~DomBase()=default
virtual void dump(const DomItem &, const Sink &sink, int indent, FilterT filter) const
virtual DomItem key(const DomItem &self, const QString &name) const
virtual DomItem field(const DomItem &self, FieldName name) const
virtual DomItem index(const DomItem &self, index_type index) const
DomElement & operator=(const DomElement &)=default
virtual void updatePathFromOwner(const Path &newPath)
Path canonicalPath(const DomItem &self) const override
Path pathFromOwner() const override
DomElement(const DomElement &o)=default
DomElement(const Path &pathFromOwner=Path())
DomItem containingObject(const DomItem &self) const override
SemanticAnalysis semanticAnalysis()
DomEnvironment(const DomEnvironment &o)=delete
void addQmlFile(const std::shared_ptr< QmlFile > &file, AddOption option=AddOption::KeepExisting)
static std::shared_ptr< DomEnvironment > create(const QStringList &loadPaths, Options options=Option::SingleThreaded, DomCreationOption creationOption=DomCreationOption::Default, const DomItem &universe=DomItem::empty)
bool finishLoadingDependencies(int waitMSec=30000)
std::shared_ptr< ExternalItemInfo< QmlFile > > qmlFileWithPath(const DomItem &self, const QString &path, EnvLookup options=EnvLookup::Normal) const
QSet< QString > moduleIndexUris(const DomItem &self, EnvLookup lookup=EnvLookup::Normal) const
LoadResult insertOrUpdateExternalItemInfo(const QString &path, std::shared_ptr< T > extItem)
void populateFromQmlFile(MutableDomItem &&qmlFile)
std::shared_ptr< LoadInfo > loadInfo(const Path &path) const
void addExternalItemInfo(const DomItem &newExtItem, const Callback &loadCallback, const Callback &endCallback)
void addDependenciesToLoad(const Path &path)
void setResourceFiles(const QStringList &v)
bool hasFile(const QString &filePath) const
Path canonicalPath() const override
std::shared_ptr< ExternalItemInfoBase > qmlDirWithPath(const DomItem &self, const QString &path, EnvLookup options=EnvLookup::Normal) const
void addJsFile(const std::shared_ptr< JsFile > &file, AddOption option=AddOption::KeepExisting)
void removePath(const QString &path)
bool commitToBase(const DomItem &self, const std::shared_ptr< DomEnvironment > &validEnv=nullptr)
QSet< QString > qmlFilePaths(const DomItem &self, EnvLookup lookup=EnvLookup::Normal) const
DomEnvironment(const std::shared_ptr< DomEnvironment > &parent, const QStringList &loadPaths, Options options=Option::SingleThreaded, DomCreationOption domCreationOption=Default)
DomItem field(const DomItem &self, FieldName name) const final override
static ErrorGroups myErrors()
QSet< int > moduleIndexMajorVersions(const DomItem &self, const QString &uri, EnvLookup lookup=EnvLookup::Normal) const
static QList< Import > defaultImplicitImports()
void setLoadPaths(const QStringList &v)
std::shared_ptr< DomEnvironment > base() const
std::shared_ptr< DomEnvironment > makeCopy(const DomItem &self) const
QList< Path > loadInfoPaths() const
std::shared_ptr< ExternalItemInfo< JsFile > > jsFileWithPath(const DomItem &self, const QString &path, EnvLookup options=EnvLookup::Normal) const
void addWorkForLoadInfo(const Path &elementCanonicalPath)
std::shared_ptr< OwningItem > doCopy(const DomItem &self) const override
static constexpr DomType kindValue
void addLoadInfo(const DomItem &self, const std::shared_ptr< LoadInfo > &loadInfo)
DomEnvironment(const QStringList &loadPaths, Options options=Option::SingleThreaded, DomCreationOption domCreationOption=Default, const std::shared_ptr< DomUniverse > &universe=nullptr)
void loadFile(const FileToLoad &file, const Callback &callback, std::optional< DomType > fileType=std::optional< DomType >(), const ErrorHandler &h=nullptr)
std::shared_ptr< DomUniverse > universe() const
DomCreationOption domCreationOption() const
QList< Import > implicitImports() const
QHash< Path, std::shared_ptr< LoadInfo > > loadInfos() const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
DomType kind() const override
void addAllLoadedCallback(const DomItem &self, Callback c)
QStringList loadPaths() const
QSet< QString > jsFilePaths(const DomItem &self, EnvLookup lookup=EnvLookup::Normal) const
A value type that references any element of the Dom.
DomItem bindings() const
DomItem top() const
DomItem goUp(int) const
QDateTime createdAt() const
T const * as() const
std::shared_ptr< OwningItem > owningItemPtr() const
DomItem operator[](const QString &component) const
std::function< void(const Path &, const DomItem &, const DomItem &)> Callback
QString toString() const
void writeOutPost(OutWriter &lw) const
bool invokeVisitorOnValue(DirectVisitor visitor, const PathEls::PathComponent &c, const T &value) const
bool visitTree(const Path &basePath, ChildrenVisitor visitor, VisitOptions options=VisitOption::Default, ChildrenVisitor openingVisitor=emptyChildrenVisitor, ChildrenVisitor closingVisitor=emptyChildrenVisitor, const FieldFilter &filter=FieldFilter::noFilter()) const
Visits recursively all the children of this item using the given visitors.
bool resolve(const Path &path, Visitor visitor, const ErrorHandler &errorHandler, const Path &fullPath=Path(), QList< Path > *visitedRefs=nullptr) const
DomItem path(const Path &p, const ErrorHandler &h=&defaultErrorHandler) const
DomItem containingFile() const
DomItem filterUp(function_ref< bool(DomType k, const DomItem &)> filter, FilterUpOptions options) const
DomItem methods() const
QString internalKindStr() const
DomItem scope(FilterUpOptions options=FilterUpOptions::ReturnOuter) const
DomItem enumerations() const
DomItem subOwnerItem(const PathEls::PathComponent &c, Owner o) const
bool visitLookup1(const QString &symbolName, function_ref< bool(const DomItem &)> visitor, LookupOptions=LookupOption::Normal, const ErrorHandler &h=nullptr, QSet< quintptr > *visited=nullptr, QList< Path > *visitedRefs=nullptr) const
DomItem child(index_type i) const
DomItem key(QStringView name) const
std::shared_ptr< T > ownerAs() const
DomItem get(const ErrorHandler &h=nullptr, QList< Path > *visitedRefs=nullptr) const
static ErrorGroups myErrors()
DomItem operator[](const char16_t *component) const
bool visitUp(function_ref< bool(const DomItem &)> visitor) const
Let the visitor visit the Dom Tree hierarchy of this DomItem.
bool invokeVisitorOnField(DirectVisitor visitor, FieldName f, T &obj) const
index_type indexes() const
bool hasAnnotations() const
bool iterateSubOwners(function_ref< bool(const DomItem &owner)> visitor) const
MutableDomItem makeCopy(CopyOption option=CopyOption::EnvConnected) const
DomItem refreshed() const
bool iterateErrors(function_ref< bool(const DomItem &, const ErrorMessage &)> visitor, bool iterate, Path inPath=Path()) const
DomItem pragmas() const
DomItem proceedToScope(const ErrorHandler &h=nullptr, QList< Path > *visitedRefs=nullptr) const
Dereference DomItems pointing to other DomItems.
QList< DomItem > values() const
DomItem universe() const
bool iterateDirectSubpaths(DirectVisitor v) const
DomItem container() const
void clearErrors(const ErrorGroups &groups=ErrorGroups({}), bool iterate=true) const
quintptr id() const
QList< QString > fields() const
bool writeOut(const QString &path, const LineWriterOptions &opt=LineWriterOptions(), FileWriter *fw=nullptr, WriteOutChecks extraChecks=WriteOutCheck::Default) const
static DomItem fromCode(const QString &code, DomType fileType=DomType::QmlFile)
Creates a new document with the given code.
QString idStr() const
DomItem(const std::shared_ptr< DomEnvironment > &)
FileWriter::Status dump(const QString &path, function_ref< bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter=noFilter, int indent=0, FileWriter *fw=nullptr) const
DomItem copy(const T &base) const
bool visitScopeChain(function_ref< bool(const DomItem &)> visitor, LookupOptions=LookupOption::Normal, const ErrorHandler &h=nullptr, QSet< quintptr > *visited=nullptr, QList< Path > *visitedRefs=nullptr) const
Let the visitor visit the QML scope hierarchy of this DomItem.
std::shared_ptr< DomTop > topPtr() const
QCborValue value() const
index_type size() const
QDateTime frozenAt() const
DomItem subListItem(const List &list) const
DomItem component(GoTo option=GoTo::Strict) const
DomItem subValueItem(const PathEls::PathComponent &c, const T &value) const
bool visitLookup(const QString &symbolName, function_ref< bool(const DomItem &)> visitor, LookupType type=LookupType::Symbol, LookupOptions=LookupOption::Normal, const ErrorHandler &errorHandler=nullptr, QSet< quintptr > *visited=nullptr, QList< Path > *visitedRefs=nullptr) const
void writeOutPre(OutWriter &lw) const
DomItem lookupFirst(const QString &symbolName, LookupType type=LookupType::Symbol, LookupOptions=LookupOption::Normal, const ErrorHandler &errorHandler=nullptr) const
bool visitIndexes(function_ref< bool(const DomItem &)> visitor) const
DomItem fileObject(GoTo option=GoTo::Strict) const
bool visitKeys(function_ref< bool(const QString &, const DomItem &)> visitor) const
bool invokeVisitorOnReferences(DirectVisitor visitor, FieldName f, const QList< Path > &paths) const
bool visitStaticTypePrototypeChains(function_ref< bool(const DomItem &)> visitor, VisitPrototypesOptions options=VisitPrototypesOption::Normal, const ErrorHandler &h=nullptr, QSet< quintptr > *visited=nullptr, QList< Path > *visitedRefs=nullptr) const
DomItem::visitStaticTypePrototypeChains.
QQmlJSScope::ConstPtr semanticScope() const
bool writeOutForFile(OutWriter &ow, WriteOutChecks extraChecks) const
bool commitToBase(const std::shared_ptr< DomEnvironment > &validPtr=nullptr) const
DomItem operator[](FieldName name) const
DomItem field(FieldName name) const
DomItem ids() const
DomItem copy(const Owner &owner, const Path &ownerPath) const
bool visitSubSymbolsNamed(const QString &name, function_ref< bool(const DomItem &)> visitor) const
DomItem wrap(const PathEls::PathComponent &c, const T &obj) const
QList< DomItem > lookup(const QString &symbolName, LookupType type=LookupType::Symbol, LookupOptions=LookupOption::Normal, const ErrorHandler &errorHandler=nullptr) const
DomItem subDataItem(const PathEls::PathComponent &c, const T &value) const
void dump(const Sink &, int indent=0, function_ref< bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter=noFilter) const
friend QMLDOM_EXPORT bool operator==(const DomItem &, const DomItem &)
QSet< QString > propertyInfoNames() const
static ErrorGroups myResolveErrors()
bool visitDirectAccessibleScopes(function_ref< bool(const DomItem &)> visitor, VisitPrototypesOptions options=VisitPrototypesOption::Normal, const ErrorHandler &h=nullptr, QSet< quintptr > *visited=nullptr, QList< Path > *visitedRefs=nullptr) const
DomItem environment() const
bool isCanonicalChild(const DomItem &child) const
index_type length() const
DomItem operator[](QStringView component) const
DomItem rootQmlObject(GoTo option=GoTo::Strict) const
DomItem directParent() const
DomItem annotations() const
Path canonicalPath() const
QStringList sortedKeys() const
void addError(ErrorMessage &&msg) const
DomItem containingObject() const
DomItem containingScriptExpression() const
QList< DomItem > getAll(const ErrorHandler &h=nullptr, QList< Path > *visitedRefs=nullptr) const
bool visitPrototypeChain(function_ref< bool(const DomItem &)> visitor, VisitPrototypesOptions options=VisitPrototypesOption::Normal, const ErrorHandler &h=nullptr, QSet< quintptr > *visited=nullptr, QList< Path > *visitedRefs=nullptr) const
DomKind domKind() const
bool isContainer() const
DomItem index(index_type) const
DomItem subReferencesItem(const PathEls::PathComponent &c, const QList< Path > &paths) const
DomItem subMapItem(const Map &map) const
bool visitLocalSymbolsNamed(const QString &name, function_ref< bool(const DomItem &)> visitor) const
bool isExternalItem() const
DomItem subReferenceItem(const PathEls::PathComponent &c, const Path &referencedObject) const
void dumpPtr(const Sink &sink) const
auto visitEl(F f) const
InternalKind internalKind() const
bool isOwningItem() const
DomItem owner() const
The owner of an element, for an qmlObject this is the containing qml file.
ErrorHandler errorHandler() const
DomItem operator[](const Path &path) const
static DomItem empty
QQmlJSScope::ConstPtr nearestSemanticScope() const
QString canonicalFilePath() const
void writeOut(OutWriter &lw) const
Path pathFromOwner() const
DomItem qmlObject(GoTo option=GoTo::Strict, FilterUpOptions options=FilterUpOptions::ReturnOuter) const
Returns the QmlObject that this belongs to.
DomItem subScriptElementWrapperItem(const ScriptElementVariant &obj) const
DomItem copy(const Owner &owner, const Path &ownerPath, const T &base) const
DomItem key(const QString &name) const
PropertyInfo propertyInfoWithName(const QString &name) const
QSet< QString > keys() const
QString name() const
DomItem children() const
bool invokeVisitorOnReference(DirectVisitor visitor, FieldName f, const Path &referencedObject) const
std::shared_ptr< QQmlJSResourceFileMapper > resourceFileMapper() const
DomItem propertyDefs() const
DomItem goToFile(const QString &filePath) const
QDateTime lastDataUpdateAt() const
DomItem(const std::shared_ptr< DomUniverse > &)
static ErrorGroup domErrorGroup
bool invokeVisitorOnLazyField(DirectVisitor visitor, FieldName f, F valueF) const
DomItem propertyInfos() const
Path canonicalPath(const DomItem &) const override
QQml::Dom::DomTop::loadFile.
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
virtual Path canonicalPath() const =0
DomTop(const DomTop &o)
DomItem::Callback Callback
DomItem containingObject(const DomItem &) const override
DomTop(int derivedFrom=0)
static DomItem create(const QString &universeName)
std::shared_ptr< ExternalItemPair< JsFile > > jsFileWithPath(const QString &path) const
static ErrorGroups myErrors()
std::shared_ptr< OwningItem > doCopy(const DomItem &self) const override
static std::shared_ptr< DomUniverse > guaranteeUniverse(const std::shared_ptr< DomUniverse > &univ)
void removePath(const QString &dir)
DomUniverse(const QString &universeName)
DomUniverse(const DomUniverse &)=delete
std::shared_ptr< ExternalItemPair< QmlFile > > qmlFileWithPath(const QString &path) const
LoadResult loadFile(const FileToLoad &file, DomType fileType, DomCreationOption creationOption={})
QSet< QString > jsFilePaths() const
DomType kind() const override
static constexpr DomType kindValue
Path canonicalPath() const override
std::shared_ptr< DomUniverse > makeCopy(const DomItem &self) const
QSet< QString > qmlFilePaths() const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
Helper class to accept eithe a string or a dumper (a function that writes to a sink).
void operator()(const Sink &s) const
void dump(const DomItem &, const Sink &s, int indent, function_ref< bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter) const override
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
static constexpr DomType kindValue
Path pathFromOwner() const override
Path canonicalPath(const DomItem &self) const override
const Empty & operator*() const
const Empty * operator->() const
DomType kind() const override
DomItem containingObject(const DomItem &self) const override
quintptr id() const override
const QList< QmlObject > & annotations() const &
const QList< EnumItem > & values() const &
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override
void setAlias(const QString &aliasName)
void setAnnotations(const QList< QmlObject > &annotations)
EnumDecl(const QString &name=QString(), const QList< EnumItem > &values=QList< EnumItem >(), const Path &pathFromOwner=Path())
void writeOut(const DomItem &self, OutWriter &lw) const override
void updatePathFromOwner(const Path &newP) override
void setName(const QString &name)
Path addAnnotation(const QmlObject &child, QmlObject **cPtr=nullptr)
Path addValue(const EnumItem &value)
static constexpr DomType kindValue
void setValues(const QList< EnumItem > &values)
DomType kind() const override
EnumItem(const QString &name=QString(), int value=0, ValueKind valueKind=ValueKind::ImplicitValue)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
const RegionComments & comments() const
RegionComments & comments()
void writeOut(const DomItem &self, OutWriter &lw) const
static constexpr DomType kindValue
convenience macro creating a new ErrorGroup and registering its groupId as translatable string
QLatin1String groupId() const
void dumpId(const Sink &sink) const
Represents a set of tags grouping a set of related error messages.
ErrorMessage debug(const Dumper &message) const
ErrorMessage error(const QString &message) const
ErrorMessage errorMessage(const DiagnosticMessage &msg, const Path &element=Path(), const QString &canonicalFilePath=QString()) const
ErrorMessage warning(const Dumper &message) const
static int cmp(const ErrorGroups &g1, const ErrorGroups &g2)
ErrorMessage debug(const QString &message) const
void dumpId(const Sink &sink) const
ErrorMessage info(const QString &message) const
ErrorMessage warning(const QString &message) const
ErrorMessage errorMessage(const Dumper &msg, ErrorLevel level, const Path &element=Path(), const QString &canonicalFilePath=QString(), SourceLocation location=SourceLocation()) const
ErrorMessage info(const Dumper &message) const
void fatal(const Dumper &msg, const Path &element=Path(), QStringView canonicalFilePath=u"", SourceLocation location=SourceLocation()) const
ErrorMessage error(const Dumper &message) const
Represents an error message connected to the dom.
ErrorMessage & withPath(const Path &)
ErrorMessage & withErrorId(QLatin1String errorId)
ErrorMessage(const ErrorGroups &errorGroups, const DiagnosticMessage &msg, const Path &path=Path(), const QString &file=QString(), QLatin1String errorId=QLatin1String(""))
static QLatin1String msg(QLatin1String errorId, ErrorMessage &&err)
ErrorMessage & withLocation(SourceLocation)
ErrorMessage handle(const ErrorHandler &errorHandler=nullptr)
static QLatin1String msg(const char *errorId, ErrorMessage &&err)
ErrorMessage & withFile(const QString &)
ErrorMessage & withItem(const DomItem &)
static ErrorMessage load(const char *errorId)
static ErrorMessage load(QLatin1String errorId, T... args)
ErrorMessage(const QString &message, const ErrorGroups &errorGroups, Level level=Level::Warning, const Path &path=Path(), const QString &file=QString(), SourceLocation location=SourceLocation(), QLatin1String errorId=QLatin1String(""))
void dump(const Sink &s) const
ErrorMessage & withFile(QStringView)
static ErrorMessage load(QLatin1String errorId)
friend int compare(const ErrorMessage &msg1, const ErrorMessage &msg2)
static void visitRegisteredMessages(function_ref< bool(const ErrorMessage &)> visitor)
static Export fromString(const Path &source, QStringView exp, const Path &typePath, const ErrorHandler &h)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
QString canonicalFilePath(const DomItem &) const final override
ExternalItemInfoBase(const ExternalItemInfoBase &o)=default
void setCurrentExposedAt(QDateTime d)
std::shared_ptr< ExternalItemInfoBase > makeCopy(const DomItem &self) const
DomType kind() const final override
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const final override
int lastValidRevision(const DomItem &self) const
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
DomItem field(const DomItem &self, FieldName name) const final override
int lastRevision(const DomItem &self) const
virtual std::shared_ptr< ExternalOwningItem > currentItem() const =0
Path canonicalPath(const DomItem &) const final override
int currentRevision(const DomItem &self) const
static constexpr DomType kindValue
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)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const final override
DomType kind() const final override
QString canonicalFilePath(const DomItem &) const final override
DomItem field(const DomItem &self, FieldName name) const final override
void refreshedDataAt(QDateTime tNew) final override
Path canonicalPath(const DomItem &self) const 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
static constexpr DomType kindValue
std::shared_ptr< T > valid
static constexpr DomType kindValue
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
static FieldFilter noLocationFilter()
const QMultiMap< QString, QString > & fieldFilterAdd() const
bool operator()(const DomItem &, const Path &, const DomItem &) const
bool addFilter(const QString &f)
bool operator()(const DomItem &, const PathEls::PathComponent &c, const DomItem &) const
static FieldFilter compareNoCommentsFilter()
static FieldFilter defaultFilter()
static FieldFilter compareFilter()
static FieldFilter noFilter()
FieldFilter(const QMultiMap< QString, QString > &fieldFilterAdd={}, const QMultiMap< QString, QString > &fieldFilterRemove={})
QMultiMap< QString, QString > fieldFilterRemove() const
Represents a Node of FileLocations tree.
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override
std::shared_ptr< OwningItem > doCopy(const DomItem &) const override
Node::Ptr makeCopy(const DomItem &self) const
Path canonicalPath(const DomItem &self) const override
static Ptr instantiate(const Ptr &parent=nullptr, const Path &p=Path())
QString logicalPath() const
QString canonicalPath() const
std::shared_ptr< DomEnvironment > environment() const
void setCanonicalPath(const QString &canonicalPath)
void setLogicalPath(const QString &logicalPath)
std::optional< InMemoryContents > content() const
static FileToLoad fromFileSystem(const std::weak_ptr< DomEnvironment > &environment, const QString &canonicalPath)
static FileToLoad fromMemory(const std::weak_ptr< DomEnvironment > &environment, const QString &path, const QString &data)
FileToLoad(const std::weak_ptr< DomEnvironment > &environment, const QString &canonicalPath, const QString &logicalPath, const std::optional< InMemoryContents > &content)
Status write(const QString &targetFile, function_ref< bool(QTextStream &)> write)
GlobalComponent(const Path &pathFromOwner=Path())
DomType kind() const override
static constexpr DomType kindValue
Path addAnnotation(const Path &selfPathFromOwner, const QmlObject &ann, QmlObject **aPtr=nullptr)
RegionComments comments
std::shared_ptr< ScriptExpression > value
static constexpr DomType kindValue
Id(const QString &idName=QString(), const Path &referredObject=Path())
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const
void updatePathFromOwner(const Path &pathFromOwner)
QList< QmlObject > annotations
Import(const QmlUri &uri=QmlUri(), Version version=Version(), const QString &importId=QString())
Import baseImport() const
friend bool operator==(const Import &i1, const Import &i2)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const
static QRegularExpression importRe()
void writeOut(const DomItem &self, OutWriter &ow) const
static Import fromFileString(const QString &importStr, const QString &importId=QString(), const ErrorHandler &handler=nullptr)
friend bool operator!=(const Import &i1, const Import &i2)
static Import fromUriString(const QString &importStr, Version v=Version(), const QString &importId=QString(), const ErrorHandler &handler=nullptr)
IndentInfo(QStringView line, int tabSize, int initialColumn=0)
JsResource(const Path &pathFromOwner=Path())
DomType kind() const override
bool iterateDirectSubpaths(const DomItem &, DirectVisitor) const override
static constexpr DomType kindValue
const QString & currentLine() const
LineWriter & write(QStringView v, TextAddType tType=TextAddType::Normal)
LineWriter & ensureSemicolon(TextAddType t=TextAddType::Extra)
void handleTrailingSpace(LineWriterOptions::TrailingSpace s)
LineWriter & ensureNewline(int nNewlines=1, TextAddType t=TextAddType::Extra)
QMap< int, std::function< bool(LineWriter &, TextAddType)> > m_textAddCallbacks
LineWriter & ensureSpace(TextAddType t=TextAddType::Extra)
const LineWriterOptions & options() const
void eof(bool ensureNewline=true)
void addInnerSink(const SinkF &s)
std::function< void(QStringView)> sink()
int addNewlinesAutospacerCallback(int nLines)
virtual void reindentAndSplit(const QString &eol, bool eof=false)
void commitLine(const QString &eol, TextAddType t=TextAddType::Normal, int untilChar=-1)
SourceLocation currentSourceLocation() const
LineWriter & ensureSpace(QStringView space, TextAddType t=TextAddType::Extra)
SourceLocation committedLocation() const
void setLineIndent(int indentAmount)
int addTextAddCallback(std::function< bool(LineWriter &, TextAddType)> callback)
void textAddCallback(TextAddType t)
LineWriter(const SinkF &innerSink, const QString &fileName, const LineWriterOptions &options=LineWriterOptions(), int lineNr=0, int columnNr=0, int utf16Offset=0, const QString &currentLine=QString())
quintptr id() const override
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor v) const override
void writeOut(const DomItem &self, OutWriter &ow, bool compact) const
static constexpr DomType kindValue
index_type indexes(const DomItem &) const override
virtual void copyTo(ListPBase *) const
virtual void moveTo(ListPBase *) const
void writeOut(const DomItem &self, OutWriter &ow) const override
DomType kind() const override
QList< const void * > m_pList
ListPBase(const Path &pathFromOwner, const QList< const void * > &pList, const QString &elType)
void moveTo(ListPBase *t) const override
ListPT(const Path &pathFromOwner, const QList< T * > &pList, const QString &elType=QString(), ListOptions options=ListOptions::Normal)
DomItem index(const DomItem &self, index_type index) const override
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor v) const override
void copyTo(ListPBase *t) const override
static constexpr DomType kindValue
static constexpr DomType kindValue
ListPBase & operator*()
ListPBase * operator->()
const ListPBase * operator->() const
ListP(const Path &pathFromOwner, const QList< T * > &pList, const QString &elType=QString(), ListOptions options=ListOptions::Normal)
const ListPBase & operator*() const
void writeOut(const DomItem &self, OutWriter &ow, bool compact) const
std::function< bool(const DomItem &, function_ref< bool(index_type, function_ref< DomItem()>)>)> IteratorFunction
List(const Path &pathFromOwner, const LookupFunction &lookup, const Length &length, const IteratorFunction &iterator, const QString &elType)
DomType kind() const override
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
const List & operator*() const
static List fromQList(const Path &pathFromOwner, const QList< T > &list, const std::function< DomItem(const DomItem &, const PathEls::PathComponent &, const T &)> &elWrapper, ListOptions options=ListOptions::Normal)
static List fromQListRef(const Path &pathFromOwner, const QList< T > &list, const std::function< DomItem(const DomItem &, const PathEls::PathComponent &, const T &)> &elWrapper, ListOptions options=ListOptions::Normal)
void dump(const DomItem &, const Sink &s, int indent, function_ref< bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)>) const override
std::function< DomItem(const DomItem &, index_type)> LookupFunction
void writeOut(const DomItem &self, OutWriter &ow) const override
quintptr id() const override
static constexpr DomType kindValue
const List * operator->() const
index_type indexes(const DomItem &self) const override
DomItem index(const DomItem &self, index_type index) const override
std::function< index_type(const DomItem &)> Length
void addEndCallback(const DomItem &self, std::function< void(Path, const DomItem &, const DomItem &)> callback)
void finishedLoadingDep(const DomItem &self, const Dependency &d)
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))
static constexpr DomType kindValue
void execEnd(const DomItem &self)
void advanceLoad(const DomItem &self)
std::shared_ptr< OwningItem > doCopy(const DomItem &self) const override
Path canonicalPath(const DomItem &self) const override
Path elementCanonicalPath() const
QList< Dependency > toDo() const
std::shared_ptr< LoadInfo > makeCopy(const DomItem &self) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
LoadInfo(const LoadInfo &o)
QList< Dependency > inProgress() const
std::function< DomItem(const DomItem &, QString)> LookupFunction
static Map fromMultiMapRef(const Path &pathFromOwner, const QMultiMap< QString, T > &mmap)
const Map * operator->() const
static Map fromFileRegionMap(const Path &pathFromOwner, const QMap< FileLocationRegion, T > &map)
Map(const Path &pathFromOwner, const LookupFunction &lookup, const Keys &keys, const QString &targetType)
const Map & operator*() const
static Map fromMapRef(const Path &pathFromOwner, const QMap< QString, T > &mmap, const std::function< DomItem(const DomItem &, const PathEls::PathComponent &, const T &)> &elWrapper)
static Map fromMultiMap(const Path &pathFromOwner, const QMultiMap< QString, T > &mmap)
std::function< QSet< QString >(const DomItem &)> Keys
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
QSet< QString > const keys(const DomItem &self) const override
quintptr id() const override
DomItem key(const DomItem &self, const QString &name) const override
static constexpr DomType kindValue
DomType kind() const override
std::shared_ptr< ScriptExpression > body
static constexpr DomType kindValue
QList< MethodParameter > parameters
std::shared_ptr< ScriptExpression > returnType
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
void writeOut(const DomItem &self, OutWriter &ow) const
void writePre(const DomItem &self, OutWriter &ow) const
QString signature(const DomItem &self) const
std::shared_ptr< ScriptExpression > defaultValue
void writeOut(const DomItem &self, OutWriter &ow) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
void writeOutSignal(const DomItem &self, OutWriter &ow) const
TypeAnnotationStyle typeAnnotationStyle
static constexpr DomType kindValue
std::shared_ptr< ScriptExpression > value
friend bool operator==(const ModuleAutoExport &i1, const ModuleAutoExport &i2)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
friend bool operator!=(const ModuleAutoExport &i1, const ModuleAutoExport &i2)
static constexpr DomType kindValue
std::shared_ptr< T > ownerAs() const
MutableDomItem addChild(QmlObject child)
friend bool operator==(const MutableDomItem &o1, const MutableDomItem &o2)
MutableDomItem addPropertyDef(const PropertyDefinition &propertyDef, AddOption option=AddOption::Overwrite)
bool commitToBase(const std::shared_ptr< DomEnvironment > &validEnvPtr=nullptr)
QString canonicalFilePath() const
MutableDomItem fileObject(GoTo option=GoTo::Strict)
MutableDomItem operator[](const char16_t *component)
FileWriter::Status dump(const QString &path, function_ref< bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter=noFilter, int indent=0, FileWriter *fw=nullptr)
MutableDomItem key(QStringView name)
MutableDomItem operator[](const QString &component)
MutableDomItem addMethod(const MethodInfo &functionDef, AddOption option=AddOption::Overwrite)
void dump(const Sink &s, int indent=0, function_ref< bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter=noFilter)
void writeOut(OutWriter &lw)
MutableDomItem(const DomItem &owner, const Path &pathFromOwner)
MutableDomItem containingObject()
void addError(ErrorMessage &&msg)
std::shared_ptr< DomTop > topPtr()
MutableDomItem key(const QString &name)
QSet< QString > const keys()
MutableDomItem qmlObject(GoTo option=GoTo::Strict, FilterUpOptions fOptions=FilterUpOptions::ReturnOuter)
QList< QString > const fields()
MutableDomItem component(GoTo option=GoTo::Strict)
MutableDomItem path(const Path &p)
MutableDomItem makeCopy(CopyOption option=CopyOption::EnvConnected)
MutableDomItem operator[](const Path &path)
MutableDomItem index(index_type i)
MutableDomItem child(index_type i)
MutableDomItem field(FieldName name)
MutableDomItem(const DomItem &item)
std::shared_ptr< OwningItem > owningItemPtr()
bool writeOut(const QString &path, const LineWriterOptions &opt=LineWriterOptions(), FileWriter *fw=nullptr)
friend bool operator!=(const MutableDomItem &o1, const MutableDomItem &o2)
MutableDomItem rootQmlObject(GoTo option=GoTo::Strict)
DomItem::CopyOption CopyOption
MutableDomItem operator[](QStringView component)
MutableDomItem addBinding(Binding binding, AddOption option=AddOption::Overwrite)
A DomItem that owns other DomItems and is managed through a shared pointer.
QDateTime createdAt() const
virtual bool iterateSubOwners(const DomItem &self, function_ref< bool(const DomItem &owner)> visitor)
virtual int revision() const
QBasicMutex * mutex() const
DomItem containingObject(const DomItem &self) const override
virtual std::shared_ptr< OwningItem > doCopy(const DomItem &self) const =0
std::shared_ptr< OwningItem > makeCopy(const DomItem &self) const
Path pathFromOwner() const override final
OwningItem(const OwningItem &&)=delete
bool iterateErrors(const DomItem &self, function_ref< bool(const DomItem &source, const ErrorMessage &msg)> visitor, const Path &inPath=Path())
virtual void addError(const DomItem &self, ErrorMessage &&msg)
QDateTime frozenAt() const
void addErrorLocal(ErrorMessage &&msg)
virtual QDateTime lastDataUpdateAt() const
void clearErrors(const ErrorGroups &groups=ErrorGroups({}))
Path canonicalPath(const DomItem &self) const override=0
QMultiMap< Path, ErrorMessage > localErrors() const
OwningItem & operator=(const OwningItem &&)=delete
OwningItem(int derivedFrom, const QDateTime &lastDataUpdateAt)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
virtual bool frozen() const
virtual void refreshedDataAt(QDateTime tNew)
OwningItem(int derivedFrom=0)
OwningItem(const OwningItem &o)
index_type index(index_type defaultValue=-1) const
QStringView stringView() const
void dump(const Sink &sink, const QString &name, bool hasSquareBrackets) const
void dump(const Sink &sink) const
bool checkName(QStringView s) const
void dump(const Sink &sink) const
bool checkName(QStringView s) const
bool checkName(QStringView s) const
QStringView stringView() const
void dump(const Sink &sink) const
index_type index(index_type=-1) const
bool checkName(QStringView s) const
void dump(const Sink &sink) const
void dump(const Sink &sink) const
bool checkName(QStringView s) const
QStringView stringView() const
bool checkName(QStringView s) const
static int cmp(const PathComponent &p1, const PathComponent &p2)
size_t hash(size_t seed) const
PathComponent & operator=(PathComponent &&)=default
PathComponent & operator=(const PathComponent &)=default
index_type index(index_type defaultValue=-1) const
PathComponent(const PathComponent &)=default
PathComponent(PathComponent &&)=default
void dump(const Sink &sink) const
const Current * asCurrent() const
PathNode(PathComponent component, Ptr parent)
const PathComponent component
void dump(const Sink &sink) const
bool checkName(QStringView s) const
PathIterator & operator-=(difference_type n)
friend difference_type operator-(const PathIterator &a, const PathIterator &b)
friend PathIterator operator-(PathIterator it, difference_type n)
std::random_access_iterator_tag iterator_category
friend difference_type operator-(PathSentinel, const PathIterator &it)
PathIterator & operator--()
PathIterator operator++(int)
friend Qt::strong_ordering compareThreeWay(const PathIterator &a, const PathIterator &b) noexcept
friend PathIterator operator+(PathIterator it, difference_type n)
PathIterator & operator++()
PathIterator operator--(int)
PathIterator & operator+=(difference_type n)
friend bool comparesEqual(const PathIterator &a, const PathIterator &b) noexcept
friend Qt::strong_ordering compareThreeWay(const PathIterator &it, PathSentinel) noexcept
friend bool comparesEqual(const PathIterator &it, PathSentinel) noexcept
friend difference_type operator-(const PathIterator &it, PathSentinel)
Path operator[](difference_type n) const
friend PathIterator operator+(difference_type n, PathIterator it)
PathIterator(const Path &path)
Represents an immutable JsonPath like path in the Qml code model (from a DomItem to another DomItem).
std::optional< index_type > headIndex() const
static Path fromKey(QStringView s)
Path dropTail(int n=1) const
Path withEmpty() const
static Path fromComponent(Component c)
Path withIndex(index_type i) const
static int cmp(const Path &p1, const Path &p2)
Compares p1 and p2 lexicographically.
static Path fromField(FieldName name)
PathSentinel end() const
Path withKey(QStringView name) const
QString headName() const
Source split() const
Splits the path at the last field or current component, or right after a root anchor.
PathIterator begin() const
PathEls::Kind Kind
static Path fromRoot(PathRoot r)
Path operator[](int i) const
Path withField(FieldName name) const
Path withKey(const QString &name) const
Path head() const
Path mid(int offset, int length) const
Path withCurrent(PathCurrent s) const
void dump(const Sink &sink) const
Path last() const
Kind headKind() const
Path mid(int offset) const
QString toString() const
Path withPath(const Path &toAdd) const
Returns a copy of this with toAdd appended to it.
static Path fromKey(const QString &s)
std::optional< FieldName > headField() const
std::optional< PathRoot > headRoot() const
Path dropFront(int n=1) const
Path withComponent(PathEls::PathComponent c) const
PathEls::PathComponent Component
static Path fromCurrent(PathCurrent c)
std::optional< PathCurrent > headCurrent() const
static Path fromIndex(index_type i)
Pragma(const QString &pragmaName=QString(), const QStringList &pragmaValues={})
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
void writeOut(const DomItem &self, OutWriter &ow) const
static constexpr DomType kindValue
static constexpr DomType kindValue
ScriptElementVariant m_nameIdentifiers
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
void writeOut(const DomItem &self, OutWriter &lw) const
ScriptElementVariant nameIdentifiers() const
void setNameIdentifiers(const ScriptElementVariant &name)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
static constexpr DomType kindValue
QQmlDomAstCreatorBase(const MutableDomItem &qmlFile)
void endVisit(AST::UiProgram *) override
std::shared_ptr< DomEnvironment > currentEnvironment()
void throwRecursionDepthError() override
void endVisitHelper(AST::PatternElement *pe, const std::shared_ptr< ScriptElements::GenericScriptElement > &element)
void loadAnnotations(AST::UiObjectMember *el)
bool visit(AST::UiProgram *program) override
void enableLoadFileLazily(bool enable=true)
void enableScriptExpressions(bool enable=true)
virtual QQmlJSASTClassListToVisit void throwRecursionDepthError() override
QQmlDomAstCreatorWithQQmlJSScope(MutableDomItem &qmlFile, QQmlJSLogger *logger, QQmlJSImporter *importer)
QQmlJSScope::ConstPtr semanticScope() const
void setIds(const QMultiMap< QString, Id > &ids)
void setNextComponentPath(const Path &p)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
QList< DomItem > subComponents(const DomItem &self) const
const QMultiMap< QString, Id > & ids() const &
void updatePathFromOwner(const Path &newPath) override
void setNameIdentifiers(const ScriptElementVariant &name)
static constexpr DomType kindValue
void writeOut(const DomItem &self, OutWriter &) const override
void setSemanticScope(const QQmlJSScope::ConstPtr &scope)
QmlComponent(const QString &name=QString())
QList< QString > subComponentsNames(const DomItem &self) const
Path addId(const Id &id, AddOption option=AddOption::Overwrite, Id **idPtr=nullptr)
ScriptElementVariant nameIdentifiers() const
DomType kind() const override
QList< QString > fields(const DomItem &) const override
void setNameIdentifiers(const ScriptElementVariant &name)
Path addChild(const QmlObject &child, QmlObject **cPtr=nullptr)
MutableDomItem addBinding(MutableDomItem &self, const Binding &binding, AddOption option)
void setMethods(const QMultiMap< QString, MethodInfo > &functionDefs)
void writeOutSortedEnumerations(const QList< DomItem > &descs, OutWriter &ow) const
void writeOut(const DomItem &self, OutWriter &ow, const QString &onTarget) const
DomItem field(const DomItem &self, FieldName name) const override
ScriptElementVariant nameIdentifiers() const
void setName(const QString &name)
QList< std::pair< SourceLocation, DomItem > > orderOfAttributes(const DomItem &self, const DomItem &component) const
bool iterateSubOwners(const DomItem &self, function_ref< bool(const DomItem &owner)> visitor) const
MutableDomItem addChild(MutableDomItem &self, const QmlObject &child)
void setAnnotations(const QList< QmlObject > &annotations)
const QMultiMap< QString, Binding > & bindings() const &
DomType kind() const override
void setNextScopePath(const Path &nextScopePath)
void updatePathFromOwner(const Path &newPath) override
void setChildren(const QList< QmlObject > &children)
Path addBinding(const Binding &binding, AddOption option, Binding **bPtr=nullptr)
Path addAnnotation(const QmlObject &annotation, QmlObject **aPtr=nullptr)
LocallyResolvedAlias resolveAlias(const DomItem &self, std::shared_ptr< ScriptExpression > accessSequence) const
void writeOutId(const DomItem &self, OutWriter &ow) const
QList< QmlObject > children() const
LocallyResolvedAlias resolveAlias(const DomItem &self, const QStringList &accessSequence) const
const QList< Path > & prototypePaths() const &
void writeOutSortedPropertyDefinition(const DomItem &self, OutWriter &ow, QSet< QString > &mergedDefBinding, const QStringList &keys) const
Path addPropertyDef(const PropertyDefinition &propertyDef, AddOption option, PropertyDefinition **pDef=nullptr)
void writeOutSortedAttributes(const DomItem &self, OutWriter &ow, const DomItem &component, const Attributes &attribs) const
const QMultiMap< QString, MethodInfo > & methods() const &
MutableDomItem addPropertyDef(MutableDomItem &self, const PropertyDefinition &propertyDef, AddOption option)
void setBindings(const QMultiMap< QString, Binding > &bindings)
QString localDefaultPropertyName() const
QString defaultPropertyName(const DomItem &self) const
void setPropertyDefs(const QMultiMap< QString, PropertyDefinition > &propertyDefs)
QmlObject(const Path &pathFromOwner=Path())
void writeOutAttributes(OutWriter &ow, const Attributes &attribs, const QString &code) const
MutableDomItem addMethod(MutableDomItem &self, const MethodInfo &functionDef, AddOption option)
void setIdStr(const QString &id)
QQmlJSScope::ConstPtr semanticScope() const
const QMultiMap< QString, PropertyDefinition > & propertyDefs() const &
void writeOut(const DomItem &self, OutWriter &lw) const override
Path addPrototypePath(const Path &prototypePath)
void setSemanticScope(const QQmlJSScope::ConstPtr &scope)
void setDefaultPropertyName(const QString &name)
void setPrototypePaths(const QList< Path > &prototypePaths)
QList< QmlObject > annotations() const
QList< QString > fields() const
QList< std::pair< SourceLocation, DomItem > > Attributes
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
Path addMethod(const MethodInfo &functionDef, AddOption option, MethodInfo **mPtr=nullptr)
bool iterateBaseDirectSubpaths(const DomItem &self, DirectVisitor) const
static QmlUri fromString(const QString &importStr)
QString absoluteLocalPath(const QString &basePath=QString()) const
QString directoryString() const
static QmlUri fromUriString(const QString &importStr)
QString localPath() const
QString moduleUri() const
friend bool operator==(const QmlUri &i1, const QmlUri &i2)
static QmlUri fromDirectoryString(const QString &importStr)
friend bool operator!=(const QmlUri &i1, const QmlUri &i2)
static bool addForPath(const DomItem &el, const Path &canonicalPath, const RefCacheEntry &entry, AddOption addOption=AddOption::KeepExisting)
static RefCacheEntry forPath(const DomItem &el, const Path &canonicalPath)
QList< QString > fields(const DomItem &self) const override
quintptr id() const override
static constexpr DomType kindValue
const Reference & operator*() const
DomItem index(const DomItem &, index_type) const override
DomItem get(const DomItem &self, const ErrorHandler &h=nullptr, QList< Path > *visitedRefs=nullptr) const
DomItem field(const DomItem &self, FieldName name) const override
QList< DomItem > getAll(const DomItem &self, const ErrorHandler &h=nullptr, QList< Path > *visitedRefs=nullptr) const
index_type indexes(const DomItem &) const override
DomType kind() const override
QSet< QString > const keys(const DomItem &) const override
const Reference * operator->() const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
Reference(const Path &referredObject=Path(), const Path &pathFromOwner=Path(), const SourceLocation &loc=SourceLocation())
DomItem key(const DomItem &, const QString &) const override
Keeps the comments associated with a DomItem.
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
friend bool operator!=(const RegionComments &c1, const RegionComments &c2)
const QMap< FileLocationRegion, CommentedElement > & regionComments() const
friend bool operator==(const RegionComments &c1, const RegionComments &c2)
Path addComment(const Comment &comment, FileLocationRegion region)
static constexpr DomType kindValue
const DomBase & operator*() const
const DomBase * operator->() const
static constexpr DomType kindValue
ScriptElementVariant element() const
ScriptElementDomWrapper(const ScriptElementVariant &element)
Use this to contain any script element.
void visitConst(F &&visitor) const
std::optional< ScriptElementT > data()
ScriptElement::PointerType< ScriptElement > base() const
Returns a pointer to the virtual base for virtual method calls.
static ScriptElementVariant fromElement(const T &element)
void setData(const ScriptElementT &data)
void replaceKindForGenericChildren(DomType oldType, DomType newType)
QStringView loc2Str(const SourceLocation &) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override
DomType kind() const override
std::shared_ptr< AstComments > astComments() const
std::shared_ptr< QQmlJS::Engine > engine() const
ScriptExpression(const QString &code, ExpressionType expressionType)
static constexpr DomType kindValue
SourceLocation locationToLocal(const SourceLocation &x) const
std::shared_ptr< ScriptExpression > makeCopy(const DomItem &self) const
ScriptExpression(const ScriptExpression &e)
ExpressionType expressionType() const
void writeOut(const DomItem &self, OutWriter &lw) const override
SourceLocation globalLocation(const DomItem &self) const
ScriptExpression(QStringView code, const std::shared_ptr< QQmlJS::Engine > &engine, AST::Node *ast, const std::shared_ptr< AstComments > &comments, ExpressionType expressionType, const SourceLocation &localOffset=SourceLocation())
void setScriptElement(const ScriptElementVariant &p)
std::shared_ptr< OwningItem > doCopy(const DomItem &) const override
ScriptElementVariant scriptElement()
void astDumper(const Sink &s, AstDumperOptions options) const
SourceLocation localOffset() const
Path canonicalPath(const DomItem &self) const override
static constexpr DomType kindValue
bool iterateDirectSubpaths(const DomItem &, DirectVisitor) const override
SimpleObjectWrapBase(const Path &pathFromOwner, const QVariant &value, quintptr idValue, DomType kind=kindValue, SimpleWrapOptions options=SimpleWrapOption::None)
virtual void moveTo(SimpleObjectWrapBase *) const
DomKind domKind() const final override
virtual void copyTo(SimpleObjectWrapBase *) const
DomType kind() const final override
quintptr id() const final override
SimpleObjectWrapT(const Path &pathFromOwner, const QVariant &v, quintptr idValue, SimpleWrapOptions o)
void moveTo(SimpleObjectWrapBase *target) const override
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override
static constexpr DomType kindValue
void writeOut(const DomItem &self, OutWriter &lw) const override
void copyTo(SimpleObjectWrapBase *target) const override
const SimpleObjectWrapBase & operator*() const
SimpleObjectWrapBase & operator*()
static SimpleObjectWrap fromObjectRef(const Path &pathFromOwner, T &value)
const SimpleObjectWrapBase * operator->() const
static constexpr DomType kindValue
SimpleObjectWrapBase * operator->()
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const
QString majorString() const
static constexpr DomType kindValue
Version(qint32 majorVersion=Undefined, qint32 minorVersion=Undefined)
QString minorString() const
int compare(Version o) const
static Version fromString(QStringView v)
QString stringValue() const
static constexpr qint32 Undefined
static constexpr qint32 Latest
QString majorSymbolicString() const
A vistor that visits all the AST:Node.
bool visit(AST::UiPublicMember *el) override
void throwRecursionDepthError() override
static QSet< int > uiKinds()
returns a set with all Ui* Nodes (i.e.
void endVisit(AST::UiImport *el) override
constexpr std::array< QStringView, size_t(FieldName::NumFieldNames)> fieldNameStrings
Provides entities to maintain mappings between elements and their location in a file.
void addRegion(const Tree &fLoc, FileLocationRegion region, SourceLocation loc)
Tree createTree(const Path &basePath)
QString canonicalPathForTesting(const Tree &base)
QQmlJS::SourceLocation region(const Tree &fLoc, FileLocationRegion region)
bool visitTree(const Tree &base, function_ref< bool(const Path &, const Tree &)> visitor, const Path &basePath=Path())
Tree ensure(const Tree &base, const Path &basePath)
Tree find(const Tree &self, const Path &p)
bool operator>=(const PathComponent &lhs, const PathComponent &rhs)
bool operator<=(const PathComponent &lhs, const PathComponent &rhs)
bool operator==(const PathComponent &lhs, const PathComponent &rhs)
bool operator!=(const PathComponent &lhs, const PathComponent &rhs)
bool operator>(const PathComponent &lhs, const PathComponent &rhs)
bool operator<(const PathComponent &lhs, const PathComponent &rhs)
Path lookupTypePath(const QString &name)
Path loadInfoPath(const Path &el)
Path moduleScopePath(const QString &uri, const ErrorHandler &errorHandler=nullptr)
Path jsFilePath(const QString &path)
Path lookupCppTypePath(const QString &name)
Path qmlFileInfoPath(const QString &canonicalFilePath)
Path moduleIndexPath(const QString &uri, int majorVersion, const ErrorHandler &errorHandler=nullptr)
Path qmlFilePath(const QString &canonicalFilePath)
Path moduleScopePath(const QString &uri, const QString &version, const ErrorHandler &errorHandler=nullptr)
Path lookupSymbolPath(const QString &name)
Path jsFileInfoPath(const QString &path)
Path lookupPropertyPath(const QString &name)
Path moduleScopePath(const QString &uri, Version version, const ErrorHandler &errorHandler=nullptr)
Path qmlFileObjectPath(const QString &canonicalFilePath)
bool operator>(Version v1, Version v2)
QMLDOM_EXPORT bool domTypeIsContainer(DomType k)
bool operator==(Version v1, Version v2)
QMLDOM_EXPORT void dumperToQDebug(const Dumper &dumper, QDebug debug)
void devNull(QStringView)
QMLDOM_EXPORT void errorToQDebug(const ErrorMessage &)
writes an ErrorMessage to QDebug
constexpr bool domTypeIsOwningItem(DomType)
Path appendUpdatableElementInQList(const Path &listPathFromOwner, QList< T > &list, const T &value, T **vPtr=nullptr)
bool operator<=(const ErrorMessage &e1, const ErrorMessage &e2)
QMLDOM_EXPORT void dumpErrorLevel(const Sink &s, ErrorLevel level)
Dumps a string describing the given error level (ErrorLevel::Error -> Error,...).
constexpr bool domTypeIsValueWrap(DomType k)
void sinkInt(const Sink &s, T i)
QMLDOM_EXPORT void silentError(const ErrorMessage &)
Error handler that ignores all errors (excluding fatal ones).
Path insertUpdatableElementInMultiMap(const Path &mapPathFromOwner, QMultiMap< K, T > &mmap, K key, const T &value, AddOption option=AddOption::KeepExisting, T **valuePtr=nullptr)
size_t qHash(const CommentAnchor &key, size_t seed=0) noexcept
bool noFilter(const DomItem &, const PathEls::PathComponent &, const DomItem &)
QMLDOM_EXPORT void dumperToQDebug(const Dumper &dumper, ErrorLevel level=ErrorLevel::Debug)
writes the dumper to the QDebug object corrsponding to the given error level
QMLDOM_EXPORT void sinkNewline(const Sink &s, int indent=0)
sinks a neline and indents by the given amount
bool operator>=(const ErrorGroups &lhs, const ErrorGroups &rhs)
QMLDOM_EXPORT void setDefaultErrorHandler(const ErrorHandler &h)
Sets the default error handler.
QMLDOM_EXPORT ErrorLevel errorLevelFromQtMsgType(QtMsgType msgType)
QMLDOM_EXPORT QMap< DomKind, QString > domKindToStringMap()
QMLDOM_EXPORT QDebug operator<<(QDebug debug, const DomItem &c)
std::shared_ptr< ExternalOwningItem > getFileItemOwner(const DomItem &fileItem)
QStringView fieldNameToString(FieldName f)
DomKind kind2domKind(DomType k)
bool operator==(const ErrorGroups &lhs, const ErrorGroups &rhs)
static DomItem keyMultiMapHelper(const DomItem &self, const QString &key, const QMultiMap< QString, T > &mmap)
bool operator!=(const DomItem &o1, const DomItem &o2)
QMLDOM_EXPORT bool domTypeIsExternalItem(DomType k)
constexpr bool domTypeIsUnattachedOwningItem(DomType)
FieldName FieldType
QMLDOM_EXPORT QMap< DomType, QString > domTypeToStringMap()
QDebug operator<<(QDebug d, FieldName f)
QMLDOM_EXPORT bool domTypeIsScope(DomType k)
std::optional< FieldName > fieldNameFromString(QStringView s)
bool operator!=(const ErrorMessage &e1, const ErrorMessage &e2)
bool operator<=(const Path &lhs, const Path &rhs)
bool operator==(const ErrorMessage &e1, const ErrorMessage &e2)
QMLDOM_EXPORT QDebug operator<<(QDebug debug, const MutableDomItem &c)
std::disjunction< std::is_same< U, V >... > IsInList
bool operator>(const Path &lhs, const Path &rhs)
bool operator<(const ErrorMessage &e1, const ErrorMessage &e2)
QMLDOM_EXPORT QString domTypeToString(DomType k)
auto writeOutWrap(const T &, const DomItem &, OutWriter &, rank< 0 >) -> void
constexpr bool domTypeIsScriptElement(DomType)
QMLDOM_EXPORT QString domKindToString(DomKind k)
bool operator>=(const ErrorMessage &e1, const ErrorMessage &e2)
constexpr bool domTypeIsDomElement(DomType)
void updatePathFromOwnerQList(QList< T > &list, const Path &newPath)
constexpr bool domTypeCanBeInline(DomType k)
bool operator<(Version v1, Version v2)
bool operator<=(Version v1, Version v2)
bool operator!=(const ErrorGroups &lhs, const ErrorGroups &rhs)
QMLDOM_EXPORT QDebug operator<<(QDebug d, const Dumper &dumper)
auto writeOutWrap(const T &t, const DomItem &self, OutWriter &lw) -> void
QDebug operator<<(QDebug debug, const Path &p)
bool operator>=(const Path &lhs, const Path &rhs)
std::variant< std::monostate, std::shared_ptr< ExternalItemInfoBase >, std::shared_ptr< ExternalItemPairBase >, std::shared_ptr< JsFile >, std::shared_ptr< QmlFile >, std::shared_ptr< ScriptExpression >, std::shared_ptr< AstComments >, std::shared_ptr< LoadInfo >, std::shared_ptr< FileLocations::Node >, std::shared_ptr< DomEnvironment >, std::shared_ptr< DomUniverse > > OwnerT
auto writeOutWrap(const T &t, const DomItem &self, OutWriter &lw, rank< 1 >) -> decltype(t.writeOut(self, lw))
QString fieldNameToQString(FieldName f)
std::variant< ConstantData, Empty, List, ListP, Map, Reference, ScriptElementDomWrapper, SimpleObjectWrap, const AstComments *, const FileLocations::Node *, const DomEnvironment *, const DomUniverse *, const EnumDecl *, const ExternalItemInfoBase *, const ExternalItemPairBase *, const GlobalComponent *, const JsFile *, const JsResource *, const LoadInfo *, const QmlComponent *, const QmlFile *, const QmlObject *, const ScriptExpression * > ElementT
bool operator!=(Version v1, Version v2)
bool operator>=(Version v1, Version v2)
bool operator<=(const ErrorGroups &lhs, const ErrorGroups &rhs)
bool operator!=(const Path &lhs, const Path &rhs)
bool operator<(const Path &lhs, const Path &rhs)
bool visitWithCustomListIteration(T *t, AST::Visitor *visitor)
std::function< void(const ErrorMessage &)> ErrorHandler
QMLDOM_EXPORT void sinkIndent(const Sink &s, int indent)
sinks the requested amount of spaces
bool operator>(const ErrorGroups &lhs, const ErrorGroups &rhs)
QMLDOM_EXPORT bool domTypeIsTopItem(DomType k)
QMLDOM_EXPORT void defaultErrorHandler(const ErrorMessage &)
Calls the default error handler (by default errorToQDebug).
void updatePathFromOwnerMultiMap(QMultiMap< K, T > &mmap, const Path &newPath)
bool operator<(const ErrorGroups &lhs, const ErrorGroups &rhs)
constexpr bool domTypeIsObjWrap(DomType k)
QMLDOM_EXPORT void sinkEscaped(const Sink &sink, QStringView s, EscapeOptions options=EscapeOptions::OuterQuotes)
dumps a string as quoted string (escaping things like quotes or newlines)
bool operator==(const Path &lhs, const Path &rhs)
bool operator>(const ErrorMessage &e1, const ErrorMessage &e2)
bool emptyChildrenVisitor(Path, const DomItem &, bool)
QMLDOM_EXPORT QString dumperToString(const Dumper &writer)
Converts a dumper to a string.
QMLDOM_EXPORT size_t qHash(const Path &, size_t seed=0)
static ErrorGroups importErrors
std::variant< std::monostate, std::shared_ptr< DomEnvironment >, std::shared_ptr< DomUniverse > > TopT
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
#define QMLDOM_EXPORT
#define Q_SCRIPTELEMENT_EXIT_IF(check)
#define Q_SCRIPTELEMENT_DISABLE()
#define NewErrorGroup(name)
#define QMLDOM_FIELD_LIST(F)
friend bool comparesEqual(const CommentAnchor &a, const CommentAnchor &b) noexcept
static CommentAnchor from(const SourceLocation &sl)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const
QMap< FileLocationRegion, SourceLocation > regions
A common base class for all the script elements.
void setSemanticScope(const QQmlJSScope::ConstPtr &scope)
virtual void createFileLocations(const std::shared_ptr< FileLocations::Node > &fileLocationOfOwner)=0
std::shared_ptr< T > PointerType
QQmlJSScope::ConstPtr semanticScope()
SubclassStorage & operator=(const SubclassStorage &o)
SubclassStorage(const SubclassStorage &&o)
SubclassStorage(const SubclassStorage &o)