Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmldomelements_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 QQMLDOMELEMENTS_P_H
5#define QQMLDOMELEMENTS_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 "qqmldomitem_p.h"
19#include "qqmldomconstants_p.h"
20#include "qqmldomcomments_p.h"
21#include "qqmldomlinewriter_p.h"
22
23#include <QtQml/private/qqmljsast_p.h>
24#include <QtQml/private/qqmljsengine_p.h>
25
26#include <QtCore/QCborValue>
27#include <QtCore/QCborMap>
28#include <QtCore/QMutexLocker>
29#include <QtCore/QPair>
30
31#include <memory>
32#include <private/qqmljsscope_p.h>
33
34#include <functional>
35#include <limits>
36
38
39namespace QQmlJS {
40namespace Dom {
41
42// namespace for utility methods building specific paths
43// using a namespace one can reopen it and add more methods in other places
44namespace Paths {
45Path moduleIndexPath(QString uri, int majorVersion, ErrorHandler errorHandler = nullptr);
46Path moduleScopePath(QString uri, Version version, ErrorHandler errorHandler = nullptr);
47Path moduleScopePath(QString uri, QString version, ErrorHandler errorHandler = nullptr);
48inline Path moduleScopePath(QString uri, ErrorHandler errorHandler = nullptr)
49{
50 return moduleScopePath(uri, QString(), errorHandler);
51}
53{
54 return Path::Root(PathRoot::Top).field(Fields::qmldirWithPath).key(path);
55}
57{
58 return qmlDirInfoPath(path).field(Fields::currentItem);
59}
61{
62 return Path::Root(PathRoot::Top).field(Fields::qmldirFileWithPath).key(path);
63}
65{
66 return qmldirFileInfoPath(path).field(Fields::currentItem);
67}
68inline Path qmlFileInfoPath(QString canonicalFilePath)
69{
70 return Path::Root(PathRoot::Top).field(Fields::qmlFileWithPath).key(canonicalFilePath);
71}
72inline Path qmlFilePath(QString canonicalFilePath)
73{
74 return qmlFileInfoPath(canonicalFilePath).field(Fields::currentItem);
75}
76inline Path qmlFileObjectPath(QString canonicalFilePath)
77{
78 return qmlFilePath(canonicalFilePath)
79 .field(Fields::components)
80 .key(QString())
81 .index(0)
82 .field(Fields::objects)
83 .index(0);
84}
86{
87 return Path::Root(PathRoot::Top).field(Fields::qmltypesFileWithPath).key(path);
88}
90{
91 return qmltypesFileInfoPath(path).field(Fields::currentItem);
92}
94{
95 return Path::Root(PathRoot::Top).field(Fields::jsFileWithPath).key(path);
96}
98{
99 return jsFileInfoPath(path).field(Fields::currentItem);
100}
102{
103 return Path::Root(PathRoot::Top).field(Fields::qmlDirectoryWithPath).key(path);
104}
106{
107 return qmlDirectoryInfoPath(path).field(Fields::currentItem);
108}
110{
111 return Path::Root(PathRoot::Top).field(Fields::globalScopeWithName).key(name);
112}
114{
115 return globalScopeInfoPath(name).field(Fields::currentItem);
116}
118{
119 return Path::Current(PathCurrent::Lookup).field(Fields::cppType).key(name);
120}
122{
123 return Path::Current(PathCurrent::Lookup).field(Fields::propertyDef).key(name);
124}
126{
127 return Path::Current(PathCurrent::Lookup).field(Fields::symbol).key(name);
128}
130{
131 return Path::Current(PathCurrent::Lookup).field(Fields::type).key(name);
132}
134{
135 return Path::Root(PathRoot::Env).field(Fields::loadInfo).key(el.toString());
136}
137} // end namespace Paths
138
140{
141public:
142 CommentableDomElement(Path pathFromOwner = Path()) : DomElement(pathFromOwner) { }
143 CommentableDomElement(const CommentableDomElement &o) : DomElement(o), m_comments(o.m_comments)
144 {
145 }
147 bool iterateDirectSubpaths(DomItem &self, DirectVisitor) override;
148 RegionComments &comments() { return m_comments; }
149 const RegionComments &comments() const { return m_comments; }
150
151private:
152 RegionComments m_comments;
153};
154
156{
157public:
158 constexpr static DomType kindValue = DomType::Version;
159 constexpr static qint32 Undefined = -1;
160 constexpr static qint32 Latest = -2;
161
162 Version(qint32 majorVersion = Undefined, qint32 minorVersion = Undefined);
164
165 bool iterateDirectSubpaths(DomItem &self, DirectVisitor);
166
167 bool isLatest() const;
168 bool isValid() const;
169 QString stringValue() const;
171 {
172 if (majorVersion >= 0 || majorVersion == Undefined)
173 return QString::number(majorVersion);
174 return QString();
175 }
177 {
178 if (majorVersion == Version::Latest)
179 return QLatin1String("Latest");
180 if (majorVersion >= 0 || majorVersion == Undefined)
181 return QString::number(majorVersion);
182 return QString();
183 }
185 {
186 if (minorVersion >= 0 || minorVersion == Undefined)
187 return QString::number(minorVersion);
188 return QString();
189 }
190 int compare(const Version &o) const
191 {
192 int c = majorVersion - o.majorVersion;
193 if (c != 0)
194 return c;
195 return minorVersion - o.minorVersion;
196 }
197
200};
201inline bool operator==(const Version &v1, const Version &v2)
202{
203 return v1.compare(v2) == 0;
204}
205inline bool operator!=(const Version &v1, const Version &v2)
206{
207 return v1.compare(v2) != 0;
208}
209inline bool operator<(const Version &v1, const Version &v2)
210{
211 return v1.compare(v2) < 0;
212}
213inline bool operator<=(const Version &v1, const Version &v2)
214{
215 return v1.compare(v2) <= 0;
216}
217inline bool operator>(const Version &v1, const Version &v2)
218{
219 return v1.compare(v2) > 0;
220}
221inline bool operator>=(const Version &v1, const Version &v2)
222{
223 return v1.compare(v2) >= 0;
224}
225
227{
228public:
229 enum class Kind { Invalid, ModuleUri, DirectoryUrl, RelativePath, AbsolutePath };
230 QmlUri() = default;
231 static QmlUri fromString(const QString &importStr);
232 static QmlUri fromUriString(const QString &importStr);
233 static QmlUri fromDirectoryString(const QString &importStr);
234 bool isValid() const;
235 bool isDirectory() const;
236 bool isModule() const;
239 QString absoluteLocalPath(const QString &basePath = QString()) const;
243 Kind kind() const;
244
245 friend bool operator==(const QmlUri &i1, const QmlUri &i2)
246 {
247 return i1.m_kind == i2.m_kind && i1.m_value == i2.m_value;
248 }
249 friend bool operator!=(const QmlUri &i1, const QmlUri &i2) { return !(i1 == i2); }
250
251private:
252 QmlUri(const QUrl &url) : m_kind(Kind::DirectoryUrl), m_value(url) { }
253 QmlUri(Kind kind, const QString &value) : m_kind(kind), m_value(value) { }
254 Kind m_kind = Kind::Invalid;
255 std::variant<QString, QUrl> m_value;
256};
257
259{
261public:
262 constexpr static DomType kindValue = DomType::Import;
263
265 QString importId = QString(), ErrorHandler handler = nullptr);
266 static Import fromFileString(QString importStr, QString importId = QString(),
267 ErrorHandler handler = nullptr);
268
269 Import(QmlUri uri = QmlUri(), Version version = Version(), QString importId = QString())
270 : uri(uri), version(version), importId(importId)
271 {
272 }
273
276 {
277 if (uri.isDirectory()) {
278 QString path = uri.absoluteLocalPath();
279 if (!path.isEmpty()) {
280 return Paths::qmlDirPath(path);
281 } else {
282 Q_ASSERT_X(false, "Import", "url imports not supported");
283 return Paths::qmldirFilePath(uri.directoryString());
284 }
285 } else {
286 return Paths::moduleScopePath(uri.moduleUri(), version);
287 }
288 }
289 Import baseImport() const { return Import { uri, version }; }
290
291 friend bool operator==(const Import &i1, const Import &i2)
292 {
293 return i1.uri == i2.uri && i1.version == i2.version && i1.importId == i2.importId
294 && i1.comments == i2.comments && i1.implicit == i2.implicit;
295 }
296 friend bool operator!=(const Import &i1, const Import &i2) { return !(i1 == i2); }
297
298 void writeOut(DomItem &self, OutWriter &ow) const;
299
300 static QRegularExpression importRe();
301
306 bool implicit = false;
307};
308
310{
311public:
312 constexpr static DomType kindValue = DomType::ModuleAutoExport;
313
315 {
316 bool cont = true;
317 cont = cont && self.dvWrapField(visitor, Fields::import, import);
318 cont = cont && self.dvValueField(visitor, Fields::inheritVersion, inheritVersion);
319 return cont;
320 }
321
322 friend bool operator==(const ModuleAutoExport &i1, const ModuleAutoExport &i2)
323 {
324 return i1.import == i2.import && i1.inheritVersion == i2.inheritVersion;
325 }
326 friend bool operator!=(const ModuleAutoExport &i1, const ModuleAutoExport &i2)
327 {
328 return !(i1 == i2);
329 }
330
331 Import import;
332 bool inheritVersion = false;
333};
334
336{
337public:
338 constexpr static DomType kindValue = DomType::Pragma;
339
340 Pragma(QString pragmaName = QString(), const QStringList &pragmaValues = {})
341 : name(pragmaName), values{ pragmaValues }
342 {
343 }
344
346 {
347 bool cont = self.dvValueField(visitor, Fields::name, name);
348 cont = cont && self.dvValueField(visitor, Fields::values, values);
349 cont = cont && self.dvWrapField(visitor, Fields::comments, comments);
350 return cont;
351 }
352
353 void writeOut(DomItem &self, OutWriter &ow) const;
354
358};
359
361{
362public:
363 constexpr static DomType kindValue = DomType::Id;
364
365 Id(QString idName = QString(), Path referredObject = Path());
366
368 void updatePathFromOwner(Path pathFromOwner);
369 Path addAnnotation(Path selfPathFromOwner, const QmlObject &ann, QmlObject **aPtr = nullptr);
370
375 std::shared_ptr<ScriptExpression> value;
376};
377
378// TODO: rename? it may contain statements and stuff, not only expressions
380{
383public:
384 enum class ExpressionType {
385 BindingExpression,
386 FunctionBody,
387 ArgInitializer,
388 ArgumentStructure,
389 ReturnType
390 };
392 constexpr static DomType kindValue = DomType::ScriptExpression;
393 DomType kind() const override { return kindValue; }
394
395 explicit ScriptExpression(QStringView code, std::shared_ptr<QQmlJS::Engine> engine,
396 AST::Node *ast, std::shared_ptr<AstComments> comments,
397 ExpressionType expressionType,
398 SourceLocation localOffset = SourceLocation(), int derivedFrom = 0,
399 QStringView preCode = QStringView(),
400 QStringView postCode = QStringView());
401
403 : ScriptExpression(QStringView(), std::shared_ptr<QQmlJS::Engine>(), nullptr,
404 std::shared_ptr<AstComments>(), ExpressionType::BindingExpression,
405 SourceLocation(), 0)
406 {
407 }
408
409 explicit ScriptExpression(QString code, ExpressionType expressionType, int derivedFrom = 0,
410 QString preCode = QString(), QString postCode = QString())
411 : OwningItem(derivedFrom), m_expressionType(expressionType)
412 {
413 setCode(code, preCode, postCode);
414 }
415
417
418 std::shared_ptr<ScriptExpression> makeCopy(DomItem &self) const
419 {
420 return std::static_pointer_cast<ScriptExpression>(doCopy(self));
421 }
422
423 std::shared_ptr<ScriptExpression> copyWithUpdatedCode(DomItem &self, QString code) const;
424
425 bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor) override;
426
427 Path canonicalPath(DomItem &self) const override { return self.m_ownerPath; }
428 // parsed and created if not available
429 AST::Node *ast() const { return m_ast; }
430 // dump of the ast (without locations)
431 void astDumper(Sink s, AstDumperOptions options) const;
433
434 // definedSymbols name, value, from
435 // usedSymbols name, locations
437 {
438 QMutexLocker l(mutex());
439 return m_code;
440 }
441
443 {
444 QMutexLocker l(mutex());
445 return m_expressionType;
446 }
447
448 bool isNull() const
449 {
450 QMutexLocker l(mutex());
451 return m_code.isNull();
452 }
453 std::shared_ptr<QQmlJS::Engine> engine() const
454 {
455 QMutexLocker l(mutex());
456 return m_engine;
457 }
458 std::shared_ptr<AstComments> astComments() const { return m_astComments; }
459 void writeOut(DomItem &self, OutWriter &lw) const override;
461 SourceLocation localOffset() const { return m_localOffset; }
462 QStringView preCode() const { return m_preCode; }
463 QStringView postCode() const { return m_postCode; }
465 ScriptElementVariant scriptElement() { return m_element; }
466
467protected:
468 std::shared_ptr<OwningItem> doCopy(DomItem &) const override
469 {
470 return std::make_shared<ScriptExpression>(*this);
471 }
472
474 {
475 SourceLocation loc = globalLocation(self);
476 return [loc, this](SourceLocation x) {
477 return SourceLocation(x.offset - m_localOffset.offset + loc.offset, x.length,
478 x.startLine - m_localOffset.startLine + loc.startLine,
479 ((x.startLine == m_localOffset.startLine) ? x.startColumn
480 - m_localOffset.startColumn + loc.startColumn
481 : x.startColumn));
482 };
483 }
484
486 {
487 return SourceLocation(
488 x.offset - m_localOffset.offset, x.length, x.startLine - m_localOffset.startLine,
489 ((x.startLine == m_localOffset.startLine)
490 ? x.startColumn - m_localOffset.startColumn
491 : x.startColumn)); // are line and column 1 based? then we should + 1
492 }
493
495 {
496 return [this](SourceLocation x) { return locationToLocal(x); };
497 }
498
499private:
500 void setCode(QString code, QString preCode, QString postCode);
501 ExpressionType m_expressionType;
502 QString m_codeStr;
503 QStringView m_code;
504 QStringView m_preCode;
505 QStringView m_postCode;
506 mutable std::shared_ptr<QQmlJS::Engine> m_engine;
507 mutable AST::Node *m_ast;
508 std::shared_ptr<AstComments> m_astComments;
509 SourceLocation m_localOffset;
510 ScriptElementVariant m_element;
511};
512
513class BindingValue;
514
516{
517public:
518 constexpr static DomType kindValue = DomType::Binding;
519
521 std::unique_ptr<BindingValue> value = std::unique_ptr<BindingValue>(),
522 BindingType bindingType = BindingType::Normal);
523 Binding(QString m_name, std::shared_ptr<ScriptExpression> value,
524 BindingType bindingType = BindingType::Normal);
525 Binding(QString m_name, QString scriptCode, BindingType bindingType = BindingType::Normal);
526 Binding(QString m_name, QmlObject value, BindingType bindingType = BindingType::Normal);
527 Binding(QString m_name, QList<QmlObject> value, BindingType bindingType = BindingType::Normal);
529 Binding(Binding &&o) = default;
532 Binding &operator=(Binding &&) = default;
533
535 DomItem valueItem(DomItem &self) const; // ### REVISIT: consider replacing return value with variant
537 QString name() const { return m_name; }
538 BindingType bindingType() const { return m_bindingType; }
539 QmlObject const *objectValue() const;
541 std::shared_ptr<ScriptExpression> scriptExpressionValue() const;
544 std::shared_ptr<ScriptExpression> scriptExpressionValue();
545 QList<QmlObject> annotations() const { return m_annotations; }
546 void setAnnotations(QList<QmlObject> annotations) { m_annotations = annotations; }
547 void setValue(std::unique_ptr<BindingValue> &&value) { m_value = std::move(value); }
548 Path addAnnotation(Path selfPathFromOwner, const QmlObject &a, QmlObject **aPtr = nullptr);
549 const RegionComments &comments() const { return m_comments; }
550 RegionComments &comments() { return m_comments; }
552 void writeOut(DomItem &self, OutWriter &lw) const;
553 void writeOutValue(DomItem &self, OutWriter &lw) const;
554 bool isSignalHandler() const
555 {
556 QString baseName = m_name.split(QLatin1Char('.')).last();
557 if (baseName.startsWith(u"on") && baseName.size() > 2 && baseName.at(2).isUpper())
558 return true;
559 return false;
560 }
562 {
563 return QStringLiteral(u"QtObject{\n %1: ").arg(n.split(u'.').last());
564 }
565 static QString postCodeForName(QStringView) { return QStringLiteral(u"\n}\n"); }
566 QString preCode() const { return preCodeForName(m_name); }
567 QString postCode() const { return postCodeForName(m_name); }
568
569private:
570 friend class QQmlDomAstCreator;
571 BindingType m_bindingType;
572 QString m_name;
573 std::unique_ptr<BindingValue> m_value;
574 QList<QmlObject> m_annotations;
575 RegionComments m_comments;
576};
577
579{
580public:
581 enum Access { Private, Protected, Public };
582
584
585 Path addAnnotation(Path selfPathFromOwner, const QmlObject &annotation,
586 QmlObject **aPtr = nullptr);
588
590 Access access = Access::Public;
592 bool isReadonly = false;
593 bool isList = false;
596};
597
599{
600 enum class Status { Invalid, ResolvedProperty, ResolvedObject, Loop, TooDeep };
601 bool valid()
602 {
603 switch (status) {
604 case Status::ResolvedProperty:
605 case Status::ResolvedObject:
606 return true;
607 default:
608 return false;
609 }
610 }
615 Status status = Status::Invalid;
616 int nAliases = 0;
617};
618
620{
621public:
622 constexpr static DomType kindValue = DomType::PropertyDefinition;
623
625 {
626 bool cont = AttributeInfo::iterateDirectSubpaths(self, visitor);
627 cont = cont && self.dvValueField(visitor, Fields::isPointer, isPointer);
628 cont = cont && self.dvValueField(visitor, Fields::isFinal, isFinal);
629 cont = cont && self.dvValueField(visitor, Fields::isAlias, isAlias());
630 cont = cont && self.dvValueField(visitor, Fields::isDefaultMember, isDefaultMember);
631 cont = cont && self.dvValueField(visitor, Fields::isRequired, isRequired);
632 cont = cont && self.dvValueField(visitor, Fields::read, read);
633 cont = cont && self.dvValueField(visitor, Fields::write, write);
634 cont = cont && self.dvValueField(visitor, Fields::bindable, bindable);
635 cont = cont && self.dvValueField(visitor, Fields::notify, notify);
636 cont = cont && self.dvReferenceField(visitor, Fields::type, typePath());
637 return cont;
638 }
639
640 Path typePath() const { return Paths::lookupTypePath(typeName); }
641
642 bool isAlias() const { return typeName == u"alias"; }
643 bool isParametricType() const;
644 void writeOut(DomItem &self, OutWriter &lw) const;
645
650 bool isFinal = false;
651 bool isPointer = false;
652 bool isDefaultMember = false;
653 bool isRequired = false;
654 std::optional<QQmlJSScope::Ptr> scope;
655};
656
658{
659public:
660 constexpr static DomType kindValue = DomType::PropertyInfo; // used to get the correct kind in ObjectWrapper
661
663
666};
667
669{
670public:
671 constexpr static DomType kindValue = DomType::MethodParameter;
672
674
675 void writeOut(DomItem &self, OutWriter &ow) const;
676 void writeOutSignal(DomItem &self, OutWriter &ow) const;
677
680 bool isPointer = false;
681 bool isReadonly = false;
682 bool isList = false;
683 std::shared_ptr<ScriptExpression> defaultValue;
689 std::shared_ptr<ScriptExpression> value;
692};
693
695{
697public:
698 enum MethodType { Signal, Method };
699 Q_ENUM(MethodType)
700
701 constexpr static DomType kindValue = DomType::MethodInfo;
702
703 Path typePath(DomItem &) const
704 {
705 return (typeName.isEmpty() ? Path() : Paths::lookupTypePath(typeName));
706 }
707
709 QString preCode(DomItem &) const; // ### REVISIT, might be simplified by using different toplevel production rules at usage site
711 void writePre(DomItem &self, OutWriter &ow) const;
712 void writeOut(DomItem &self, OutWriter &ow) const;
713 void setCode(QString code)
714 {
715 body = std::make_shared<ScriptExpression>(
716 code, ScriptExpression::ExpressionType::FunctionBody, 0,
717 QLatin1String("function foo(){\n"), QLatin1String("\n}\n"));
718 }
719 MethodInfo() = default;
720 std::optional<QQmlJSScope::Ptr> semanticScope() const { return m_semanticScope; }
721 void setSemanticScope(QQmlJSScope::Ptr scope) { m_semanticScope = scope; }
722
723 // TODO: make private + add getters/setters
725 MethodType methodType = Method;
726 std::shared_ptr<ScriptExpression> body;
727 std::shared_ptr<ScriptExpression> returnType;
728 bool isConstructor = false;
729 std::optional<QQmlJSScope::Ptr> m_semanticScope;
730};
731
733{
734public:
735 constexpr static DomType kindValue = DomType::EnumItem;
736
737 EnumItem(QString name = QString(), int value = 0) : m_name(name), m_value(value) { }
738
740
741 QString name() const { return m_name; }
742 double value() const { return m_value; }
743 RegionComments &comments() { return m_comments; }
744 const RegionComments &comments() const { return m_comments; }
745 void writeOut(DomItem &self, OutWriter &lw) const;
746
747private:
748 QString m_name;
749 double m_value;
750 RegionComments m_comments;
751};
752
754{
755public:
756 constexpr static DomType kindValue = DomType::EnumDecl;
757 DomType kind() const override { return kindValue; }
758
760 Path pathFromOwner = Path())
761 : CommentableDomElement(pathFromOwner), m_name(name), m_values(values)
762 {
763 }
764
765 bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor) override;
766
767 QString name() const { return m_name; }
768 void setName(QString name) { m_name = name; }
769 const QList<EnumItem> &values() const & { return m_values; }
770 bool isFlag() const { return m_isFlag; }
771 void setIsFlag(bool flag) { m_isFlag = flag; }
772 QString alias() const { return m_alias; }
773 void setAlias(QString aliasName) { m_alias = aliasName; }
776 {
777 m_values.append(value);
778 return Path::Field(Fields::values).index(index_type(m_values.size() - 1));
779 }
780 void updatePathFromOwner(Path newP) override;
781
782 const QList<QmlObject> &annotations() const & { return m_annotations; }
784 Path addAnnotation(const QmlObject &child, QmlObject **cPtr = nullptr);
785 void writeOut(DomItem &self, OutWriter &lw) const override;
786
787private:
788 QString m_name;
789 bool m_isFlag = false;
790 QString m_alias;
791 QList<EnumItem> m_values;
792 QList<QmlObject> m_annotations;
793};
794
796{
798public:
799 constexpr static DomType kindValue = DomType::QmlObject;
800 DomType kind() const override { return kindValue; }
801
802 QmlObject(Path pathFromOwner = Path());
806 QList<QString> fields(DomItem &) const override { return fields(); }
808 DomItem field(DomItem &self, QStringView name) const override
809 {
810 return const_cast<QmlObject *>(this)->field(self, name);
811 }
812 void updatePathFromOwner(Path newPath) override;
815 virtual bool iterateSubOwners(DomItem &self, function_ref<bool(DomItem &owner)> visitor) const;
816
817 QString idStr() const { return m_idStr; }
818 QString name() const { return m_name; }
819 const QList<Path> &prototypePaths() const & { return m_prototypePaths; }
820 Path nextScopePath() const { return m_nextScopePath; }
821 const QMultiMap<QString, PropertyDefinition> &propertyDefs() const & { return m_propertyDefs; }
822 const QMultiMap<QString, Binding> &bindings() const & { return m_bindings; }
823 const QMultiMap<QString, MethodInfo> &methods() const & { return m_methods; }
824 QList<QmlObject> children() const { return m_children; }
825 QList<QmlObject> annotations() const { return m_annotations; }
826
827 void setIdStr(QString id) { m_idStr = id; }
828 void setName(QString name) { m_name = name; }
829 void setDefaultPropertyName(QString name) { m_defaultPropertyName = name; }
830 void setPrototypePaths(QList<Path> prototypePaths) { m_prototypePaths = prototypePaths; }
832 {
833 index_type idx = index_type(m_prototypePaths.indexOf(prototypePath));
834 if (idx == -1) {
835 idx = index_type(m_prototypePaths.size());
836 m_prototypePaths.append(prototypePath);
837 }
838 return Path::Field(Fields::prototypes).index(idx);
839 }
840 void setNextScopePath(Path nextScopePath) { m_nextScopePath = nextScopePath; }
842 {
843 m_propertyDefs = propertyDefs;
844 }
845 void setBindings(QMultiMap<QString, Binding> bindings) { m_bindings = bindings; }
846 void setMethods(QMultiMap<QString, MethodInfo> functionDefs) { m_methods = functionDefs; }
848 {
849 m_children = children;
850 if (pathFromOwner())
851 updatePathFromOwner(pathFromOwner());
852 }
854 {
855 m_annotations = annotations;
856 if (pathFromOwner())
857 updatePathFromOwner(pathFromOwner());
858 }
860 PropertyDefinition **pDef = nullptr)
861 {
862 return insertUpdatableElementInMultiMap(pathFromOwner().field(Fields::propertyDefs),
863 m_propertyDefs, propertyDef.name, propertyDef,
864 option, pDef);
865 }
868
869 Path addBinding(Binding binding, AddOption option, Binding **bPtr = nullptr)
870 {
871 return insertUpdatableElementInMultiMap(pathFromOwner().field(Fields::bindings), m_bindings,
872 binding.name(), binding, option, bPtr);
873 }
875 Path addMethod(MethodInfo functionDef, AddOption option, MethodInfo **mPtr = nullptr)
876 {
877 return insertUpdatableElementInMultiMap(pathFromOwner().field(Fields::methods), m_methods,
878 functionDef.name, functionDef, option, mPtr);
879 }
882 {
883 return appendUpdatableElementInQList(pathFromOwner().field(Fields::children), m_children,
884 child, cPtr);
885 }
887 {
888 Path p = addChild(child);
889 return MutableDomItem(self.owner().item(), p);
890 }
891 Path addAnnotation(const QmlObject &annotation, QmlObject **aPtr = nullptr)
892 {
893 return appendUpdatableElementInQList(pathFromOwner().field(Fields::annotations),
894 m_annotations, annotation, aPtr);
895 }
896 void writeOut(DomItem &self, OutWriter &ow, QString onTarget) const;
897 void writeOut(DomItem &self, OutWriter &lw) const override { writeOut(self, lw, QString()); }
898
900 std::shared_ptr<ScriptExpression> accessSequence) const;
901 LocallyResolvedAlias resolveAlias(DomItem &self, const QStringList &accessSequence) const;
902
903 std::optional<QQmlJSScope::Ptr> semanticScope() const { return m_scope; }
904 void setSemanticScope(const QQmlJSScope::Ptr &scope) { m_scope = scope; }
905
906private:
907 friend class QQmlDomAstCreator;
908 QString m_idStr;
909 QString m_name;
910 QList<Path> m_prototypePaths;
911 Path m_nextScopePath;
912 QString m_defaultPropertyName;
916 QList<QmlObject> m_children;
917 QList<QmlObject> m_annotations;
918 std::optional<QQmlJSScope::Ptr> m_scope;
919};
920
922{
924public:
928 {
929 bool cont = true;
930 cont = cont && self.dvValueField(visitor, Fields::uri, uri);
931 cont = cont && self.dvValueField(visitor, Fields::typeName, typeName);
932 cont = cont && self.dvWrapField(visitor, Fields::version, version);
933 if (typePath)
934 cont = cont && self.dvReferenceField(visitor, Fields::type, typePath);
935 cont = cont && self.dvValueField(visitor, Fields::isInternal, isInternal);
936 cont = cont && self.dvValueField(visitor, Fields::isSingleton, isSingleton);
938 cont = cont && self.dvReferenceField(visitor, Fields::exportSource, exportSourcePath);
939 return cont;
940 }
941
947 bool isInternal = false;
948 bool isSingleton = false;
949};
950
952{
953public:
955 Component(Path pathFromOwner = Path());
956 Component(const Component &o) = default;
957 Component &operator=(const Component &) = default;
958
959 bool iterateDirectSubpaths(DomItem &, DirectVisitor) override;
960 void updatePathFromOwner(Path newPath) override;
961 DomItem field(DomItem &self, QStringView name) const override
962 {
963 return const_cast<Component *>(this)->field(self, name);
964 }
965 DomItem field(DomItem &self, QStringView name);
966
967 QString name() const { return m_name; }
968 const QMultiMap<QString, EnumDecl> &enumerations() const & { return m_enumerations; }
969 const QList<QmlObject> &objects() const & { return m_objects; }
970 bool isSingleton() const { return m_isSingleton; }
971 bool isCreatable() const { return m_isCreatable; }
972 bool isComposite() const { return m_isComposite; }
973 QString attachedTypeName() const { return m_attachedTypeName; }
974 Path attachedTypePath(DomItem &) const { return m_attachedTypePath; }
975
976 void setName(QString name) { m_name = name; }
978 {
979 m_enumerations = enumerations;
980 }
981 Path addEnumeration(const EnumDecl &enumeration, AddOption option = AddOption::Overwrite,
982 EnumDecl **ePtr = nullptr)
983 {
984 return insertUpdatableElementInMultiMap(pathFromOwner().field(Fields::enumerations),
985 m_enumerations, enumeration.name(), enumeration,
986 option, ePtr);
987 }
988 void setObjects(QList<QmlObject> objects) { m_objects = objects; }
989 Path addObject(const QmlObject &object, QmlObject **oPtr = nullptr);
990 void setIsSingleton(bool isSingleton) { m_isSingleton = isSingleton; }
991 void setIsCreatable(bool isCreatable) { m_isCreatable = isCreatable; }
992 void setIsComposite(bool isComposite) { m_isComposite = isComposite; }
993 void setAttachedTypeName(QString name) { m_attachedTypeName = name; }
994 void setAttachedTypePath(Path p) { m_attachedTypePath = p; }
995
996private:
997 friend class QQmlDomAstCreator;
998 QString m_name;
999 QMultiMap<QString, EnumDecl> m_enumerations;
1000 QList<QmlObject> m_objects;
1001 bool m_isSingleton = false;
1002 bool m_isCreatable = true;
1003 bool m_isComposite = true;
1004 QString m_attachedTypeName;
1005 Path m_attachedTypePath;
1006};
1007
1009{
1010public:
1011 constexpr static DomType kindValue = DomType::JsResource;
1012 DomType kind() const override { return kindValue; }
1013
1014 JsResource(Path pathFromOwner = Path()) : Component(pathFromOwner) { }
1016 { // to do: complete
1017 return true;
1018 }
1019 // globalSymbols defined/exported, required/used
1020};
1021
1023{
1024public:
1025 constexpr static DomType kindValue = DomType::QmltypesComponent;
1026 DomType kind() const override { return kindValue; }
1027
1028 QmltypesComponent(Path pathFromOwner = Path()) : Component(pathFromOwner) { }
1030 const QList<Export> &exports() const & { return m_exports; }
1031 QString fileName() const { return m_fileName; }
1032 void setExports(QList<Export> exports) { m_exports = exports; }
1033 void addExport(const Export &exportedEntry) { m_exports.append(exportedEntry); }
1034 void setFileName(QString fileName) { m_fileName = fileName; }
1035 const QList<int> &metaRevisions() const & { return m_metaRevisions; }
1036 void setMetaRevisions(QList<int> metaRevisions) { m_metaRevisions = metaRevisions; }
1037 void setInterfaceNames(const QStringList& interfaces) { m_interfaceNames = interfaces; }
1038 const QStringList &interfaceNames() const & { return m_interfaceNames; }
1039 QString extensionTypeName() const { return m_extensionTypeName; }
1040 void setExtensionTypeName(const QString &name) { m_extensionTypeName = name; }
1041 QString valueTypeName() const { return m_valueTypeName; }
1042 void setValueTypeName(const QString &name) { m_valueTypeName = name; }
1043 bool hasCustomParser() const { return m_hasCustomParser; }
1044 void setHasCustomParser(bool v) { m_hasCustomParser = v; }
1045 bool extensionIsNamespace() const { return m_extensionIsNamespace; }
1046 void setExtensionIsNamespace(bool v) { m_extensionIsNamespace = v; }
1047 QQmlJSScope::AccessSemantics accessSemantics() const { return m_accessSemantics; }
1049private:
1050 QList<Export> m_exports;
1051 QList<int> m_metaRevisions;
1052 QString m_fileName; // remove?
1053 QStringList m_interfaceNames;
1054 bool m_hasCustomParser = false;
1055 bool m_extensionIsNamespace = false;
1056 QString m_valueTypeName;
1057 QString m_extensionTypeName;
1058 QQmlJSScope::AccessSemantics m_accessSemantics;
1059};
1060
1062{
1063public:
1064 constexpr static DomType kindValue = DomType::QmlComponent;
1065 DomType kind() const override { return kindValue; }
1066
1068 {
1069 setIsComposite(true);
1070 setIsCreatable(true);
1071 }
1072
1074 : Component(o), m_nextComponentPath(o.m_nextComponentPath), m_ids(o.m_ids)
1075 {
1076 }
1078
1079 bool iterateDirectSubpaths(DomItem &self, DirectVisitor) override;
1080
1081 const QMultiMap<QString, Id> &ids() const & { return m_ids; }
1082 Path nextComponentPath() const { return m_nextComponentPath; }
1084 void setNextComponentPath(Path p) { m_nextComponentPath = p; }
1085 void updatePathFromOwner(Path newPath) override;
1086 Path addId(const Id &id, AddOption option = AddOption::Overwrite, Id **idPtr = nullptr)
1087 {
1088 // warning does nor remove old idStr when overwriting...
1089 return insertUpdatableElementInMultiMap(pathFromOwner().field(Fields::ids), m_ids, id.name,
1090 id, option, idPtr);
1091 }
1092 void writeOut(DomItem &self, OutWriter &) const override;
1093 QList<QString> subComponentsNames(DomItem &self) const;
1094 QList<DomItem> subComponents(DomItem &self) const;
1095
1096 void setSemanticScope(const QQmlJSScope::Ptr &scope) { m_semanticScope = scope; }
1097 std::optional<QQmlJSScope::Ptr> semanticScope() { return m_semanticScope; }
1098
1099private:
1100 friend class QQmlDomAstCreator;
1101 Path m_nextComponentPath;
1103 std::optional<QQmlJSScope::Ptr> m_semanticScope;
1104};
1105
1107{
1108public:
1109 constexpr static DomType kindValue = DomType::GlobalComponent;
1110 DomType kind() const override { return kindValue; }
1111
1112 GlobalComponent(Path pathFromOwner = Path()) : Component(pathFromOwner) { }
1113};
1114
1116
1118{
1120public:
1121 constexpr static DomType kindValue = DomType::ImportScope;
1122
1123 ImportScope() = default;
1124 ~ImportScope() = default;
1125
1126 const QList<Path> &importSourcePaths() const & { return m_importSourcePaths; }
1127
1128 const QMap<QString, ImportScope> &subImports() const & { return m_subImports; }
1129
1131
1133 {
1135 for (Path p : allSources(self)) {
1136 QSet<QString> ks = self.path(p.field(Fields::exports), self.errorHandler()).keys();
1137 res += ks;
1138 }
1139 return res;
1140 }
1141
1143 {
1145 for (Path p : allSources(self)) {
1146 DomItem source = self.path(p.field(Fields::exports), self.errorHandler());
1147 DomItem els = source.key(name);
1148 int nEls = els.indexes();
1149 for (int i = 0; i < nEls; ++i)
1150 res.append(els.index(i));
1151 if (nEls == 0 && els) {
1152 self.addError(importErrors.warning(
1153 tr("Looking up '%1' expected a list of exports, not %2")
1154 .arg(name, els.toString())));
1155 }
1156 }
1157 return res;
1158 }
1159
1161 {
1163 for (DomItem &i : importedItemsWithName(self, name))
1164 if (const Export *e = i.as<Export>())
1165 res.append(*e);
1166 else
1167 self.addError(importErrors.warning(
1168 tr("Expected Export looking up '%1', not %2").arg(name, i.toString())));
1169 return res;
1170 }
1171
1173
1174 void addImport(QStringList p, Path targetExports)
1175 {
1176 if (!p.isEmpty()) {
1177 QString current = p.takeFirst();
1178 m_subImports[current].addImport(p, targetExports);
1179 } else if (!m_importSourcePaths.contains(targetExports)) {
1180 m_importSourcePaths.append(targetExports);
1181 }
1182 }
1183
1184private:
1185 QList<Path> m_importSourcePaths;
1186 QMap<QString, ImportScope> m_subImports;
1187};
1188
1190{
1191public:
1194 BindingValue(std::shared_ptr<ScriptExpression> o);
1199
1202
1203private:
1204 friend class Binding;
1205 void clearValue();
1206
1207 BindingValueKind kind;
1208 union {
1211 std::shared_ptr<ScriptExpression> scriptExpression;
1213 };
1214};
1215
1216} // end namespace Dom
1217} // end namespace QQmlJS
1219#endif // QQMLDOMELEMENTS_P_H
constexpr bool isUpper() const noexcept
Returns true if the character is an uppercase letter, for example category() is Letter_Uppercase.
Definition qchar.h:475
Definition qlist.h:74
Definition qmap.h:186
\inmodule QtCore
Definition qmutex.h:317
Associates comments with AST::Node *.
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor)
void updatePathFromOwner(Path newPath)
Path addAnnotation(Path selfPathFromOwner, const QmlObject &annotation, QmlObject **aPtr=nullptr)
BindingValue(const QList< QmlObject > &l)
DomItem value(DomItem &binding)
void updatePathFromOwner(Path newPath)
BindingValue(const BindingValue &o)
BindingValue & operator=(const BindingValue &o)
std::shared_ptr< ScriptExpression > scriptExpression
BindingValue(const QmlObject &o)
BindingValue(std::shared_ptr< ScriptExpression > o)
void setValue(std::unique_ptr< BindingValue > &&value)
void setAnnotations(QList< QmlObject > annotations)
BindingType bindingType() const
std::shared_ptr< ScriptExpression > scriptExpressionValue() const
RegionComments & comments()
Binding & operator=(const Binding &)
Path addAnnotation(Path selfPathFromOwner, const QmlObject &a, QmlObject **aPtr=nullptr)
QList< QmlObject > annotations() const
Binding(QString m_name, QmlObject value, BindingType bindingType=BindingType::Normal)
static QString preCodeForName(QStringView n)
Binding(QString m_name, QList< QmlObject > value, BindingType bindingType=BindingType::Normal)
Binding(QString m_name=QString(), std::unique_ptr< BindingValue > value=std::unique_ptr< BindingValue >(), BindingType bindingType=BindingType::Normal)
QmlObject const * objectValue() const
Binding(QString m_name, std::shared_ptr< ScriptExpression > value, BindingType bindingType=BindingType::Normal)
QList< QmlObject > * arrayValue()
Binding(const Binding &o)
QList< QmlObject > const * arrayValue() const
static QString postCodeForName(QStringView)
void writeOutValue(DomItem &self, OutWriter &lw) const
Binding & operator=(Binding &&)=default
const RegionComments & comments() const
DomItem valueItem(DomItem &self) const
Binding(Binding &&o)=default
QmlObject * objectValue()
std::shared_ptr< ScriptExpression > scriptExpressionValue()
Binding(QString m_name, QString scriptCode, BindingType bindingType=BindingType::Normal)
BindingValueKind valueKind() const
void updatePathFromOwner(Path newPath)
bool iterateDirectSubpaths(DomItem &self, DirectVisitor)
void writeOut(DomItem &self, OutWriter &lw) const
const RegionComments & comments() const
CommentableDomElement & operator=(const CommentableDomElement &o)=default
CommentableDomElement(Path pathFromOwner=Path())
CommentableDomElement(const CommentableDomElement &o)
void setName(QString name)
void setIsSingleton(bool isSingleton)
void setIsComposite(bool isComposite)
Component & operator=(const Component &)=default
void setIsCreatable(bool isCreatable)
const QMultiMap< QString, EnumDecl > & enumerations() const &
Component(const Component &o)=default
void setEnumerations(QMultiMap< QString, EnumDecl > enumerations)
void setAttachedTypeName(QString name)
Path attachedTypePath(DomItem &) const
DomItem field(DomItem &self, QStringView name) const override
Path addEnumeration(const EnumDecl &enumeration, AddOption option=AddOption::Overwrite, EnumDecl **ePtr=nullptr)
void setObjects(QList< QmlObject > objects)
QString attachedTypeName() const
const QList< QmlObject > & objects() const &
static ErrorGroup domErrorGroup
DomItem key(QString name)
index_type indexes()
DomItem index(index_type)
const QList< QmlObject > & annotations() const &
void setAnnotations(QList< QmlObject > annotations)
void setValues(QList< EnumItem > values)
const QList< EnumItem > & values() const &
void updatePathFromOwner(Path newP) override
Path addValue(EnumItem value)
void setAlias(QString aliasName)
void setName(QString name)
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor) override
Path addAnnotation(const QmlObject &child, QmlObject **cPtr=nullptr)
void writeOut(DomItem &self, OutWriter &lw) const override
DomType kind() const override
EnumDecl(QString name=QString(), QList< EnumItem > values=QList< EnumItem >(), Path pathFromOwner=Path())
void writeOut(DomItem &self, OutWriter &lw) const
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor)
const RegionComments & comments() const
EnumItem(QString name=QString(), int value=0)
RegionComments & comments()
Represents a set of tags grouping a set of related error messages.
ErrorMessage warning(QString message) const
static Export fromString(Path source, QStringView exp, Path typePath, ErrorHandler h)
static constexpr DomType kindValue
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor)
DomType kind() const override
GlobalComponent(Path pathFromOwner=Path())
RegionComments comments
std::shared_ptr< ScriptExpression > value
Path addAnnotation(Path selfPathFromOwner, const QmlObject &ann, QmlObject **aPtr=nullptr)
bool iterateDirectSubpaths(DomItem &self, DirectVisitor)
void updatePathFromOwner(Path pathFromOwner)
Id(QString idName=QString(), Path referredObject=Path())
QList< QmlObject > annotations
const QList< Path > & importSourcePaths() const &
const QMap< QString, ImportScope > & subImports() const &
QList< Path > allSources(DomItem &self) const
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor)
void addImport(QStringList p, Path targetExports)
QList< DomItem > importedItemsWithName(DomItem &self, QString name) const
QList< Export > importedExportsWithName(DomItem &self, QString name) const
QSet< QString > importedNames(DomItem &self) const
Import(QmlUri uri=QmlUri(), Version version=Version(), QString importId=QString())
bool iterateDirectSubpaths(DomItem &self, DirectVisitor)
Import baseImport() const
friend bool operator==(const Import &i1, const Import &i2)
static Import fromUriString(QString importStr, Version v=Version(), QString importId=QString(), ErrorHandler handler=nullptr)
void writeOut(DomItem &self, OutWriter &ow) const
static Import fromFileString(QString importStr, QString importId=QString(), ErrorHandler handler=nullptr)
friend bool operator!=(const Import &i1, const Import &i2)
DomType kind() const override
bool iterateDirectSubpaths(DomItem &, DirectVisitor) override
JsResource(Path pathFromOwner=Path())
std::shared_ptr< ScriptExpression > body
std::optional< QQmlJSScope::Ptr > semanticScope() const
void writeOut(DomItem &self, OutWriter &ow) const
void writePre(DomItem &self, OutWriter &ow) const
std::optional< QQmlJSScope::Ptr > m_semanticScope
QList< MethodParameter > parameters
QString postCode(DomItem &) const
std::shared_ptr< ScriptExpression > returnType
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor)
QString preCode(DomItem &) const
void setCode(QString code)
void setSemanticScope(QQmlJSScope::Ptr scope)
void writeOut(DomItem &self, OutWriter &ow) const
std::shared_ptr< ScriptExpression > defaultValue
void writeOutSignal(DomItem &self, OutWriter &ow) const
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor)
std::shared_ptr< ScriptExpression > value
friend bool operator==(const ModuleAutoExport &i1, const ModuleAutoExport &i2)
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor)
friend bool operator!=(const ModuleAutoExport &i1, const ModuleAutoExport &i2)
static Path Root(PathRoot r)
Path key(QString name) const
Path field(QString name) const
Path index(index_type i) const
static Path Current(PathCurrent c)
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor)
void writeOut(DomItem &self, OutWriter &ow) const
Pragma(QString pragmaName=QString(), const QStringList &pragmaValues={})
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor)
void writeOut(DomItem &self, OutWriter &lw) const
std::optional< QQmlJSScope::Ptr > scope
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor)
void setIds(QMultiMap< QString, Id > ids)
std::optional< QQmlJSScope::Ptr > semanticScope()
const QMultiMap< QString, Id > & ids() const &
void setSemanticScope(const QQmlJSScope::Ptr &scope)
QmlComponent(const QmlComponent &o)
Path addId(const Id &id, AddOption option=AddOption::Overwrite, Id **idPtr=nullptr)
QmlComponent & operator=(const QmlComponent &)=default
DomType kind() const override
QmlComponent(QString name=QString())
void setDefaultPropertyName(QString name)
LocallyResolvedAlias resolveAlias(DomItem &self, std::shared_ptr< ScriptExpression > accessSequence) const
void setNextScopePath(Path nextScopePath)
MutableDomItem addBinding(MutableDomItem &self, Binding binding, AddOption option)
void setChildren(QList< QmlObject > children)
void setAnnotations(QList< QmlObject > annotations)
MutableDomItem addChild(MutableDomItem &self, QmlObject child)
void setBindings(QMultiMap< QString, Binding > bindings)
QmlObject(Path pathFromOwner=Path())
Path addChild(QmlObject child, QmlObject **cPtr=nullptr)
const QMultiMap< QString, Binding > & bindings() const &
DomType kind() const override
Path addPropertyDef(PropertyDefinition propertyDef, AddOption option, PropertyDefinition **pDef=nullptr)
void setName(QString name)
Path addAnnotation(const QmlObject &annotation, QmlObject **aPtr=nullptr)
QList< QmlObject > children() const
std::optional< QQmlJSScope::Ptr > semanticScope() const
const QList< Path > & prototypePaths() const &
const QMultiMap< QString, MethodInfo > & methods() const &
QList< QString > fields(DomItem &) const override
Path addBinding(Binding binding, AddOption option, Binding **bPtr=nullptr)
DomItem field(DomItem &self, QStringView name)
void writeOut(DomItem &self, OutWriter &ow, QString onTarget) const
DomItem field(DomItem &self, QStringView name) const override
virtual bool iterateSubOwners(DomItem &self, function_ref< bool(DomItem &owner)> visitor) const
QString localDefaultPropertyName() const
void setPropertyDefs(QMultiMap< QString, PropertyDefinition > propertyDefs)
bool iterateDirectSubpaths(DomItem &self, DirectVisitor) override
bool iterateBaseDirectSubpaths(DomItem &self, DirectVisitor)
MutableDomItem addMethod(MutableDomItem &self, MethodInfo functionDef, AddOption option)
LocallyResolvedAlias resolveAlias(DomItem &self, const QStringList &accessSequence) const
void writeOut(DomItem &self, OutWriter &lw) const override
Path addMethod(MethodInfo functionDef, AddOption option, MethodInfo **mPtr=nullptr)
const QMultiMap< QString, PropertyDefinition > & propertyDefs() const &
Path addPrototypePath(Path prototypePath)
MutableDomItem addPropertyDef(MutableDomItem &self, PropertyDefinition propertyDef, AddOption option)
QList< QmlObject > annotations() const
QList< QString > fields() const
void setPrototypePaths(QList< Path > prototypePaths)
void setMethods(QMultiMap< QString, MethodInfo > functionDefs)
void updatePathFromOwner(Path newPath) override
void setSemanticScope(const QQmlJSScope::Ptr &scope)
QString defaultPropertyName(DomItem &self) const
Kind kind() const
QString absoluteLocalPath(const QString &basePath=QString()) const
static QmlUri fromDirectoryString(const QString &importStr)
QUrl directoryUrl() const
QString directoryString() const
static QmlUri fromUriString(const QString &importStr)
bool isValid() const
QString toString() const
bool isDirectory() const
QString localPath() const
bool isModule() const
static QmlUri fromString(const QString &importStr)
QString moduleUri() const
friend bool operator==(const QmlUri &i1, const QmlUri &i2)
friend bool operator!=(const QmlUri &i1, const QmlUri &i2)
void setValueTypeName(const QString &name)
void setFileName(QString fileName)
void setInterfaceNames(const QStringList &interfaces)
bool iterateDirectSubpaths(DomItem &, DirectVisitor) override
QQmlJSScope::AccessSemantics accessSemantics() const
void setAccessSemantics(QQmlJSScope::AccessSemantics v)
QmltypesComponent(Path pathFromOwner=Path())
void setExports(QList< Export > exports)
void setMetaRevisions(QList< int > metaRevisions)
void setExtensionTypeName(const QString &name)
const QList< int > & metaRevisions() const &
const QList< Export > & exports() const &
void addExport(const Export &exportedEntry)
const QStringList & interfaceNames() const &
DomType kind() const override
Keeps the comments associated with a DomItem.
Use this to contain any script element.
DomType kind() const override
std::shared_ptr< AstComments > astComments() const
std::shared_ptr< QQmlJS::Engine > engine() const
std::shared_ptr< ScriptExpression > makeCopy(DomItem &self) const
Path canonicalPath(DomItem &self) const override
std::function< SourceLocation(SourceLocation)> locationToLocalF(DomItem &) const
std::shared_ptr< ScriptExpression > copyWithUpdatedCode(DomItem &self, QString code) const
ScriptExpression(const ScriptExpression &e)
ExpressionType expressionType() const
bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor) override
QString astRelocatableDump() const
ScriptExpression(QString code, ExpressionType expressionType, int derivedFrom=0, QString preCode=QString(), QString postCode=QString())
void setScriptElement(const ScriptElementVariant &p)
void astDumper(Sink s, AstDumperOptions options) const
std::function< SourceLocation(SourceLocation)> locationToGlobalF(DomItem &self) const
SourceLocation locationToLocal(SourceLocation x) const
std::shared_ptr< OwningItem > doCopy(DomItem &) const override
ScriptElementVariant scriptElement()
SourceLocation localOffset() const
SourceLocation globalLocation(DomItem &self) const
ScriptExpression(QStringView code, std::shared_ptr< QQmlJS::Engine > engine, AST::Node *ast, std::shared_ptr< AstComments > comments, ExpressionType expressionType, SourceLocation localOffset=SourceLocation(), int derivedFrom=0, QStringView preCode=QStringView(), QStringView postCode=QStringView())
void writeOut(DomItem &self, OutWriter &lw) const override
QString majorString() const
int compare(const Version &o) const
QString minorString() const
QString majorSymbolicString() const
\inmodule QtCore \reentrant
Definition qset.h:18
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:76
QString toString() const
Returns a deep copy of this string view's data as a QString.
Definition qstring.h:1014
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition qstring.cpp:5299
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.
Definition qstring.cpp:7956
qsizetype size() const
Returns the number of characters in this string.
Definition qstring.h:182
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
Definition qstring.h:1079
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
QString & append(QChar c)
Definition qstring.cpp:3227
\inmodule QtCore
Definition qurl.h:94
double e
Path lookupPropertyPath(QString name)
Path qmlFilePath(QString canonicalFilePath)
Path moduleScopePath(QString uri, Version version, ErrorHandler)
Path loadInfoPath(Path el)
Path jsFilePath(QString path)
Path qmldirFilePath(QString path)
Path lookupSymbolPath(QString name)
Path qmltypesFilePath(QString path)
Path qmlDirectoryInfoPath(QString path)
Path lookupCppTypePath(QString name)
Path jsFileInfoPath(QString path)
Path qmldirFileInfoPath(QString path)
Path qmlDirectoryPath(QString path)
Path qmlDirPath(QString path)
Path qmlDirInfoPath(QString path)
Path qmlFileInfoPath(QString canonicalFilePath)
Path lookupTypePath(QString name)
Path qmltypesFileInfoPath(QString path)
Path globalScopePath(QString name)
Path globalScopeInfoPath(QString name)
Path moduleIndexPath(QString uri, int majorVersion, ErrorHandler errorHandler)
Path qmlFileObjectPath(QString canonicalFilePath)
std::function< void(const ErrorMessage &)> ErrorHandler
bool operator!=(const Version &v1, const Version &v2)
Path insertUpdatableElementInMultiMap(Path mapPathFromOwner, QMultiMap< K, T > &mmap, K key, const T &value, AddOption option=AddOption::KeepExisting, T **valuePtr=nullptr)
qint64 index_type
bool operator>(const Version &v1, const Version &v2)
bool operator>=(const Version &v1, const Version &v2)
bool operator==(const Version &v1, const Version &v2)
bool operator<=(const Version &v1, const Version &v2)
bool operator<(const Version &v1, const Version &v2)
static ErrorGroups importErrors
Path appendUpdatableElementInQList(Path listPathFromOwner, QList< T > &list, const T &value, T **vPtr=nullptr)
AccessSemantics
Definition qqmlsa_p.h:40
Combined button and popup list for selecting options.
#define Q_DECLARE_TR_FUNCTIONS(context)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
@ Invalid
const char * typeName
GLint GLfloat GLfloat GLfloat v2
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLenum GLsizei const GLuint * ids
GLenum GLuint id
[7]
GLenum access
GLint GLfloat GLfloat v1
GLuint name
GLfloat n
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLchar * source
GLuint res
const GLubyte * c
GLsizei const GLchar *const * path
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLuint GLenum option
#define QMLDOM_EXPORT
#define NewErrorGroup(name)
static bool fromString(const QMetaObject *mo, QString s, Allocate &&allocate)
static bool isComposite(const QQmlJSScope::ConstPtr &scope)
#define Q_ASSERT_X(cond, x, msg)
Definition qrandom.cpp:48
SSL_CTX int(*) void arg)
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define QStringLiteral(str)
#define tr(X)
#define Q_ENUM(x)
#define Q_GADGET
int qint32
Definition qtypes.h:44
ReturnedValue read(const char *data)
gzip write("uncompressed data")
QStringList keys
QUrl url("example.com")
[constructor-url-reference]
QObject::connect nullptr
QMutex mutex
[2]
QLayoutItem * child
[0]
QJSEngine engine
[0]
QStringView el
\inmodule QtCore \reentrant
Definition qchar.h:17