Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmldommoduleindex_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLDOMMODULEINDEX_P_H
5#define QQMLDOMMODULEINDEX_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qqmldomelements_p.h"
19
21
22namespace QQmlJS {
23namespace Dom {
24
25class QMLDOM_EXPORT ModuleScope final : public DomBase
26{
27public:
28 constexpr static DomType kindValue = DomType::ModuleScope;
29 DomType kind() const override { return kindValue; }
30
31 ModuleScope(QString uri = QString(), const Version &version = Version())
32 : uri(uri), version(version)
33 {
34 }
35
37 {
38 return Path::Field(Fields::moduleScope)
39 .key(version.isValid() ? QString::number(version.minorVersion) : QString());
40 }
41 Path pathFromOwner(DomItem &) const override { return pathFromOwner(); }
42 Path canonicalPath(DomItem &self) const override
43 {
44 return self.owner().canonicalPath().path(pathFromOwner());
45 }
46 bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor) override;
47
50};
51
53{
55
56protected:
57 std::shared_ptr<OwningItem> doCopy(DomItem &self) const override;
58
59public:
60 enum class Status { NotLoaded, Loading, Loaded };
61 constexpr static DomType kindValue = DomType::ModuleIndex;
62 DomType kind() const override { return kindValue; }
63
64 ModuleIndex(QString uri, int majorVersion, int derivedFrom = 0,
66 : OwningItem(derivedFrom, lastDataUpdateAt), m_uri(uri), m_majorVersion(majorVersion)
67 {
68 }
69
71
73
74 std::shared_ptr<ModuleIndex> makeCopy(DomItem &self) const
75 {
76 return std::static_pointer_cast<ModuleIndex>(doCopy(self));
77 }
78
79 Path canonicalPath(DomItem &) const override
80 {
81 return Paths::moduleIndexPath(uri(), majorVersion());
82 }
83
84 bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor) override;
85
86 QSet<QString> exportNames(DomItem &self) const;
87
88 QList<DomItem> exportsWithNameAndMinorVersion(DomItem &self, QString name,
89 int minorVersion) const;
90
91 QString uri() const { return m_uri; }
92 int majorVersion() const { return m_majorVersion; }
93 QList<Path> sources() const;
94
96 {
98 return m_moduleScope.keys();
99 }
100 ModuleScope *ensureMinorVersion(int minorVersion);
101 void mergeWith(std::shared_ptr<ModuleIndex> o);
103 {
104 QMutexLocker l(mutex());
105 if (!m_qmltypesFilesPaths.contains(p))
106 m_qmltypesFilesPaths.append(p);
107 }
108
109 QList<Path> qmldirsToLoad(DomItem &self);
111 {
112 QMutexLocker l(mutex());
113 return m_qmltypesFilesPaths;
114 }
116 {
117 QMutexLocker l(mutex());
118 return m_qmldirPaths;
119 }
121 {
122 QMutexLocker l(mutex());
123 return m_directoryPaths;
124 }
125 QList<DomItem> autoExports(DomItem &self) const;
126
127private:
128 QString m_uri;
129 int m_majorVersion;
130
131 QList<Path> m_qmltypesFilesPaths;
132 QList<Path> m_qmldirPaths;
133 QList<Path> m_directoryPaths;
134 QMap<int, ModuleScope *> m_moduleScope;
135};
136
137} // end namespace Dom
138} // end namespace QQmlJS
140#endif // QQMLDOMMODULEINDEX_P_H
\inmodule QtCore\reentrant
Definition qdatetime.h:257
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)
Definition qlist.h:74
Definition qmap.h:186
\inmodule QtCore
Definition qmutex.h:317
DomType kind() const override
QList< Path > qmldirPaths() const
std::shared_ptr< ModuleIndex > makeCopy(DomItem &self) const
QList< int > minorVersions() const
Path canonicalPath(DomItem &) const override
QList< Path > directoryPaths() const
ModuleIndex(QString uri, int majorVersion, int derivedFrom=0, QDateTime lastDataUpdateAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
QList< Path > qmltypesFilesPaths() const
Path pathFromOwner(DomItem &) const override
Path canonicalPath(DomItem &self) const override
ModuleScope(QString uri=QString(), const Version &version=Version())
DomType kind() const override
Path key(QString name) const
Definition qset.h:18
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:7822
Combined button and popup list for selecting options.
#define Q_DECLARE_TR_FUNCTIONS(context)
GLuint name
GLsizei GLenum * sources
GLfloat GLfloat p
[1]
#define QMLDOM_EXPORT
QMutex mutex
[2]