@swagger-api/apidom-parser-adapter-yaml-1-2 1.0.0-beta.8 → 1.0.0-rc.0
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.
- package/CHANGELOG.md +182 -0
- package/dist/1496cfca5e4d41188323a914b9705264.wasm +0 -0
- package/dist/apidom-parser-adapter-yaml-1-2.browser.js +17851 -17918
- package/dist/apidom-parser-adapter-yaml1-2.browser.min.js +1 -1
- package/package.json +10 -10
- package/src/lexical-analysis/node.cjs +1 -0
- package/src/lexical-analysis/node.mjs +1 -0
- package/src/syntactic-analysis/TreeCursorSyntaxNode.cjs +8 -4
- package/src/syntactic-analysis/TreeCursorSyntaxNode.mjs +8 -4
- package/src/syntactic-analysis/indirect/visitors/CstVisitor.cjs +77 -146
- package/src/syntactic-analysis/indirect/visitors/CstVisitor.mjs +78 -147
- package/src/syntactic-analysis/indirect/visitors/YamlAstVisitor.cjs +1 -6
- package/src/syntactic-analysis/indirect/visitors/YamlAstVisitor.mjs +2 -7
- package/wasm/tree-sitter-yaml.wasm +0 -0
- package/dist/083dd6647843baf16cbefd09aae31f27.wasm +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swagger-api/apidom-parser-adapter-yaml-1-2",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
4
|
"description": "Parser adapter for parsing YAML documents into base namespace.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"build:es": "npm run build:wasm && npm run build:wasm:copy && cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'",
|
|
31
31
|
"build:cjs": "npm run build:wasm && npm run build:wasm:copy && BABEL_ENV=cjs babel src --out-dir src --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
|
|
32
32
|
"build:umd:browser": "npm run build:wasm && npm run build:wasm:copy && cross-env BABEL_ENV=browser webpack --config config/webpack/browser.config.js --progress",
|
|
33
|
-
"build:wasm": "node ../../scripts/file-exists.js
|
|
34
|
-
"build:wasm:copy": "copyfiles -u
|
|
33
|
+
"build:wasm": "node ../../scripts/file-exists.js ./node_modules/@tree-sitter-grammars/tree-sitter-yaml/tree-sitter-yaml.wasm && exit 0 || cd ./node_modules/@tree-sitter-grammars/tree-sitter-yaml && tree-sitter generate ./grammar.js && tree-sitter build --wasm && node-gyp rebuild",
|
|
34
|
+
"build:wasm:copy": "copyfiles -u 3 ./node_modules/@tree-sitter-grammars/tree-sitter-yaml/tree-sitter-yaml.wasm wasm",
|
|
35
35
|
"lint": "eslint ./",
|
|
36
36
|
"lint:fix": "eslint ./ --fix",
|
|
37
37
|
"clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
"author": "Vladimir Gorej",
|
|
52
52
|
"license": "Apache-2.0",
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@babel/runtime-corejs3": "^7.
|
|
55
|
-
"@swagger-api/apidom-ast": "^1.0.0-
|
|
56
|
-
"@swagger-api/apidom-core": "^1.0.0-
|
|
57
|
-
"@swagger-api/apidom-error": "^1.0.0-
|
|
58
|
-
"@tree-sitter-grammars/tree-sitter-yaml": "=0.7.
|
|
54
|
+
"@babel/runtime-corejs3": "^7.26.10",
|
|
55
|
+
"@swagger-api/apidom-ast": "^1.0.0-rc.0",
|
|
56
|
+
"@swagger-api/apidom-core": "^1.0.0-rc.0",
|
|
57
|
+
"@swagger-api/apidom-error": "^1.0.0-rc.0",
|
|
58
|
+
"@tree-sitter-grammars/tree-sitter-yaml": "=0.7.1",
|
|
59
59
|
"@types/ramda": "~0.30.0",
|
|
60
60
|
"ramda": "~0.30.0",
|
|
61
61
|
"ramda-adjunct": "^5.0.0",
|
|
62
|
-
"tree-sitter": "=0.22.
|
|
62
|
+
"tree-sitter": "=0.22.4",
|
|
63
63
|
"web-tree-sitter": "=0.24.5"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"README.md",
|
|
77
77
|
"CHANGELOG.md"
|
|
78
78
|
],
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "af4b6e0fcae489477729581c52036725ac57a412"
|
|
80
80
|
}
|
|
@@ -4,9 +4,11 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.default = void 0;
|
|
5
5
|
class TreeCursorSyntaxNode {
|
|
6
6
|
type;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
startPositionRow;
|
|
8
|
+
startPositionColumn;
|
|
9
9
|
startIndex;
|
|
10
|
+
endPositionRow;
|
|
11
|
+
endPositionColumn;
|
|
10
12
|
endIndex;
|
|
11
13
|
text;
|
|
12
14
|
isNamed;
|
|
@@ -17,9 +19,11 @@ class TreeCursorSyntaxNode {
|
|
|
17
19
|
previousSibling;
|
|
18
20
|
constructor(cursor) {
|
|
19
21
|
this.type = cursor.nodeType;
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
+
this.startPositionRow = cursor.startPosition.row;
|
|
23
|
+
this.startPositionColumn = cursor.startPosition.column;
|
|
22
24
|
this.startIndex = cursor.startIndex;
|
|
25
|
+
this.endPositionRow = cursor.endPosition.row;
|
|
26
|
+
this.endPositionColumn = cursor.endPosition.column;
|
|
23
27
|
this.endIndex = cursor.endIndex;
|
|
24
28
|
this.text = cursor.nodeText;
|
|
25
29
|
this.isNamed = cursor.nodeIsNamed;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
class TreeCursorSyntaxNode {
|
|
2
2
|
type;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
startPositionRow;
|
|
4
|
+
startPositionColumn;
|
|
5
5
|
startIndex;
|
|
6
|
+
endPositionRow;
|
|
7
|
+
endPositionColumn;
|
|
6
8
|
endIndex;
|
|
7
9
|
text;
|
|
8
10
|
isNamed;
|
|
@@ -13,9 +15,11 @@ class TreeCursorSyntaxNode {
|
|
|
13
15
|
previousSibling;
|
|
14
16
|
constructor(cursor) {
|
|
15
17
|
this.type = cursor.nodeType;
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
+
this.startPositionRow = cursor.startPosition.row;
|
|
19
|
+
this.startPositionColumn = cursor.startPosition.column;
|
|
18
20
|
this.startIndex = cursor.startIndex;
|
|
21
|
+
this.endPositionRow = cursor.endPosition.row;
|
|
22
|
+
this.endPositionColumn = cursor.endPosition.column;
|
|
19
23
|
this.endIndex = cursor.endIndex;
|
|
20
24
|
this.text = cursor.nodeText;
|
|
21
25
|
this.isNamed = cursor.nodeIsNamed;
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.keyMap = exports.isNode = exports.default = void 0;
|
|
6
6
|
var _apidomAst = require("@swagger-api/apidom-ast");
|
|
7
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
7
8
|
var _TreeCursorSyntaxNode = _interopRequireDefault(require("../../TreeCursorSyntaxNode.cjs"));
|
|
8
9
|
const keyMap = exports.keyMap = {
|
|
9
10
|
stream: ['children'],
|
|
@@ -24,31 +25,14 @@ class CstVisitor {
|
|
|
24
25
|
static isKind(ending) {
|
|
25
26
|
return node => node != null && typeof node === 'object' && 'type' in node && typeof node.type === 'string' && node.type.endsWith(ending);
|
|
26
27
|
}
|
|
27
|
-
static toPosition(node) {
|
|
28
|
-
const start = new _apidomAst.Point({
|
|
29
|
-
row: node.startPosition.row,
|
|
30
|
-
column: node.startPosition.column,
|
|
31
|
-
char: node.startIndex
|
|
32
|
-
});
|
|
33
|
-
const end = new _apidomAst.Point({
|
|
34
|
-
row: node.endPosition.row,
|
|
35
|
-
column: node.endPosition.column,
|
|
36
|
-
char: node.endIndex
|
|
37
|
-
});
|
|
38
|
-
return new _apidomAst.Position({
|
|
39
|
-
start,
|
|
40
|
-
end
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
28
|
static kindNodeToYamlAnchor(node) {
|
|
44
29
|
const {
|
|
45
30
|
anchor: anchorNode
|
|
46
31
|
} = node;
|
|
47
32
|
if (typeof anchorNode === 'undefined') return undefined;
|
|
48
|
-
return new _apidomAst.YamlAnchor({
|
|
49
|
-
name: anchorNode.text
|
|
50
|
-
|
|
51
|
-
});
|
|
33
|
+
return new _apidomAst.YamlAnchor((0, _apidomCore.assignSourceMap)({
|
|
34
|
+
name: anchorNode.text
|
|
35
|
+
}, anchorNode));
|
|
52
36
|
}
|
|
53
37
|
static hasKeyValuePairEmptyKey(node) {
|
|
54
38
|
if (node.type !== 'block_mapping_pair' && node.type !== 'flow_pair') {
|
|
@@ -70,12 +54,10 @@ class CstVisitor {
|
|
|
70
54
|
} = node;
|
|
71
55
|
const explicitName = (tagNode == null ? void 0 : tagNode.text) || (node.type === 'plain_scalar' ? '?' : '!');
|
|
72
56
|
const kind = node.type.endsWith('mapping') ? _apidomAst.YamlNodeKind.Mapping : node.type.endsWith('sequence') ? _apidomAst.YamlNodeKind.Sequence : _apidomAst.YamlNodeKind.Scalar;
|
|
73
|
-
|
|
74
|
-
return new _apidomAst.YamlTag({
|
|
57
|
+
return new _apidomAst.YamlTag((0, _apidomCore.assignSourceMap)({
|
|
75
58
|
explicitName,
|
|
76
|
-
kind
|
|
77
|
-
|
|
78
|
-
});
|
|
59
|
+
kind
|
|
60
|
+
}, tagNode));
|
|
79
61
|
}
|
|
80
62
|
|
|
81
63
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -83,12 +65,10 @@ class CstVisitor {
|
|
|
83
65
|
referenceManager;
|
|
84
66
|
stream = {
|
|
85
67
|
enter: node => {
|
|
86
|
-
|
|
87
|
-
return new _apidomAst.YamlStream({
|
|
68
|
+
return new _apidomAst.YamlStream((0, _apidomCore.assignSourceMap)({
|
|
88
69
|
children: node.children,
|
|
89
|
-
position,
|
|
90
70
|
isMissing: node.isMissing
|
|
91
|
-
});
|
|
71
|
+
}, node));
|
|
92
72
|
},
|
|
93
73
|
leave: stream => {
|
|
94
74
|
return new _apidomAst.ParseResult({
|
|
@@ -99,58 +79,50 @@ class CstVisitor {
|
|
|
99
79
|
yaml_directive = {
|
|
100
80
|
enter: node => {
|
|
101
81
|
var _node$firstNamedChild;
|
|
102
|
-
const position = CstVisitor.toPosition(node);
|
|
103
82
|
const version = node == null || (_node$firstNamedChild = node.firstNamedChild) == null ? void 0 : _node$firstNamedChild.text;
|
|
104
|
-
return new _apidomAst.YamlDirective({
|
|
105
|
-
position,
|
|
83
|
+
return new _apidomAst.YamlDirective((0, _apidomCore.assignSourceMap)({
|
|
106
84
|
name: '%YAML',
|
|
107
85
|
parameters: {
|
|
108
86
|
version
|
|
109
87
|
}
|
|
110
|
-
});
|
|
88
|
+
}, node));
|
|
111
89
|
}
|
|
112
90
|
};
|
|
113
91
|
tag_directive = {
|
|
114
92
|
enter: node => {
|
|
115
|
-
const position = CstVisitor.toPosition(node);
|
|
116
93
|
const tagHandleNode = node.children[0];
|
|
117
94
|
const tagPrefixNode = node.children[1];
|
|
118
|
-
const tagDirective = new _apidomAst.YamlDirective({
|
|
119
|
-
position,
|
|
95
|
+
const tagDirective = new _apidomAst.YamlDirective((0, _apidomCore.assignSourceMap)({
|
|
120
96
|
name: '%TAG',
|
|
121
97
|
parameters: {
|
|
122
98
|
handle: tagHandleNode == null ? void 0 : tagHandleNode.text,
|
|
123
99
|
prefix: tagPrefixNode == null ? void 0 : tagPrefixNode.text
|
|
124
100
|
}
|
|
125
|
-
});
|
|
101
|
+
}, node));
|
|
126
102
|
this.schema.registerTagDirective(tagDirective);
|
|
127
103
|
return tagDirective;
|
|
128
104
|
}
|
|
129
105
|
};
|
|
130
106
|
reserved_directive = {
|
|
131
107
|
enter: node => {
|
|
132
|
-
const position = CstVisitor.toPosition(node);
|
|
133
108
|
const directiveNameNode = node.children[0];
|
|
134
109
|
const directiveParameter1Node = node.children[1];
|
|
135
110
|
const directiveParameter2Node = node.children[2];
|
|
136
|
-
return new _apidomAst.YamlDirective({
|
|
137
|
-
position,
|
|
111
|
+
return new _apidomAst.YamlDirective((0, _apidomCore.assignSourceMap)({
|
|
138
112
|
name: directiveNameNode == null ? void 0 : directiveNameNode.text,
|
|
139
113
|
parameters: {
|
|
140
114
|
handle: directiveParameter1Node == null ? void 0 : directiveParameter1Node.text,
|
|
141
115
|
prefix: directiveParameter2Node == null ? void 0 : directiveParameter2Node.text
|
|
142
116
|
}
|
|
143
|
-
});
|
|
117
|
+
}, node));
|
|
144
118
|
}
|
|
145
119
|
};
|
|
146
120
|
document = {
|
|
147
121
|
enter: node => {
|
|
148
|
-
|
|
149
|
-
return new _apidomAst.YamlDocument({
|
|
122
|
+
return new _apidomAst.YamlDocument((0, _apidomCore.assignSourceMap)({
|
|
150
123
|
children: node.children,
|
|
151
|
-
position,
|
|
152
124
|
isMissing: node.isMissing
|
|
153
|
-
});
|
|
125
|
+
}, node));
|
|
154
126
|
},
|
|
155
127
|
leave: node => {
|
|
156
128
|
node.children = node.children.flat();
|
|
@@ -169,21 +141,17 @@ class CstVisitor {
|
|
|
169
141
|
if (CstVisitor.isScalar(kindCandidate) || CstVisitor.isMapping(kindCandidate) || CstVisitor.isSequence(kindCandidate)) {
|
|
170
142
|
return node.children;
|
|
171
143
|
}
|
|
172
|
-
|
|
173
144
|
// kind node not present in flow node, creating empty node
|
|
174
|
-
const emptyPoint = new _apidomAst.Point({
|
|
175
|
-
row: kindCandidate.endPosition.row,
|
|
176
|
-
column: kindCandidate.endPosition.column,
|
|
177
|
-
char: kindCandidate.endIndex
|
|
178
|
-
});
|
|
179
145
|
const emptyScalarNode = new _apidomAst.YamlScalar({
|
|
180
146
|
content: '',
|
|
181
147
|
anchor: CstVisitor.kindNodeToYamlAnchor(kindCandidate),
|
|
182
148
|
tag: CstVisitor.kindNodeToYamlTag(kindCandidate),
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
149
|
+
startPositionRow: kindCandidate.endPositionRow,
|
|
150
|
+
startPositionColumn: kindCandidate.endPositionColumn,
|
|
151
|
+
startIndex: kindCandidate.endIndex,
|
|
152
|
+
endPositionRow: kindCandidate.endPositionRow,
|
|
153
|
+
endPositionColumn: kindCandidate.endPositionColumn,
|
|
154
|
+
endIndex: kindCandidate.endIndex,
|
|
187
155
|
styleGroup: _apidomAst.YamlStyleGroup.Flow,
|
|
188
156
|
style: _apidomAst.YamlStyle.Plain
|
|
189
157
|
});
|
|
@@ -203,25 +171,22 @@ class CstVisitor {
|
|
|
203
171
|
};
|
|
204
172
|
block_mapping = {
|
|
205
173
|
enter: node => {
|
|
206
|
-
const position = CstVisitor.toPosition(node);
|
|
207
174
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
208
175
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
209
|
-
const mappingNode = new _apidomAst.YamlMapping({
|
|
176
|
+
const mappingNode = new _apidomAst.YamlMapping((0, _apidomCore.assignSourceMap)({
|
|
210
177
|
children: node.children,
|
|
211
|
-
position,
|
|
212
178
|
anchor,
|
|
213
179
|
tag,
|
|
214
180
|
styleGroup: _apidomAst.YamlStyleGroup.Block,
|
|
215
181
|
style: _apidomAst.YamlStyle.NextLine,
|
|
216
182
|
isMissing: node.isMissing
|
|
217
|
-
});
|
|
183
|
+
}, node));
|
|
218
184
|
this.registerAnchor(mappingNode);
|
|
219
185
|
return this.schema.resolve(mappingNode);
|
|
220
186
|
}
|
|
221
187
|
};
|
|
222
188
|
block_mapping_pair = {
|
|
223
189
|
enter: node => {
|
|
224
|
-
const position = CstVisitor.toPosition(node);
|
|
225
190
|
const children = [...node.children];
|
|
226
191
|
if (CstVisitor.hasKeyValuePairEmptyKey(node)) {
|
|
227
192
|
const keyNode = this.createKeyValuePairEmptyKey(node);
|
|
@@ -231,35 +196,31 @@ class CstVisitor {
|
|
|
231
196
|
const valueNode = this.createKeyValuePairEmptyValue(node);
|
|
232
197
|
children.push(valueNode);
|
|
233
198
|
}
|
|
234
|
-
return new _apidomAst.YamlKeyValuePair({
|
|
199
|
+
return new _apidomAst.YamlKeyValuePair((0, _apidomCore.assignSourceMap)({
|
|
235
200
|
children,
|
|
236
|
-
position,
|
|
237
201
|
styleGroup: _apidomAst.YamlStyleGroup.Block,
|
|
238
202
|
isMissing: node.isMissing
|
|
239
|
-
});
|
|
203
|
+
}, node));
|
|
240
204
|
}
|
|
241
205
|
};
|
|
242
206
|
flow_mapping = {
|
|
243
207
|
enter: node => {
|
|
244
|
-
const position = CstVisitor.toPosition(node);
|
|
245
208
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
246
209
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
247
|
-
const mappingNode = new _apidomAst.YamlMapping({
|
|
210
|
+
const mappingNode = new _apidomAst.YamlMapping((0, _apidomCore.assignSourceMap)({
|
|
248
211
|
children: node.children,
|
|
249
|
-
position,
|
|
250
212
|
anchor,
|
|
251
213
|
tag,
|
|
252
214
|
styleGroup: _apidomAst.YamlStyleGroup.Flow,
|
|
253
215
|
style: _apidomAst.YamlStyle.Explicit,
|
|
254
216
|
isMissing: node.isMissing
|
|
255
|
-
});
|
|
217
|
+
}, node));
|
|
256
218
|
this.registerAnchor(mappingNode);
|
|
257
219
|
return this.schema.resolve(mappingNode);
|
|
258
220
|
}
|
|
259
221
|
};
|
|
260
222
|
flow_pair = {
|
|
261
223
|
enter: node => {
|
|
262
|
-
const position = CstVisitor.toPosition(node);
|
|
263
224
|
const children = [...node.children];
|
|
264
225
|
if (CstVisitor.hasKeyValuePairEmptyKey(node)) {
|
|
265
226
|
const keyNode = this.createKeyValuePairEmptyKey(node);
|
|
@@ -269,12 +230,11 @@ class CstVisitor {
|
|
|
269
230
|
const valueNode = this.createKeyValuePairEmptyValue(node);
|
|
270
231
|
children.push(valueNode);
|
|
271
232
|
}
|
|
272
|
-
return new _apidomAst.YamlKeyValuePair({
|
|
233
|
+
return new _apidomAst.YamlKeyValuePair((0, _apidomCore.assignSourceMap)({
|
|
273
234
|
children,
|
|
274
|
-
position,
|
|
275
235
|
styleGroup: _apidomAst.YamlStyleGroup.Flow,
|
|
276
236
|
isMissing: node.isMissing
|
|
277
|
-
});
|
|
237
|
+
}, node));
|
|
278
238
|
}
|
|
279
239
|
};
|
|
280
240
|
keyValuePair = {
|
|
@@ -284,17 +244,15 @@ class CstVisitor {
|
|
|
284
244
|
};
|
|
285
245
|
block_sequence = {
|
|
286
246
|
enter: node => {
|
|
287
|
-
const position = CstVisitor.toPosition(node);
|
|
288
247
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
289
248
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
290
|
-
const sequenceNode = new _apidomAst.YamlSequence({
|
|
249
|
+
const sequenceNode = new _apidomAst.YamlSequence((0, _apidomCore.assignSourceMap)({
|
|
291
250
|
children: node.children,
|
|
292
|
-
position,
|
|
293
251
|
anchor,
|
|
294
252
|
tag,
|
|
295
253
|
styleGroup: _apidomAst.YamlStyleGroup.Block,
|
|
296
254
|
style: _apidomAst.YamlStyle.NextLine
|
|
297
|
-
});
|
|
255
|
+
}, node));
|
|
298
256
|
this.registerAnchor(sequenceNode);
|
|
299
257
|
return this.schema.resolve(sequenceNode);
|
|
300
258
|
}
|
|
@@ -307,21 +265,18 @@ class CstVisitor {
|
|
|
307
265
|
}
|
|
308
266
|
|
|
309
267
|
// create empty node
|
|
310
|
-
const emptyPoint = new _apidomAst.Point({
|
|
311
|
-
row: node.endPosition.row,
|
|
312
|
-
column: node.endPosition.column,
|
|
313
|
-
char: node.endIndex
|
|
314
|
-
});
|
|
315
268
|
const emptyScalarNode = new _apidomAst.YamlScalar({
|
|
316
269
|
content: '',
|
|
317
270
|
tag: new _apidomAst.YamlTag({
|
|
318
271
|
explicitName: '?',
|
|
319
272
|
kind: _apidomAst.YamlNodeKind.Scalar
|
|
320
273
|
}),
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
274
|
+
startPositionRow: node.endPositionRow,
|
|
275
|
+
startPositionColumn: node.endPositionColumn,
|
|
276
|
+
startIndex: node.endIndex,
|
|
277
|
+
endPositionRow: node.endPositionRow,
|
|
278
|
+
endPositionColumn: node.endPositionColumn,
|
|
279
|
+
endIndex: node.endIndex,
|
|
325
280
|
styleGroup: _apidomAst.YamlStyleGroup.Flow,
|
|
326
281
|
style: _apidomAst.YamlStyle.Plain
|
|
327
282
|
});
|
|
@@ -330,17 +285,15 @@ class CstVisitor {
|
|
|
330
285
|
};
|
|
331
286
|
flow_sequence = {
|
|
332
287
|
enter: node => {
|
|
333
|
-
const position = CstVisitor.toPosition(node);
|
|
334
288
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
335
289
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
336
|
-
const sequenceNode = new _apidomAst.YamlSequence({
|
|
290
|
+
const sequenceNode = new _apidomAst.YamlSequence((0, _apidomCore.assignSourceMap)({
|
|
337
291
|
children: node.children.flat(),
|
|
338
|
-
position,
|
|
339
292
|
anchor,
|
|
340
293
|
tag,
|
|
341
294
|
styleGroup: _apidomAst.YamlStyleGroup.Flow,
|
|
342
295
|
style: _apidomAst.YamlStyle.Explicit
|
|
343
|
-
});
|
|
296
|
+
}, node));
|
|
344
297
|
this.registerAnchor(sequenceNode);
|
|
345
298
|
return this.schema.resolve(sequenceNode);
|
|
346
299
|
}
|
|
@@ -352,69 +305,61 @@ class CstVisitor {
|
|
|
352
305
|
};
|
|
353
306
|
plain_scalar = {
|
|
354
307
|
enter: node => {
|
|
355
|
-
const position = CstVisitor.toPosition(node);
|
|
356
308
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
357
309
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
358
|
-
const scalarNode = new _apidomAst.YamlScalar({
|
|
310
|
+
const scalarNode = new _apidomAst.YamlScalar((0, _apidomCore.assignSourceMap)({
|
|
359
311
|
content: node.text,
|
|
360
312
|
anchor,
|
|
361
313
|
tag,
|
|
362
|
-
position,
|
|
363
314
|
styleGroup: _apidomAst.YamlStyleGroup.Flow,
|
|
364
315
|
style: _apidomAst.YamlStyle.Plain
|
|
365
|
-
});
|
|
316
|
+
}, node));
|
|
366
317
|
this.registerAnchor(scalarNode);
|
|
367
318
|
return this.schema.resolve(scalarNode);
|
|
368
319
|
}
|
|
369
320
|
};
|
|
370
321
|
single_quote_scalar = {
|
|
371
322
|
enter: node => {
|
|
372
|
-
const position = CstVisitor.toPosition(node);
|
|
373
323
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
374
324
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
375
|
-
const scalarNode = new _apidomAst.YamlScalar({
|
|
325
|
+
const scalarNode = new _apidomAst.YamlScalar((0, _apidomCore.assignSourceMap)({
|
|
376
326
|
content: node.text,
|
|
377
327
|
anchor,
|
|
378
328
|
tag,
|
|
379
|
-
position,
|
|
380
329
|
styleGroup: _apidomAst.YamlStyleGroup.Flow,
|
|
381
330
|
style: _apidomAst.YamlStyle.SingleQuoted
|
|
382
|
-
});
|
|
331
|
+
}, node));
|
|
383
332
|
this.registerAnchor(scalarNode);
|
|
384
333
|
return this.schema.resolve(scalarNode);
|
|
385
334
|
}
|
|
386
335
|
};
|
|
387
336
|
double_quote_scalar = {
|
|
388
337
|
enter: node => {
|
|
389
|
-
const position = CstVisitor.toPosition(node);
|
|
390
338
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
391
339
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
392
|
-
const scalarNode = new _apidomAst.YamlScalar({
|
|
340
|
+
const scalarNode = new _apidomAst.YamlScalar((0, _apidomCore.assignSourceMap)({
|
|
393
341
|
content: node.text,
|
|
394
342
|
anchor,
|
|
395
343
|
tag,
|
|
396
|
-
position,
|
|
397
344
|
styleGroup: _apidomAst.YamlStyleGroup.Flow,
|
|
398
345
|
style: _apidomAst.YamlStyle.DoubleQuoted
|
|
399
|
-
});
|
|
346
|
+
}, node));
|
|
400
347
|
this.registerAnchor(scalarNode);
|
|
401
348
|
return this.schema.resolve(scalarNode);
|
|
402
349
|
}
|
|
403
350
|
};
|
|
404
351
|
block_scalar = {
|
|
405
352
|
enter: node => {
|
|
406
|
-
const position = CstVisitor.toPosition(node);
|
|
407
353
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
408
354
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
409
355
|
const style = node.text.startsWith('|') ? _apidomAst.YamlStyle.Literal : node.text.startsWith('>') ? _apidomAst.YamlStyle.Folded : _apidomAst.YamlStyle.Plain;
|
|
410
|
-
const scalarNode = new _apidomAst.YamlScalar({
|
|
356
|
+
const scalarNode = new _apidomAst.YamlScalar((0, _apidomCore.assignSourceMap)({
|
|
411
357
|
content: node.text,
|
|
412
358
|
anchor,
|
|
413
359
|
tag,
|
|
414
|
-
position,
|
|
415
360
|
styleGroup: _apidomAst.YamlStyleGroup.Block,
|
|
416
361
|
style
|
|
417
|
-
});
|
|
362
|
+
}, node));
|
|
418
363
|
this.registerAnchor(scalarNode);
|
|
419
364
|
return this.schema.resolve(scalarNode);
|
|
420
365
|
}
|
|
@@ -444,30 +389,26 @@ class CstVisitor {
|
|
|
444
389
|
enter(node) {
|
|
445
390
|
// missing anonymous literals from CST transformed into AST literal nodes
|
|
446
391
|
if (node instanceof _TreeCursorSyntaxNode.default && !node.isNamed) {
|
|
447
|
-
const position = CstVisitor.toPosition(node);
|
|
448
392
|
const value = node.type || node.text;
|
|
449
393
|
const {
|
|
450
394
|
isMissing
|
|
451
395
|
} = node;
|
|
452
|
-
return new _apidomAst.Literal({
|
|
396
|
+
return new _apidomAst.Literal((0, _apidomCore.assignSourceMap)({
|
|
453
397
|
value,
|
|
454
|
-
position,
|
|
455
398
|
isMissing
|
|
456
|
-
});
|
|
399
|
+
}, node));
|
|
457
400
|
}
|
|
458
401
|
return undefined;
|
|
459
402
|
}
|
|
460
403
|
|
|
461
404
|
// eslint-disable-next-line class-methods-use-this
|
|
462
405
|
ERROR(node, key, parent, path) {
|
|
463
|
-
const
|
|
464
|
-
const errorNode = new _apidomAst.Error({
|
|
406
|
+
const errorNode = new _apidomAst.Error((0, _apidomCore.assignSourceMap)({
|
|
465
407
|
children: node.children,
|
|
466
|
-
position,
|
|
467
408
|
isUnexpected: !node.hasError,
|
|
468
409
|
isMissing: node.isMissing,
|
|
469
410
|
value: node.text
|
|
470
|
-
});
|
|
411
|
+
}, node));
|
|
471
412
|
if (path.length === 0) {
|
|
472
413
|
return new _apidomAst.ParseResult({
|
|
473
414
|
children: [errorNode]
|
|
@@ -481,35 +422,30 @@ class CstVisitor {
|
|
|
481
422
|
}
|
|
482
423
|
}
|
|
483
424
|
createKeyValuePairEmptyKey(node) {
|
|
484
|
-
const emptyPoint = new _apidomAst.Point({
|
|
485
|
-
row: node.startPosition.row,
|
|
486
|
-
column: node.startPosition.column,
|
|
487
|
-
char: node.startIndex
|
|
488
|
-
});
|
|
489
425
|
const {
|
|
490
426
|
keyNode
|
|
491
427
|
} = node;
|
|
492
428
|
const children = (keyNode == null ? void 0 : keyNode.children) || [];
|
|
493
429
|
const tagNode = children.find(CstVisitor.isKind('tag'));
|
|
494
430
|
const anchorNode = children.find(CstVisitor.isKind('anchor'));
|
|
495
|
-
const tag = typeof tagNode !== 'undefined' ? new _apidomAst.YamlTag({
|
|
431
|
+
const tag = typeof tagNode !== 'undefined' ? new _apidomAst.YamlTag((0, _apidomCore.assignSourceMap)({
|
|
496
432
|
explicitName: tagNode.text,
|
|
497
|
-
kind: _apidomAst.YamlNodeKind.Scalar
|
|
498
|
-
|
|
499
|
-
}) : new _apidomAst.YamlTag({
|
|
433
|
+
kind: _apidomAst.YamlNodeKind.Scalar
|
|
434
|
+
}, tagNode)) : new _apidomAst.YamlTag({
|
|
500
435
|
explicitName: '?',
|
|
501
436
|
kind: _apidomAst.YamlNodeKind.Scalar
|
|
502
437
|
});
|
|
503
|
-
const anchor = typeof anchorNode !== 'undefined' ? new _apidomAst.YamlAnchor({
|
|
504
|
-
name: anchorNode.text
|
|
505
|
-
|
|
506
|
-
}) : undefined;
|
|
438
|
+
const anchor = typeof anchorNode !== 'undefined' ? new _apidomAst.YamlAnchor((0, _apidomCore.assignSourceMap)({
|
|
439
|
+
name: anchorNode.text
|
|
440
|
+
}, anchorNode)) : undefined;
|
|
507
441
|
const scalarNode = new _apidomAst.YamlScalar({
|
|
508
442
|
content: '',
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
443
|
+
startPositionRow: node.startPositionRow,
|
|
444
|
+
startPositionColumn: node.startPositionColumn,
|
|
445
|
+
startIndex: node.startIndex,
|
|
446
|
+
endPositionRow: node.startPositionRow,
|
|
447
|
+
endPositionColumn: node.startPositionColumn,
|
|
448
|
+
endIndex: node.startIndex,
|
|
513
449
|
tag,
|
|
514
450
|
anchor,
|
|
515
451
|
styleGroup: _apidomAst.YamlStyleGroup.Flow,
|
|
@@ -519,35 +455,30 @@ class CstVisitor {
|
|
|
519
455
|
return scalarNode;
|
|
520
456
|
}
|
|
521
457
|
createKeyValuePairEmptyValue(node) {
|
|
522
|
-
const emptyPoint = new _apidomAst.Point({
|
|
523
|
-
row: node.endPosition.row,
|
|
524
|
-
column: node.endPosition.column,
|
|
525
|
-
char: node.endIndex
|
|
526
|
-
});
|
|
527
458
|
const {
|
|
528
459
|
valueNode
|
|
529
460
|
} = node;
|
|
530
461
|
const children = (valueNode == null ? void 0 : valueNode.children) || [];
|
|
531
462
|
const tagNode = children.find(CstVisitor.isKind('tag'));
|
|
532
463
|
const anchorNode = children.find(CstVisitor.isKind('anchor'));
|
|
533
|
-
const tag = typeof tagNode !== 'undefined' ? new _apidomAst.YamlTag({
|
|
464
|
+
const tag = typeof tagNode !== 'undefined' ? new _apidomAst.YamlTag((0, _apidomCore.assignSourceMap)({
|
|
534
465
|
explicitName: tagNode.text,
|
|
535
|
-
kind: _apidomAst.YamlNodeKind.Scalar
|
|
536
|
-
|
|
537
|
-
}) : new _apidomAst.YamlTag({
|
|
466
|
+
kind: _apidomAst.YamlNodeKind.Scalar
|
|
467
|
+
}, tagNode)) : new _apidomAst.YamlTag({
|
|
538
468
|
explicitName: '?',
|
|
539
469
|
kind: _apidomAst.YamlNodeKind.Scalar
|
|
540
470
|
});
|
|
541
|
-
const anchor = typeof anchorNode !== 'undefined' ? new _apidomAst.YamlAnchor({
|
|
542
|
-
name: anchorNode.text
|
|
543
|
-
|
|
544
|
-
}) : undefined;
|
|
471
|
+
const anchor = typeof anchorNode !== 'undefined' ? new _apidomAst.YamlAnchor((0, _apidomCore.assignSourceMap)({
|
|
472
|
+
name: anchorNode.text
|
|
473
|
+
}, anchorNode)) : undefined;
|
|
545
474
|
const scalarNode = new _apidomAst.YamlScalar({
|
|
546
475
|
content: '',
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
476
|
+
startPositionRow: node.endPositionRow,
|
|
477
|
+
startPositionColumn: node.endPositionColumn,
|
|
478
|
+
startIndex: node.endIndex,
|
|
479
|
+
endPositionRow: node.endPositionRow,
|
|
480
|
+
endPositionColumn: node.endPositionColumn,
|
|
481
|
+
endIndex: node.endIndex,
|
|
551
482
|
tag,
|
|
552
483
|
anchor,
|
|
553
484
|
styleGroup: _apidomAst.YamlStyleGroup.Flow,
|