@abaplint/transpiler-cli 2.12.10 → 2.12.11
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/build/bundle.js +220 -114
- package/package.json +3 -3
package/build/bundle.js
CHANGED
|
@@ -53783,7 +53783,7 @@ class Registry {
|
|
|
53783
53783
|
}
|
|
53784
53784
|
static abaplintVersion() {
|
|
53785
53785
|
// magic, see build script "version.sh"
|
|
53786
|
-
return "2.113.
|
|
53786
|
+
return "2.113.241";
|
|
53787
53787
|
}
|
|
53788
53788
|
getDDICReferences() {
|
|
53789
53789
|
return this.ddicReferences;
|
|
@@ -56694,6 +56694,7 @@ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "./nod
|
|
|
56694
56694
|
const include_graph_1 = __webpack_require__(/*! ../utils/include_graph */ "./node_modules/@abaplint/core/build/src/utils/include_graph.js");
|
|
56695
56695
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
|
|
56696
56696
|
const objects_1 = __webpack_require__(/*! ../objects */ "./node_modules/@abaplint/core/build/src/objects/index.js");
|
|
56697
|
+
const severity_1 = __webpack_require__(/*! ../severity */ "./node_modules/@abaplint/core/build/src/severity.js");
|
|
56697
56698
|
class CheckIncludeConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
56698
56699
|
}
|
|
56699
56700
|
exports.CheckIncludeConf = CheckIncludeConf;
|
|
@@ -56722,7 +56723,7 @@ class CheckInclude {
|
|
|
56722
56723
|
}
|
|
56723
56724
|
initialize(reg) {
|
|
56724
56725
|
this.reg = reg;
|
|
56725
|
-
this.graph = new include_graph_1.IncludeGraph(this.reg);
|
|
56726
|
+
this.graph = new include_graph_1.IncludeGraph(this.reg, this.getConfig().severity || severity_1.Severity.Error);
|
|
56726
56727
|
return this;
|
|
56727
56728
|
}
|
|
56728
56729
|
run(obj) {
|
|
@@ -77420,10 +77421,11 @@ class Graph {
|
|
|
77420
77421
|
}
|
|
77421
77422
|
}
|
|
77422
77423
|
class IncludeGraph {
|
|
77423
|
-
constructor(reg) {
|
|
77424
|
+
constructor(reg, severity = severity_1.Severity.Error) {
|
|
77424
77425
|
this.reg = reg;
|
|
77425
77426
|
this.issues = [];
|
|
77426
77427
|
this.graph = new Graph();
|
|
77428
|
+
this.severity = severity;
|
|
77427
77429
|
this.build();
|
|
77428
77430
|
}
|
|
77429
77431
|
listMainForInclude(filename) {
|
|
@@ -77453,7 +77455,7 @@ class IncludeGraph {
|
|
|
77453
77455
|
if (f === undefined) {
|
|
77454
77456
|
throw new Error("findUnusedIncludes internal error");
|
|
77455
77457
|
}
|
|
77456
|
-
const issue = issue_1.Issue.atPosition(f, new position_1.Position(1, 1), "INCLUDE not used anywhere", new check_include_1.CheckInclude().getMetadata().key,
|
|
77458
|
+
const issue = issue_1.Issue.atPosition(f, new position_1.Position(1, 1), "INCLUDE not used anywhere", new check_include_1.CheckInclude().getMetadata().key, this.severity);
|
|
77457
77459
|
ret.push(issue);
|
|
77458
77460
|
}
|
|
77459
77461
|
return ret;
|
|
@@ -77481,12 +77483,12 @@ class IncludeGraph {
|
|
|
77481
77483
|
if (found === undefined) {
|
|
77482
77484
|
const ifFound = s.concatTokens().toUpperCase().includes("IF FOUND");
|
|
77483
77485
|
if (ifFound === false) {
|
|
77484
|
-
const issue = issue_1.Issue.atStatement(f, s, "Include " + name + " not found", new check_include_1.CheckInclude().getMetadata().key,
|
|
77486
|
+
const issue = issue_1.Issue.atStatement(f, s, "Include " + name + " not found", new check_include_1.CheckInclude().getMetadata().key, this.severity);
|
|
77485
77487
|
this.issues.push(issue);
|
|
77486
77488
|
}
|
|
77487
77489
|
}
|
|
77488
77490
|
else if (found.include === false) {
|
|
77489
|
-
const issue = issue_1.Issue.atStatement(f, s, "Not possible to INCLUDE a main program, " + name, new check_include_1.CheckInclude().getMetadata().key,
|
|
77491
|
+
const issue = issue_1.Issue.atStatement(f, s, "Not possible to INCLUDE a main program, " + name, new check_include_1.CheckInclude().getMetadata().key, this.severity);
|
|
77490
77492
|
this.issues.push(issue);
|
|
77491
77493
|
}
|
|
77492
77494
|
else {
|
|
@@ -82497,7 +82499,9 @@ class ValueBodyTranspiler {
|
|
|
82497
82499
|
let post = "";
|
|
82498
82500
|
let extraFields = "";
|
|
82499
82501
|
const hasLines = body.findDirectExpression(core_1.Expressions.ValueBodyLine) !== undefined;
|
|
82500
|
-
|
|
82502
|
+
const children = body.getChildren();
|
|
82503
|
+
for (let i = 0; i < children.length; i++) {
|
|
82504
|
+
const child = children[i];
|
|
82501
82505
|
if (child.get() instanceof core_1.Expressions.FieldAssignment && child instanceof core_1.Nodes.ExpressionNode) {
|
|
82502
82506
|
const transpiled = new field_assignment_1.FieldAssignmentTranspiler().transpile(child, traversal, context).getCode();
|
|
82503
82507
|
if (hasLines === false) {
|
|
@@ -82523,117 +82527,22 @@ class ValueBodyTranspiler {
|
|
|
82523
82527
|
ret.appendString(".set(" + source.getCode() + ".clone())");
|
|
82524
82528
|
}
|
|
82525
82529
|
else if (child.get() instanceof core_1.Expressions.For && child instanceof core_1.Nodes.ExpressionNode) {
|
|
82526
|
-
const
|
|
82527
|
-
|
|
82528
|
-
|
|
82529
|
-
|
|
82530
|
-
|
|
82531
|
-
|
|
82532
|
-
|
|
82533
|
-
if (whereNode) {
|
|
82534
|
-
const where = traversal.traverse(whereNode).getCode();
|
|
82535
|
-
loopWhere = `, {"where": async ` + where + `}`;
|
|
82536
|
-
}
|
|
82537
|
-
const base = loop.findDirectExpression(core_1.Expressions.ValueBase);
|
|
82538
|
-
if (base) {
|
|
82539
|
-
throw new Error("ValueBody FOR todo, base, " + body.concatTokens());
|
|
82540
|
-
}
|
|
82541
|
-
let targetDeclare = "";
|
|
82542
|
-
let targetAction = "";
|
|
82543
|
-
const fs = loop.findDirectExpression(core_1.Expressions.TargetFieldSymbol);
|
|
82544
|
-
if (fs) {
|
|
82545
|
-
targetDeclare = new statements_1.FieldSymbolTranspiler().transpile(fs, traversal).getCode();
|
|
82546
|
-
const targetName = new source_field_symbol_1.SourceFieldSymbolTranspiler().transpile(fs, traversal).getCode();
|
|
82547
|
-
targetAction = `${targetName}.assign(unique1);`;
|
|
82530
|
+
const forNodes = [];
|
|
82531
|
+
let idx = i;
|
|
82532
|
+
while (idx < children.length) {
|
|
82533
|
+
const candidate = children[idx];
|
|
82534
|
+
if (candidate.get() instanceof core_1.Expressions.For && candidate instanceof core_1.Nodes.ExpressionNode) {
|
|
82535
|
+
forNodes.push(candidate);
|
|
82536
|
+
idx++;
|
|
82548
82537
|
}
|
|
82549
82538
|
else {
|
|
82550
|
-
|
|
82551
|
-
if (field === undefined) {
|
|
82552
|
-
throw new Error("ValueBody FOR empty field todo, " + body.concatTokens());
|
|
82553
|
-
}
|
|
82554
|
-
targetAction = `const ${field.getCode()} = unique1.clone();`;
|
|
82555
|
-
}
|
|
82556
|
-
const llet = child.findDirectExpression(core_1.Expressions.Let);
|
|
82557
|
-
if (llet) {
|
|
82558
|
-
targetAction += new let_1.LetTranspiler().transpile(llet, traversal).getCode();
|
|
82559
|
-
}
|
|
82560
|
-
const source = traversal.traverse(loop.findDirectExpression(core_1.Expressions.Source)).getCode();
|
|
82561
|
-
const val = new type_name_or_infer_1.TypeNameOrInfer().transpile(typ, traversal).getCode();
|
|
82562
|
-
ret = new chunk_1.Chunk().appendString(`await (async () => {
|
|
82563
|
-
${targetDeclare}
|
|
82564
|
-
const VAL = ${val};
|
|
82565
|
-
for await (const unique1 of abap.statements.loop(${source}${loopWhere})) {
|
|
82566
|
-
${targetAction}
|
|
82567
|
-
VAL`);
|
|
82568
|
-
post = ";\n}\nreturn VAL;\n})()";
|
|
82569
|
-
}
|
|
82570
|
-
else {
|
|
82571
|
-
const counter = child.findDirectExpression(core_1.Expressions.InlineFieldDefinition);
|
|
82572
|
-
if (counter === undefined) {
|
|
82573
|
-
throw new Error("ValueBody FOR todo, " + body.concatTokens());
|
|
82574
|
-
}
|
|
82575
|
-
if (["GROUPS", "FROM", "TO"].some(token => child.findDirectTokenByText(token))) {
|
|
82576
|
-
throw new Error("ValueBody FOR todo, " + body.concatTokens());
|
|
82577
|
-
}
|
|
82578
|
-
if (child.findDirectExpression(core_1.Expressions.ComponentCond)) {
|
|
82579
|
-
throw new Error("ValueBody FOR todo, component cond, " + body.concatTokens());
|
|
82580
|
-
}
|
|
82581
|
-
const cond = child.findDirectExpression(core_1.Expressions.Cond);
|
|
82582
|
-
if (cond === undefined) {
|
|
82583
|
-
throw new Error("ValueBody FOR missing condition, " + body.concatTokens());
|
|
82584
|
-
}
|
|
82585
|
-
const hasUntil = child.findDirectTokenByText("UNTIL") !== undefined;
|
|
82586
|
-
const hasWhile = child.findDirectTokenByText("WHILE") !== undefined;
|
|
82587
|
-
if ((hasUntil ? 1 : 0) + (hasWhile ? 1 : 0) !== 1) {
|
|
82588
|
-
throw new Error("ValueBody FOR todo, condition, " + body.concatTokens());
|
|
82589
|
-
}
|
|
82590
|
-
const fieldExpr = counter.findDirectExpression(core_1.Expressions.Field);
|
|
82591
|
-
const fieldName = fieldExpr?.concatTokens().toLowerCase();
|
|
82592
|
-
if (fieldName === undefined) {
|
|
82593
|
-
throw new Error("ValueBody FOR todo, inline field, " + body.concatTokens());
|
|
82594
|
-
}
|
|
82595
|
-
const scope = traversal.findCurrentScopeByToken(counter.getFirstToken());
|
|
82596
|
-
const variable = scope?.findVariable(fieldName);
|
|
82597
|
-
if (variable === undefined) {
|
|
82598
|
-
throw new Error("ValueBody FOR todo, variable, " + body.concatTokens());
|
|
82599
|
-
}
|
|
82600
|
-
const declare = transpile_types_1.TranspileTypes.declare(variable);
|
|
82601
|
-
const counterName = traversal_1.Traversal.prefixVariable(fieldName);
|
|
82602
|
-
const startSource = counter.findDirectExpression(core_1.Expressions.Source);
|
|
82603
|
-
if (startSource === undefined) {
|
|
82604
|
-
throw new Error("ValueBody FOR missing initial value, " + body.concatTokens());
|
|
82605
|
-
}
|
|
82606
|
-
const start = traversal.traverse(startSource).getCode();
|
|
82607
|
-
const thenExpr = child.findExpressionAfterToken("THEN");
|
|
82608
|
-
let incrementExpression = "";
|
|
82609
|
-
if (thenExpr && thenExpr instanceof core_1.Nodes.ExpressionNode) {
|
|
82610
|
-
incrementExpression = traversal.traverse(thenExpr).getCode();
|
|
82611
|
-
}
|
|
82612
|
-
else {
|
|
82613
|
-
incrementExpression = `abap.operators.add(${counterName}, new abap.types.Integer().set(1))`;
|
|
82614
|
-
}
|
|
82615
|
-
const incrementLine = `${counterName}.set(${incrementExpression});`;
|
|
82616
|
-
const llet = child.findDirectExpression(core_1.Expressions.Let);
|
|
82617
|
-
let letCode = "";
|
|
82618
|
-
if (llet) {
|
|
82619
|
-
letCode = new let_1.LetTranspiler().transpile(llet, traversal).getCode();
|
|
82620
|
-
}
|
|
82621
|
-
const letSection = letCode === "" ? "" : " " + letCode.replace(/\n/g, "\n ") + "\n";
|
|
82622
|
-
const condCode = traversal.traverse(cond).getCode();
|
|
82623
|
-
const val = new type_name_or_infer_1.TypeNameOrInfer().transpile(typ, traversal).getCode();
|
|
82624
|
-
const preCheck = hasWhile ? ` if (!(${condCode})) {\n break;\n }\n` : "";
|
|
82625
|
-
let postLoop = ` ${incrementLine}\n`;
|
|
82626
|
-
if (hasUntil) {
|
|
82627
|
-
postLoop += ` if (${condCode}) {\n break;\n }\n`;
|
|
82539
|
+
break;
|
|
82628
82540
|
}
|
|
82629
|
-
ret = new chunk_1.Chunk().appendString(`await (async () => {
|
|
82630
|
-
${declare}
|
|
82631
|
-
${counterName}.set(${start});
|
|
82632
|
-
const VAL = ${val};
|
|
82633
|
-
while (true) {
|
|
82634
|
-
${preCheck}${letSection} VAL`);
|
|
82635
|
-
post = ";\n" + postLoop + "}\nreturn VAL;\n})()";
|
|
82636
82541
|
}
|
|
82542
|
+
i = idx - 1;
|
|
82543
|
+
const result = this.buildForChain(forNodes, typ, traversal, body);
|
|
82544
|
+
ret = result.chunk;
|
|
82545
|
+
post = result.post;
|
|
82637
82546
|
}
|
|
82638
82547
|
else if (child instanceof core_1.Nodes.TokenNode && child.getFirstToken().getStr().toUpperCase() === "DEFAULT") {
|
|
82639
82548
|
// note: this is last in the body, so its okay to prepend and postpend
|
|
@@ -82655,6 +82564,203 @@ ${preCheck}${letSection} VAL`);
|
|
|
82655
82564
|
}
|
|
82656
82565
|
return ret.appendString(post);
|
|
82657
82566
|
}
|
|
82567
|
+
buildForChain(forNodes, typ, traversal, body) {
|
|
82568
|
+
const val = new type_name_or_infer_1.TypeNameOrInfer().transpile(typ, traversal).getCode();
|
|
82569
|
+
const chunk = new chunk_1.Chunk();
|
|
82570
|
+
const preLoopDecls = [];
|
|
82571
|
+
const descriptors = [];
|
|
82572
|
+
const levelIndents = [];
|
|
82573
|
+
let uniqueCounter = 1;
|
|
82574
|
+
for (const child of forNodes) {
|
|
82575
|
+
const loop = child.findDirectExpression(core_1.Expressions.InlineLoopDefinition);
|
|
82576
|
+
if (loop) {
|
|
82577
|
+
if (["THEN", "UNTIL", "WHILE", "FROM", "TO", "GROUPS"].some(token => child.findDirectTokenByText(token))) {
|
|
82578
|
+
throw new Error("ValueBody FOR todo, " + body.concatTokens());
|
|
82579
|
+
}
|
|
82580
|
+
let loopWhere = "";
|
|
82581
|
+
const whereNode = child.findDirectExpression(core_1.Expressions.ComponentCond);
|
|
82582
|
+
if (whereNode) {
|
|
82583
|
+
const where = traversal.traverse(whereNode).getCode();
|
|
82584
|
+
loopWhere = `, {"where": async ` + where + `}`;
|
|
82585
|
+
}
|
|
82586
|
+
const base = loop.findDirectExpression(core_1.Expressions.ValueBase);
|
|
82587
|
+
if (base) {
|
|
82588
|
+
throw new Error("ValueBody FOR todo, base, " + body.concatTokens());
|
|
82589
|
+
}
|
|
82590
|
+
let targetDeclare = "";
|
|
82591
|
+
let targetAction = "";
|
|
82592
|
+
const fs = loop.findDirectExpression(core_1.Expressions.TargetFieldSymbol);
|
|
82593
|
+
const uniqueName = `unique${uniqueCounter++}`;
|
|
82594
|
+
if (fs) {
|
|
82595
|
+
targetDeclare = new statements_1.FieldSymbolTranspiler().transpile(fs, traversal).getCode();
|
|
82596
|
+
const targetName = new source_field_symbol_1.SourceFieldSymbolTranspiler().transpile(fs, traversal).getCode();
|
|
82597
|
+
targetAction = `${targetName}.assign(${uniqueName});`;
|
|
82598
|
+
}
|
|
82599
|
+
else {
|
|
82600
|
+
const field = traversal.traverse(loop.findDirectExpression(core_1.Expressions.TargetField));
|
|
82601
|
+
if (field === undefined) {
|
|
82602
|
+
throw new Error("ValueBody FOR empty field todo, " + body.concatTokens());
|
|
82603
|
+
}
|
|
82604
|
+
targetAction = `const ${field.getCode()} = ${uniqueName}.clone();`;
|
|
82605
|
+
}
|
|
82606
|
+
const llet = child.findDirectExpression(core_1.Expressions.Let);
|
|
82607
|
+
if (llet) {
|
|
82608
|
+
targetAction += new let_1.LetTranspiler().transpile(llet, traversal).getCode();
|
|
82609
|
+
}
|
|
82610
|
+
const preBodyStatements = [];
|
|
82611
|
+
if (targetAction !== "") {
|
|
82612
|
+
preBodyStatements.push(targetAction);
|
|
82613
|
+
}
|
|
82614
|
+
const source = traversal.traverse(loop.findDirectExpression(core_1.Expressions.Source)).getCode();
|
|
82615
|
+
if (targetDeclare !== "") {
|
|
82616
|
+
preLoopDecls.push(targetDeclare);
|
|
82617
|
+
}
|
|
82618
|
+
const descriptor = {
|
|
82619
|
+
beforeLoop: [],
|
|
82620
|
+
open: `for await (const ${uniqueName} of abap.statements.loop(${source}${loopWhere})) {`,
|
|
82621
|
+
preBody: preBodyStatements,
|
|
82622
|
+
postBody: [],
|
|
82623
|
+
close: "}",
|
|
82624
|
+
};
|
|
82625
|
+
const loopTokens = loop.concatTokens().toUpperCase();
|
|
82626
|
+
const indexTarget = loopTokens.includes("INDEX INTO") ? loop.findExpressionAfterToken("INTO") : undefined;
|
|
82627
|
+
if (indexTarget && indexTarget instanceof core_1.Nodes.ExpressionNode) {
|
|
82628
|
+
const indexCode = traversal.traverse(indexTarget).getCode();
|
|
82629
|
+
const counterName = `unique${uniqueCounter++}`;
|
|
82630
|
+
descriptor.beforeLoop.push(`let ${counterName} = 1;`);
|
|
82631
|
+
descriptor.preBody.push(`const ${indexCode} = new abap.types.Integer().set(${counterName});`);
|
|
82632
|
+
descriptor.postBody.push(`${counterName}++;`);
|
|
82633
|
+
}
|
|
82634
|
+
descriptors.push(descriptor);
|
|
82635
|
+
}
|
|
82636
|
+
else {
|
|
82637
|
+
const counter = child.findDirectExpression(core_1.Expressions.InlineFieldDefinition);
|
|
82638
|
+
if (counter === undefined) {
|
|
82639
|
+
throw new Error("ValueBody FOR todo, " + body.concatTokens());
|
|
82640
|
+
}
|
|
82641
|
+
if (["GROUPS", "FROM", "TO"].some(token => child.findDirectTokenByText(token))) {
|
|
82642
|
+
throw new Error("ValueBody FOR todo, " + body.concatTokens());
|
|
82643
|
+
}
|
|
82644
|
+
if (child.findDirectExpression(core_1.Expressions.ComponentCond)) {
|
|
82645
|
+
throw new Error("ValueBody FOR todo, component cond, " + body.concatTokens());
|
|
82646
|
+
}
|
|
82647
|
+
const cond = child.findDirectExpression(core_1.Expressions.Cond);
|
|
82648
|
+
if (cond === undefined) {
|
|
82649
|
+
throw new Error("ValueBody FOR missing condition, " + body.concatTokens());
|
|
82650
|
+
}
|
|
82651
|
+
const hasUntil = child.findDirectTokenByText("UNTIL") !== undefined;
|
|
82652
|
+
const hasWhile = child.findDirectTokenByText("WHILE") !== undefined;
|
|
82653
|
+
if ((hasUntil ? 1 : 0) + (hasWhile ? 1 : 0) !== 1) {
|
|
82654
|
+
throw new Error("ValueBody FOR todo, condition, " + body.concatTokens());
|
|
82655
|
+
}
|
|
82656
|
+
const fieldExpr = counter.findDirectExpression(core_1.Expressions.Field);
|
|
82657
|
+
const fieldName = fieldExpr?.concatTokens().toLowerCase();
|
|
82658
|
+
if (fieldName === undefined) {
|
|
82659
|
+
throw new Error("ValueBody FOR todo, inline field, " + body.concatTokens());
|
|
82660
|
+
}
|
|
82661
|
+
const scope = traversal.findCurrentScopeByToken(counter.getFirstToken());
|
|
82662
|
+
const variable = scope?.findVariable(fieldName);
|
|
82663
|
+
if (variable === undefined) {
|
|
82664
|
+
throw new Error("ValueBody FOR todo, variable, " + body.concatTokens());
|
|
82665
|
+
}
|
|
82666
|
+
const declare = transpile_types_1.TranspileTypes.declare(variable);
|
|
82667
|
+
const counterName = traversal_1.Traversal.prefixVariable(fieldName);
|
|
82668
|
+
const startSource = counter.findDirectExpression(core_1.Expressions.Source);
|
|
82669
|
+
if (startSource === undefined) {
|
|
82670
|
+
throw new Error("ValueBody FOR missing initial value, " + body.concatTokens());
|
|
82671
|
+
}
|
|
82672
|
+
const start = traversal.traverse(startSource).getCode();
|
|
82673
|
+
const thenExpr = child.findExpressionAfterToken("THEN");
|
|
82674
|
+
let incrementExpression = "";
|
|
82675
|
+
if (thenExpr && thenExpr instanceof core_1.Nodes.ExpressionNode) {
|
|
82676
|
+
incrementExpression = traversal.traverse(thenExpr).getCode();
|
|
82677
|
+
}
|
|
82678
|
+
else {
|
|
82679
|
+
incrementExpression = `abap.operators.add(${counterName}, new abap.types.Integer().set(1))`;
|
|
82680
|
+
}
|
|
82681
|
+
const incrementLine = `${counterName}.set(${incrementExpression});`;
|
|
82682
|
+
const llet = child.findDirectExpression(core_1.Expressions.Let);
|
|
82683
|
+
let letCode = "";
|
|
82684
|
+
if (llet) {
|
|
82685
|
+
letCode = new let_1.LetTranspiler().transpile(llet, traversal).getCode();
|
|
82686
|
+
}
|
|
82687
|
+
const condCode = traversal.traverse(cond).getCode();
|
|
82688
|
+
const preCheck = hasWhile ? `if (!(${condCode})) {\n break;\n}` : "";
|
|
82689
|
+
const postLoop = [];
|
|
82690
|
+
postLoop.push(incrementLine);
|
|
82691
|
+
if (hasUntil) {
|
|
82692
|
+
postLoop.push(`if (${condCode}) {\n break;\n}`);
|
|
82693
|
+
}
|
|
82694
|
+
descriptors.push({
|
|
82695
|
+
beforeLoop: [declare, `${counterName}.set(${start});`],
|
|
82696
|
+
open: "while (true) {",
|
|
82697
|
+
preBody: [preCheck, letCode].filter(s => s !== ""),
|
|
82698
|
+
postBody: postLoop,
|
|
82699
|
+
close: "}",
|
|
82700
|
+
});
|
|
82701
|
+
}
|
|
82702
|
+
}
|
|
82703
|
+
if (descriptors.length === 0) {
|
|
82704
|
+
throw new Error("ValueBodyTranspiler FOR internal error");
|
|
82705
|
+
}
|
|
82706
|
+
chunk.appendString("await (async () => {\n");
|
|
82707
|
+
this.appendBlocks(chunk, preLoopDecls, "");
|
|
82708
|
+
chunk.appendString(`const VAL = ${val};\n`);
|
|
82709
|
+
let indent = "";
|
|
82710
|
+
for (const desc of descriptors) {
|
|
82711
|
+
this.appendBlocks(chunk, desc.beforeLoop, indent);
|
|
82712
|
+
chunk.appendString(indent + desc.open + "\n");
|
|
82713
|
+
indent += " ";
|
|
82714
|
+
levelIndents.push(indent);
|
|
82715
|
+
this.appendBlocks(chunk, desc.preBody, indent);
|
|
82716
|
+
}
|
|
82717
|
+
chunk.appendString(indent + "VAL");
|
|
82718
|
+
let post = ";\n";
|
|
82719
|
+
for (let i = descriptors.length - 1; i >= 0; i--) {
|
|
82720
|
+
const desc = descriptors[i];
|
|
82721
|
+
const currentIndent = levelIndents[i] ?? "";
|
|
82722
|
+
post += this.blocksToString(desc.postBody, currentIndent);
|
|
82723
|
+
const parentIndent = currentIndent.substring(0, Math.max(0, currentIndent.length - 2));
|
|
82724
|
+
post += parentIndent + desc.close + "\n";
|
|
82725
|
+
}
|
|
82726
|
+
post += "return VAL;\n})()";
|
|
82727
|
+
return { chunk, post };
|
|
82728
|
+
}
|
|
82729
|
+
appendBlocks(chunk, blocks, indent) {
|
|
82730
|
+
for (const block of blocks) {
|
|
82731
|
+
this.appendBlock(chunk, block, indent);
|
|
82732
|
+
}
|
|
82733
|
+
}
|
|
82734
|
+
appendBlock(chunk, block, indent) {
|
|
82735
|
+
if (block === "") {
|
|
82736
|
+
return;
|
|
82737
|
+
}
|
|
82738
|
+
const lines = block.split("\n");
|
|
82739
|
+
for (const line of lines) {
|
|
82740
|
+
const clean = line.replace(/\r/g, "");
|
|
82741
|
+
if (clean.trim() === "") {
|
|
82742
|
+
continue;
|
|
82743
|
+
}
|
|
82744
|
+
chunk.appendString(indent + clean + "\n");
|
|
82745
|
+
}
|
|
82746
|
+
}
|
|
82747
|
+
blocksToString(blocks, indent) {
|
|
82748
|
+
let ret = "";
|
|
82749
|
+
for (const block of blocks) {
|
|
82750
|
+
if (block === "") {
|
|
82751
|
+
continue;
|
|
82752
|
+
}
|
|
82753
|
+
const lines = block.split("\n");
|
|
82754
|
+
for (const line of lines) {
|
|
82755
|
+
const clean = line.replace(/\r/g, "");
|
|
82756
|
+
if (clean.trim() === "") {
|
|
82757
|
+
continue;
|
|
82758
|
+
}
|
|
82759
|
+
ret += indent + clean + "\n";
|
|
82760
|
+
}
|
|
82761
|
+
}
|
|
82762
|
+
return ret;
|
|
82763
|
+
}
|
|
82658
82764
|
}
|
|
82659
82765
|
exports.ValueBodyTranspiler = ValueBodyTranspiler;
|
|
82660
82766
|
//# sourceMappingURL=value_body.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.11",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"author": "abaplint",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@abaplint/core": "^2.113.
|
|
31
|
-
"@abaplint/transpiler": "^2.12.
|
|
30
|
+
"@abaplint/core": "^2.113.241",
|
|
31
|
+
"@abaplint/transpiler": "^2.12.11",
|
|
32
32
|
"@types/glob": "^8.1.0",
|
|
33
33
|
"@types/node": "^24.10.1",
|
|
34
34
|
"@types/progress": "^2.0.7",
|