Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
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(const 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(const DomItem &) const override { return pathFromOwner(); }
42 Path canonicalPath(const DomItem &self) const override
43 {
44 return self.owner().canonicalPath().path(pathFromOwner());
45 }
46 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override;
47
50};
51
53{
55
56protected:
57 std::shared_ptr<OwningItem> doCopy(const 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
65 const QString &uri, int majorVersion, int derivedFrom = 0,
66 const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
67 : OwningItem(derivedFrom, lastDataUpdateAt), m_uri(uri), m_majorVersion(majorVersion)
68 {
69 }
70
72
74
75 std::shared_ptr<ModuleIndex> makeCopy(const DomItem &self) const
76 {
77 return std::static_pointer_cast<ModuleIndex>(doCopy(self));
78 }
79
80 Path canonicalPath(const DomItem &) const override
81 {
82 return Paths::moduleIndexPath(uri(), majorVersion());
83 }
84
85 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override;
86
87 QSet<QString> exportNames(const DomItem &self) const;
88
89 QList<DomItem> exportsWithNameAndMinorVersion(const DomItem &self, const QString &name,
90 int minorVersion) const;
91
92 QString uri() const { return m_uri; }
93 int majorVersion() const { return m_majorVersion; }
94 QList<Path> sources() const;
95
96 QList<int> minorVersions() const
97 {
99 return m_moduleScope.keys();
100 }
101 ModuleScope *ensureMinorVersion(int minorVersion);
102 void mergeWith(const std::shared_ptr<ModuleIndex> &o);
104 {
105 QMutexLocker l(mutex());
106 if (!m_qmltypesFilesPaths.contains(p))
107 m_qmltypesFilesPaths.append(p);
108 }
109
110 QList<Path> qmldirsToLoad(const DomItem &self);
111 QList<Path> qmltypesFilesPaths() const
112 {
113 QMutexLocker l(mutex());
114 return m_qmltypesFilesPaths;
115 }
116 QList<Path> qmldirPaths() const
117 {
118 QMutexLocker l(mutex());
119 return m_qmldirPaths;
120 }
121 QList<Path> directoryPaths() const
122 {
123 QMutexLocker l(mutex());
124 return m_directoryPaths;
125 }
126 QList<DomItem> autoExports(const DomItem &self) const;
127
128private:
129 QString m_uri;
130 int m_majorVersion;
131
132 QList<Path> m_qmltypesFilesPaths;
133 QList<Path> m_qmldirPaths;
134 QList<Path> m_directoryPaths;
135 QMap<int, ModuleScope *> m_moduleScope;
136};
137
138} // end namespace Dom
139} // end namespace QQmlJS
141#endif // QQMLDOMMODULEINDEX_P_H
\inmodule QtCore\reentrant
Definition qdatetime.h:283
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)
\inmodule QtCore
Definition qmutex.h:313
DomType kind() const override
QList< Path > qmldirPaths() const
Path canonicalPath(const DomItem &) const override
QList< int > minorVersions() const
std::shared_ptr< ModuleIndex > makeCopy(const DomItem &self) const
void addQmltypeFilePath(const Path &p)
QList< Path > directoryPaths() const
ModuleIndex(const QString &uri, int majorVersion, int derivedFrom=0, const QDateTime &lastDataUpdateAt=QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
QList< Path > qmltypesFilesPaths() const
ModuleScope(const QString &uri=QString(), const Version &version=Version())
Path pathFromOwner(const DomItem &) const override
Path canonicalPath(const DomItem &self) const override
DomType kind() const override
Path key(const QString &name) const
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
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:8084
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]