@swagger-api/apidom-parser-adapter-yaml-1-2 1.0.0-beta.9 → 1.0.0-rc.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.
- 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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Error, isNode as isCSTNode, Literal, ParseResult,
|
|
1
|
+
import { Error, isNode as isCSTNode, Literal, ParseResult, YamlAlias, YamlAnchor, YamlComment, YamlDirective, YamlDocument, YamlKeyValuePair, YamlMapping, YamlNodeKind, YamlScalar, YamlSequence, YamlStream, YamlStyle, YamlStyleGroup, YamlTag } from '@swagger-api/apidom-ast';
|
|
2
|
+
import { assignSourceMap } from '@swagger-api/apidom-core';
|
|
2
3
|
import TreeCursorSyntaxNode from "../../TreeCursorSyntaxNode.mjs";
|
|
3
4
|
export const keyMap = {
|
|
4
5
|
stream: ['children'],
|
|
@@ -19,31 +20,14 @@ class CstVisitor {
|
|
|
19
20
|
static isKind(ending) {
|
|
20
21
|
return node => node != null && typeof node === 'object' && 'type' in node && typeof node.type === 'string' && node.type.endsWith(ending);
|
|
21
22
|
}
|
|
22
|
-
static toPosition(node) {
|
|
23
|
-
const start = new Point({
|
|
24
|
-
row: node.startPosition.row,
|
|
25
|
-
column: node.startPosition.column,
|
|
26
|
-
char: node.startIndex
|
|
27
|
-
});
|
|
28
|
-
const end = new Point({
|
|
29
|
-
row: node.endPosition.row,
|
|
30
|
-
column: node.endPosition.column,
|
|
31
|
-
char: node.endIndex
|
|
32
|
-
});
|
|
33
|
-
return new Position({
|
|
34
|
-
start,
|
|
35
|
-
end
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
23
|
static kindNodeToYamlAnchor(node) {
|
|
39
24
|
const {
|
|
40
25
|
anchor: anchorNode
|
|
41
26
|
} = node;
|
|
42
27
|
if (typeof anchorNode === 'undefined') return undefined;
|
|
43
|
-
return new YamlAnchor({
|
|
44
|
-
name: anchorNode.text
|
|
45
|
-
|
|
46
|
-
});
|
|
28
|
+
return new YamlAnchor(assignSourceMap({
|
|
29
|
+
name: anchorNode.text
|
|
30
|
+
}, anchorNode));
|
|
47
31
|
}
|
|
48
32
|
static hasKeyValuePairEmptyKey(node) {
|
|
49
33
|
if (node.type !== 'block_mapping_pair' && node.type !== 'flow_pair') {
|
|
@@ -65,12 +49,10 @@ class CstVisitor {
|
|
|
65
49
|
} = node;
|
|
66
50
|
const explicitName = (tagNode === null || tagNode === void 0 ? void 0 : tagNode.text) || (node.type === 'plain_scalar' ? '?' : '!');
|
|
67
51
|
const kind = node.type.endsWith('mapping') ? YamlNodeKind.Mapping : node.type.endsWith('sequence') ? YamlNodeKind.Sequence : YamlNodeKind.Scalar;
|
|
68
|
-
|
|
69
|
-
return new YamlTag({
|
|
52
|
+
return new YamlTag(assignSourceMap({
|
|
70
53
|
explicitName,
|
|
71
|
-
kind
|
|
72
|
-
|
|
73
|
-
});
|
|
54
|
+
kind
|
|
55
|
+
}, tagNode));
|
|
74
56
|
}
|
|
75
57
|
|
|
76
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -78,12 +60,10 @@ class CstVisitor {
|
|
|
78
60
|
referenceManager;
|
|
79
61
|
stream = {
|
|
80
62
|
enter: node => {
|
|
81
|
-
|
|
82
|
-
return new YamlStream({
|
|
63
|
+
return new YamlStream(assignSourceMap({
|
|
83
64
|
children: node.children,
|
|
84
|
-
position,
|
|
85
65
|
isMissing: node.isMissing
|
|
86
|
-
});
|
|
66
|
+
}, node));
|
|
87
67
|
},
|
|
88
68
|
leave: stream => {
|
|
89
69
|
return new ParseResult({
|
|
@@ -94,58 +74,50 @@ class CstVisitor {
|
|
|
94
74
|
yaml_directive = {
|
|
95
75
|
enter: node => {
|
|
96
76
|
var _node$firstNamedChild;
|
|
97
|
-
const position = CstVisitor.toPosition(node);
|
|
98
77
|
const version = node === null || node === void 0 || (_node$firstNamedChild = node.firstNamedChild) === null || _node$firstNamedChild === void 0 ? void 0 : _node$firstNamedChild.text;
|
|
99
|
-
return new YamlDirective({
|
|
100
|
-
position,
|
|
78
|
+
return new YamlDirective(assignSourceMap({
|
|
101
79
|
name: '%YAML',
|
|
102
80
|
parameters: {
|
|
103
81
|
version
|
|
104
82
|
}
|
|
105
|
-
});
|
|
83
|
+
}, node));
|
|
106
84
|
}
|
|
107
85
|
};
|
|
108
86
|
tag_directive = {
|
|
109
87
|
enter: node => {
|
|
110
|
-
const position = CstVisitor.toPosition(node);
|
|
111
88
|
const tagHandleNode = node.children[0];
|
|
112
89
|
const tagPrefixNode = node.children[1];
|
|
113
|
-
const tagDirective = new YamlDirective({
|
|
114
|
-
position,
|
|
90
|
+
const tagDirective = new YamlDirective(assignSourceMap({
|
|
115
91
|
name: '%TAG',
|
|
116
92
|
parameters: {
|
|
117
93
|
handle: tagHandleNode === null || tagHandleNode === void 0 ? void 0 : tagHandleNode.text,
|
|
118
94
|
prefix: tagPrefixNode === null || tagPrefixNode === void 0 ? void 0 : tagPrefixNode.text
|
|
119
95
|
}
|
|
120
|
-
});
|
|
96
|
+
}, node));
|
|
121
97
|
this.schema.registerTagDirective(tagDirective);
|
|
122
98
|
return tagDirective;
|
|
123
99
|
}
|
|
124
100
|
};
|
|
125
101
|
reserved_directive = {
|
|
126
102
|
enter: node => {
|
|
127
|
-
const position = CstVisitor.toPosition(node);
|
|
128
103
|
const directiveNameNode = node.children[0];
|
|
129
104
|
const directiveParameter1Node = node.children[1];
|
|
130
105
|
const directiveParameter2Node = node.children[2];
|
|
131
|
-
return new YamlDirective({
|
|
132
|
-
position,
|
|
106
|
+
return new YamlDirective(assignSourceMap({
|
|
133
107
|
name: directiveNameNode === null || directiveNameNode === void 0 ? void 0 : directiveNameNode.text,
|
|
134
108
|
parameters: {
|
|
135
109
|
handle: directiveParameter1Node === null || directiveParameter1Node === void 0 ? void 0 : directiveParameter1Node.text,
|
|
136
110
|
prefix: directiveParameter2Node === null || directiveParameter2Node === void 0 ? void 0 : directiveParameter2Node.text
|
|
137
111
|
}
|
|
138
|
-
});
|
|
112
|
+
}, node));
|
|
139
113
|
}
|
|
140
114
|
};
|
|
141
115
|
document = {
|
|
142
116
|
enter: node => {
|
|
143
|
-
|
|
144
|
-
return new YamlDocument({
|
|
117
|
+
return new YamlDocument(assignSourceMap({
|
|
145
118
|
children: node.children,
|
|
146
|
-
position,
|
|
147
119
|
isMissing: node.isMissing
|
|
148
|
-
});
|
|
120
|
+
}, node));
|
|
149
121
|
},
|
|
150
122
|
leave: node => {
|
|
151
123
|
node.children = node.children.flat();
|
|
@@ -164,21 +136,17 @@ class CstVisitor {
|
|
|
164
136
|
if (CstVisitor.isScalar(kindCandidate) || CstVisitor.isMapping(kindCandidate) || CstVisitor.isSequence(kindCandidate)) {
|
|
165
137
|
return node.children;
|
|
166
138
|
}
|
|
167
|
-
|
|
168
139
|
// kind node not present in flow node, creating empty node
|
|
169
|
-
const emptyPoint = new Point({
|
|
170
|
-
row: kindCandidate.endPosition.row,
|
|
171
|
-
column: kindCandidate.endPosition.column,
|
|
172
|
-
char: kindCandidate.endIndex
|
|
173
|
-
});
|
|
174
140
|
const emptyScalarNode = new YamlScalar({
|
|
175
141
|
content: '',
|
|
176
142
|
anchor: CstVisitor.kindNodeToYamlAnchor(kindCandidate),
|
|
177
143
|
tag: CstVisitor.kindNodeToYamlTag(kindCandidate),
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
144
|
+
startPositionRow: kindCandidate.endPositionRow,
|
|
145
|
+
startPositionColumn: kindCandidate.endPositionColumn,
|
|
146
|
+
startIndex: kindCandidate.endIndex,
|
|
147
|
+
endPositionRow: kindCandidate.endPositionRow,
|
|
148
|
+
endPositionColumn: kindCandidate.endPositionColumn,
|
|
149
|
+
endIndex: kindCandidate.endIndex,
|
|
182
150
|
styleGroup: YamlStyleGroup.Flow,
|
|
183
151
|
style: YamlStyle.Plain
|
|
184
152
|
});
|
|
@@ -198,25 +166,22 @@ class CstVisitor {
|
|
|
198
166
|
};
|
|
199
167
|
block_mapping = {
|
|
200
168
|
enter: node => {
|
|
201
|
-
const position = CstVisitor.toPosition(node);
|
|
202
169
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
203
170
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
204
|
-
const mappingNode = new YamlMapping({
|
|
171
|
+
const mappingNode = new YamlMapping(assignSourceMap({
|
|
205
172
|
children: node.children,
|
|
206
|
-
position,
|
|
207
173
|
anchor,
|
|
208
174
|
tag,
|
|
209
175
|
styleGroup: YamlStyleGroup.Block,
|
|
210
176
|
style: YamlStyle.NextLine,
|
|
211
177
|
isMissing: node.isMissing
|
|
212
|
-
});
|
|
178
|
+
}, node));
|
|
213
179
|
this.registerAnchor(mappingNode);
|
|
214
180
|
return this.schema.resolve(mappingNode);
|
|
215
181
|
}
|
|
216
182
|
};
|
|
217
183
|
block_mapping_pair = {
|
|
218
184
|
enter: node => {
|
|
219
|
-
const position = CstVisitor.toPosition(node);
|
|
220
185
|
const children = [...node.children];
|
|
221
186
|
if (CstVisitor.hasKeyValuePairEmptyKey(node)) {
|
|
222
187
|
const keyNode = this.createKeyValuePairEmptyKey(node);
|
|
@@ -226,35 +191,31 @@ class CstVisitor {
|
|
|
226
191
|
const valueNode = this.createKeyValuePairEmptyValue(node);
|
|
227
192
|
children.push(valueNode);
|
|
228
193
|
}
|
|
229
|
-
return new YamlKeyValuePair({
|
|
194
|
+
return new YamlKeyValuePair(assignSourceMap({
|
|
230
195
|
children,
|
|
231
|
-
position,
|
|
232
196
|
styleGroup: YamlStyleGroup.Block,
|
|
233
197
|
isMissing: node.isMissing
|
|
234
|
-
});
|
|
198
|
+
}, node));
|
|
235
199
|
}
|
|
236
200
|
};
|
|
237
201
|
flow_mapping = {
|
|
238
202
|
enter: node => {
|
|
239
|
-
const position = CstVisitor.toPosition(node);
|
|
240
203
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
241
204
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
242
|
-
const mappingNode = new YamlMapping({
|
|
205
|
+
const mappingNode = new YamlMapping(assignSourceMap({
|
|
243
206
|
children: node.children,
|
|
244
|
-
position,
|
|
245
207
|
anchor,
|
|
246
208
|
tag,
|
|
247
209
|
styleGroup: YamlStyleGroup.Flow,
|
|
248
210
|
style: YamlStyle.Explicit,
|
|
249
211
|
isMissing: node.isMissing
|
|
250
|
-
});
|
|
212
|
+
}, node));
|
|
251
213
|
this.registerAnchor(mappingNode);
|
|
252
214
|
return this.schema.resolve(mappingNode);
|
|
253
215
|
}
|
|
254
216
|
};
|
|
255
217
|
flow_pair = {
|
|
256
218
|
enter: node => {
|
|
257
|
-
const position = CstVisitor.toPosition(node);
|
|
258
219
|
const children = [...node.children];
|
|
259
220
|
if (CstVisitor.hasKeyValuePairEmptyKey(node)) {
|
|
260
221
|
const keyNode = this.createKeyValuePairEmptyKey(node);
|
|
@@ -264,12 +225,11 @@ class CstVisitor {
|
|
|
264
225
|
const valueNode = this.createKeyValuePairEmptyValue(node);
|
|
265
226
|
children.push(valueNode);
|
|
266
227
|
}
|
|
267
|
-
return new YamlKeyValuePair({
|
|
228
|
+
return new YamlKeyValuePair(assignSourceMap({
|
|
268
229
|
children,
|
|
269
|
-
position,
|
|
270
230
|
styleGroup: YamlStyleGroup.Flow,
|
|
271
231
|
isMissing: node.isMissing
|
|
272
|
-
});
|
|
232
|
+
}, node));
|
|
273
233
|
}
|
|
274
234
|
};
|
|
275
235
|
keyValuePair = {
|
|
@@ -279,17 +239,15 @@ class CstVisitor {
|
|
|
279
239
|
};
|
|
280
240
|
block_sequence = {
|
|
281
241
|
enter: node => {
|
|
282
|
-
const position = CstVisitor.toPosition(node);
|
|
283
242
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
284
243
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
285
|
-
const sequenceNode = new YamlSequence({
|
|
244
|
+
const sequenceNode = new YamlSequence(assignSourceMap({
|
|
286
245
|
children: node.children,
|
|
287
|
-
position,
|
|
288
246
|
anchor,
|
|
289
247
|
tag,
|
|
290
248
|
styleGroup: YamlStyleGroup.Block,
|
|
291
249
|
style: YamlStyle.NextLine
|
|
292
|
-
});
|
|
250
|
+
}, node));
|
|
293
251
|
this.registerAnchor(sequenceNode);
|
|
294
252
|
return this.schema.resolve(sequenceNode);
|
|
295
253
|
}
|
|
@@ -302,21 +260,18 @@ class CstVisitor {
|
|
|
302
260
|
}
|
|
303
261
|
|
|
304
262
|
// create empty node
|
|
305
|
-
const emptyPoint = new Point({
|
|
306
|
-
row: node.endPosition.row,
|
|
307
|
-
column: node.endPosition.column,
|
|
308
|
-
char: node.endIndex
|
|
309
|
-
});
|
|
310
263
|
const emptyScalarNode = new YamlScalar({
|
|
311
264
|
content: '',
|
|
312
265
|
tag: new YamlTag({
|
|
313
266
|
explicitName: '?',
|
|
314
267
|
kind: YamlNodeKind.Scalar
|
|
315
268
|
}),
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
269
|
+
startPositionRow: node.endPositionRow,
|
|
270
|
+
startPositionColumn: node.endPositionColumn,
|
|
271
|
+
startIndex: node.endIndex,
|
|
272
|
+
endPositionRow: node.endPositionRow,
|
|
273
|
+
endPositionColumn: node.endPositionColumn,
|
|
274
|
+
endIndex: node.endIndex,
|
|
320
275
|
styleGroup: YamlStyleGroup.Flow,
|
|
321
276
|
style: YamlStyle.Plain
|
|
322
277
|
});
|
|
@@ -325,17 +280,15 @@ class CstVisitor {
|
|
|
325
280
|
};
|
|
326
281
|
flow_sequence = {
|
|
327
282
|
enter: node => {
|
|
328
|
-
const position = CstVisitor.toPosition(node);
|
|
329
283
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
330
284
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
331
|
-
const sequenceNode = new YamlSequence({
|
|
285
|
+
const sequenceNode = new YamlSequence(assignSourceMap({
|
|
332
286
|
children: node.children.flat(),
|
|
333
|
-
position,
|
|
334
287
|
anchor,
|
|
335
288
|
tag,
|
|
336
289
|
styleGroup: YamlStyleGroup.Flow,
|
|
337
290
|
style: YamlStyle.Explicit
|
|
338
|
-
});
|
|
291
|
+
}, node));
|
|
339
292
|
this.registerAnchor(sequenceNode);
|
|
340
293
|
return this.schema.resolve(sequenceNode);
|
|
341
294
|
}
|
|
@@ -347,69 +300,61 @@ class CstVisitor {
|
|
|
347
300
|
};
|
|
348
301
|
plain_scalar = {
|
|
349
302
|
enter: node => {
|
|
350
|
-
const position = CstVisitor.toPosition(node);
|
|
351
303
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
352
304
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
353
|
-
const scalarNode = new YamlScalar({
|
|
305
|
+
const scalarNode = new YamlScalar(assignSourceMap({
|
|
354
306
|
content: node.text,
|
|
355
307
|
anchor,
|
|
356
308
|
tag,
|
|
357
|
-
position,
|
|
358
309
|
styleGroup: YamlStyleGroup.Flow,
|
|
359
310
|
style: YamlStyle.Plain
|
|
360
|
-
});
|
|
311
|
+
}, node));
|
|
361
312
|
this.registerAnchor(scalarNode);
|
|
362
313
|
return this.schema.resolve(scalarNode);
|
|
363
314
|
}
|
|
364
315
|
};
|
|
365
316
|
single_quote_scalar = {
|
|
366
317
|
enter: node => {
|
|
367
|
-
const position = CstVisitor.toPosition(node);
|
|
368
318
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
369
319
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
370
|
-
const scalarNode = new YamlScalar({
|
|
320
|
+
const scalarNode = new YamlScalar(assignSourceMap({
|
|
371
321
|
content: node.text,
|
|
372
322
|
anchor,
|
|
373
323
|
tag,
|
|
374
|
-
position,
|
|
375
324
|
styleGroup: YamlStyleGroup.Flow,
|
|
376
325
|
style: YamlStyle.SingleQuoted
|
|
377
|
-
});
|
|
326
|
+
}, node));
|
|
378
327
|
this.registerAnchor(scalarNode);
|
|
379
328
|
return this.schema.resolve(scalarNode);
|
|
380
329
|
}
|
|
381
330
|
};
|
|
382
331
|
double_quote_scalar = {
|
|
383
332
|
enter: node => {
|
|
384
|
-
const position = CstVisitor.toPosition(node);
|
|
385
333
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
386
334
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
387
|
-
const scalarNode = new YamlScalar({
|
|
335
|
+
const scalarNode = new YamlScalar(assignSourceMap({
|
|
388
336
|
content: node.text,
|
|
389
337
|
anchor,
|
|
390
338
|
tag,
|
|
391
|
-
position,
|
|
392
339
|
styleGroup: YamlStyleGroup.Flow,
|
|
393
340
|
style: YamlStyle.DoubleQuoted
|
|
394
|
-
});
|
|
341
|
+
}, node));
|
|
395
342
|
this.registerAnchor(scalarNode);
|
|
396
343
|
return this.schema.resolve(scalarNode);
|
|
397
344
|
}
|
|
398
345
|
};
|
|
399
346
|
block_scalar = {
|
|
400
347
|
enter: node => {
|
|
401
|
-
const position = CstVisitor.toPosition(node);
|
|
402
348
|
const tag = CstVisitor.kindNodeToYamlTag(node);
|
|
403
349
|
const anchor = CstVisitor.kindNodeToYamlAnchor(node);
|
|
404
350
|
const style = node.text.startsWith('|') ? YamlStyle.Literal : node.text.startsWith('>') ? YamlStyle.Folded : YamlStyle.Plain;
|
|
405
|
-
const scalarNode = new YamlScalar({
|
|
351
|
+
const scalarNode = new YamlScalar(assignSourceMap({
|
|
406
352
|
content: node.text,
|
|
407
353
|
anchor,
|
|
408
354
|
tag,
|
|
409
|
-
position,
|
|
410
355
|
styleGroup: YamlStyleGroup.Block,
|
|
411
356
|
style
|
|
412
|
-
});
|
|
357
|
+
}, node));
|
|
413
358
|
this.registerAnchor(scalarNode);
|
|
414
359
|
return this.schema.resolve(scalarNode);
|
|
415
360
|
}
|
|
@@ -439,30 +384,26 @@ class CstVisitor {
|
|
|
439
384
|
enter(node) {
|
|
440
385
|
// missing anonymous literals from CST transformed into AST literal nodes
|
|
441
386
|
if (node instanceof TreeCursorSyntaxNode && !node.isNamed) {
|
|
442
|
-
const position = CstVisitor.toPosition(node);
|
|
443
387
|
const value = node.type || node.text;
|
|
444
388
|
const {
|
|
445
389
|
isMissing
|
|
446
390
|
} = node;
|
|
447
|
-
return new Literal({
|
|
391
|
+
return new Literal(assignSourceMap({
|
|
448
392
|
value,
|
|
449
|
-
position,
|
|
450
393
|
isMissing
|
|
451
|
-
});
|
|
394
|
+
}, node));
|
|
452
395
|
}
|
|
453
396
|
return undefined;
|
|
454
397
|
}
|
|
455
398
|
|
|
456
399
|
// eslint-disable-next-line class-methods-use-this
|
|
457
400
|
ERROR(node, key, parent, path) {
|
|
458
|
-
const
|
|
459
|
-
const errorNode = new Error({
|
|
401
|
+
const errorNode = new Error(assignSourceMap({
|
|
460
402
|
children: node.children,
|
|
461
|
-
position,
|
|
462
403
|
isUnexpected: !node.hasError,
|
|
463
404
|
isMissing: node.isMissing,
|
|
464
405
|
value: node.text
|
|
465
|
-
});
|
|
406
|
+
}, node));
|
|
466
407
|
if (path.length === 0) {
|
|
467
408
|
return new ParseResult({
|
|
468
409
|
children: [errorNode]
|
|
@@ -476,35 +417,30 @@ class CstVisitor {
|
|
|
476
417
|
}
|
|
477
418
|
}
|
|
478
419
|
createKeyValuePairEmptyKey(node) {
|
|
479
|
-
const emptyPoint = new Point({
|
|
480
|
-
row: node.startPosition.row,
|
|
481
|
-
column: node.startPosition.column,
|
|
482
|
-
char: node.startIndex
|
|
483
|
-
});
|
|
484
420
|
const {
|
|
485
421
|
keyNode
|
|
486
422
|
} = node;
|
|
487
423
|
const children = (keyNode === null || keyNode === void 0 ? void 0 : keyNode.children) || [];
|
|
488
424
|
const tagNode = children.find(CstVisitor.isKind('tag'));
|
|
489
425
|
const anchorNode = children.find(CstVisitor.isKind('anchor'));
|
|
490
|
-
const tag = typeof tagNode !== 'undefined' ? new YamlTag({
|
|
426
|
+
const tag = typeof tagNode !== 'undefined' ? new YamlTag(assignSourceMap({
|
|
491
427
|
explicitName: tagNode.text,
|
|
492
|
-
kind: YamlNodeKind.Scalar
|
|
493
|
-
|
|
494
|
-
}) : new YamlTag({
|
|
428
|
+
kind: YamlNodeKind.Scalar
|
|
429
|
+
}, tagNode)) : new YamlTag({
|
|
495
430
|
explicitName: '?',
|
|
496
431
|
kind: YamlNodeKind.Scalar
|
|
497
432
|
});
|
|
498
|
-
const anchor = typeof anchorNode !== 'undefined' ? new YamlAnchor({
|
|
499
|
-
name: anchorNode.text
|
|
500
|
-
|
|
501
|
-
}) : undefined;
|
|
433
|
+
const anchor = typeof anchorNode !== 'undefined' ? new YamlAnchor(assignSourceMap({
|
|
434
|
+
name: anchorNode.text
|
|
435
|
+
}, anchorNode)) : undefined;
|
|
502
436
|
const scalarNode = new YamlScalar({
|
|
503
437
|
content: '',
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
438
|
+
startPositionRow: node.startPositionRow,
|
|
439
|
+
startPositionColumn: node.startPositionColumn,
|
|
440
|
+
startIndex: node.startIndex,
|
|
441
|
+
endPositionRow: node.startPositionRow,
|
|
442
|
+
endPositionColumn: node.startPositionColumn,
|
|
443
|
+
endIndex: node.startIndex,
|
|
508
444
|
tag,
|
|
509
445
|
anchor,
|
|
510
446
|
styleGroup: YamlStyleGroup.Flow,
|
|
@@ -514,35 +450,30 @@ class CstVisitor {
|
|
|
514
450
|
return scalarNode;
|
|
515
451
|
}
|
|
516
452
|
createKeyValuePairEmptyValue(node) {
|
|
517
|
-
const emptyPoint = new Point({
|
|
518
|
-
row: node.endPosition.row,
|
|
519
|
-
column: node.endPosition.column,
|
|
520
|
-
char: node.endIndex
|
|
521
|
-
});
|
|
522
453
|
const {
|
|
523
454
|
valueNode
|
|
524
455
|
} = node;
|
|
525
456
|
const children = (valueNode === null || valueNode === void 0 ? void 0 : valueNode.children) || [];
|
|
526
457
|
const tagNode = children.find(CstVisitor.isKind('tag'));
|
|
527
458
|
const anchorNode = children.find(CstVisitor.isKind('anchor'));
|
|
528
|
-
const tag = typeof tagNode !== 'undefined' ? new YamlTag({
|
|
459
|
+
const tag = typeof tagNode !== 'undefined' ? new YamlTag(assignSourceMap({
|
|
529
460
|
explicitName: tagNode.text,
|
|
530
|
-
kind: YamlNodeKind.Scalar
|
|
531
|
-
|
|
532
|
-
}) : new YamlTag({
|
|
461
|
+
kind: YamlNodeKind.Scalar
|
|
462
|
+
}, tagNode)) : new YamlTag({
|
|
533
463
|
explicitName: '?',
|
|
534
464
|
kind: YamlNodeKind.Scalar
|
|
535
465
|
});
|
|
536
|
-
const anchor = typeof anchorNode !== 'undefined' ? new YamlAnchor({
|
|
537
|
-
name: anchorNode.text
|
|
538
|
-
|
|
539
|
-
}) : undefined;
|
|
466
|
+
const anchor = typeof anchorNode !== 'undefined' ? new YamlAnchor(assignSourceMap({
|
|
467
|
+
name: anchorNode.text
|
|
468
|
+
}, anchorNode)) : undefined;
|
|
540
469
|
const scalarNode = new YamlScalar({
|
|
541
470
|
content: '',
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
471
|
+
startPositionRow: node.endPositionRow,
|
|
472
|
+
startPositionColumn: node.endPositionColumn,
|
|
473
|
+
startIndex: node.endIndex,
|
|
474
|
+
endPositionRow: node.endPositionRow,
|
|
475
|
+
endPositionColumn: node.endPositionColumn,
|
|
476
|
+
endIndex: node.endIndex,
|
|
546
477
|
tag,
|
|
547
478
|
anchor,
|
|
548
479
|
styleGroup: YamlStyleGroup.Flow,
|
|
@@ -155,12 +155,7 @@ class YamlAstVisitor {
|
|
|
155
155
|
if (!this.sourceMap) {
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
|
-
|
|
159
|
-
// @ts-ignore
|
|
160
|
-
sourceMap.position = node.position;
|
|
161
|
-
// @ts-ignore
|
|
162
|
-
sourceMap.astNode = node;
|
|
163
|
-
element.meta.set('sourceMap', sourceMap);
|
|
158
|
+
(0, _apidomCore.assignSourceMap)(element, node);
|
|
164
159
|
}
|
|
165
160
|
}
|
|
166
161
|
var _default = exports.default = YamlAstVisitor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNodeType as getCSTNodeType, isNode as isCSTNode, YamlStyle } from '@swagger-api/apidom-ast';
|
|
2
|
-
import { ParseResultElement, AnnotationElement, CommentElement,
|
|
2
|
+
import { ParseResultElement, AnnotationElement, CommentElement, MemberElement, ObjectElement, ArrayElement, isPrimitiveElement, isElement, keyMap as keyMapApiDOM, getNodeType as getNodeTypeApiDOM, createNamespace, assignSourceMap } from '@swagger-api/apidom-core';
|
|
3
3
|
export const keyMap = {
|
|
4
4
|
stream: ['children'],
|
|
5
5
|
document: ['children'],
|
|
@@ -150,12 +150,7 @@ class YamlAstVisitor {
|
|
|
150
150
|
if (!this.sourceMap) {
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
// @ts-ignore
|
|
155
|
-
sourceMap.position = node.position;
|
|
156
|
-
// @ts-ignore
|
|
157
|
-
sourceMap.astNode = node;
|
|
158
|
-
element.meta.set('sourceMap', sourceMap);
|
|
153
|
+
assignSourceMap(element, node);
|
|
159
154
|
}
|
|
160
155
|
}
|
|
161
156
|
export default YamlAstVisitor;
|
|
Binary file
|
|
Binary file
|