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 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | namespace QQmlJS{ |
27 | namespace Dom { |
28 | |
29 | Q_NAMESPACE_EXPORT(QMLDOM_EXPORT) |
30 | |
31 | enum class PathRoot { |
32 | Other, |
33 | Modules, |
34 | Cpp, |
35 | Libs, |
36 | Top, |
37 | Env, |
38 | Universe |
39 | }; |
40 | Q_ENUM_NS(PathRoot) |
41 | |
42 | enum 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 | }; |
55 | Q_ENUM_NS(PathCurrent) |
56 | |
57 | enum class Language { QmlQuick1, QmlQuick2, QmlQuick3, QmlCompiled, QmlAnnotation, Qbs }; |
58 | Q_ENUM_NS(Language) |
59 | |
60 | enum 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 | }; |
64 | Q_ENUM_NS(ResolveOption) |
65 | Q_DECLARE_FLAGS(ResolveOptions, ResolveOption) |
66 | Q_DECLARE_OPERATORS_FOR_FLAGS(ResolveOptions) |
67 | |
68 | enum 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 | }; |
76 | Q_ENUM_NS(VisitOption) |
77 | Q_DECLARE_FLAGS(VisitOptions, VisitOption) |
78 | Q_DECLARE_OPERATORS_FOR_FLAGS(VisitOptions) |
79 | |
80 | enum 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 | }; |
87 | Q_ENUM_NS(LookupOption) |
88 | Q_DECLARE_FLAGS(LookupOptions, LookupOption) |
89 | Q_DECLARE_OPERATORS_FOR_FLAGS(LookupOptions) |
90 | |
91 | enum class LookupType { PropertyDef, Binding, Property, Method, Type, CppType, Symbol }; |
92 | Q_ENUM_NS(LookupType) |
93 | |
94 | enum class VisitPrototypesOption { |
95 | Normal = 0, |
96 | SkipFirst = 0x1, |
97 | RevisitWarn = 0x2, |
98 | ManualProceedToScope = 0x4 |
99 | }; |
100 | Q_ENUM_NS(VisitPrototypesOption) |
101 | Q_DECLARE_FLAGS(VisitPrototypesOptions, VisitPrototypesOption) |
102 | Q_DECLARE_OPERATORS_FOR_FLAGS(VisitPrototypesOptions) |
103 | |
104 | enum class DomKind { Empty, Object, List, Map, Value, ScriptElement }; |
105 | Q_ENUM_NS(DomKind) |
106 | |
107 | enum 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 | ScriptTemplateLiteral, |
224 | ScriptTemplateStringPart, |
225 | ScriptTaggedTemplate, |
226 | ScriptTryCatchStatement, |
227 | ScriptThrowStatement, |
228 | ScriptLabelledStatement, |
229 | ScriptBreakStatement, |
230 | ScriptContinueStatement, |
231 | ScriptConditionalExpression, |
232 | ScriptEmptyStatement, |
233 | ScriptParenthesizedExpression, |
234 | ScriptFunctionExpression, |
235 | ScriptYieldExpression, |
236 | ScriptNewExpression, |
237 | ScriptNewMemberExpression, |
238 | ScriptThisExpression, |
239 | ScriptSuperLiteral, |
240 | |
241 | ScriptElementStop, // marker to check if a DomType is a scriptelement or not |
242 | }; |
243 | Q_ENUM_NS(DomType) |
244 | |
245 | enum class SimpleWrapOption { None = 0, ValueType = 1 }; |
246 | Q_ENUM_NS(SimpleWrapOption) |
247 | Q_DECLARE_FLAGS(SimpleWrapOptions, SimpleWrapOption) |
248 | Q_DECLARE_OPERATORS_FOR_FLAGS(SimpleWrapOptions) |
249 | |
250 | enum class BindingValueKind { Object, ScriptExpression, Array, Empty }; |
251 | Q_ENUM_NS(BindingValueKind) |
252 | |
253 | enum class BindingType { Normal, OnBinding }; |
254 | Q_ENUM_NS(BindingType) |
255 | |
256 | enum class ListOptions { |
257 | Normal, |
258 | Reverse |
259 | }; |
260 | Q_ENUM_NS(ListOptions) |
261 | |
262 | enum class EscapeOptions{ |
263 | OuterQuotes, |
264 | NoOuterQuotes |
265 | }; |
266 | Q_ENUM_NS(EscapeOptions) |
267 | |
268 | enum class ErrorLevel{ |
269 | Debug = QtMsgType::QtDebugMsg, |
270 | Info = QtMsgType::QtInfoMsg, |
271 | Warning = QtMsgType::QtWarningMsg, |
272 | Error = QtMsgType::QtCriticalMsg, |
273 | Fatal = QtMsgType::QtFatalMsg |
274 | }; |
275 | Q_ENUM_NS(ErrorLevel) |
276 | |
277 | enum class AstDumperOption { |
278 | None=0, |
279 | NoLocations=0x1, |
280 | NoAnnotations=0x2, |
281 | DumpNode=0x4, |
282 | SloppyCompare=0x8 |
283 | }; |
284 | Q_ENUM_NS(AstDumperOption) |
285 | Q_DECLARE_FLAGS(AstDumperOptions, AstDumperOption) |
286 | Q_DECLARE_OPERATORS_FOR_FLAGS(AstDumperOptions) |
287 | |
288 | enum class GoTo { |
289 | Strict, // never go to an non uniquely defined result |
290 | MostLikely // if needed go up to the most likely location between multiple options |
291 | }; |
292 | Q_ENUM_NS(GoTo) |
293 | |
294 | enum class AddOption { KeepExisting, Overwrite }; |
295 | Q_ENUM_NS(AddOption) |
296 | |
297 | /*! |
298 | \internal |
299 | FilterUpOptions decide in which direction the filtering is done. |
300 | ReturnInner starts the search at top(), and work its way down to the current |
301 | element. |
302 | ReturnOuter and ReturnOuterNoSelf starts the search at the current element and |
303 | works their way up to to top(). |
304 | */ |
305 | enum class FilterUpOptions { ReturnOuter, ReturnOuterNoSelf, ReturnInner }; |
306 | Q_ENUM_NS(FilterUpOptions) |
307 | |
308 | enum class WriteOutCheck { |
309 | None = 0x0, |
310 | UpdatedDomCompare = 0x1, |
311 | UpdatedDomStable = 0x2, |
312 | Reparse = 0x4, |
313 | ReparseCompare = 0x8, |
314 | ReparseStable = 0x10, |
315 | DumpOnFailure = 0x20, |
316 | All = 0x3F, |
317 | Default = Reparse | ReparseCompare | ReparseStable |
318 | }; |
319 | Q_ENUM_NS(WriteOutCheck) |
320 | Q_DECLARE_FLAGS(WriteOutChecks, WriteOutCheck) |
321 | Q_DECLARE_OPERATORS_FOR_FLAGS(WriteOutChecks) |
322 | |
323 | enum class LocalSymbolsType { |
324 | None = 0x0, |
325 | ObjectType = 0x1, |
326 | ValueType = 0x2, |
327 | Signal = 0x4, |
328 | Method = 0x8, |
329 | Attribute = 0x10, |
330 | Id = 0x20, |
331 | Namespace = 0x40, |
332 | Global = 0x80, |
333 | MethodParameter = 0x100, |
334 | Singleton = 0x200, |
335 | AttachedType = 0x400, |
336 | }; |
337 | Q_ENUM_NS(LocalSymbolsType) |
338 | Q_DECLARE_FLAGS(LocalSymbolsTypes, LocalSymbolsType) |
339 | Q_DECLARE_OPERATORS_FOR_FLAGS(LocalSymbolsTypes) |
340 | |
341 | /*! |
342 | \internal |
343 | The FileLocationRegion allows to map the different FileLocation subregions to their position in |
344 | the actual code. For example, \c{ColonTokenRegion} denotes the position of the ':' token in a |
345 | binding like `myProperty: something()`, or the ':' token in a pragma like `pragma Hello: World`. |
346 | |
347 | These are used for formatting in qmlformat and autocompletion in qmlls. |
348 | |
349 | MainRegion denotes the entire FileLocation region. |
350 | |
351 | \sa{OutWriter::regionToString}, {FileLocations::regionName} |
352 | */ |
353 | enum FileLocationRegion : int { |
354 | AsTokenRegion, |
355 | BreakKeywordRegion, |
356 | DoKeywordRegion, |
357 | CaseKeywordRegion, |
358 | CatchKeywordRegion, |
359 | ColonTokenRegion, |
360 | CommaTokenRegion, |
361 | ComponentKeywordRegion, |
362 | ContinueKeywordRegion, |
363 | DefaultKeywordRegion, |
364 | EllipsisTokenRegion, |
365 | ElseKeywordRegion, |
366 | EnumKeywordRegion, |
367 | EnumValueRegion, |
368 | EqualTokenRegion, |
369 | ForKeywordRegion, |
370 | FinallyKeywordRegion, |
371 | FirstSemicolonTokenRegion, |
372 | FunctionKeywordRegion, |
373 | IdColonTokenRegion, |
374 | IdNameRegion, |
375 | IdTokenRegion, |
376 | IdentifierRegion, |
377 | IfKeywordRegion, |
378 | ImportTokenRegion, |
379 | ImportUriRegion, |
380 | InOfTokenRegion, |
381 | LeftBraceRegion, |
382 | LeftBracketRegion, |
383 | LeftParenthesisRegion, |
384 | MainRegion, |
385 | NewKeywordRegion, |
386 | OperatorTokenRegion, |
387 | OnTargetRegion, |
388 | OnTokenRegion, |
389 | PragmaKeywordRegion, |
390 | PragmaValuesRegion, |
391 | PropertyKeywordRegion, |
392 | QuestionMarkTokenRegion, |
393 | ReadonlyKeywordRegion, |
394 | RequiredKeywordRegion, |
395 | ReturnKeywordRegion, |
396 | RightBraceRegion, |
397 | RightBracketRegion, |
398 | RightParenthesisRegion, |
399 | SecondSemicolonRegion, |
400 | SemicolonTokenRegion, |
401 | SignalKeywordRegion, |
402 | SuperKeywordRegion, |
403 | StarTokenRegion, |
404 | SwitchKeywordRegion, |
405 | ThisKeywordRegion, |
406 | ThrowKeywordRegion, |
407 | TryKeywordRegion, |
408 | TypeIdentifierRegion, |
409 | TypeModifierRegion, |
410 | VersionRegion, |
411 | WhileKeywordRegion, |
412 | YieldKeywordRegion, |
413 | }; |
414 | Q_ENUM_NS(FileLocationRegion); |
415 | |
416 | enum DomCreationOption : char { |
417 | None = 0, |
418 | WithSemanticAnalysis = 1, |
419 | WithScriptExpressions = 2, |
420 | WithRecovery = 4 |
421 | }; |
422 | |
423 | Q_DECLARE_FLAGS(DomCreationOptions, DomCreationOption); |
424 | |
425 | } // end namespace Dom |
426 | } // end namespace QQmlJS |
427 | |
428 | QT_END_NAMESPACE |
429 | |
430 | #endif // QQMLDOMCONSTANTS_P_H |
431 |
Definitions
Learn Advanced QML with KDAB
Find out more