@effected/yaml 0.25.0 → 0.25.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/YamlFormat.js +6 -35
- package/internal/composer/comments.js +9 -31
- package/package.json +1 -1
package/YamlFormat.js
CHANGED
|
@@ -137,17 +137,8 @@ function requoteNode(node, text, quote) {
|
|
|
137
137
|
if (node instanceof YamlScalar) {
|
|
138
138
|
if (requoteScalarText(text, node, quote, "escaping") === void 0) return node;
|
|
139
139
|
return YamlScalar.make({
|
|
140
|
-
|
|
141
|
-
style: quote === "\"" ? "double-quoted" : "single-quoted"
|
|
142
|
-
...definedFields({
|
|
143
|
-
commentBefore: node.commentBefore,
|
|
144
|
-
comment: node.comment,
|
|
145
|
-
spaceBefore: node.spaceBefore,
|
|
146
|
-
raw: node.raw,
|
|
147
|
-
sourceMultiline: node.sourceMultiline
|
|
148
|
-
}),
|
|
149
|
-
offset: node.offset,
|
|
150
|
-
length: node.length
|
|
140
|
+
...node,
|
|
141
|
+
style: quote === "\"" ? "double-quoted" : "single-quoted"
|
|
151
142
|
});
|
|
152
143
|
}
|
|
153
144
|
if (node instanceof YamlMap) return rebuildMap(node, node.items.map((pair) => YamlPair.make({
|
|
@@ -401,34 +392,14 @@ function modifyNode(node, path, depth, value) {
|
|
|
401
392
|
}
|
|
402
393
|
function rebuildMap(node, items) {
|
|
403
394
|
return YamlMap.make({
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
...definedFields({
|
|
407
|
-
tag: node.tag,
|
|
408
|
-
anchor: node.anchor,
|
|
409
|
-
commentBefore: node.commentBefore,
|
|
410
|
-
comment: node.comment,
|
|
411
|
-
spaceBefore: node.spaceBefore,
|
|
412
|
-
sourceMultiline: node.sourceMultiline
|
|
413
|
-
}),
|
|
414
|
-
offset: node.offset,
|
|
415
|
-
length: node.length
|
|
395
|
+
...node,
|
|
396
|
+
items
|
|
416
397
|
});
|
|
417
398
|
}
|
|
418
399
|
function rebuildSeq(node, items) {
|
|
419
400
|
return YamlSeq.make({
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
...definedFields({
|
|
423
|
-
tag: node.tag,
|
|
424
|
-
anchor: node.anchor,
|
|
425
|
-
commentBefore: node.commentBefore,
|
|
426
|
-
comment: node.comment,
|
|
427
|
-
spaceBefore: node.spaceBefore,
|
|
428
|
-
sourceMultiline: node.sourceMultiline
|
|
429
|
-
}),
|
|
430
|
-
offset: node.offset,
|
|
431
|
-
length: node.length
|
|
401
|
+
...node,
|
|
402
|
+
items
|
|
432
403
|
});
|
|
433
404
|
}
|
|
434
405
|
/**
|
|
@@ -169,44 +169,22 @@ function columnAt(text, offset) {
|
|
|
169
169
|
* included.
|
|
170
170
|
*/
|
|
171
171
|
function withCommentFields(node, fields) {
|
|
172
|
+
const merged = mergedCommentFields(node, fields);
|
|
172
173
|
if (node instanceof YamlScalar) return new YamlScalar({
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
...node.tag !== void 0 ? { tag: node.tag } : {},
|
|
176
|
-
...node.anchor !== void 0 ? { anchor: node.anchor } : {},
|
|
177
|
-
...mergedCommentFields(node, fields),
|
|
178
|
-
...node.chomp !== void 0 ? { chomp: node.chomp } : {},
|
|
179
|
-
...node.blockIndent !== void 0 ? { blockIndent: node.blockIndent } : {},
|
|
180
|
-
...node.raw !== void 0 ? { raw: node.raw } : {},
|
|
181
|
-
...node.sourceMultiline !== void 0 ? { sourceMultiline: node.sourceMultiline } : {},
|
|
182
|
-
offset: node.offset,
|
|
183
|
-
length: node.length
|
|
174
|
+
...node,
|
|
175
|
+
...merged
|
|
184
176
|
});
|
|
185
177
|
if (node instanceof YamlMap) return new YamlMap({
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
...node.tag !== void 0 ? { tag: node.tag } : {},
|
|
189
|
-
...node.anchor !== void 0 ? { anchor: node.anchor } : {},
|
|
190
|
-
...mergedCommentFields(node, fields),
|
|
191
|
-
...node.sourceMultiline !== void 0 ? { sourceMultiline: node.sourceMultiline } : {},
|
|
192
|
-
offset: node.offset,
|
|
193
|
-
length: node.length
|
|
178
|
+
...node,
|
|
179
|
+
...merged
|
|
194
180
|
});
|
|
195
181
|
if (node instanceof YamlSeq) return new YamlSeq({
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
...node.tag !== void 0 ? { tag: node.tag } : {},
|
|
199
|
-
...node.anchor !== void 0 ? { anchor: node.anchor } : {},
|
|
200
|
-
...mergedCommentFields(node, fields),
|
|
201
|
-
...node.sourceMultiline !== void 0 ? { sourceMultiline: node.sourceMultiline } : {},
|
|
202
|
-
offset: node.offset,
|
|
203
|
-
length: node.length
|
|
182
|
+
...node,
|
|
183
|
+
...merged
|
|
204
184
|
});
|
|
205
185
|
return new YamlAlias({
|
|
206
|
-
|
|
207
|
-
...
|
|
208
|
-
offset: node.offset,
|
|
209
|
-
length: node.length
|
|
186
|
+
...node,
|
|
187
|
+
...merged
|
|
210
188
|
});
|
|
211
189
|
}
|
|
212
190
|
function mergedCommentFields(existing, incoming) {
|