@sap-ux/cds-annotation-parser 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +74 -0
  3. package/dist/constants.d.ts +6 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/constants.js +10 -0
  6. package/dist/constants.js.map +1 -0
  7. package/dist/find-annotation-node.d.ts +40 -0
  8. package/dist/find-annotation-node.d.ts.map +1 -0
  9. package/dist/find-annotation-node.js +135 -0
  10. package/dist/find-annotation-node.js.map +1 -0
  11. package/dist/index.d.ts +7 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +52 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/parser/factory.d.ts +6 -0
  16. package/dist/parser/factory.d.ts.map +1 -0
  17. package/dist/parser/factory.js +13 -0
  18. package/dist/parser/factory.js.map +1 -0
  19. package/dist/parser/index.d.ts +11 -0
  20. package/dist/parser/index.d.ts.map +1 -0
  21. package/dist/parser/index.js +17 -0
  22. package/dist/parser/index.js.map +1 -0
  23. package/dist/parser/parser.d.ts +242 -0
  24. package/dist/parser/parser.d.ts.map +1 -0
  25. package/dist/parser/parser.js +385 -0
  26. package/dist/parser/parser.js.map +1 -0
  27. package/dist/parser/tokens.d.ts +103 -0
  28. package/dist/parser/tokens.d.ts.map +1 -0
  29. package/dist/parser/tokens.js +287 -0
  30. package/dist/parser/tokens.js.map +1 -0
  31. package/dist/transformer/annotation-ast-nodes.d.ts +178 -0
  32. package/dist/transformer/annotation-ast-nodes.d.ts.map +1 -0
  33. package/dist/transformer/annotation-ast-nodes.js +69 -0
  34. package/dist/transformer/annotation-ast-nodes.js.map +1 -0
  35. package/dist/transformer/ast.d.ts +6 -0
  36. package/dist/transformer/ast.d.ts.map +1 -0
  37. package/dist/transformer/ast.js +1227 -0
  38. package/dist/transformer/ast.js.map +1 -0
  39. package/dist/transformer/expressions.d.ts +87 -0
  40. package/dist/transformer/expressions.d.ts.map +1 -0
  41. package/dist/transformer/expressions.js +548 -0
  42. package/dist/transformer/expressions.js.map +1 -0
  43. package/dist/transformer/index.d.ts +5 -0
  44. package/dist/transformer/index.d.ts.map +1 -0
  45. package/dist/transformer/index.js +42 -0
  46. package/dist/transformer/index.js.map +1 -0
  47. package/dist/transformer/range.d.ts +20 -0
  48. package/dist/transformer/range.d.ts.map +1 -0
  49. package/dist/transformer/range.js +31 -0
  50. package/dist/transformer/range.js.map +1 -0
  51. package/dist/utils/index.d.ts +4 -0
  52. package/dist/utils/index.d.ts.map +1 -0
  53. package/dist/utils/index.js +17 -0
  54. package/dist/utils/index.js.map +1 -0
  55. package/package.json +38 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # @sap-ux/cds-annotation-parser
