9#include <QtQml/private/qqmljsparser_p.h>
10#include <QtQml/private/qqmljslexer_p.h>
11#include <QtQml/private/qqmljsengine_p.h>
12#include <private/qqmljstypedescriptionreader_p.h>
14#include <QtCore/qdir.h>
30void QmltypesReader::insertProperty(
32 QMap<int, QmlObject> &objs)
35 prop.name =
property.propertyName();
36 prop.typeName =
property.typeName();
37 prop.isPointer =
property.isPointer();
38 prop.isReadonly = !
property.isWritable();
39 prop.isRequired = jsScope->isPropertyLocallyRequired(prop.name);
40 prop.isList =
property.isList();
41 int revision =
property.revision();
42 prop.isFinal =
property.isFinal();
43 prop.bindable =
property.bindable();
44 prop.read =
property.read();
45 prop.write =
property.write();
46 prop.notify =
property.notify();
48 if (prop.name.isEmpty() || prop.typeName.isEmpty()) {
50 .
warning(
tr(
"Property object is missing a name or type script binding."))
58 QMap<int, QmlObject> &objs)
63 case QQmlJSMetaMethodType::Method:
64 case QQmlJSMetaMethodType::Slot:
67 case QQmlJSMetaMethodType::Signal:
75 for (
int i = 0;
i < nParam; ++
i) {
77 param.name = parameters[
i].name();
78 param.typeName = parameters[
i].typeName();
79 methodInfo.parameters.append(
param);
83 int revision = metaMethod.
revision();
85 if (methodInfo.name.isEmpty()) {
96 res.setName(metaEnum.name());
97 res.setAlias(metaEnum.alias());
98 res.setIsFlag(metaEnum.isFlag());
101 for (
const auto &k : metaEnum.
keys()) {
102 if (metaEnum.hasValues())
103 lastValue = metaEnum.value(k);
113 const QList<QQmlJSScope::Export> &exportsList)
116 comp.setSemanticScope(jsScope);
117 QMap<int, QmlObject> objects;
119 bool hasExports =
false;
121 int metaRev = jsE.version().toEncodedVersion<
int>();
124 object.setSemanticScope(jsScope);
125 objects.insert(metaRev,
object);
129 object.setSemanticScope(jsScope);
130 objects.insert(0,
object);
133 bool incrementedPath =
false;
137 QHash<QString, QQmlJSMetaProperty> els = jsScope->ownProperties();
139 auto end = els.cend();
141 insertProperty(jsScope,
it.value(), objects);
146 QMultiHash<QString, QQmlJSMetaMethod> els = jsScope->ownMethods();
148 auto end = els.cend();
150 insertSignalOrMethod(
it.value(), objects);
155 QHash<QString, QQmlJSMetaEnum> els = jsScope->ownEnumerations();
157 auto end = els.cend();
159 comp.addEnumeration(enumFromMetaEnum(
it.value()));
163 comp.setFileName(jsScope->filePath());
164 comp.setName(jsScope->internalName());
165 m_currentPath = m_currentPath.
key(comp.name())
167 incrementedPath =
true;
168 prototype = jsScope->baseTypeName();
169 defaultPropertyName = jsScope->ownDefaultPropertyName();
170 comp.setInterfaceNames(jsScope->interfaceNames());
175 comp.setIsSingleton(jsScope->isSingleton());
176 comp.setIsCreatable(jsScope->isCreatable());
177 comp.setIsComposite(jsScope->isComposite());
178 comp.setHasCustomParser(jsScope->hasCustomParser());
179 comp.setValueTypeName(jsScope->valueTypeName());
180 comp.setAccessSemantics(jsScope->accessSemantics());
181 comp.setExtensionTypeName(jsScope->extensionTypeName());
182 comp.setExtensionIsJavaScript(jsScope->extensionIsJavaScript());
183 comp.setExtensionIsNamespace(jsScope->extensionIsNamespace());
185 QMap<int, Path> revToPath;
186 auto it = objects.end();
187 auto begin = objects.begin();
190 Path compPath = qmltypesFile()
192 .
field(Fields::components)
201 tr(
"negative meta revision %1 not supported").
arg(
it.key())));
203 revToPath.insert(
it.key(), compPath.field(Fields::objects).index(objectIndex));
204 Path nextObjectPath = compPath.field(Fields::objects).index(++objectIndex);
208 it->setName(prototype);
210 it->addPrototypePath(nextObjectPath);
214 metaRevs.append(
it.key());
216 comp.setMetaRevisions(metaRevs);
219 QList<Export> exports;
221 auto v = jsE.version();
222 int metaRev =
v.toEncodedVersion<
int>();
224 e.uri = jsE.package();
225 e.typeName = jsE.type();
226 e.isSingleton = jsScope->isSingleton();
227 e.version =
Version((
v.hasMajorVersion() ?
v.majorVersion() :
Version::Latest),
228 (
v.hasMinorVersion() ?
v.minorVersion() :
Version::Latest));
229 e.typePath = revToPath.value(metaRev);
231 qCWarning(domLog) <<
"could not find version" << metaRev <<
"in" << revToPath.keys();
233 e.exportSourcePath = exportSourcePath;
237 if (comp.name().isEmpty()) {
239 .
error(
tr(
"Component definition is missing a name binding."))
251 qmltypesFilePtr()->code());
253 QList<QQmlJSExportedScope> objects;
254 const bool isValid = reader(&objects, &dependencies);
255 for (
const auto &
obj : std::as_const(objects))
256 insertComponent(
obj.scope,
obj.exports);
257 qmltypesFilePtr()->setIsValid(isValid);
267 qmltypesFilePtr()->addErrorLocal(
message.handle());
qsizetype size() const noexcept
QString canonicalFilePath() const
Path canonicalPath() const
Represents a set of tags grouping a set of related error messages.
Represents an error message connected to the dom.
Path dropTail(int n=1) const
Path key(const QString &name) const
Path field(const QString &name) const
Path index(index_type i) const
const_iterator cbegin() const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QSet< QString >::iterator it
Path lookupCppTypePath(const QString &name)
static ErrorGroups readerParseErrors()
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
#define qCWarning(category,...)
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
GLint GLenum GLint components
GLuint GLsizei const GLchar * message
GLenum const GLint * param
#define NewErrorGroup(name)
QDebug warning(QAnyStringView fileName, int lineNumber)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)