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

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