2
+
3
+ ## Installation
4
+ Npm
5
+ `npm install --save @sap-ux/cds-annotation-parser`
6
+
7
+ Yarn
8
+ `yarn add @sap-ux/cds-annotation-parser`
9
+
10
+ Pnpm
11
+ `pnpm add @sap-ux/cds-annotation-parser`
12
+
13
+ ## Usage
14
+ Examples of how to use CDS annotation parsing and abstract syntax tree (AST) node search functions.
15
+
16
+ ```Typescript
17
+ import { parse, findAnnotationNode, getAstNodes, getNode } from '@sap-ux/cds-annotation-parser';
18
+
19
+ const ast = parse(`
20
+ UI.LineItem #table1 : [
21
+ {
22
+ $type: 'UI.DataField',
23
+ value: some.path,
24
+ Label: 'Sample column'
25
+ }
26
+ ]';
27
+ `);
28
+
29
+ if (ast !== undefined) {
30
+ // Expected pathToLabel: "/value/items/0/properties/2/value"
31
+ const pathToLabel = findAnnotationNode(ast, {
32
+ position: { line: 5, character: 15 },
33
+ includeDelimiterCharacters: true
34
+ });
35
+
36
+ // An array of nodes matching each segment of the path.
37
+ const nodes = getAstNodes(ast, pathToLabel);
38
+ const serializedNodes = nodes.map((n) =>
39
+ Array.isArray(n) ? '<array of child elements>' : typeof n === 'object' ? `Node of type '${n.type}'` : n
40
+ );
41
+ /* Expected serializedNodes:
42
+ [
43
+ "Node of type 'collection'",
44
+ "<array of child elements>",
45
+ "Node of type 'record'",
46
+ "<array of child elements>",
47
+ "Node of type 'record-property'",
48
+ "Node of type 'string'",
49
+ ]
50
+ */
51
+
52
+ const termNode = getNode(ast, '/term');
53
+ if (termNode.type === 'path') {
54
+ // expected termName: "UI.LineItem"
55
+ const termName = termNode.value;
56
+ }
57
+
58
+ const qualifierNode = getNode(ast, '/qualifier');
59
+ if (qualifierNode.type === 'qualifier') {
60
+ // expected qualifier: "table1"
61
+ const qualifier = qualifierNode.value;
62
+ }
63
+
64
+ const propertyValueNode = getNode(ast, '/value/items/0/properties/1/value');
65
+ if (propertyValueNode.type === 'path') {
66
+ // expected value: "some.path"
67
+ const value = propertyValueNode.value;
68
+ }
69
+ }
70
+
71
+ ```
72
+
73
+ ## Keywords
74
+ OData annotations CAP CDS
@@ -0,0 +1,6 @@
1
+ export declare enum ReservedProperties {
2
+ Type = "$Type",
3
+ Value = "$value",
4
+ EdmJson = "$edmJson"
5
+ }
6
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,kBAAkB;IAC1B,IAAI,UAAU;IACd,KAAK,WAAW;IAChB,OAAO,aAAa;CACvB"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReservedProperties = void 0;
4
+ var ReservedProperties;
5
+ (function (ReservedProperties) {
6
+ ReservedProperties["Type"] = "$Type";
7
+ ReservedProperties["Value"] = "$value";
8
+ ReservedProperties["EdmJson"] = "$edmJson";
9
+ })(ReservedProperties = exports.ReservedProperties || (exports.ReservedProperties = {}));
10
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC1B,oCAAc,CAAA;IACd,sCAAgB,CAAA;IAChB,0CAAoB,CAAA;AACxB,CAAC,EAJW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAI7B"}
@@ -0,0 +1,40 @@
1
+ import type { Position } from 'vscode-languageserver-types';
2
+ import type { AnnotationNode } from './transformer/annotation-ast-nodes';
3
+ export interface PositionVisitorOptions {
4
+ /**
5
+ * Position by which each node is matched.
6
+ */
7
+ position: Position;
8
+ /**
9
+ * Some nodes has delimiters e.g string with ''.
10
+ * Setting this option to true will make the visitor also consider these delimiters as part of the node
11
+ * and will match the node if the position is inside the delimiter.
12
+ */
13
+ includeDelimiterCharacters: boolean;
14
+ }
15
+ /**
16
+ * Searches for an AST node in the given AST tree based on provided search options.
17
+ *
18
+ * @param assignment AST root element
19
+ * @param options Search options (element position, flag whether delimiter characters should be considered)
20
+ * @returns Path to the found AST node or empty string
21
+ */
22
+ export declare const findAnnotationNode: (assignment: AnnotationNode | undefined, options: PositionVisitorOptions) => string;
23
+ export type ChildNode = AnnotationNode | AnnotationNode[];
24
+ /**
25
+ * Traverses the nodes using path and returns last matching node.
26
+ *
27
+ * @param root Node from which to start the traversal.
28
+ * @param path Path used to traverse.
29
+ * @returns Node matching path
30
+ */
31
+ export declare const getNode: (root: AnnotationNode, path: string) => ChildNode | undefined;
32
+ /**
33
+ * Converts path to an array of nodes matching each segment of the path.
34
+ *
35
+ * @param root Node from which to start the traversal
36
+ * @param path Path to a node
37
+ * @returns Array containing all the matched nodes
38
+ */
39
+ export declare function getAstNodes(root: AnnotationNode, path: string): ChildNode[] | undefined;
40
+ //# sourceMappingURL=find-annotation-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-annotation-node.d.ts","sourceRoot":"","sources":["../src/find-annotation-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAsB,MAAM,oCAAoC,CAAC;AAkC7F,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;;OAIG;IACH,0BAA0B,EAAE,OAAO,CAAC;CACvC;AAyFD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,eAAgB,cAAc,GAAG,SAAS,WAAW,sBAAsB,KAAG,MAC3C,CAAC;AAEnE,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,cAAc,EAAE,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,SAAU,cAAc,QAAQ,MAAM,KAAG,SAAS,GAAG,SAWxE,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,SAAS,CAavF"}
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAstNodes = exports.getNode = exports.findAnnotationNode = void 0;
4
+ const transformer_1 = require("./transformer");
5
+ const odata_annotation_core_1 = require("@sap-ux/odata-annotation-core");
6
+ const LEAF_NODE_TYPES = new Set([
7
+ transformer_1.IDENTIFIER_TYPE,
8
+ transformer_1.ENUM_TYPE,
9
+ transformer_1.BOOLEAN_TYPE,
10
+ transformer_1.NUMBER_LITERAL_TYPE,
11
+ transformer_1.STRING_LITERAL_TYPE,
12
+ transformer_1.PATH_TYPE,
13
+ transformer_1.EMPTY_VALUE_TYPE,
14
+ transformer_1.OPERATOR_TYPE
15
+ ]);
16
+ /**
17
+ * Visitor which visits all the nodes for which the specified position is in range.
18
+ *
19
+ */
20
+ class PositionVisitor {
21
+ constructor() {
22
+ this.createNodeHandler(transformer_1.ANNOTATION_GROUP_TYPE, ['name', 'items'], []);
23
+ this.createNodeHandler(transformer_1.ANNOTATION_GROUP_ITEMS_TYPE, [], ['items']);
24
+ this.createNodeHandler(transformer_1.ANNOTATION_TYPE, ['term', 'value'], []);
25
+ this.createNodeHandler(transformer_1.RECORD_TYPE, [], ['properties', 'annotations']);
26
+ this.createNodeHandler(transformer_1.RECORD_PROPERTY_TYPE, ['name', 'value'], []);
27
+ this.createNodeHandler(transformer_1.COLLECTION_TYPE, [], ['items']);
28
+ this.createNodeHandler(transformer_1.CORRECT_EXPRESSION_TYPE, [], ['operators', 'operands']);
29
+ this.createNodeHandler(transformer_1.INCORRECT_EXPRESSION_TYPE, [], ['operators', 'operands']);
30
+ this.createNodeHandler(transformer_1.UNSUPPORTED_OPERATOR_EXPRESSION_TYPE, [], ['operators', 'operands']);
31
+ }
32
+ /**
33
+ * Visits all nodes (including children) which have the provided position in their ranges.
34
+ *
35
+ * @param node Node to be visited
36
+ * @param options Visitor options
37
+ * @param segment Name of the segment which should be added to path if the position is in the nodes range
38
+ * @returns Visitor result value
39
+ */
40
+ visit(node, options, segment) {
41
+ const { position } = options;
42
+ if ((0, odata_annotation_core_1.positionContained)((0, transformer_1.nodeRange)(node, options.includeDelimiterCharacters), position)) {
43
+ if (LEAF_NODE_TYPES.has(node.type)) {
44
+ return segment !== undefined ? [segment] : [];
45
+ }
46
+ if (this[node.type]) {
47
+ return this[node.type](node, options, segment);
48
+ }
49
+ else {
50
+ throw new Error(`No visitor function found for type ${node.type}`);
51
+ }
52
+ }
53
+ return [];
54
+ }
55
+ /**
56
+ *
57
+ * @param nodeType Type of an annotation node
58
+ * @param scalarProperties Array with names of scalar properties of an annotation node
59
+ * @param collectionProperties Array with names of collection valued properties of an annotation node
60
+ */
61
+ createNodeHandler(nodeType, scalarProperties, collectionProperties) {
62
+ this[nodeType] = (node, options, segment = '') => {
63
+ for (const propertyName of scalarProperties) {
64
+ const children = this.visit(node[propertyName], options, propertyName);
65
+ if (children.length) {
66
+ return [segment, ...children];
67
+ }
68
+ }
69
+ for (const propertyName of collectionProperties) {
70
+ let i = 0;
71
+ for (const item of node[propertyName] || []) {
72
+ const children = this.visit(item, options, i);
73
+ if (children.length) {
74
+ return [segment, propertyName, ...children];
75
+ }
76
+ i++;
77
+ }
78
+ }
79
+ return [segment];
80
+ };
81
+ }
82
+ }
83
+ const visitor = new PositionVisitor();
84
+ /**
85
+ * Searches for an AST node in the given AST tree based on provided search options.
86
+ *
87
+ * @param assignment AST root element
88
+ * @param options Search options (element position, flag whether delimiter characters should be considered)
89
+ * @returns Path to the found AST node or empty string
90
+ */
91
+ const findAnnotationNode = (assignment, options) => assignment ? visitor.visit(assignment, options).join('/') : '';
92
+ exports.findAnnotationNode = findAnnotationNode;
93
+ /**
94
+ * Traverses the nodes using path and returns last matching node.
95
+ *
96
+ * @param root Node from which to start the traversal.
97
+ * @param path Path used to traverse.
98
+ * @returns Node matching path
99
+ */
100
+ const getNode = (root, path) => {
101
+ const segments = path.split('/');
102
+ let node = root;
103
+ for (let i = 1; i < segments.length; i++) {
104
+ const segment = segments[i];
105
+ node = node[segment];
106
+ if (!Array.isArray(node) && !(node === null || node === void 0 ? void 0 : node.type)) {
107
+ return undefined;
108
+ }
109
+ }
110
+ return node;
111
+ };
112
+ exports.getNode = getNode;
113
+ /**
114
+ * Converts path to an array of nodes matching each segment of the path.
115
+ *
116
+ * @param root Node from which to start the traversal
117
+ * @param path Path to a node
118
+ * @returns Array containing all the matched nodes
119
+ */
120
+ function getAstNodes(root, path) {
121
+ const segments = path.split('/');
122
+ let node = root;
123
+ const nodes = [];
124
+ for (let i = 1; i < segments.length; i++) {
125
+ const segment = segments[i];
126
+ node = node[segment];
127
+ if (!Array.isArray(node) && !(node === null || node === void 0 ? void 0 : node.type)) {
128
+ return undefined;
129
+ }
130
+ nodes.push(node);
131
+ }
132
+ return nodes;
133
+ }
134
+ exports.getAstNodes = getAstNodes;
135
+ //# sourceMappingURL=find-annotation-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3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AA,OAAO,WAWlB;AAEF;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,IAAoB,EAAE,IAAY;IAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,IAAI,GAA0B,IAAI,CAAC;IACvC,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,GAAI,IAAgD,CAAC,OAAO,CAAC,CAAC;QAClE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAA,EAAE;YACrC,OAAO,SAAS,CAAC;SACpB;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpB;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAbD,kCAaC"}
@@ -0,0 +1,7 @@
1
+ import type { Position } from 'vscode-languageserver-types';
2
+ export declare const parse: (text: string, startPosition?: Position) => import("./transformer/annotation-ast-nodes").AstResult;
3
+ export { EMPTY_VALUE_TYPE, RECORD_PROPERTY_TYPE, PATH_TYPE, STRING_LITERAL_TYPE, ANNOTATION_TYPE, RECORD_TYPE, ANNOTATION_GROUP_ITEMS_TYPE, ANNOTATION_GROUP_TYPE, BOOLEAN_TYPE, NUMBER_LITERAL_TYPE, ENUM_TYPE, OPERATOR_TYPE, UNSUPPORTED_OPERATOR_EXPRESSION_TYPE, INCORRECT_EXPRESSION_TYPE, CORRECT_EXPRESSION_TYPE, EXPRESSION_TYPES, COLLECTION_TYPE, TOKEN_TYPE, QUOTED_LITERAL_TYPE, QUALIFIER_TYPE, MULTI_LINE_STRING_LITERAL_TYPE, SEPARATOR_TYPE, IDENTIFIER_TYPE, Record, Node, AnnotationValue, AnnotationGroup, AnnotationNodeType, AnnotationGroupItems, Collection, Enum, Expression, UnsupportedOperatorExpression, IncorrectExpression, CorrectExpression, operatorMap, positionIsInExpressionWhiteSpace, containsIncorrectExpressions, getEdmOperatorMap, StringLiteral, Path, EmptyValue, BooleanLiteral, NumberLiteral, QuotedLiteralKind, Token, QuotedLiteral, MultiLineStringLiteral, Identifier, Annotation, RecordProperty, AnnotationNode, Assignment, Separator, NarrowAnnotationNode, nodeRange, isContainer } from './transformer';
4
+ export { arePositionsEqual, copyPosition, copyRange, areRangesEqual } from './transformer';
5
+ export { ReservedProperties } from './constants';
6
+ export { findAnnotationNode, getNode, getAstNodes } from './find-annotation-node';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAI5D,eAAO,MAAM,KAAK,SAAU,MAAM,kBAAkB,QAAQ,2DAG3D,CAAC;AAEF,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,2BAA2B,EAC3B,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,oCAAoC,EACpC,yBAAyB,EACzB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,8BAA8B,EAC9B,cAAc,EACd,eAAe,EACf,MAAM,EACN,IAAI,EACJ,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,UAAU,EACV,6BAA6B,EAC7B,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,gCAAgC,EAChC,4BAA4B,EAC5B,iBAAiB,EACjB,aAAa,EACb,IAAI,EACJ,UAAU,EACV,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,KAAK,EACL,aAAa,EACb,sBAAsB,EACtB,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,WAAW,EACd,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAstNodes = exports.getNode = exports.findAnnotationNode = exports.ReservedProperties = exports.areRangesEqual = exports.copyRange = exports.copyPosition = exports.arePositionsEqual = exports.isContainer = exports.nodeRange = exports.getEdmOperatorMap = exports.containsIncorrectExpressions = exports.positionIsInExpressionWhiteSpace = exports.operatorMap = exports.IDENTIFIER_TYPE = exports.SEPARATOR_TYPE = exports.MULTI_LINE_STRING_LITERAL_TYPE = exports.QUALIFIER_TYPE = exports.QUOTED_LITERAL_TYPE = exports.TOKEN_TYPE = exports.COLLECTION_TYPE = exports.EXPRESSION_TYPES = exports.CORRECT_EXPRESSION_TYPE = exports.INCORRECT_EXPRESSION_TYPE = exports.UNSUPPORTED_OPERATOR_EXPRESSION_TYPE = exports.OPERATOR_TYPE = exports.ENUM_TYPE = exports.NUMBER_LITERAL_TYPE = exports.BOOLEAN_TYPE = exports.ANNOTATION_GROUP_TYPE = exports.ANNOTATION_GROUP_ITEMS_TYPE = exports.RECORD_TYPE = exports.ANNOTATION_TYPE = exports.STRING_LITERAL_TYPE = exports.PATH_TYPE = exports.RECORD_PROPERTY_TYPE = exports.EMPTY_VALUE_TYPE = exports.parse = void 0;
4
+ const parser_1 = require("./parser");
5
+ const transformer_1 = require("./transformer");
6
+ const parse = (text, startPosition) => {
7
+ const { cst, tokens } = (0, parser_1.parse)(text);
8
+ return (0, transformer_1.buildAst)(cst, tokens, startPosition);
9
+ };
10
+ exports.parse = parse;
11
+ var transformer_2 = require("./transformer");
12
+ Object.defineProperty(exports, "EMPTY_VALUE_TYPE", { enumerable: true, get: function () { return transformer_2.EMPTY_VALUE_TYPE; } });
13
+ Object.defineProperty(exports, "RECORD_PROPERTY_TYPE", { enumerable: true, get: function () { return transformer_2.RECORD_PROPERTY_TYPE; } });
14
+ Object.defineProperty(exports, "PATH_TYPE", { enumerable: true, get: function () { return transformer_2.PATH_TYPE; } });
15
+ Object.defineProperty(exports, "STRING_LITERAL_TYPE", { enumerable: true, get: function () { return transformer_2.STRING_LITERAL_TYPE; } });
16
+ Object.defineProperty(exports, "ANNOTATION_TYPE", { enumerable: true, get: function () { return transformer_2.ANNOTATION_TYPE; } });
17
+ Object.defineProperty(exports, "RECORD_TYPE", { enumerable: true, get: function () { return transformer_2.RECORD_TYPE; } });
18
+ Object.defineProperty(exports, "ANNOTATION_GROUP_ITEMS_TYPE", { enumerable: true, get: function () { return transformer_2.ANNOTATION_GROUP_ITEMS_TYPE; } });
19
+ Object.defineProperty(exports, "ANNOTATION_GROUP_TYPE", { enumerable: true, get: function () { return transformer_2.ANNOTATION_GROUP_TYPE; } });
20
+ Object.defineProperty(exports, "BOOLEAN_TYPE", { enumerable: true, get: function () { return transformer_2.BOOLEAN_TYPE; } });
21
+ Object.defineProperty(exports, "NUMBER_LITERAL_TYPE", { enumerable: true, get: function () { return transformer_2.NUMBER_LITERAL_TYPE; } });
22
+ Object.defineProperty(exports, "ENUM_TYPE", { enumerable: true, get: function () { return transformer_2.ENUM_TYPE; } });
23
+ Object.defineProperty(exports, "OPERATOR_TYPE", { enumerable: true, get: function () { return transformer_2.OPERATOR_TYPE; } });
24
+ Object.defineProperty(exports, "UNSUPPORTED_OPERATOR_EXPRESSION_TYPE", { enumerable: true, get: function () { return transformer_2.UNSUPPORTED_OPERATOR_EXPRESSION_TYPE; } });
25
+ Object.defineProperty(exports, "INCORRECT_EXPRESSION_TYPE", { enumerable: true, get: function () { return transformer_2.INCORRECT_EXPRESSION_TYPE; } });
26
+ Object.defineProperty(exports, "CORRECT_EXPRESSION_TYPE", { enumerable: true, get: function () { return transformer_2.CORRECT_EXPRESSION_TYPE; } });
27
+ Object.defineProperty(exports, "EXPRESSION_TYPES", { enumerable: true, get: function () { return transformer_2.EXPRESSION_TYPES; } });
28
+ Object.defineProperty(exports, "COLLECTION_TYPE", { enumerable: true, get: function () { return transformer_2.COLLECTION_TYPE; } });
29
+ Object.defineProperty(exports, "TOKEN_TYPE", { enumerable: true, get: function () { return transformer_2.TOKEN_TYPE; } });
30
+ Object.defineProperty(exports, "QUOTED_LITERAL_TYPE", { enumerable: true, get: function () { return transformer_2.QUOTED_LITERAL_TYPE; } });
31
+ Object.defineProperty(exports, "QUALIFIER_TYPE", { enumerable: true, get: function () { return transformer_2.QUALIFIER_TYPE; } });
32
+ Object.defineProperty(exports, "MULTI_LINE_STRING_LITERAL_TYPE", { enumerable: true, get: function () { return transformer_2.MULTI_LINE_STRING_LITERAL_TYPE; } });
33
+ Object.defineProperty(exports, "SEPARATOR_TYPE", { enumerable: true, get: function () { return transformer_2.SEPARATOR_TYPE; } });
34
+ Object.defineProperty(exports, "IDENTIFIER_TYPE", { enumerable: true, get: function () { return transformer_2.IDENTIFIER_TYPE; } });
35
+ Object.defineProperty(exports, "operatorMap", { enumerable: true, get: function () { return transformer_2.operatorMap; } });
36
+ Object.defineProperty(exports, "positionIsInExpressionWhiteSpace", { enumerable: true, get: function () { return transformer_2.positionIsInExpressionWhiteSpace; } });
37
+ Object.defineProperty(exports, "containsIncorrectExpressions", { enumerable: true, get: function () { return transformer_2.containsIncorrectExpressions; } });
38
+ Object.defineProperty(exports, "getEdmOperatorMap", { enumerable: true, get: function () { return transformer_2.getEdmOperatorMap; } });
39
+ Object.defineProperty(exports, "nodeRange", { enumerable: true, get: function () { return transformer_2.nodeRange; } });
40
+ Object.defineProperty(exports, "isContainer", { enumerable: true, get: function () { return transformer_2.isContainer; } });
41
+ var transformer_3 = require("./transformer");
42
+ Object.defineProperty(exports, "arePositionsEqual", { enumerable: true, get: function () { return transformer_3.arePositionsEqual; } });
43
+ Object.defineProperty(exports, "copyPosition", { enumerable: true, get: function () { return transformer_3.copyPosition; } });
44
+ Object.defineProperty(exports, "copyRange", { enumerable: true, get: function () { return transformer_3.copyRange; } });
45
+ Object.defineProperty(exports, "areRangesEqual", { enumerable: true, get: function () { return transformer_3.areRangesEqual; } });
46
+ var constants_1 = require("./constants");
47
+ Object.defineProperty(exports, "ReservedProperties", { enumerable: true, get: function () { return constants_1.ReservedProperties; } });
48
+ var find_annotation_node_1 = require("./find-annotation-node");
49
+ Object.defineProperty(exports, "findAnnotationNode", { enumerable: true, get: function () { return find_annotation_node_1.findAnnotationNode; } });
50
+ Object.defineProperty(exports, "getNode", { enumerable: true, get: function () { return find_annotation_node_1.getNode; } });
51
+ Object.defineProperty(exports, "getAstNodes", { enumerable: true, get: function () { return find_annotation_node_1.getAstNodes; } });
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,qCAAwD;AACxD,+CAAyC;AAElC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,aAAwB,EAAE,EAAE;IAC5D,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,cAAmB,EAAC,IAAI,CAAC,CAAC;IAClD,OAAO,IAAA,sBAAQ,EAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;AAChD,CAAC,CAAC;AAHW,QAAA,KAAK,SAGhB;AAEF,6CA0DuB;AAzDnB,+GAAA,gBAAgB,OAAA;AAChB,mHAAA,oBAAoB,OAAA;AACpB,wGAAA,SAAS,OAAA;AACT,kHAAA,mBAAmB,OAAA;AACnB,8GAAA,eAAe,OAAA;AACf,0GAAA,WAAW,OAAA;AACX,0HAAA,2BAA2B,OAAA;AAC3B,oHAAA,qBAAqB,OAAA;AACrB,2GAAA,YAAY,OAAA;AACZ,kHAAA,mBAAmB,OAAA;AACnB,wGAAA,SAAS,OAAA;AACT,4GAAA,aAAa,OAAA;AACb,mIAAA,oCAAoC,OAAA;AACpC,wHAAA,yBAAyB,OAAA;AACzB,sHAAA,uBAAuB,OAAA;AACvB,+GAAA,gBAAgB,OAAA;AAChB,8GAAA,eAAe,OAAA;AACf,yGAAA,UAAU,OAAA;AACV,kHAAA,mBAAmB,OAAA;AACnB,6GAAA,cAAc,OAAA;AACd,6HAAA,8BAA8B,OAAA;AAC9B,6GAAA,cAAc,OAAA;AACd,8GAAA,eAAe,OAAA;AAaf,0GAAA,WAAW,OAAA;AACX,+HAAA,gCAAgC,OAAA;AAChC,2HAAA,4BAA4B,OAAA;AAC5B,gHAAA,iBAAiB,OAAA;AAiBjB,wGAAA,SAAS,OAAA;AACT,0GAAA,WAAW,OAAA;AAGf,6CAA2F;AAAlF,gHAAA,iBAAiB,OAAA;AAAE,2GAAA,YAAY,OAAA;AAAE,wGAAA,SAAS,OAAA;AAAE,6GAAA,cAAc,OAAA;AACnE,yCAAiD;AAAxC,+GAAA,kBAAkB,OAAA;AAC3B,+DAAkF;AAAzE,0HAAA,kBAAkB,OAAA;AAAE,+GAAA,OAAO,OAAA;AAAE,mHAAA,WAAW,OAAA"}
@@ -0,0 +1,6 @@
1
+ import { Lexer } from 'chevrotain';
2
+ import { AnnotationParser } from './parser';
3
+ export declare const lexer: Lexer;
4
+ export declare const parser: AnnotationParser;
5
+ export declare const Visitor: new (...args: any[]) => import("chevrotain").ICstVisitor<any, any>;
6
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/parser/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,eAAO,MAAM,KAAK,OAGhB,CAAC;AACH,eAAO,MAAM,MAAM,kBAAyB,CAAC;AAE7C,eAAO,MAAM,OAAO,oEAAwC,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Visitor = exports.parser = exports.lexer = void 0;
4
+ const chevrotain_1 = require("chevrotain");
5
+ const tokens_1 = require("./tokens");
6
+ const parser_1 = require("./parser");
7
+ exports.lexer = new chevrotain_1.Lexer(tokens_1.lexerDefinition, {
8
+ // Enable validation for debugging
9
+ skipValidations: true
10
+ });
11
+ exports.parser = new parser_1.AnnotationParser();
12
+ exports.Visitor = exports.parser.getBaseCstVisitorConstructor();
13
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/parser/factory.ts"],"names":[],"mappings":";;;AAAA,2CAAmC;AAEnC,qCAA2C;AAC3C,qCAA4C;AAE/B,QAAA,KAAK,GAAG,IAAI,kBAAK,CAAC,wBAAe,EAAE;IAC5C,kCAAkC;IAClC,eAAe,EAAE,IAAI;CACxB,CAAC,CAAC;AACU,QAAA,MAAM,GAAG,IAAI,yBAAgB,EAAE,CAAC;AAEhC,QAAA,OAAO,GAAG,cAAM,CAAC,4BAA4B,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { IToken, ILexingError, IRecognitionException } from 'chevrotain';
2
+ import type { DeclarationCstNode } from './parser';
3
+ interface ParseResult {
4
+ cst: DeclarationCstNode;
5
+ tokens: IToken[];
6
+ lexErrors: ILexingError[];
7
+ parseErrors: IRecognitionException[];
8
+ }
9
+ export declare const parse: (text: string) => ParseResult;
10
+ export {};
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnD,UAAU,WAAW;IACjB,GAAG,EAAE,kBAAkB,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,WAAW,EAAE,qBAAqB,EAAE,CAAC;CACxC;AAED,eAAO,MAAM,KAAK,SAAU,MAAM,KAAG,WAUpC,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = void 0;
4
+ const factory_1 = require("./factory");
5
+ const parse = (text) => {
6
+ const { tokens, errors: lexErrors } = factory_1.lexer.tokenize(text);
7
+ factory_1.parser.text = text;
8
+ factory_1.parser.input = tokens;
9
+ return {
10
+ cst: factory_1.parser.declaration(),
11
+ tokens,
12
+ lexErrors,
13
+ parseErrors: factory_1.parser.errors
14
+ };
15
+ };
16
+ exports.parse = parse;
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":";;;AACA,uCAA0C;AASnC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAe,EAAE;IAC/C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,eAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3D,gBAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,gBAAM,CAAC,KAAK,GAAG,MAAM,CAAC;IACtB,OAAO;QACH,GAAG,EAAE,gBAAM,CAAC,WAAW,EAAwB;QAC/C,MAAM;QACN,SAAS;QACT,WAAW,EAAE,gBAAM,CAAC,MAAM;KAC7B,CAAC;AACN,CAAC,CAAC;AAVW,QAAA,KAAK,SAUhB"}