@abaplint/transpiler-cli 2.13.91 → 2.13.92

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 CHANGED
@@ -35333,6 +35333,11 @@ class Source {
35333
35333
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
35334
35334
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
35335
35335
  }
35336
+ if ((foundType === null || foundType === void 0 ? void 0 : foundType.isGeneric()) && bodyType !== undefined) {
35337
+ this.addIfInferred(node, input, bodyType);
35338
+ this.traverseRemainingChildren(children, input);
35339
+ return bodyType;
35340
+ }
35336
35341
  this.addIfInferred(node, input, foundType);
35337
35342
  this.traverseRemainingChildren(children, input);
35338
35343
  return foundType;
@@ -71237,7 +71242,7 @@ class Registry {
71237
71242
  }
71238
71243
  static abaplintVersion() {
71239
71244
  // magic, see build script "version.js"
71240
- return "2.120.58";
71245
+ return "2.120.59";
71241
71246
  }
71242
71247
  getDDICReferences() {
71243
71248
  return this.ddicReferences;
@@ -85675,6 +85680,7 @@ __exportStar(__webpack_require__(/*! ./types_naming */ "./node_modules/@abaplint
85675
85680
  __exportStar(__webpack_require__(/*! ./uncaught_exception */ "./node_modules/@abaplint/core/build/src/rules/uncaught_exception.js"), exports);
85676
85681
  __exportStar(__webpack_require__(/*! ./unknown_types */ "./node_modules/@abaplint/core/build/src/rules/unknown_types.js"), exports);
85677
85682
  __exportStar(__webpack_require__(/*! ./unnecessary_chaining */ "./node_modules/@abaplint/core/build/src/rules/unnecessary_chaining.js"), exports);
85683
+ __exportStar(__webpack_require__(/*! ./unnecessary_loop_guard */ "./node_modules/@abaplint/core/build/src/rules/unnecessary_loop_guard.js"), exports);
85678
85684
  __exportStar(__webpack_require__(/*! ./unnecessary_pragma */ "./node_modules/@abaplint/core/build/src/rules/unnecessary_pragma.js"), exports);
85679
85685
  __exportStar(__webpack_require__(/*! ./unnecessary_return */ "./node_modules/@abaplint/core/build/src/rules/unnecessary_return.js"), exports);
85680
85686
  __exportStar(__webpack_require__(/*! ./unreachable_code */ "./node_modules/@abaplint/core/build/src/rules/unreachable_code.js"), exports);
@@ -85687,6 +85693,7 @@ __exportStar(__webpack_require__(/*! ./unused_variables */ "./node_modules/@abap
85687
85693
  __exportStar(__webpack_require__(/*! ./use_bool_expression */ "./node_modules/@abaplint/core/build/src/rules/use_bool_expression.js"), exports);
85688
85694
  __exportStar(__webpack_require__(/*! ./use_class_based_exceptions */ "./node_modules/@abaplint/core/build/src/rules/use_class_based_exceptions.js"), exports);
85689
85695
  __exportStar(__webpack_require__(/*! ./use_line_exists */ "./node_modules/@abaplint/core/build/src/rules/use_line_exists.js"), exports);
85696
+ __exportStar(__webpack_require__(/*! ./use_message_class */ "./node_modules/@abaplint/core/build/src/rules/use_message_class.js"), exports);
85690
85697
  __exportStar(__webpack_require__(/*! ./use_new */ "./node_modules/@abaplint/core/build/src/rules/use_new.js"), exports);
85691
85698
  __exportStar(__webpack_require__(/*! ./when_others_last */ "./node_modules/@abaplint/core/build/src/rules/when_others_last.js"), exports);
85692
85699
  __exportStar(__webpack_require__(/*! ./whitespace_end */ "./node_modules/@abaplint/core/build/src/rules/whitespace_end.js"), exports);
@@ -99423,6 +99430,151 @@ exports.UnnecessaryChaining = UnnecessaryChaining;
99423
99430
 
99424
99431
  /***/ },
99425
99432
 
99433
+ /***/ "./node_modules/@abaplint/core/build/src/rules/unnecessary_loop_guard.js"
99434
+ /*!*******************************************************************************!*\
99435
+ !*** ./node_modules/@abaplint/core/build/src/rules/unnecessary_loop_guard.js ***!
99436
+ \*******************************************************************************/
99437
+ (__unused_webpack_module, exports, __webpack_require__) {
99438
+
99439
+ "use strict";
99440
+
99441
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
99442
+ if (k2 === undefined) k2 = k;
99443
+ var desc = Object.getOwnPropertyDescriptor(m, k);
99444
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
99445
+ desc = { enumerable: true, get: function() { return m[k]; } };
99446
+ }
99447
+ Object.defineProperty(o, k2, desc);
99448
+ }) : (function(o, m, k, k2) {
99449
+ if (k2 === undefined) k2 = k;
99450
+ o[k2] = m[k];
99451
+ }));
99452
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
99453
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
99454
+ }) : function(o, v) {
99455
+ o["default"] = v;
99456
+ });
99457
+ var __importStar = (this && this.__importStar) || (function () {
99458
+ var ownKeys = function(o) {
99459
+ ownKeys = Object.getOwnPropertyNames || function (o) {
99460
+ var ar = [];
99461
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
99462
+ return ar;
99463
+ };
99464
+ return ownKeys(o);
99465
+ };
99466
+ return function (mod) {
99467
+ if (mod && mod.__esModule) return mod;
99468
+ var result = {};
99469
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
99470
+ __setModuleDefault(result, mod);
99471
+ return result;
99472
+ };
99473
+ })();
99474
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
99475
+ exports.UnnecessaryLoopGuard = exports.UnnecessaryLoopGuardConf = void 0;
99476
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
99477
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
99478
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js"));
99479
+ const Structures = __importStar(__webpack_require__(/*! ../abap/3_structures/structures */ "./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js"));
99480
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
99481
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
99482
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
99483
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
99484
+ class UnnecessaryLoopGuardConf extends _basic_rule_config_1.BasicRuleConfig {
99485
+ }
99486
+ exports.UnnecessaryLoopGuardConf = UnnecessaryLoopGuardConf;
99487
+ class UnnecessaryLoopGuard extends _abap_rule_1.ABAPRule {
99488
+ constructor() {
99489
+ super(...arguments);
99490
+ this.conf = new UnnecessaryLoopGuardConf();
99491
+ }
99492
+ getMetadata() {
99493
+ return {
99494
+ key: "unnecessary_loop_guard",
99495
+ title: "Unnecessary loop guard",
99496
+ shortDescription: `Detects unnecessary IS [NOT] INITIAL check before LOOP AT`,
99497
+ extendedInformation: `LOOP AT iterates zero times on an empty table, so an IS [NOT] INITIAL guard is redundant.`,
99498
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix],
99499
+ badExample: `IF lt_data IS NOT INITIAL.
99500
+ LOOP AT lt_data INTO DATA(ls_item).
99501
+ WRITE ls_item-name.
99502
+ ENDLOOP.
99503
+ ENDIF.`,
99504
+ goodExample: `LOOP AT lt_data INTO DATA(ls_item).
99505
+ WRITE ls_item-name.
99506
+ ENDLOOP.`,
99507
+ };
99508
+ }
99509
+ getConfig() {
99510
+ return this.conf;
99511
+ }
99512
+ setConfig(conf) {
99513
+ this.conf = conf;
99514
+ }
99515
+ runParsed(file) {
99516
+ const issues = [];
99517
+ const stru = file.getStructure();
99518
+ if (stru === undefined) {
99519
+ return issues;
99520
+ }
99521
+ for (const ifStru of stru.findAllStructuresRecursive(Structures.If)) {
99522
+ if (ifStru.findDirectStructures(Structures.ElseIf).length > 0
99523
+ || ifStru.findDirectStructures(Structures.Else).length > 0) {
99524
+ continue;
99525
+ }
99526
+ const ifStatement = ifStru.findDirectStatement(Statements.If);
99527
+ if (ifStatement === undefined) {
99528
+ continue;
99529
+ }
99530
+ const cond = ifStatement.findDirectExpression(Expressions.Cond);
99531
+ if (cond === undefined) {
99532
+ continue;
99533
+ }
99534
+ const compareNodes = cond.findDirectExpressions(Expressions.Compare);
99535
+ if (compareNodes.length !== 1) {
99536
+ continue;
99537
+ }
99538
+ const m = compareNodes[0].concatTokens().toUpperCase().match(/^(.+?)\s+IS\s+(?:NOT\s+)?INITIAL\s*$/);
99539
+ if (!m) {
99540
+ continue;
99541
+ }
99542
+ const tableName = m[1];
99543
+ const bodyStructures = ifStru.findDirectStructures(Structures.Body);
99544
+ if (bodyStructures.length !== 1) {
99545
+ continue;
99546
+ }
99547
+ const normalStructures = bodyStructures[0].findDirectStructures(Structures.Normal);
99548
+ if (normalStructures.length !== 1) {
99549
+ continue;
99550
+ }
99551
+ const loopStructures = normalStructures[0].findDirectStructures(Structures.Loop);
99552
+ if (loopStructures.length !== 1) {
99553
+ continue;
99554
+ }
99555
+ const loopStatement = loopStructures[0].findDirectStatement(Statements.Loop);
99556
+ if (loopStatement === undefined) {
99557
+ continue;
99558
+ }
99559
+ const loopSource = loopStatement.findFirstExpression(Expressions.LoopSource);
99560
+ if (loopSource === undefined) {
99561
+ continue;
99562
+ }
99563
+ if (loopSource.concatTokens().toUpperCase() !== tableName) {
99564
+ continue;
99565
+ }
99566
+ const endifStatement = ifStru.findDirectStatement(Statements.EndIf);
99567
+ const fix = edit_helper_1.EditHelper.merge(edit_helper_1.EditHelper.deleteStatement(file, ifStatement), edit_helper_1.EditHelper.deleteStatement(file, endifStatement));
99568
+ issues.push(issue_1.Issue.atStatement(file, ifStatement, "Unnecessary IS [NOT] INITIAL check before LOOP AT", this.getMetadata().key, this.conf.severity, fix));
99569
+ }
99570
+ return issues;
99571
+ }
99572
+ }
99573
+ exports.UnnecessaryLoopGuard = UnnecessaryLoopGuard;
99574
+ //# sourceMappingURL=unnecessary_loop_guard.js.map
99575
+
99576
+ /***/ },
99577
+
99426
99578
  /***/ "./node_modules/@abaplint/core/build/src/rules/unnecessary_pragma.js"
