/**************************************************************************** ** ** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ **/ #ifndef DOMTOP_H #define DOMTOP_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include "qqmldomitem_p.h" #include "qqmldomelements_p.h" #include "qqmldomexternalitems_p.h" #include #include #include #include #include #include #include QT_BEGIN_NAMESPACE namespace QQmlJS { namespace Dom { class QMLDOM_EXPORT ParsingTask { public: QCborMap toCbor() const { return QCborMap( {{ QString::fromUtf16(Fields::requestedAt), QCborValue(requestedAt)}, { QString::fromUtf16(Fields::loadOptions), int(loadOptions)}, { QString::fromUtf16(Fields::kind), int(kind)}, { QString::fromUtf16(Fields::canonicalPath), canonicalPath}, { QString::fromUtf16(Fields::logicalPath), logicalPath}, { QString::fromUtf16(Fields::contents), contents}, { QString::fromUtf16(Fields::contentsDate), QCborValue(contentsDate)}, { QString::fromUtf16(Fields::hasCallback), bool(callback)}}); } QDateTime requestedAt; LoadOptions loadOptions; DomType kind; QString canonicalPath; QString logicalPath; QString contents; QDateTime contentsDate; std::weak_ptr requestingUniverse; // make it a shared_ptr? function callback; }; class QMLDOM_EXPORT ExternalItemPairBase: public OwningItem { // all access should have the lock of the DomUniverse containing this Q_DECLARE_TR_FUNCTIONS(ExternalItemPairBase); public: constexpr static DomType kindValue = DomType::ExternalItemPair; DomType kind() const final override { return kindValue; } ExternalItemPairBase(QDateTime validExposedAt = QDateTime::fromMSecsSinceEpoch(0), QDateTime currentExposedAt = QDateTime::fromMSecsSinceEpoch(0), int derivedFrom=0, QDateTime lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0)): OwningItem(derivedFrom, lastDataUpdateAt), validExposedAt(validExposedAt), currentExposedAt(currentExposedAt) {} ExternalItemPairBase(const ExternalItemPairBase &o): OwningItem(o), validExposedAt(o.validExposedAt), currentExposedAt(o.currentExposedAt) {} virtual std::shared_ptr validItem() const = 0; virtual DomItem validItem(DomItem &self) const = 0; virtual std::shared_ptr currentItem() const = 0; virtual DomItem currentItem(DomItem &self) const = 0; QString canonicalFilePath(DomItem &) const final override; Path canonicalPath(DomItem &self) const final override; bool iterateDirectSubpaths(DomItem &self, DirectVisitor) final override; DomItem field(DomItem &self, QStringView name) const final override { return OwningItem::field(self, name); } bool currentIsValid() const; std::shared_ptr makeCopy(DomItem &self) const { return std::static_pointer_cast(doCopy(self)); } QDateTime lastDataUpdateAt() const final override { if (currentItem()) return currentItem()->lastDataUpdateAt(); return ExternalItemPairBase::lastDataUpdateAt(); } void refreshedDataAt(QDateTime tNew) final override { return OwningItem::refreshedDataAt(tNew); if (currentItem()) currentItem()->refreshedDataAt(tNew); } friend class DomUniverse; QDateTime validExposedAt; QDateTime currentExposedAt; }; template class QMLDOM_EXPORT ExternalItemPair final : public ExternalItemPairBase { // all access should have the lock of the DomUniverse containing this protected: std::shared_ptr doCopy(DomItem &) const override { return std::shared_ptr(new ExternalItemPair(*this)); } public: constexpr static DomType kindValue = DomType::ExternalItemPair; friend class DomUniverse; ExternalItemPair(std::shared_ptr valid = {}, std::shared_ptr current = {}, QDateTime validExposedAt = QDateTime::fromMSecsSinceEpoch(0), QDateTime currentExposedAt = QDateTime::fromMSecsSinceEpoch(0), int derivedFrom = 0, QDateTime lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0)): ExternalItemPairBase(validExposedAt, currentExposedAt, derivedFrom, lastDataUpdateAt), valid(valid), current(current) {} ExternalItemPair(const ExternalItemPair &o): ExternalItemPairBase(o), valid(o.valid), current(o.current) { QMutexLocker l(mutex()); } std::shared_ptr validItem() const override { return valid; } DomItem validItem(DomItem &self) const override { return self.copy(valid); } std::shared_ptr currentItem() const override { return current; } DomItem currentItem(DomItem &self) const override { return self.copy(current); } std::shared_ptr makeCopy(DomItem &self) const { return std::static_pointer_cast(doCopy(self)); } std::shared_ptr valid; std::shared_ptr current; }; class QMLDOM_EXPORT DomTop: public OwningItem { public: DomTop(QMap extraOwningItems = {}, int derivedFrom = 0) : OwningItem(derivedFrom), m_extraOwningItems(extraOwningItems) {} DomTop(const DomTop &o): OwningItem(o) { QMap items = o.extraOwningItems(); { QMutexLocker l(mutex()); m_extraOwningItems = items; } } using Callback = DomItem::Callback; virtual Path canonicalPath() const = 0; Path canonicalPath(DomItem &) const override; DomItem containingObject(DomItem &) const override; bool iterateDirectSubpaths(DomItem &self, DirectVisitor) override; template void setExtraOwningItem(QString fieldName, std::shared_ptr item) { QMutexLocker l(mutex()); if (!item) m_extraOwningItems.remove(fieldName); else m_extraOwningItems.insert(fieldName, item); } void clearExtraOwningItems(); QMap extraOwningItems() const; private: QMap m_extraOwningItems; }; class QMLDOM_EXPORT DomUniverse final : public DomTop { Q_GADGET Q_DECLARE_TR_FUNCTIONS(DomUniverse); protected: std::shared_ptr doCopy(DomItem &self) const override; public: enum class Option{ Default, SingleThreaded }; Q_ENUM(Option) Q_DECLARE_FLAGS(Options, Option); constexpr static DomType kindValue = DomType::DomUniverse; DomType kind() const override { return kindValue; } static ErrorGroups myErrors(); DomUniverse(QString universeName, Options options = Option::SingleThreaded); DomUniverse(const DomUniverse &) = delete; static std::shared_ptr guaranteeUniverse(std::shared_ptr univ); static DomItem create(QString universeName, Options options = Option::SingleThreaded); Path canonicalPath() const override; using DomTop::canonicalPath; bool iterateDirectSubpaths(DomItem &self, DirectVisitor) override; std::shared_ptr makeCopy(DomItem &self) const { return std::static_pointer_cast(doCopy(self)); } void loadFile(DomItem &self, QString filePath, QString logicalPath, Callback callback, LoadOptions loadOptions, std::optional fileType = std::optional()); void loadFile(DomItem &self, QString canonicalFilePath, QString logicalPath, QString code, QDateTime codeDate, Callback callback, LoadOptions loadOptions, std::optional fileType = std::optional()); void execQueue(); void removePath(const QString &dir); std::shared_ptr> globalScopeWithName(QString name) const { QMutexLocker l(mutex()); return m_globalScopeWithName.value(name); } std::shared_ptr> ensureGlobalScopeWithName(QString name) { if (auto current = globalScopeWithName(name)) return current; std::shared_ptr newScope(new GlobalScope(name)); std::shared_ptr> newValue( new ExternalItemPair(newScope, newScope)); QMutexLocker l(mutex()); if (auto current = m_globalScopeWithName.value(name)) return current; m_globalScopeWithName.insert(name, newValue); return newValue; } QSet globalScopeNames() const { QMap>> map; { QMutexLocker l(mutex()); map = m_globalScopeWithName; } return QSet(map.keyBegin(), map.keyEnd()); } std::shared_ptr> qmlDirectoryWithPath(QString path) const { QMutexLocker l(mutex()); return m_qmlDirectoryWithPath.value(path); } QSet qmlDirectoryPaths() const { QMap>> map; { QMutexLocker l(mutex()); map = m_qmlDirectoryWithPath; } return QSet(map.keyBegin(), map.keyEnd()); } std::shared_ptr> qmldirFileWithPath(QString path) const { QMutexLocker l(mutex()); return m_qmldirFileWithPath.value(path); } QSet qmldirFilePaths() const { QMap>> map; { QMutexLocker l(mutex()); map = m_qmldirFileWithPath; } return QSet(map.keyBegin(), map.keyEnd()); } std::shared_ptr> qmlFileWithPath(QString path) const { QMutexLocker l(mutex()); return m_qmlFileWithPath.value(path); } QSet qmlFilePaths() const { QMap>> map; { QMutexLocker l(mutex()); map = m_qmlFileWithPath; } return QSet(map.keyBegin(), map.keyEnd()); } std::shared_ptr> jsFileWithPath(QString path) const { QMutexLocker l(mutex()); return m_jsFileWithPath.value(path); } QSet jsFilePaths() const { QMap>> map; { QMutexLocker l(mutex()); map = m_jsFileWithPath; } return QSet(map.keyBegin(), map.keyEnd()); } std::shared_ptr> qmltypesFileWithPath(QString path) const { QMutexLocker l(mutex()); return m_qmltypesFileWithPath.value(path); } QSet qmltypesFilePaths() const { QMap>> map; { QMutexLocker l(mutex()); map = m_qmltypesFileWithPath; } return QSet(map.keyBegin(), map.keyEnd()); } QString name() const { return m_name; } Options options() const { return m_options; } QQueue queue() const { QMutexLocker l(mutex()); return m_queue; } private: QString m_name; Options m_options; QMap>> m_globalScopeWithName; QMap>> m_qmlDirectoryWithPath; QMap>> m_qmldirFileWithPath; QMap>> m_qmlFileWithPath; QMap>> m_jsFileWithPath; QMap>> m_qmltypesFileWithPath; QQueue m_queue; }; Q_DECLARE_OPERATORS_FOR_FLAGS(DomUniverse::Options) class QMLDOM_EXPORT ExternalItemInfoBase: public OwningItem { Q_DECLARE_TR_FUNCTIONS(ExternalItemInfoBase); public: constexpr static DomType kindValue = DomType::ExternalItemInfo; DomType kind() const final override { return kindValue; } ExternalItemInfoBase(Path canonicalPath, QDateTime currentExposedAt = QDateTime::fromMSecsSinceEpoch(0), int derivedFrom = 0, QDateTime lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0)) : OwningItem(derivedFrom, lastDataUpdateAt), m_canonicalPath(canonicalPath), m_currentExposedAt(currentExposedAt) {} ExternalItemInfoBase(const ExternalItemInfoBase &o) = default; virtual std::shared_ptr currentItem() const = 0; virtual DomItem currentItem(DomItem &) const = 0; QString canonicalFilePath(DomItem &) const final override; Path canonicalPath() const { return m_canonicalPath; } Path canonicalPath(DomItem &) const final override { return canonicalPath(); } bool iterateDirectSubpaths(DomItem &self, DirectVisitor) final override; DomItem field(DomItem &self, QStringView name) const final override { return OwningItem::field(self, name); } int currentRevision(DomItem &self) const; int lastRevision(DomItem &self) const; int lastValidRevision(DomItem &self) const; std::shared_ptr makeCopy(DomItem &self) const { return std::static_pointer_cast(doCopy(self)); } QDateTime lastDataUpdateAt() const final override { if (currentItem()) return currentItem()->lastDataUpdateAt(); return OwningItem::lastDataUpdateAt(); } void refreshedDataAt(QDateTime tNew) final override { return OwningItem::refreshedDataAt(tNew); if (currentItem()) currentItem()->refreshedDataAt(tNew); } void ensureLogicalFilePath(QString path) { QMutexLocker l(mutex()); if (!m_logicalFilePaths.contains(path)) m_logicalFilePaths.append(path); } QDateTime currentExposedAt() const { QMutexLocker l(mutex()); // should not be needed, as it should not change... return m_currentExposedAt; } void setCurrentExposedAt(QDateTime d) { QMutexLocker l(mutex()); // should not be needed, as it should not change... m_currentExposedAt = d; } QStringList logicalFilePaths() const { QMutexLocker l(mutex()); return m_logicalFilePaths; } private: friend class DomEnvironment; Path m_canonicalPath; QDateTime m_currentExposedAt; QStringList m_logicalFilePaths; }; template class ExternalItemInfo final : public ExternalItemInfoBase { protected: std::shared_ptr doCopy(DomItem &) const override { return std::shared_ptr(new ExternalItemInfo(*this)); } public: constexpr static DomType kindValue = DomType::ExternalItemInfo; ExternalItemInfo(std::shared_ptr current = std::shared_ptr(), QDateTime currentExposedAt = QDateTime::fromMSecsSinceEpoch(0), int derivedFrom = 0, QDateTime lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0)) : ExternalItemInfoBase(current->canonicalPath().dropTail(), currentExposedAt, derivedFrom, lastDataUpdateAt), current(current) {} ExternalItemInfo(QString canonicalPath) : current(new T(canonicalPath)) { } ExternalItemInfo(const ExternalItemInfo &o): ExternalItemInfoBase(o), current(o.current) { QMutexLocker l(mutex()); } std::shared_ptr makeCopy(DomItem &self) const { return std::static_pointer_cast(doCopy(self)); } std::shared_ptr currentItem() const override { return current; } DomItem currentItem(DomItem &self) const override { return self.copy(current); } std::shared_ptr current; }; class Dependency { // internal, should be cleaned, but nobody should use this... public: bool operator==(Dependency const &o) const { return uri == o.uri && version.majorVersion == o.version.majorVersion && version.minorVersion == o.version.minorVersion && filePath == o.filePath; } QString uri; // either dotted uri or file:, http: https: uri Version version; QString filePath; // for file deps DomType fileType; }; class QMLDOM_EXPORT LoadInfo final : public OwningItem { Q_DECLARE_TR_FUNCTIONS(LoadInfo); protected: std::shared_ptr doCopy(DomItem &self) const override; public: constexpr static DomType kindValue = DomType::LoadInfo; DomType kind() const override { return kindValue; } enum class Status { NotStarted, // dependencies non checked yet Starting, // adding deps InProgress, // waiting for all deps to be loaded CallingCallbacks, // calling callbacks Done // fully loaded }; LoadInfo(Path elPath = Path(), Status status = Status::NotStarted, int nLoaded = 0, int derivedFrom = 0, QDateTime lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0)) : OwningItem(derivedFrom, lastDataUpdateAt), m_elementCanonicalPath(elPath), m_status(status), m_nLoaded(nLoaded) { } LoadInfo(const LoadInfo &o) : OwningItem(o), m_elementCanonicalPath(o.elementCanonicalPath()) { { QMutexLocker l(o.mutex()); m_status = o.m_status; m_nLoaded = o.m_nLoaded; m_toDo = o.m_toDo; m_inProgress = o.m_inProgress; m_endCallbacks = o.m_endCallbacks; } QMutexLocker l(mutex()); } Path canonicalPath(DomItem &self) const override; bool iterateDirectSubpaths(DomItem &self, DirectVisitor) override; std::shared_ptr makeCopy(DomItem &self) const { return std::static_pointer_cast(doCopy(self)); } void addError(DomItem &self, ErrorMessage msg) override { self.path(elementCanonicalPath()).addError(msg); } void addEndCallback(DomItem &self, std::function callback); void advanceLoad(DomItem &self); void finishedLoadingDep(DomItem &self, const Dependency &d); void execEnd(DomItem &self); Status status() const { QMutexLocker l(mutex()); return m_status; } int nLoaded() const { QMutexLocker l(mutex()); return m_nLoaded; } Path elementCanonicalPath() const { QMutexLocker l(mutex()); // we should never change this, remove lock? return m_elementCanonicalPath; } int nNotDone() const { QMutexLocker l(mutex()); return m_toDo.length() + m_inProgress.length(); } QList inProgress() const { QMutexLocker l(mutex()); return m_inProgress; } QList toDo() const { QMutexLocker l(mutex()); return m_toDo; } int nCallbacks() const { QMutexLocker l(mutex()); return m_endCallbacks.length(); } private: void doAddDependencies(DomItem &self); void addDependency(DomItem &self, const Dependency &dep); Path m_elementCanonicalPath; Status m_status; int m_nLoaded; QQueue m_toDo; QList m_inProgress; QList> m_endCallbacks; }; enum class EnvLookup { Normal, NoBase, BaseOnly }; enum class Changeable { ReadOnly, Writable }; class QMLDOM_EXPORT RefCacheEntry { Q_GADGET public: enum class Cached { None, First, All }; Q_ENUM(Cached) static RefCacheEntry forPath(DomItem &el, Path canonicalPath); static bool addForPath(DomItem &el, Path canonicalPath, const RefCacheEntry &entry, AddOption addOption = AddOption::KeepExisting); Cached cached = Cached::None; QList canonicalPaths; }; class QMLDOM_EXPORT DomEnvironment final : public DomTop { Q_GADGET Q_DECLARE_TR_FUNCTIONS(DomEnvironment); protected: std::shared_ptr doCopy(DomItem &self) const override; public: enum class Option { Default = 0x0, KeepValid = 0x1, // if there is a previous valid version, use that instead of the latest 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 NoReload = 0x4, // never reload something that was already loaded by the parent environment WeakLoad = 0x8, // load only the names of the available types, not the types (qml files) themselves SingleThreaded = 0x10, // do all operations in a single thread NoDependencies = 0x20 // will not load dependencies (useful when editing) }; Q_ENUM(Option) Q_DECLARE_FLAGS(Options, Option); static ErrorGroups myErrors(); constexpr static DomType kindValue = DomType::DomEnvironment; DomType kind() const override; Path canonicalPath() const override; using DomTop::canonicalPath; bool iterateDirectSubpaths(DomItem &self, DirectVisitor) override; DomItem field(DomItem &self, QStringView name) const final override; std::shared_ptr makeCopy(DomItem &self) const; void loadFile(DomItem &self, QString filePath, QString logicalPath, Callback loadCallback, Callback directDepsCallback, Callback endCallback, LoadOptions loadOptions, std::optional fileType = std::optional(), ErrorHandler h = nullptr); void loadFile(DomItem &self, QString canonicalFilePath, QString logicalPath, QString code, QDateTime codeDate, Callback loadCallback, Callback directDepsCallback, Callback endCallback, LoadOptions loadOptions, std::optional fileType = std::optional(), ErrorHandler h = nullptr); void loadModuleDependency(DomItem &self, QString uri, Version v, Callback loadCallback = nullptr, Callback endCallback = nullptr, ErrorHandler = nullptr); void loadBuiltins(DomItem &self, Callback callback = nullptr, ErrorHandler h = nullptr); void removePath(const QString &path); std::shared_ptr universe() const; QSet moduleIndexUris(DomItem &self, EnvLookup lookup = EnvLookup::Normal) const; QSet moduleIndexMajorVersions(DomItem &self, QString uri, EnvLookup lookup = EnvLookup::Normal) const; std::shared_ptr moduleIndexWithUri(DomItem &self, QString uri, int majorVersion, EnvLookup lookup, Changeable changeable, ErrorHandler errorHandler = nullptr); std::shared_ptr moduleIndexWithUri(DomItem &self, QString uri, int majorVersion, EnvLookup lookup = EnvLookup::Normal) const; std::shared_ptr> qmlDirectoryWithPath(DomItem &self, QString path, EnvLookup options = EnvLookup::Normal) const; QSet qmlDirectoryPaths(DomItem &self, EnvLookup options = EnvLookup::Normal) const; std::shared_ptr> qmldirFileWithPath(DomItem &self, QString path, EnvLookup options = EnvLookup::Normal) const; QSet qmldirFilePaths(DomItem &self, EnvLookup options = EnvLookup::Normal) const; std::shared_ptr qmlDirWithPath(DomItem &self, QString path, EnvLookup options = EnvLookup::Normal) const; QSet qmlDirPaths(DomItem &self, EnvLookup options = EnvLookup::Normal) const; std::shared_ptr> qmlFileWithPath(DomItem &self, QString path, EnvLookup options = EnvLookup::Normal) const; QSet qmlFilePaths(DomItem &self, EnvLookup lookup = EnvLookup::Normal) const; std::shared_ptr> jsFileWithPath(DomItem &self, QString path, EnvLookup options = EnvLookup::Normal) const; QSet jsFilePaths(DomItem &self, EnvLookup lookup = EnvLookup::Normal) const; std::shared_ptr> qmltypesFileWithPath(DomItem &self, QString path, EnvLookup options = EnvLookup::Normal) const; QSet qmltypesFilePaths(DomItem &self, EnvLookup lookup = EnvLookup::Normal) const; std::shared_ptr> globalScopeWithName(DomItem &self, QString name, EnvLookup lookup = EnvLookup::Normal) const; std::shared_ptr> ensureGlobalScopeWithName(DomItem &self, QString name, EnvLookup lookup = EnvLookup::Normal); QSet globalScopeNames(DomItem &self, EnvLookup lookup = EnvLookup::Normal) const; explicit DomEnvironment(QStringList loadPaths, Options options = Option::SingleThreaded, std::shared_ptr universe = nullptr); explicit DomEnvironment(std::shared_ptr parent, QStringList loadPaths, Options options = Option::SingleThreaded); DomEnvironment(const DomEnvironment &o) = delete; static DomItem create(QStringList loadPaths, Options options = Option::SingleThreaded, DomItem &universe = DomItem::empty); std::shared_ptr> addQmlFile(std::shared_ptr file, AddOption option = AddOption::KeepExisting); std::shared_ptr> addQmlDirectory(std::shared_ptr file, AddOption option = AddOption::KeepExisting); std::shared_ptr> addQmldirFile(std::shared_ptr file, AddOption option = AddOption::KeepExisting); std::shared_ptr> addQmltypesFile(std::shared_ptr file, AddOption option = AddOption::KeepExisting); std::shared_ptr> addJsFile(std::shared_ptr file, AddOption option = AddOption::KeepExisting); std::shared_ptr> addGlobalScope(std::shared_ptr file, AddOption option = AddOption::KeepExisting); bool commitToBase(DomItem &self); void addLoadInfo(DomItem &self, std::shared_ptr loadInfo); std::shared_ptr loadInfo(Path path) const; QList loadInfoPaths() const; QHash> loadInfos() const; void loadPendingDependencies(DomItem &self); bool finishLoadingDependencies(DomItem &self, int waitMSec = 30000); void addWorkForLoadInfo(Path elementCanonicalPath); Options options() const; std::shared_ptr base() const; QStringList loadPaths() const; QString globalScopeName() const; static QList defaultImplicitImports(); QList implicitImports() const; void addAllLoadedCallback(DomItem &self, Callback c); void clearReferenceCache(); private: friend class RefCacheEntry; template QSet getStrings(function_ref()> getBase, const QMap &selfMap, EnvLookup lookup) const; Callback callbackForQmlDirectory(DomItem &self, Callback loadCallback, Callback directDepsCallback, Callback endCallback); Callback callbackForQmlFile(DomItem &self, Callback loadCallback, Callback directDepsCallback, Callback endCallback); Callback callbackForQmltypesFile(DomItem &self, Callback loadCallback, Callback directDepsCallback, Callback endCallback); Callback callbackForQmldirFile(DomItem &self, Callback loadCallback, Callback directDepsCallback, Callback endCallback); std::shared_ptr lookupModuleInEnv(const QString &uri, int majorVersion) const; // ModuleLookupResult contains the ModuleIndex pointer, and an indicator whether it was found // in m_base or in m_moduleIndexWithUri struct ModuleLookupResult { enum Origin : bool {FromBase, FromGlobal}; std::shared_ptr module; Origin fromBase = FromGlobal; }; // helper function used by the moduleIndexWithUri methods ModuleLookupResult moduleIndexWithUriHelper(DomItem &self, QString uri, int majorVersion, EnvLookup lookup = EnvLookup::Normal) const; const Options m_options; const std::shared_ptr m_base; const std::shared_ptr m_universe; QStringList m_loadPaths; // paths for qml QString m_globalScopeName; QMap>> m_moduleIndexWithUri; QMap>> m_globalScopeWithName; QMap>> m_qmlDirectoryWithPath; QMap>> m_qmldirFileWithPath; QMap>> m_qmlFileWithPath; QMap>> m_jsFileWithPath; QMap>> m_qmltypesFileWithPath; QQueue m_loadsWithWork; QQueue m_inProgress; QHash> m_loadInfos; QList m_implicitImports; QList m_allLoadedCallback; QHash m_referenceCache; }; Q_DECLARE_OPERATORS_FOR_FLAGS(DomEnvironment::Options) } // end namespace Dom } // end namespace QQmlJS QT_END_NAMESPACE #endif // DOMTOP_H