4#ifndef QQMLJSSCOPESBYID_P_H
5#define QQMLJSSCOPESBYID_P_H
20#include <QtCore/qhash.h>
21#include <QtCore/qstring.h>
43 QString id(
const QQmlJSScope::ConstPtr &scope,
const QQmlJSScope::ConstPtr &referrer,
44 QQmlJSScopesByIdOptions options =
Default)
const
46 const QQmlJSScope::ConstPtr referrerRoot = componentRoot(referrer);
47 for (
auto it = m_scopesById.begin(), end = m_scopesById.end(); it != end; ++it) {
48 if (*it == scope && isComponentVisible(componentRoot(*it), referrerRoot, options))
55
56
57
58
60 QQmlJSScopesByIdOptions options =
Default)
const
62 Q_ASSERT(!id.isEmpty());
63 const auto range = m_scopesById.equal_range(id);
64 if (range.first == range.second)
65 return QQmlJSScope::ConstPtr();
66 const QQmlJSScope::ConstPtr referrerRoot = componentRoot(referrer);
68 for (
auto it = range.first; it != range.second; ++it) {
69 if (isComponentVisible(componentRoot(*it), referrerRoot, options))
73 return QQmlJSScope::ConstPtr();
76 void insert(
const QString &id,
const QQmlJSScope::ConstPtr &scope)
78 Q_ASSERT(!id.isEmpty());
79 m_scopesById.insert(id, scope);
82 void clear() { m_scopesById.clear(); }
85
86
87
88
89
90
94 static QQmlJSScope::ConstPtr componentRoot(
const QQmlJSScope::ConstPtr &inner)
96 QQmlJSScope::ConstPtr scope = inner;
97 while (scope && !scope->isComponentRootElement() && !scope->isInlineComponent()) {
98 if (QQmlJSScope::ConstPtr parent = scope->parentScope())
106 bool isComponentVisible(
const QQmlJSScope::ConstPtr &observed,
107 const QQmlJSScope::ConstPtr &observer,
108 QQmlJSScopesByIdOptions options)
const
111 return observed == observer;
113 for (QQmlJSScope::ConstPtr scope = observer; scope; scope = scope->parentScope()) {
114 if (scope == observed)
121 QMultiHash<QString, QQmlJSScope::ConstPtr> m_scopesById;
122 bool m_componentsAreBound =
false;
123 bool m_signaturesAreEnforced =
true;
124 bool m_valueTypesAreAddressable =
false;
bool signaturesAreEnforced() const
bool componentsAreBound() const
bool existsAnywhereInDocument(const QString &id) const
void setValueTypesAreAddressable(bool addressable)
void setComponentsAreBound(bool bound)
QString id(const QQmlJSScope::ConstPtr &scope, const QQmlJSScope::ConstPtr &referrer, QQmlJSScopesByIdOptions options=Default) const
void setSignaturesAreEnforced(bool enforced)
bool valueTypesAreAddressable() const
QQmlJSScope::ConstPtr scope(const QString &id, const QQmlJSScope::ConstPtr &referrer, QQmlJSScopesByIdOptions options=Default) const
void insert(const QString &id, const QQmlJSScope::ConstPtr &scope)
QString errorMessage() const
QQmlJSTypeDescriptionReader(QString fileName, QString data)
bool operator()(QList< QQmlJSExportedScope > *objects, QStringList *dependencies)
QString warningMessage() const
QQmlJSTypeReader(QQmlJSImporter *importer, const QString &file)
bool operator()(const QSharedPointer< QQmlJSScope > &scope)
QList< QQmlJS::DiagnosticMessage > errors() const
friend bool operator==(const Import &a, const Import &b)
QTypeRevision version() const
bool isDependency() const
friend size_t qHash(const Import &key, size_t seed=0) noexcept
Import(QString prefix, QString name, QTypeRevision version, bool isFile, bool isDependency)
Combined button and popup list for selecting options.
static QStringList aliases(const QQmlJSScope::ConstPtr &scope)
static bool isVersionAllowed(const QQmlJSScope::Export &exportEntry, const QQmlJS::Import &importDescription)
static bool isComposite(const QQmlJSScope::ConstPtr &scope)
static QString resolvePreferredPath(const QString &qmldirPath, const QString &prefer, QQmlJSResourceFileMapper *mapper)
static const QString prefixedName(const QString &prefix, const QString &name)
static const QLatin1String SlashQmldir
static QString internalName(const QQmlJSScope::ConstPtr &scope)
static const QLatin1String PluginsDotQmltypes
@ PreferQmlFilesFromSourceFolder
@ AssumeComponentsAreBound
Q_DECLARE_FLAGS(QQmlJSScopesByIdOptions, QQmlJSScopesByIdOption)
QString name(const QQmlJSScope::ConstPtr &type) const
void addTypes(ContextualTypes &&types)
void addTypes(const ContextualTypes &types)
CompileContext context() const
bool isNullType(const QString &name) const
ImportedScope< QQmlJSScope::ConstPtr > type(const QString &name) const
bool hasType(const QString &name) const
ContextualTypes(CompileContext context, const QHash< QString, ImportedScope< QQmlJSScope::ConstPtr > > types, const QQmlJSScope::ConstPtr &arrayType)
QQmlJSScope::ConstPtr arrayType() const
void setType(const QString &name, const ImportedScope< QQmlJSScope::ConstPtr > &type)
void clearType(const QString &name)