source: node_modules/yaml/dist/compose/resolve-block-seq.js@ 65b6638

main
Last change on this file since 65b6638 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1'use strict';
2
3var YAMLSeq = require('../nodes/YAMLSeq.js');
4var resolveProps = require('./resolve-props.js');
5var utilFlowIndentCheck = require('./util-flow-indent-check.js');
6
7function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, tag) {
8 const NodeClass = tag?.nodeClass ?? YAMLSeq.YAMLSeq;
9 const seq = new NodeClass(ctx.schema);
10 if (ctx.atRoot)
11 ctx.atRoot = false;
12 let offset = bs.offset;
13 let commentEnd = null;
14 for (const { start, value } of bs.items) {
15 const props = resolveProps.resolveProps(start, {
16 indicator: 'seq-item-ind',
17 next: value,
18 offset,
19 onError,
20 startOnNewline: true
21 });
22 if (!props.found) {
23 if (props.anchor || props.tag || value) {
24 if (value && value.type === 'block-seq')
25 onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
26 else
27 onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
28 }
29 else {
30 commentEnd = props.end;
31 if (props.comment)
32 seq.comment = props.comment;
33 continue;
34 }
35 }
36 const node = value
37 ? composeNode(ctx, value, props, onError)
38 : composeEmptyNode(ctx, props.end, start, null, props, onError);
39 if (ctx.schema.compat)
40 utilFlowIndentCheck.flowIndentCheck(bs.indent, value, onError);
41 offset = node.range[2];
42 seq.items.push(node);
43 }
44 seq.range = [bs.offset, offset, commentEnd ?? offset];
45 return seq;
46}
47
48exports.resolveBlockSeq = resolveBlockSeq;
Note: See TracBrowser for help on using the repository browser.