99427
99579
  /*!***************************************************************************!*\
99428
99580
  !*** ./node_modules/@abaplint/core/build/src/rules/unnecessary_pragma.js ***!
@@ -101497,6 +101649,103 @@ exports.UseLineExists = UseLineExists;
101497
101649
 
101498
101650
  /***/ },
101499
101651
 
101652
+ /***/ "./node_modules/@abaplint/core/build/src/rules/use_message_class.js"
101653
+ /*!**************************************************************************!*\
101654
+ !*** ./node_modules/@abaplint/core/build/src/rules/use_message_class.js ***!
101655
+ \**************************************************************************/
101656
+ (__unused_webpack_module, exports, __webpack_require__) {
101657
+
101658
+ "use strict";
101659
+
101660
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
101661
+ if (k2 === undefined) k2 = k;
101662
+ var desc = Object.getOwnPropertyDescriptor(m, k);
101663
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
101664
+ desc = { enumerable: true, get: function() { return m[k]; } };
101665
+ }
101666
+ Object.defineProperty(o, k2, desc);
101667
+ }) : (function(o, m, k, k2) {
101668
+ if (k2 === undefined) k2 = k;
101669
+ o[k2] = m[k];
101670
+ }));
101671
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
101672
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
101673
+ }) : function(o, v) {
101674
+ o["default"] = v;
101675
+ });
101676
+ var __importStar = (this && this.__importStar) || (function () {
101677
+ var ownKeys = function(o) {
101678
+ ownKeys = Object.getOwnPropertyNames || function (o) {
101679
+ var ar = [];
101680
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
101681
+ return ar;
101682
+ };
101683
+ return ownKeys(o);
101684
+ };
101685
+ return function (mod) {
101686
+ if (mod && mod.__esModule) return mod;
101687
+ var result = {};
101688
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
101689
+ __setModuleDefault(result, mod);
101690
+ return result;
101691
+ };
101692
+ })();
101693
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
101694
+ exports.UseMessageClass = exports.UseMessageClassConf = void 0;
101695
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
101696
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
101697
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
101698
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js"));
101699
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
101700
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
101701
+ class UseMessageClassConf extends _basic_rule_config_1.BasicRuleConfig {
101702
+ }
101703
+ exports.UseMessageClassConf = UseMessageClassConf;
101704
+ class UseMessageClass extends _abap_rule_1.ABAPRule {
101705
+ constructor() {
101706
+ super(...arguments);
101707
+ this.conf = new UseMessageClassConf();
101708
+ }
101709
+ getMetadata() {
101710
+ return {
101711
+ key: "use_message_class",
101712
+ title: "Use message class",
101713
+ shortDescription: `Define messages in SE91 instead of using inline text or variables`,
101714
+ tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
101715
+ badExample: `MESSAGE 'Something went wrong' TYPE 'E'.`,
101716
+ goodExample: `MESSAGE e001(bc_msg).`,
101717
+ };
101718
+ }
101719
+ getConfig() {
101720
+ return this.conf;
101721
+ }
101722
+ setConfig(conf) {
101723
+ this.conf = conf;
101724
+ }
101725
+ runParsed(file, _obj) {
101726
+ const structure = file.getStructure();
101727
+ if (structure === undefined) {
101728
+ return [];
101729
+ }
101730
+ const issues = [];
101731
+ const key = this.getMetadata().key;
101732
+ for (const statement of structure.findAllStatements(Statements.Message)) {
101733
+ // The parser populates MessageSource only for the class-based forms (e001(bc_msg) or ID/TYPE/NUMBER).
101734
+ // The text form (MESSAGE <source> TYPE <source>) uses MessageSourceSource directly with no MessageSource child.
101735
+ // Absence of MessageSource is therefore a reliable discriminator between the two forms.
101736
+ if (statement.findDirectExpression(Expressions.MessageSource) !== undefined) {
101737
+ continue;
101738
+ }
101739
+ issues.push(issue_1.Issue.atStatement(file, statement, "Use a message class (SE91) instead of inline text or variable", key, this.conf.severity));
101740
+ }
101741
+ return issues;
101742
+ }
101743
+ }
101744
+ exports.UseMessageClass = UseMessageClass;
101745
+ //# sourceMappingURL=use_message_class.js.map
101746
+
101747
+ /***/ },
101748
+
101500
101749
  /***/ "./node_modules/@abaplint/core/build/src/rules/use_new.js"
