101
*/
102
export function parseCommaSeparatedList(value: string, offset: number = 0): YamlScalarNode[] {
103
>
// Wrap the value as a YAML flow sequence and parse it.
yaml.ts
104
>
const parsed = parse(`[${value}]`);
105
>
// Items from the synthetic string start at offset 1 (after the '[').
106
>
// Shift them so they're relative to the original document position.
107
>
const shift = offset - 1;
108
>
const items: YamlScalarNode[] = [];
109
>
if (parsed && parsed.type === 'sequence') {
110
>
for (const item of parsed.items) {
111
if (item.type === 'scalar') {
112
items.push({ ...item, startOffset: item.startOffset + shift, endOffset: item.endOffset + shift });
113
}
114
}
116
items.push({ type: 'scalar', value, rawValue: value, startOffset: offset, endOffset: value.length + offset, format: 'none' });
117
}
119
>
}
120
121
// -- AST Node Types ----------------------------------------------------------