1// Copyright (C) 2020 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 QQMLDOMCONSTANTS_P_H
5#define QQMLDOMCONSTANTS_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 "qqmldom_global.h"
19
20#include <QtCore/QObject>
21#include <QtCore/QMetaObject>
22#include <QtCore/private/qglobal_p.h>
23
24QT_BEGIN_NAMESPACE
25
26namespace QQmlJS{
27namespace Dom {
28
29Q_NAMESPACE_EXPORT(QMLDOM_EXPORT)
30
31enum class PathRoot {
32 Other,
33 Modules,
34 Cpp,
35 Libs,
36 Top,
37 Env,
38 Universe
39};
40Q_ENUM_NS(PathRoot)
41
42enum class PathCurrent {
43 Other,
44 Obj,
45 ObjChain,
46 ScopeChain,
47 Component,
48 Module,
49 Ids,
50 Types,
51 LookupStrict,
52 LookupDynamic,
53 Lookup
54};
55Q_ENUM_NS(PathCurrent)
56
57enum class Language { QmlQuick1, QmlQuick2, QmlQuick3, QmlCompiled, QmlAnnotation, Qbs };
58Q_ENUM_NS(Language)
59
60enum class ResolveOption{
61 None=0,
62 TraceVisit=0x1 // call the function along all elements of the path, not just for the target (the function might be called even if the target is never reached)
63};
64Q_ENUM_NS(ResolveOption)
65Q_DECLARE_FLAGS(ResolveOptions, ResolveOption)
66Q_DECLARE_OPERATORS_FOR_FLAGS(ResolveOptions)
67
68enum class VisitOption {
69 None = 0,
70 VisitSelf = 0x1, // Visit the start item
71 VisitAdopted = 0x2, // Visit adopted types (but never recurses them)
72 Recurse = 0x4, // recurse non adopted types
73 NoPath = 0x8, // does not generate path consistent with visit
74 Default = VisitOption::VisitSelf | VisitOption::VisitAdopted | VisitOption::Recurse
75};
76Q_ENUM_NS(VisitOption)
77Q_DECLARE_FLAGS(VisitOptions, VisitOption)
78Q_DECLARE_OPERATORS_FOR_FLAGS(VisitOptions)
79
80enum class LookupOption {
81 Normal = 0,
82 Strict = 0x1,
83 VisitTopClassType = 0x2, // static lookup of class (singleton) or attached type, the default is
84 // visiting instance methods
85 SkipFirstScope = 0x4
86};
87Q_ENUM_NS(LookupOption)
88Q_DECLARE_FLAGS(LookupOptions, LookupOption)
89Q_DECLARE_OPERATORS_FOR_FLAGS(LookupOptions)
90
91enum class LookupType { PropertyDef, Binding, Property, Method, Type, CppType, Symbol };
92Q_ENUM_NS(LookupType)
93
94enum class VisitPrototypesOption {
95 Normal = 0,
96 SkipFirst = 0x1,
97 RevisitWarn = 0x2,
98 ManualProceedToScope = 0x4
99};
100Q_ENUM_NS(VisitPrototypesOption)
101Q_DECLARE_FLAGS(VisitPrototypesOptions, VisitPrototypesOption)
102Q_DECLARE_OPERATORS_FOR_FLAGS(VisitPrototypesOptions)
103
104enum class DomKind { Empty, Object, List, Map, Value, ScriptElement };
105Q_ENUM_NS(DomKind)
106
107enum class DomType {
108 Empty, // only for default ctor
109
110 ExternalItemInfo, // base class for anything represented by an actual file
111 ExternalItemPair, // pair of newest version of item, and latest valid update ### REVISIT
112 // ExternalOwningItems refer to an external path and can be shared between environments
113 QmlDirectory, // dir e.g. used for implicit import
114 QmldirFile, // qmldir
115 JsFile, // file
116 QmlFile, // file
117 QmltypesFile, // qmltypes
118 GlobalScope, // language dependent (currently no difference)
119 /* enum A { B, C }
120 * *
121 EnumItem is marked with * */
122 EnumItem,
123
124 // types
125 EnumDecl, // A in above example
126 JsResource, // QML file contains QML object, JSFile contains JsResource
127 QmltypesComponent, // Component inside a qmltypes fles; compared to component it has exported
128 // meta-object revisions; singleton flag; can export multiple names
129 QmlComponent, // "normal" QML file based Component; also can represent inline components
130 GlobalComponent, // component of global object ### REVISIT, try to replace with one of the above
131
132 ModuleAutoExport, // dependent imports to automatically load when a module is imported
133 ModuleIndex, // index for all the imports of a major version
134 ModuleScope, // a specific import with full version
135 ImportScope, // the scope including the types coming from one or more imports
136 Export, // An exported type
137
138 // header stuff
139 Import, // wrapped
140 Pragma,
141
142 // qml elements
143 Id,
144 QmlObject, // the Item in Item {}; also used to represent types in qmltype files
145 ConstantData, // the 2 in "property int i: 2"; can be any generic data in a QML document
146 SimpleObjectWrap, // internal wrapping to give uniform DOMItem access; ### research more
147 ScriptExpression, // wraps an AST script expression as a DOMItem
148 Reference, // reference to another DOMItem; e.g. asking for a type of an object returns a
149 // Reference
150 PropertyDefinition, // _just_ the property definition; without the binding, even if it's one
151 // line
152 Binding, // the part after the ":"
153 MethodParameter,
154 MethodInfo, // container of MethodParameter
155 Version, // wrapped
156 Comment,
157 CommentedElement, // attached to AST if they have pre-/post-comments?
158 RegionComments, // DomItems have attached RegionComments; can attach comments to fine grained
159 // "regions" in a DomItem; like the default keyword of a property definition
160 AstComments, // hash-table from AST node to commented element
161 FileLocations, // mapping from DomItem to file location ### REVISIT: try to move out of
162 // hierarchy?
163 UpdatedScriptExpression, // used in writeOut method when formatting changes ### Revisit: try to
164 // move out of DOM hierarchy
165
166 // convenience collecting types
167 PropertyInfo, // not a DOM Item, just a convenience class
168
169 // Moc objects, mainly for testing ### Try to remove them; replace their usage in tests with
170 // "real" instances
171 MockObject,
172 MockOwner,
173
174 // containers
175 Map,
176 List,
177 ListP,
178
179 // supporting objects
180 LoadInfo, // owning, used inside DomEnvironment ### REVISIT: move out of hierarchy
181 ErrorMessage, // wrapped
182 AttachedInfo, // owning
183
184 // Dom top level
185 DomEnvironment, // a consistent view of modules, types, files, etc.
186 DomUniverse, // a cache of what can be found in the DomEnvironment, contains the latest valid
187 // version for every file/type, etc. + latest overall
188
189 // Dom Script elements
190 // TODO
191 ScriptElementWrap, // internal wrapping to give uniform access of script elements (e.g. for
192 // statement lists)
193 ScriptElementStart, // marker to check if a DomType is a scriptelement or not
194 ScriptBlockStatement = ScriptElementStart,
195 ScriptIdentifierExpression,
196 ScriptLiteral,
197 ScriptForStatement,
198 ScriptIfStatement,
199 ScriptBinaryExpression,
200 ScriptFunctionDeclaration,
201 ScriptVariableDeclaration,
202 ScriptVariableDeclarationEntry,
203 ScriptReturnStatement,
204 ScriptGenericElement,
205 ScriptCallExpression,
206 ScriptParameter,
207 ScriptFormalParameter,
208 ScriptArray,
209 ScriptObject,
210 ScriptProperty,
211 ScriptType,
212 ScriptQualifiedIdentifierExpression,
213 ScriptQualifiedIdentifierBit,
214 ScriptElision,
215 ScriptArrayEntry,
216 ScriptPattern,
217
218 ScriptElementStop, // marker to check if a DomType is a scriptelement or not
219};
220Q_ENUM_NS(DomType)
221
222enum class SimpleWrapOption { None = 0, ValueType = 1 };
223Q_ENUM_NS(SimpleWrapOption)
224Q_DECLARE_FLAGS(SimpleWrapOptions, SimpleWrapOption)
225Q_DECLARE_OPERATORS_FOR_FLAGS(SimpleWrapOptions)
226
227enum class BindingValueKind { Object, ScriptExpression, Array, Empty };
228Q_ENUM_NS(BindingValueKind)
229
230enum class BindingType { Normal, OnBinding };
231Q_ENUM_NS(BindingType)
232
233enum class ListOptions {
234 Normal,
235 Reverse
236};
237Q_ENUM_NS(ListOptions)
238
239enum class LoadOption {
240 DefaultLoad = 0x0,
241 ForceLoad = 0x1,
242};
243Q_ENUM_NS(LoadOption)
244Q_DECLARE_FLAGS(LoadOptions, LoadOption)
245Q_DECLARE_OPERATORS_FOR_FLAGS(LoadOptions)
246
247enum class EscapeOptions{
248 OuterQuotes,
249 NoOuterQuotes
250};
251Q_ENUM_NS(EscapeOptions)
252
253enum class ErrorLevel{
254 Debug = QtMsgType::QtDebugMsg,
255 Info = QtMsgType::QtInfoMsg,
256 Warning = QtMsgType::QtWarningMsg,
257 Error = QtMsgType::QtCriticalMsg,
258 Fatal = QtMsgType::QtFatalMsg
259};
260Q_ENUM_NS(ErrorLevel)
261
262enum class AstDumperOption {
263 None=0,
264 NoLocations=0x1,
265 NoAnnotations=0x2,
266 DumpNode=0x4,
267 SloppyCompare=0x8
268};
269Q_ENUM_NS(AstDumperOption)
270Q_DECLARE_FLAGS(AstDumperOptions, AstDumperOption)
271Q_DECLARE_OPERATORS_FOR_FLAGS(AstDumperOptions)
272
273enum class GoTo {
274 Strict, // never go to an non uniquely defined result
275 MostLikely // if needed go up to the most likely location between multiple options
276};
277Q_ENUM_NS(GoTo)
278
279enum class AddOption { KeepExisting, Overwrite };
280Q_ENUM_NS(AddOption)
281
282enum class FilterUpOptions { ReturnOuter, ReturnOuterNoSelf, ReturnInner };
283Q_ENUM_NS(FilterUpOptions)
284
285enum class WriteOutCheck {
286 None = 0x0,
287 UpdatedDomCompare = 0x1,
288 UpdatedDomStable = 0x2,
289 Reparse = 0x4,
290 ReparseCompare = 0x8,
291 ReparseStable = 0x10,
292 DumpOnFailure = 0x20,
293 All = 0x3F,
294 Default = Reparse | ReparseCompare | ReparseStable
295};
296Q_ENUM_NS(WriteOutCheck)
297Q_DECLARE_FLAGS(WriteOutChecks, WriteOutCheck)
298Q_DECLARE_OPERATORS_FOR_FLAGS(WriteOutChecks)
299
300enum class LocalSymbolsType {
301 None = 0x0,
302 QmlTypes = 0x1,
303 Types = 0x3,
304 Signals = 0x4,
305 Methods = 0xC,
306 Attributes = 0x10,
307 Ids = 0x20,
308 Components = 0x40,
309 Namespaces = 0x80,
310 Globals = 0x100,
311 MethodParameters = 0x200,
312 All = 0x3FF
313};
314Q_ENUM_NS(LocalSymbolsType)
315Q_DECLARE_FLAGS(LocalSymbolsTypes, LocalSymbolsType)
316Q_DECLARE_OPERATORS_FOR_FLAGS(LocalSymbolsTypes)
317
318} // end namespace Dom
319} // end namespace QQmlJS
320
321QT_END_NAMESPACE
322
323#endif // QQMLDOMCONSTANTS_P_H
324

source code of qtdeclarative/src/qmldom/qqmldomconstants_p.h