101501
101750
  /*!****************************************************************!*\
101502
101751
  !*** ./node_modules/@abaplint/core/build/src/rules/use_new.js ***!
@@ -104938,6 +105187,7 @@ var __importStar = (this && this.__importStar) || (function () {
104938
105187
  Object.defineProperty(exports, "__esModule", ({ value: true }));
104939
105188
  exports.AttributeNameTranspiler = void 0;
104940
105189
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
105190
+ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
104941
105191
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
104942
105192
  class AttributeNameTranspiler {
104943
105193
  transpile(node, traversal) {
@@ -104948,6 +105198,16 @@ class AttributeNameTranspiler {
104948
105198
  && ref.getVisibility() === abaplint.Visibility.Private) {
104949
105199
  concat = "#" + concat;
104950
105200
  }
105201
+ // an attribute declared in an interface lives on the object as "<intf>$<name>",
105202
+ // also when it is reached via an interface reference without the "intf~" alias,
105203
+ // eg. "obj->method( )->value" where method returns "REF TO lif_intf"
105204
+ const interfaceName = traversal.isInterfaceAttribute(node.getFirstToken());
105205
+ if (interfaceName && concat.startsWith(interfaceName) === false) {
105206
+ concat = traversal_1.Traversal.escapeNamespace(interfaceName) + "$" + traversal_1.Traversal.escapeNamespace(concat).replace("~", "$");
105207
+ }
105208
+ else {
105209
+ concat = traversal_1.Traversal.escapeNamespace(concat).replace("~", "$");
105210
+ }
104951
105211
  return new chunk_1.Chunk().append(concat, node, traversal);
104952
105212
  }
104953
105213
  }
@@ -119514,10 +119774,22 @@ class ReadTableTranspiler {
119514
119774
  const s = traversal.traverse(source).getCode();
119515
119775
  let field = "";
119516
119776
  let key = left.concatTokens().toLowerCase();
119777
+ // the component name is a JS object key, computed at runtime for a dynamic variable
119778
+ let keyExpression = "";
119517
119779
  if (left.get() instanceof abaplint.Expressions.Dynamic
119518
119780
  && left instanceof abaplint.Nodes.ExpressionNode) {
119519
- key = key.substring(2, key.length - 2);
119520
- field = "i." + key;
119781
+ const chain = left.findDirectExpression(abaplint.Expressions.FieldChain);
119782
+ if (chain) {
119783
+ // WITH TABLE KEY (variable) = value
119784
+ const name = new expressions_1.FieldChainTranspiler(true).transpile(chain, traversal).getCode();
119785
+ keyExpression = name + ".trimEnd().toLowerCase()";
119786
+ field = "i[" + keyExpression + "]";
119787
+ }
119788
+ else {
119789
+ // WITH TABLE KEY ('LITERAL') = value
119790
+ key = key.substring(2, key.length - 2);
119791
+ field = "i." + key;
119792
+ }
119521
119793
  }
119522
119794
  else if (left.get() instanceof abaplint.Expressions.ComponentChainSimple
119523
119795
  && left instanceof abaplint.Nodes.ExpressionNode) {
@@ -119529,17 +119801,18 @@ class ReadTableTranspiler {
119529
119801
  if (field === "i.table_line") {
119530
119802
  usesTableLine = true;
119531
119803
  }
119804
+ const simpleKey = keyExpression !== "" ? "[" + keyExpression + "]" : JSON.stringify(key);
119532
119805
  if (s.includes("await")) {
119533
119806
  const id = unique_identifier_1.UniqueIdentifier.get();
119534
119807
  prefix += "const " + id + " = " + s + ";\n";
119535
119808
  withKey.push("abap.compare.eq(" + field + ", " + id + ")");
119536
119809
  withKeyValue.push(`{key: (i) => {return ${field}}, value: ${id}}`);
119537
- withKeySimple.push(`${JSON.stringify(key)}: ${id}`);
119810
+ withKeySimple.push(`${simpleKey}: ${id}`);
119538
119811
  }
119539
119812
  else {
119540
119813
  withKey.push("abap.compare.eq(" + field + ", " + s + ")");
119541
119814
  withKeyValue.push(`{key: (i) => {return ${field}}, value: ${s}}`);
119542
- withKeySimple.push(`${JSON.stringify(key)}: ${s}`);
119815
+ withKeySimple.push(`${simpleKey}: ${s}`);
119543
119816
  }
119544
119817
  }
119545
119818
  extra.push("withKey: (i) => {return " + withKey.join(" && ") + ";}");
package/build/types.d.ts CHANGED
@@ -12,6 +12,13 @@ export interface ITranspilerConfig {
12
12
  exclude_filter?: string[];
13
13
  /** @minLength 1 */
14
14
  output_folder: string;
15
+ /** experimental */
16
+ converter?: {
17
+ /** @uniqueItems true */
18
+ input_folder: string | string[];
19
+ /** @minLength 1 */
20
+ output_folder: string;
21
+ };
15
22
  libs?: {
16
23
  url?: string;
17
24
  /** relative to the current working directory */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.13.91",
3
+ "version": "2.13.92",
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.120.58",
31
- "@abaplint/transpiler": "^2.13.91",
30
+ "@abaplint/core": "^2.120.59",
31
+ "@abaplint/transpiler": "^2.13.92",
32
32
  "@types/glob": "^9.0.0",
33
33
  "@types/node": "^26.6.2",
34
34
  "@types/progress": "^2.0.7",