parseman 0.30.0 → 0.31.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/dist/compiler/codegen.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/index.cjs +6 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +6 -4
- package/dist/index.js.map +2 -2
- package/dist/language-service/index.cjs +1 -1
- package/dist/language-service/index.cjs.map +2 -2
- package/dist/language-service/index.js +1 -1
- package/dist/language-service/index.js.map +2 -2
- package/dist/plugin/index.cjs +6 -4
- package/dist/plugin/index.cjs.map +2 -2
- package/dist/plugin/index.js +6 -4
- package/dist/plugin/index.js.map +2 -2
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/plugin/index.js
CHANGED
|
@@ -4385,9 +4385,9 @@ function emitLeafCapture(ctx, valExpr, startExpr, endExpr) {
|
|
|
4385
4385
|
const i = ind(ctx);
|
|
4386
4386
|
const lf = v(ctx, "_lf");
|
|
4387
4387
|
return [
|
|
4388
|
-
`${i}if (_ctx._cstLeaves) {`,
|
|
4388
|
+
`${i}if (_ctx._cstLeaves || _ctx._cstRawChildren) {`,
|
|
4389
4389
|
`${i} const ${lf} = { _tag: 'leaf', value: ${valExpr}, span: { start: ${startExpr}, end: ${endExpr} } }`,
|
|
4390
|
-
`${i} _ctx._cstLeaves.push(${lf})`,
|
|
4390
|
+
`${i} if (_ctx._cstLeaves) _ctx._cstLeaves.push(${lf})`,
|
|
4391
4391
|
`${i} if (_ctx._cstRawChildren) _ctx._cstRawChildren.push(${lf})`,
|
|
4392
4392
|
`${i}}`
|
|
4393
4393
|
];
|
|
@@ -5791,8 +5791,10 @@ function emitNode(def, ctx, pos) {
|
|
|
5791
5791
|
const directCstV = !structural && (!capturesChildren || !capturesRaw) ? v(ctx, "_dcst") : null;
|
|
5792
5792
|
const directCstGate = directCstV === null ? "false" : `${profileCapture} || _ctx.build?._parsemanCstOutput === true`;
|
|
5793
5793
|
const structuralCapturesTrivia = structural && (def.captureTrivia === true || def.trailingTrivia === true);
|
|
5794
|
+
const chNeededExpr = def.unwrap || def.collapse ? "true" : `(_ctx._pmReadsCh ??= (_ctx.build === undefined || _ctx.build._parsemanReadsChildren !== false || _ctx.build._parsemanCstCollapse !== undefined))`;
|
|
5795
|
+
const chAlloc = def.unwrap || def.collapse ? `${profileRecognizer} ? undefined : []` : `${profileRecognizer} ? undefined : ((${profileCapture} || ${chNeededExpr}) ? [] : undefined)`;
|
|
5794
5796
|
const allocStmt = structural ? `${i}const ${capTLv} = !(${profileRecognizer}) && (${profileCapture} || ${structuralCapturesTrivia ? "true" : hostTriviaGate}), ${capSTv} = !(${profileRecognizer} || ${profileCapture}) && (_ctx._pmCapST ??= (_ctx.build === undefined || _hostReads(_ctx.build, 6)))${capFv ? `, ${capFv} = !(${profileRecognizer}) && (${profileCapture} || (_ctx.build !== undefined && _hostReads(_ctx.build, 2)))` : ""}
|
|
5795
|
-
${i}const ${chV} = ${
|
|
5797
|
+
${i}const ${chV} = ${chAlloc}, ${rawV} = ${profileRecognizer} ? undefined : [], ${tlV} = ${profileRecognizer} ? undefined : ${innerEnablesTriviaCapture ? "[]" : `${capTLv} ? [] : _EMPTY_TL`}` : capturesTrivia ? `${directCstV ? `${i}const ${directCstV} = ${directCstGate}
|
|
5796
5798
|
` : ""}${i}const ${capTLv} = !(${profileRecognizer}), ${chV} = ${profileRecognizer} ? undefined : ${capturesChildren ? "[]" : `${directCstV} ? [] : undefined`}, ${rawV} = ${profileRecognizer} ? undefined : ${capturesRaw ? "[]" : `${directCstV} ? [] : undefined`}, ${tlV} = ${profileRecognizer} ? undefined : []` : `${directCstV ? `${i}const ${directCstV} = ${directCstGate}
|
|
5797
5799
|
` : ""}${i}const ${chV} = ${profileRecognizer} ? undefined : ${capturesChildren ? "[]" : `${directCstV} ? [] : undefined`}, ${rawV} = ${profileRecognizer} ? undefined : ${capturesRaw ? "[]" : `${directCstV} ? [] : undefined`}`;
|
|
5798
5800
|
const innerTl = structural || capturesTrivia ? structural && !innerEnablesTriviaCapture ? `${capTLv} ? ${tlV} : undefined` : tlV : "undefined";
|
|
@@ -7464,7 +7466,7 @@ function cstBuildHost(typeOrOptions, children2, _fields, span, rawChildren, triv
|
|
|
7464
7466
|
return buildCstNode(typeOrOptions, children2 ?? [], _fields, span ?? { start: 0, end: 0 }, rawChildren, triviaLog, state);
|
|
7465
7467
|
}
|
|
7466
7468
|
const collapse = normalizeCstCollapse(typeOrOptions?.collapse);
|
|
7467
|
-
const host = (type, children3, fields, span2, rawChildren2, triviaLog2, state2) => buildCstNode(type, children3, fields, span2, rawChildren2, triviaLog2, state2);
|
|
7469
|
+
const host = (type, children3, fields, span2, rawChildren2, triviaLog2, state2) => buildCstNode(type, children3 ?? [], fields, span2, rawChildren2, triviaLog2, state2);
|
|
7468
7470
|
host._parsemanCstOutput = true;
|
|
7469
7471
|
if (collapse) host._parsemanCstCollapse = collapse;
|
|
7470
7472
|
return host;
|