7#include <QtCore/QFileInfo>
8#include <QtCore/QScopeGuard>
32 cont = cont && self.dvValueField(visitor, Fields::uri,
uri);
33 cont = cont && self.dvWrapField(visitor, Fields::version,
version);
34 cont = cont && self.dvItemField(visitor, Fields::exports, [
this, &self]() {
36 return self.subMapItem(
Map(
37 self.pathFromOwner().field(Fields::exports),
39 DomItem mapExpOw = mapExp.owner();
40 QList<DomItem> exports =
41 mapExp.ownerAs<ModuleIndex>()->exportsWithNameAndMinorVersion(
42 mapExpOw, name, minorVersion);
43 return mapExp.subListItem(List::fromQList<DomItem>(
44 mapExp.pathFromOwner().key(name), exports,
45 [](DomItem &, const PathEls::PathComponent &, DomItem &el) {
56 cont = cont && self.dvItemField(visitor, Fields::symbols, [&self]() {
58 return self.subMapItem(
Map(
59 self.pathFromOwner().field(Fields::symbols),
61 QList<Path> symb({ basePath.key(name) });
65 DomItem mapExpOw = mapExp.owner();
66 return mapExp.ownerAs<ModuleIndex>()->exportNames(mapExpOw);
70 cont = cont &&
self.dvItemField(visitor, Fields::autoExports, [
this, &self]() {
71 return containingObject(self).field(Fields::autoExports);
76std::shared_ptr<OwningItem> ModuleIndex::doCopy(
DomItem &)
const
78 return std::make_shared<ModuleIndex>(*
this);
82 :
OwningItem(
o), m_uri(
o.uri()), m_majorVersion(
o.majorVersion())
87 m_qmltypesFilesPaths +=
o.m_qmltypesFilesPaths;
88 m_qmldirPaths +=
o.m_qmldirPaths;
89 m_directoryPaths +=
o.m_directoryPaths;
90 scopes =
o.m_moduleScope;
105 scopes = m_moduleScope;
106 m_moduleScope.clear();
118 bool cont = self.dvValueField(visitor, Fields::uri,
uri());
119 cont = cont && self.dvValueField(visitor, Fields::majorVersion,
majorVersion());
120 cont = cont && self.dvItemField(visitor, Fields::moduleScope, [
this, &self]() {
121 return self.subMapItem(
Map(
125 int minorVersion = minorVersionStr.
toInt(&
ok);
144 cont = cont && self.dvItemField(visitor, Fields::sources, [
this, &self]() {
147 cont = cont && self.dvValueLazyField(visitor, Fields::autoExports, [
this, &self]() {
157 for (
int i = 0;
i < mySources.
size(); ++
i) {
159 res +=
source.field(Fields::exports).keys();
179 DomItem env = self.environment();
181 bool outdated =
false;
182 for (
Path p : cachedPaths) {
186 qWarning() <<
"referenceCache outdated, reference at " << selfPath
187 <<
" leads to invalid path " <<
p;
202 for (
Path p : mySources) {
206 if (!knownAutoImportUris.
contains(iPtr->import.uri.toString())
208 knownAutoImportUris.
insert(iPtr->import.uri.toString());
209 knownExports.
append(*iPtr);
211 cachedPaths.
append(
i.canonicalPath());
222 int minorVersion)
const
225 .
field(Fields::exports)
230 if (minorVersion < 0)
231 minorVersion = std::numeric_limits<int>::max();
233 for (
int i = 0;
i < mySources.
size(); ++
i) {
236 int nExports = exports.
indexes();
239 for (
int j = 0;
j < nExports; ++
j) {
244 if (versionPtr ==
nullptr || !versionPtr->
isValid()) {
249 .
error(
tr(
"Module %1 (unversioned) has versioned entries "
252 source.canonicalPath().toString()))
260 res.append(exportItem);
267 if (!
res.isEmpty()) {
269 .
error(
tr(
"Module %1 (major version %2) has versioned and "
270 "unversioned entries for '%3'")
285 res += m_qmltypesFilesPaths;
286 if (!m_qmldirPaths.isEmpty())
287 res += m_qmldirPaths.first();
288 else if (!m_directoryPaths.isEmpty())
289 res += m_directoryPaths.first();
295 if (minorVersion < 0)
299 auto it = m_moduleScope.find(minorVersion);
300 if (
it != m_moduleScope.end())
305 auto cleanup =
qScopeGuard([&newScope] {
delete newScope; });
308 auto it = m_moduleScope.find(minorVersion);
309 if (
it != m_moduleScope.end()) {
314 m_moduleScope.insert(minorVersion,
res);
327 qmltypesPaths =
o->m_qmltypesFilesPaths;
328 scopes =
o->m_moduleScope;
332 for (
Path qttPath : qmltypesPaths) {
333 if (!m_qmltypesFilesPaths.contains((qttPath)))
334 m_qmltypesFilesPaths.append(qttPath);
349 DomItem env = self.environment();
362 logicalPath = subPathV;
382 }
else if (
uri() != u
"QML") {
384 .warning(
tr(
"Failed to find main qmldir file for %1 %2")
static constexpr QChar fromLatin1(char c) noexcept
Converts the Latin-1 character c to its equivalent QChar.
\inmodule QtCore \reentrant
bool isFile() const
Returns true if this object points to a file or to a symbolic link to a file.
QString canonicalFilePath() const
Returns the canonical path including the file name, i.e.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
virtual DomItem field(DomItem &self, QStringView name) const
Represents a consistent set of types organized in modules, it is the top level of the DOM.
static ErrorGroup domErrorGroup
DomItem key(QString name)
std::shared_ptr< T > ownerAs()
DomItem index(index_type)
DomItem path(Path p, ErrorHandler h=&defaultErrorHandler)
DomItem field(QStringView name)
Represents a set of tags grouping a set of related error messages.
ErrorMessage error(QString message) const
ErrorMessage & withPath(const Path &)
void mergeWith(std::shared_ptr< ModuleIndex > o)
ModuleScope * ensureMinorVersion(int minorVersion)
QList< Path > qmldirPaths() const
QList< Path > sources() const
QList< int > minorVersions() const
QList< DomItem > exportsWithNameAndMinorVersion(DomItem &self, QString name, int minorVersion) const
Path canonicalPath(DomItem &) const override
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor) override
QList< DomItem > autoExports(DomItem &self) const
QList< Path > qmldirsToLoad(DomItem &self)
QSet< QString > exportNames(DomItem &self) const
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor) override
QBasicMutex * mutex() const
void addErrorLocal(ErrorMessage msg)
Path pathFromOwner() const
Path key(QString name) const
Path field(QString name) const
static Path Current(PathCurrent c)
static bool addForPath(DomItem &el, Path canonicalPath, const RefCacheEntry &entry, AddOption addOption=AddOption::KeepExisting)
static RefCacheEntry forPath(DomItem &el, Path canonicalPath)
QList< Path > canonicalPaths
static constexpr qint32 Undefined
static constexpr qint32 Latest
bool contains(const T &value) const
iterator insert(const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
void clear()
Clears the contents of the string and makes it null.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QMap< QString, QString > map
[6]
QSet< QString >::iterator it
Path moduleScopePath(QString uri, Version version, ErrorHandler)
Path qmldirFilePath(QString path)
static ErrorGroups myVersioningErrors()
static ErrorGroups myExportErrors()
Combined button and popup list for selecting options.
static const QPainterPath::ElementType * subPath(const QPainterPath::ElementType *t, const QPainterPath::ElementType *end, const qreal *points, bool *closed)
GLuint64 GLenum void * handle
GLsizei GLsizei GLchar * source
GLsizei const GLchar *const * path
#define NewErrorGroup(name)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
QLatin1StringView QLatin1String
bool contains(const AT &t) const noexcept