Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmldommock_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 QQMLDOMMOCK_P_H
5#define QQMLDOMMOCK_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"
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 <functional>
32#include <limits>
33
35
36namespace QQmlJS {
37namespace Dom {
38
39// mainly for debugging purposes
40class MockObject final : public CommentableDomElement
41{
42public:
44 DomType kind() const override { return kindValue; }
45
46 MockObject(const Path &pathFromOwner = Path(), QMap<QString, MockObject> subObjects = {},
47 QMap<QString, QCborValue> subValues = {})
49 {
50 }
51
52 MockObject copy() const;
54
55 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override;
56
59};
60
61// mainly for debugging purposes
62class MockOwner final : public OwningItem
63{
64protected:
65 std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override;
66
67public:
69 DomType kind() const override { return kindValue; }
70
71 MockOwner(const Path &pathFromTop = Path(), int derivedFrom = 0,
72 QMap<QString, MockObject> subObjects = {}, QMap<QString, QCborValue> subValues = {},
76 : OwningItem(derivedFrom),
83 {
84 }
85
86 MockOwner(const Path &pathFromTop, int derivedFrom, QDateTime dataRefreshedAt,
87 QMap<QString, MockObject> subObjects = {}, QMap<QString, QCborValue> subValues = {})
88 : OwningItem(derivedFrom, dataRefreshedAt),
92 {
93 }
94
95 MockOwner(const MockOwner &o);
96
97 std::shared_ptr<MockOwner> makeCopy(const DomItem &self) const;
98 Path canonicalPath(const DomItem &self) const override;
99
100 bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override;
101
108};
109
110} // end namespace Dom
111} // end namespace QQmlJS
112QT_END_NAMESPACE
113#endif // QQMLDOMELEMENTS_P_H
QMultiMap< quint32, const QList< Comment > * > allCommentsInNode(AST::Node *n)
void updatePathFromOwner(const Path &newPath)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
Path addAnnotation(const Path &selfPathFromOwner, const QmlObject &annotation, QmlObject **aPtr=nullptr)
BindingValue(const QList< QmlObject > &l)
void updatePathFromOwner(const Path &newPath)
BindingValue(const std::shared_ptr< ScriptExpression > &o)
BindingValue(const BindingValue &o)
DomItem value(const DomItem &binding) const
BindingValue & operator=(const BindingValue &o)
BindingValue(const QmlObject &o)
std::shared_ptr< ScriptExpression > scriptExpressionValue() const
Binding & operator=(const Binding &)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const
Path addAnnotation(const Path &selfPathFromOwner, const QmlObject &a, QmlObject **aPtr=nullptr)
void updatePathFromOwner(const Path &newPath)
QmlObject const * objectValue() const
DomItem valueItem(const DomItem &self) const
QList< QmlObject > * arrayValue()
Binding(const Binding &o)
Binding(const QString &m_name, std::unique_ptr< BindingValue > value, BindingType bindingType=BindingType::Normal)
QList< QmlObject > const * arrayValue() const
void writeOut(const DomItem &self, OutWriter &lw) const
Binding(const QString &m_name, const QString &scriptCode, BindingType bindingType=BindingType::Normal)
void writeOutValue(const DomItem &self, OutWriter &lw) const
Binding(const QString &m_name=QString())
Binding(const QString &m_name, const QmlObject &value, BindingType bindingType=BindingType::Normal)
QmlObject * objectValue()
std::shared_ptr< ScriptExpression > scriptExpressionValue()
BindingValueKind valueKind() const
Binding(const QString &m_name, const std::shared_ptr< ScriptExpression > &value, BindingType bindingType=BindingType::Normal)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
CommentableDomElement(const Path &pathFromOwner=Path())
void updatePathFromOwner(const Path &newPath) override
Component(const Path &pathFromOwner=Path())
Path addObject(const QmlObject &object, QmlObject **oPtr=nullptr)
Path attachedTypePath(const DomItem &) const
DomItem field(const DomItem &self, QStringView name) const override
bool iterateDirectSubpaths(const DomItem &, DirectVisitor) const override
Component(const QString &name)
virtual void updatePathFromOwner(const Path &newPath)
static ErrorGroup domErrorGroup
DomItem owner() const
DomItem environment() const
Path pathFromOwner() const
DomItem containingObject() const
DomItem path(const Path &p, const ErrorHandler &h=&defaultErrorHandler) const
DomItem subReferenceItem(const PathEls::PathComponent &c, const Path &referencedObject) const
DomItem top() const
DomItem subMapItem(const Map &map) const
InternalKind internalKind() const
Path canonicalPath() const
void writeOut(OutWriter &lw) const
void writeOutPost(OutWriter &lw) const
void writeOutPre(OutWriter &lw) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override
void setAnnotations(const QList< QmlObject > &annotations)
void writeOut(const DomItem &self, OutWriter &lw) const override
void updatePathFromOwner(const Path &newP) override
Path addAnnotation(const QmlObject &child, QmlObject **cPtr=nullptr)
void writeOut(const DomItem &self, OutWriter &lw) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
Represents a set of tags grouping a set of related error messages.
ErrorMessage warning(const Dumper &message) const
ErrorMessage error(const Dumper &message) const
Represents and maintains a mapping between elements and their location in a file.
Path addAnnotation(const Path &selfPathFromOwner, const QmlObject &ann, QmlObject **aPtr=nullptr)
Id(const QString &idName=QString(), const Path &referredObject=Path())
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const
void updatePathFromOwner(const Path &pathFromOwner)
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
QList< Path > allSources(const DomItem &self) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const
void writeOut(const DomItem &self, OutWriter &ow) const
void eof(bool ensureNewline=true)
void writeOut(const DomItem &self, OutWriter &ow, bool compact) const
Path typePath(const DomItem &) const
QString postCode(const DomItem &) const
QString preCode(const DomItem &) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
void writeOut(const DomItem &self, OutWriter &ow) const
QString signature(const DomItem &self) const
void writeOut(const DomItem &self, OutWriter &ow) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
void writeOutSignal(const DomItem &self, OutWriter &ow) const
TypeAnnotationStyle typeAnnotationStyle
MockObject(const Path &pathFromOwner=Path(), QMap< QString, MockObject > subObjects={}, QMap< QString, QCborValue > subValues={})
QMap< QString, MockObject > subObjects
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
DomType kind() const override
MockObject copy() const
std::pair< QString, MockObject > asStringPair() const
static constexpr DomType kindValue
QMap< QString, QCborValue > subValues
QMap< QString, MockObject > subObjects
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
std::shared_ptr< OwningItem > doCopy(const DomItem &self) const override
std::shared_ptr< MockOwner > makeCopy(const DomItem &self) const
MockOwner(const MockOwner &o)
Path canonicalPath(const DomItem &self) const override
static constexpr DomType kindValue
QMap< QString, QMap< QString, MockObject > > subMaps
QMap< QString, QCborValue > subValues
DomType kind() const override
MockOwner(const Path &pathFromTop=Path(), int derivedFrom=0, QMap< QString, MockObject > subObjects={}, QMap< QString, QCborValue > subValues={}, QMap< QString, QMap< QString, MockObject > > subMaps={}, QMap< QString, QMultiMap< QString, MockObject > > subMultiMaps={}, QMap< QString, QList< MockObject > > subLists={})
MutableDomItem path(const Path &p)
OutWriter & ensureNewline(int nNewlines=1)
int increaseIndent(int level=1)
int decreaseIndent(int level=1, int expectedIndent=-1)
void itemStart(const DomItem &it)
void eof(bool ensureNewline=true)
void itemEnd(const DomItem &it)
int addNewlinesAutospacerCallback(int nLines)
void addErrorLocal(ErrorMessage &&msg)
OwningItem(int derivedFrom=0)
static Path Root(PathRoot r)
Path operator[](int i) const
Path last() const
void writeOut(const DomItem &self, OutWriter &ow) const
void writeOut(const DomItem &self, OutWriter &lw) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
QList< DomItem > subComponents(const DomItem &self) const
void updatePathFromOwner(const Path &newPath) override
void writeOut(const DomItem &self, OutWriter &) const override
QList< QString > subComponentsNames(const DomItem &self) const
void writeOut(const DomItem &self, OutWriter &ow, const QString &onTarget) const
MutableDomItem addBinding(MutableDomItem &self, Binding binding, AddOption option)
void updatePathFromOwner(const Path &newPath) override
static constexpr DomType kindValue
void writeOutSortedEnumerations(const DomItem &component, OutWriter &ow) const
LocallyResolvedAlias resolveAlias(const DomItem &self, std::shared_ptr< ScriptExpression > accessSequence) const
void writeOutId(const DomItem &self, OutWriter &ow) const
LocallyResolvedAlias resolveAlias(const DomItem &self, const QStringList &accessSequence) const
virtual bool iterateSubOwners(const DomItem &self, function_ref< bool(const DomItem &owner)> visitor) const
void writeOutSortedPropertyDefinition(const DomItem &self, OutWriter &ow, QSet< QString > &mergedDefBinding) const
Path addPropertyDef(const PropertyDefinition &propertyDef, AddOption option, PropertyDefinition **pDef=nullptr)
Path addBinding(Binding binding, AddOption option, Binding **bPtr=nullptr)
MutableDomItem addPropertyDef(MutableDomItem &self, const PropertyDefinition &propertyDef, AddOption option)
DomItem field(const DomItem &self, QStringView name) const override
QString localDefaultPropertyName() const
QString defaultPropertyName(const DomItem &self) const
QmlObject(const Path &pathFromOwner=Path())
void writeOutSortedAttributes(const DomItem &self, OutWriter &ow, const DomItem &component) const
MutableDomItem addMethod(MutableDomItem &self, const MethodInfo &functionDef, AddOption option)
void writeOutAttributes(const DomItem &self, OutWriter &ow, const DomItem &component, const QString &code) const
QList< QPair< SourceLocation, DomItem > > orderOfAttributes(const DomItem &self, const DomItem &component) const
QList< QString > fields() const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override
Path addMethod(const MethodInfo &functionDef, AddOption option, MethodInfo **mPtr=nullptr)
bool iterateBaseDirectSubpaths(const DomItem &self, DirectVisitor) const
Kind kind() const
QString absoluteLocalPath(const QString &basePath=QString()) const
QUrl directoryUrl() const
QString directoryString() const
bool isValid() const
QString toString() const
bool isDirectory() const
QString localPath() const
bool isModule() const
QString moduleUri() const
bool iterateDirectSubpaths(const DomItem &, DirectVisitor) const override
Use this to contain any script element.
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override
ScriptExpression(const ScriptExpression &e)
void writeOut(const DomItem &self, OutWriter &lw) const override
SourceLocation globalLocation(const DomItem &self) const
QString astRelocatableDump() const
void setScriptElement(const ScriptElementVariant &p)
void astDumper(const Sink &s, AstDumperOptions options) const
ScriptExpression(QStringView code, const std::shared_ptr< QQmlJS::Engine > &engine, AST::Node *ast, const std::shared_ptr< AstComments > &comments, ExpressionType expressionType, SourceLocation localOffset=SourceLocation(), int derivedFrom=0, QStringView preCode=QStringView(), QStringView postCode=QStringView())
std::shared_ptr< ScriptExpression > copyWithUpdatedCode(const DomItem &self, const QString &code) const
bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const
Version(qint32 majorVersion=Undefined, qint32 minorVersion=Undefined)
QString stringValue() const
A vistor that visits all the AST:Node.
Path moduleIndexPath(const QString &uri, int majorVersion, const ErrorHandler &errorHandler=nullptr)
Path moduleScopePath(const QString &uri, const QString &version, const ErrorHandler &errorHandler=nullptr)
Path moduleScopePath(const QString &uri, Version version, const ErrorHandler &errorHandler=nullptr)
static ErrorGroups domParsingErrors()
Combined button and popup list for selecting options.
#define NewErrorGroup(name)