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 ScriptRegExpLiteral,
198 ScriptForStatement,
199 ScriptIfStatement,
200 ScriptPostExpression,
201 ScriptUnaryExpression,
202 ScriptBinaryExpression,
203 ScriptVariableDeclaration,
204 ScriptVariableDeclarationEntry,
205 ScriptReturnStatement,
206 ScriptGenericElement,
207 ScriptCallExpression,
208 ScriptFormalParameter,
209 ScriptArray,
210 ScriptObject,
211 ScriptProperty,
212 ScriptType,
213 ScriptElision,
214 ScriptArrayEntry,
215 ScriptPattern,
216 ScriptSwitchStatement,
217 ScriptCaseBlock,
218 ScriptCaseClause,
219 ScriptDefaultClause,
220 ScriptWhileStatement,
221 ScriptDoWhileStatement,
222 ScriptForEachStatement,
223 ScriptTemplateExpressionPart,
224 ScriptTemplateLiteral,
225 ScriptTemplateStringPart,
226 ScriptTaggedTemplate,
227 ScriptTryCatchStatement,
228 ScriptThrowStatement,
229 ScriptLabelledStatement,
230 ScriptBreakStatement,
231 ScriptContinueStatement,
232 ScriptConditionalExpression,
233 ScriptEmptyStatement,
234 ScriptParenthesizedExpression,
235 ScriptFunctionExpression,
236 ScriptYieldExpression,
237 ScriptNewExpression,
238 ScriptNewMemberExpression,
239 ScriptThisExpression,
240 ScriptSuperLiteral,
241
242 ScriptElementStop, // marker to check if a DomType is a scriptelement or not
243};
244Q_ENUM_NS(DomType)
245
246enum class SimpleWrapOption { None = 0, ValueType = 1 };
247Q_ENUM_NS(SimpleWrapOption)
248Q_DECLARE_FLAGS(SimpleWrapOptions, SimpleWrapOption)
249Q_DECLARE_OPERATORS_FOR_FLAGS(SimpleWrapOptions)
250
251enum class BindingValueKind { Object, ScriptExpression, Array, Empty };
252Q_ENUM_NS(BindingValueKind)
253
254enum class BindingType { Normal, OnBinding };
255Q_ENUM_NS(BindingType)
256
257enum class ListOptions {
258 Normal,
259 Reverse
260};
261Q_ENUM_NS(ListOptions)
262
263enum class EscapeOptions{
264 OuterQuotes,
265 NoOuterQuotes
266};
267Q_ENUM_NS(EscapeOptions)
268
269enum class ErrorLevel{
270 Debug = QtMsgType::QtDebugMsg,
271 Info = QtMsgType::QtInfoMsg,
272 Warning = QtMsgType::QtWarningMsg,
273 Error = QtMsgType::QtCriticalMsg,
274 Fatal = QtMsgType::QtFatalMsg
275};
276Q_ENUM_NS(ErrorLevel)
277
278enum class AstDumperOption {
279 None=0,
280 NoLocations=0x1,
281 NoAnnotations=0x2,
282 DumpNode=0x4,
283 SloppyCompare=0x8
284};
285Q_ENUM_NS(AstDumperOption)
286Q_DECLARE_FLAGS(AstDumperOptions, AstDumperOption)
287Q_DECLARE_OPERATORS_FOR_FLAGS(AstDumperOptions)
288
289enum class GoTo {
290 Strict, // never go to an non uniquely defined result
291 MostLikely // if needed go up to the most likely location between multiple options
292};
293Q_ENUM_NS(GoTo)
294
295enum class AddOption { KeepExisting, Overwrite };
296Q_ENUM_NS(AddOption)
297
298/*!
299\internal
300FilterUpOptions decide in which direction the filtering is done.
301ReturnInner starts the search at top(), and work its way down to the current
302element.
303ReturnOuter and ReturnOuterNoSelf starts the search at the current element and
304works their way up to to top().
305*/
306enum class FilterUpOptions { ReturnOuter, ReturnOuterNoSelf, ReturnInner };
307Q_ENUM_NS(FilterUpOptions)
308
309enum class WriteOutCheck {
310 None = 0x0,
311 UpdatedDomCompare = 0x1,
312 UpdatedDomStable = 0x2,
313 Reparse = 0x4,
314 ReparseCompare = 0x8,
315 ReparseStable = 0x10,
316 DumpOnFailure = 0x20,
317 All = 0x3F,
318 Default = Reparse | ReparseCompare | ReparseStable
319};
320Q_ENUM_NS(WriteOutCheck)
321Q_DECLARE_FLAGS(WriteOutChecks, WriteOutCheck)
322Q_DECLARE_OPERATORS_FOR_FLAGS(WriteOutChecks)
323
324enum class LocalSymbolsType {
325 None = 0x0,
326 ObjectType = 0x1,
327 ValueType = 0x2,
328 Signal = 0x4,
329 Method = 0x8,
330 Attribute = 0x10,
331 Id = 0x20,
332 Namespace = 0x40,
333 Global = 0x80,
334 MethodParameter = 0x100,
335 Singleton = 0x200,
336 AttachedType = 0x400,
337};
338Q_ENUM_NS(LocalSymbolsType)
339Q_DECLARE_FLAGS(LocalSymbolsTypes, LocalSymbolsType)
340Q_DECLARE_OPERATORS_FOR_FLAGS(LocalSymbolsTypes)
341
342/*!
343\internal
344The FileLocationRegion allows to map the different FileLocation subregions to their position in
345the actual code. For example, \c{ColonTokenRegion} denotes the position of the ':' token in a
346binding like `myProperty: something()`, or the ':' token in a pragma like `pragma Hello: World`.
347
348These are used for formatting in qmlformat and autocompletion in qmlls.
349
350MainRegion denotes the entire FileLocation region.
351
352\sa{OutWriter::regionToString}, {FileLocations::regionName}
353*/
354enum FileLocationRegion : int {
355 AsTokenRegion,
356 BreakKeywordRegion,
357 DoKeywordRegion,
358 CaseKeywordRegion,
359 CatchKeywordRegion,
360 ColonTokenRegion,
361 CommaTokenRegion,
362 ComponentKeywordRegion,
363 ContinueKeywordRegion,
364 DefaultKeywordRegion,
365 DollarLeftBraceTokenRegion,
366 EllipsisTokenRegion,
367 ElseKeywordRegion,
368 EnumKeywordRegion,
369 EnumValueRegion,
370 EqualTokenRegion,
371 ForKeywordRegion,
372 FinallyKeywordRegion,
373 FirstSemicolonTokenRegion,
374 FunctionKeywordRegion,
375 IdColonTokenRegion,
376 IdNameRegion,
377 IdTokenRegion,
378 IdentifierRegion,
379 IfKeywordRegion,
380 ImportTokenRegion,
381 ImportUriRegion,
382 InOfTokenRegion,
383 LeftBacktickTokenRegion,
384 LeftBraceRegion,
385 LeftBracketRegion,
386 LeftParenthesisRegion,
387 MainRegion,
388 NewKeywordRegion,
389 OperatorTokenRegion,
390 OnTargetRegion,
391 OnTokenRegion,
392 PragmaKeywordRegion,
393 PragmaValuesRegion,
394 PropertyKeywordRegion,
395 QuestionMarkTokenRegion,
396 ReadonlyKeywordRegion,
397 RequiredKeywordRegion,
398 ReturnKeywordRegion,
399 RightBacktickTokenRegion,
400 RightBraceRegion,
401 RightBracketRegion,
402 RightParenthesisRegion,
403 SecondSemicolonRegion,
404 SemicolonTokenRegion,
405 SignalKeywordRegion,
406 SuperKeywordRegion,
407 StarTokenRegion,
408 SwitchKeywordRegion,
409 ThisKeywordRegion,
410 ThrowKeywordRegion,
411 TryKeywordRegion,
412 TypeIdentifierRegion,
413 TypeModifierRegion,
414 VersionRegion,
415 WhileKeywordRegion,
416 YieldKeywordRegion,
417};
418Q_ENUM_NS(FileLocationRegion);
419
420enum DomCreationOption : char {
421 Default, // required by qmlformat for example
422 Extended, // required by qmlls for example
423 Minimal, // required by QmlDocumentParser in Qt Design Studio, for example
424};
425
426} // end namespace Dom
427} // end namespace QQmlJS
428
429QT_END_NAMESPACE
430
431#endif // QQMLDOMCONSTANTS_P_H
432

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