@abaplint/transpiler-cli 2.13.90 → 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
@@ -324,6 +324,7 @@ const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_
324
324
  const config_1 = __webpack_require__(/*! ./config */ "./build/config.js");
325
325
  const file_operations_1 = __webpack_require__(/*! ./file_operations */ "./build/file_operations.js");
326
326
  const git_clone_1 = __webpack_require__(/*! ./git_clone */ "./build/git_clone.js");
327
+ const lib_folder_1 = __webpack_require__(/*! ./lib_folder */ "./build/lib_folder.js");
327
328
  class Progress {
328
329
  bar;
329
330
  set(total, _text) {
@@ -339,13 +340,17 @@ async function loadLib(config) {
339
340
  for (const lib of config.libs || []) {
340
341
  let dir = "";
341
342
  let cleanupFolder = false;
342
- if (lib.folder !== undefined && lib.folder !== "" && fs.existsSync(process.cwd() + lib.folder)) {
343
- console.log("From folder: " + lib.folder);
344
- dir = process.cwd() + lib.folder;
343
+ const folder = (0, lib_folder_1.resolveLibFolder)(lib.folder, process.cwd());
344
+ if (folder !== undefined && fs.existsSync(folder)) {
345
+ console.log("From folder: " + folder);
346
+ dir = folder;
345
347
  }
346
348
  else {
347
349
  if (lib.url === undefined || lib.url === "") {
348
- throw new Error("Library must define a non-empty url or an existing folder");
350
+ if (folder === undefined) {
351
+ throw new Error("Library must define a non-empty url or an existing folder");
352
+ }
353
+ throw new Error("Library folder not found: " + folder);
349
354
  }
350
355
  console.log("Clone: " + lib.url);
351
356
  dir = fs.mkdtempSync(path.join(os.tmpdir(), "abap_transpile-"));
@@ -489,6 +494,65 @@ run().then(() => {
489
494
 
490
495
  /***/ },
491
496
 
497
+ /***/ "./build/lib_folder.js"
498
+ /*!*****************************!*\
499
+ !*** ./build/lib_folder.js ***!
500
+ \*****************************/
501
+ (__unused_webpack_module, exports, __webpack_require__) {
502
+
503
+ "use strict";
504
+
505
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
506
+ if (k2 === undefined) k2 = k;
507
+ var desc = Object.getOwnPropertyDescriptor(m, k);
508
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
509
+ desc = { enumerable: true, get: function() { return m[k]; } };
510
+ }
511
+ Object.defineProperty(o, k2, desc);
512
+ }) : (function(o, m, k, k2) {
513
+ if (k2 === undefined) k2 = k;
514
+ o[k2] = m[k];
515
+ }));
516
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
517
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
518
+ }) : function(o, v) {
519
+ o["default"] = v;
520
+ });
521
+ var __importStar = (this && this.__importStar) || (function () {
522
+ var ownKeys = function(o) {
523
+ ownKeys = Object.getOwnPropertyNames || function (o) {
524
+ var ar = [];
525
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
526
+ return ar;
527
+ };
528
+ return ownKeys(o);
529
+ };
530
+ return function (mod) {
531
+ if (mod && mod.__esModule) return mod;
532
+ var result = {};
533
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
534
+ __setModuleDefault(result, mod);
535
+ return result;
536
+ };
537
+ })();
538
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
539
+ exports.resolveLibFolder = resolveLibFolder;
540
+ const path = __importStar(__webpack_require__(/*! path */ "path"));
541
+ // A lib "folder" is relative to the current working directory. It used to be
542
+ // concatenated onto cwd, so it only worked when it started with a separator;
543
+ // "deps" silently became "/path/to/cwddeps" and the lib was cloned instead.
544
+ // join() keeps the leading separator working, so existing configuration is
545
+ // unaffected, and accepts "deps" and "./deps" as well.
546
+ function resolveLibFolder(folder, cwd) {
547
+ if (folder === undefined || folder === "") {
548
+ return undefined;
549
+ }
550
+ return path.join(cwd, folder);
551
+ }
552
+ //# sourceMappingURL=lib_folder.js.map
553
+
554
+ /***/ },
555
+
492
556
  /***/ "./node_modules/@abaplint/core/build/src/abap/1_lexer/lexer.js"
493
557
  /*!*********************************************************************!*\
494
558
  !*** ./node_modules/@abaplint/core/build/src/abap/1_lexer/lexer.js ***!
@@ -6972,7 +7036,8 @@ const Expressions = __importStar(__webpack_require__(/*! . */ "./node_modules/@a
6972
7036
  const tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js");
6973
7037
  class MethodDefReturning extends combi_1.Expression {
6974
7038
  getRunnable() {
6975
- const value = (0, combi_1.seq)("VALUE", (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
7039
+ // see MethodParam: the lexer gives "!VALUE" as one Identifier
7040
+ const value = (0, combi_1.seq)((0, combi_1.altPrio)("VALUE", "!VALUE"), (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
6976
7041
  return (0, combi_1.seq)("RETURNING", value, Expressions.TypeParam);
6977
7042
  }
6978
7043
  }
@@ -7050,8 +7115,11 @@ const Expressions = __importStar(__webpack_require__(/*! . */ "./node_modules/@a
7050
7115
  const tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js");
7051
7116
  class MethodParam extends combi_1.Expression {
7052
7117
  getRunnable() {
7053
- const ref = (0, combi_1.seq)("REFERENCE", (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
7054
- const value = (0, combi_1.seq)("VALUE", (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
7118
+ // The escape is part of the token: the lexer gives "!VALUE" as a single
7119
+ // Identifier, so a literal "VALUE" cannot match it and the whole METHODS
7120
+ // statement falls back to Unknown.
7121
+ const ref = (0, combi_1.seq)((0, combi_1.altPrio)("REFERENCE", "!REFERENCE"), (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
7122
+ const value = (0, combi_1.seq)((0, combi_1.altPrio)("VALUE", "!VALUE"), (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
7055
7123
  const fieldsOrValue = (0, combi_1.seq)((0, combi_1.altPrio)(value, ref, Expressions.MethodParamName), Expressions.TypeParam);
7056
7124
  return fieldsOrValue;
7057
7125
  }
@@ -12035,6 +12103,10 @@ class StatementParser {
12035
12103
  let add = [];
12036
12104
  let pre = [];
12037
12105
  let colon = undefined;
12106
+ // inside EXEC SQL and an AMDP body a colon reads a host variable, ":lv_a",
12107
+ // and is not the chaining marker; recognized here because nativeSQL() runs
12108
+ // afterwards and can only re-wrap what this has already cut
12109
+ let native = false;
12038
12110
  for (const token of wa.tokens) {
12039
12111
  if (token instanceof Tokens.Comment) {
12040
12112
  wa.statements.push(new nodes_1.StatementNode(new _statement_1.Comment()).setChildren(this.tokensToNodes([token])));
@@ -12044,6 +12116,7 @@ class StatementParser {
12044
12116
  const str = token.getStr();
12045
12117
  if (str.length === 1) {
12046
12118
  if (str === ".") {
12119
+ native = this.nativeAfter(native, add, colon);
12047
12120
  wa.addUnknown(pre, add, colon);
12048
12121
  add = [];
12049
12122
  pre = [];
@@ -12053,13 +12126,13 @@ class StatementParser {
12053
12126
  wa.addUnknown(pre, add, colon);
12054
12127
  add = [];
12055
12128
  }
12056
- else if (str === ":" && colon === undefined) {
12129
+ else if (str === ":" && colon === undefined && native === false) {
12057
12130
  colon = token;
12058
12131
  add.pop(); // do not add colon token to statement
12059
12132
  pre.push(...add);
12060
12133
  add = [];
12061
12134
  }
12062
- else if (str === ":") {
12135
+ else if (str === ":" && native === false) {
12063
12136
  add.pop(); // do not add colon token to statement
12064
12137
  }
12065
12138
  }
@@ -12068,6 +12141,36 @@ class StatementParser {
12068
12141
  wa.addUnknown(pre, add, colon);
12069
12142
  }
12070
12143
  }
12144
+ /** whether the statement that just ended opens or closes a region where a
12145
+ * colon belongs to the statement rather than chaining it */
12146
+ nativeAfter(native, tokens, colon) {
12147
+ // a pragma sits between the closing keyword and the period, so it is left
12148
+ // out before the last word is read: "ENDEXEC ##NEEDED." closes the region
12149
+ const words = tokens.filter(t => !(t instanceof Tokens.Pragma)).map(t => t.getStr().toUpperCase());
12150
+ // a native body usually arrives as one blob terminated by its own closing
12151
+ // keyword, so the terminator is the word before the period
12152
+ if (words[words.length - 2] === "ENDEXEC" || words[words.length - 2] === "ENDMETHOD") {
12153
+ return false;
12154
+ }
12155
+ if (colon !== undefined) {
12156
+ // a fragment of a chain cannot OPEN a region: it is only part of a
12157
+ // statement, and taking "DATA: lv_a TYPE i, exec sql." for one would
12158
+ // turn chaining off for the rest of the file
12159
+ return native;
12160
+ }
12161
+ if (words[0] === "EXEC" && words[1] === "SQL") {
12162
+ return true;
12163
+ }
12164
+ // "BY DATABASE" as well as LANGUAGE, and not LANGUAGE alone: a method
12165
+ // may be NAMED language
12166
+ if (words[0] === "METHOD"
12167
+ && words.includes("BY")
12168
+ && words.includes("DATABASE")
12169
+ && words.includes("LANGUAGE")) {
12170
+ return true;
12171
+ }
12172
+ return native;
12173
+ }
12071
12174
  }
12072
12175
  exports.StatementParser = StatementParser;
12073
12176
  //# sourceMappingURL=statement_parser.js.map
@@ -35230,6 +35333,11 @@ class Source {
35230
35333
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
35231
35334
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
35232
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
+ }
35233
35341
  this.addIfInferred(node, input, foundType);
35234
35342
  this.traverseRemainingChildren(children, input);
35235
35343
  return foundType;
@@ -54444,7 +54552,9 @@ class MethodParameters {
54444
54552
  }
54445
54553
  isPassByValue(param) {
54446
54554
  var _a;
54447
- return param.getFirstToken().getStr().toUpperCase() === "VALUE"
54555
+ // "!" is the identifier escape, generated code has eg. "IMPORTING !VALUE(iv_foo)"
54556
+ const first = param.getFirstToken().getStr().toUpperCase();
54557
+ return (first === "VALUE" || first === "!VALUE")
54448
54558
  && ((_a = param.getChildren()[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "(";
54449
54559
  }
54450
54560
  }
@@ -71132,7 +71242,7 @@ class Registry {
71132
71242
  }
71133
71243
  static abaplintVersion() {
71134
71244
  // magic, see build script "version.js"
71135
- return "2.120.56";
71245
+ return "2.120.59";
71136
71246
  }
71137
71247
  getDDICReferences() {
71138
71248
  return this.ddicReferences;
@@ -85528,7 +85638,9 @@ __exportStar(__webpack_require__(/*! ./prefer_insert_into_table */ "./node_modul
85528
85638
  __exportStar(__webpack_require__(/*! ./prefer_is_not */ "./node_modules/@abaplint/core/build/src/rules/prefer_is_not.js"), exports);
85529
85639
  __exportStar(__webpack_require__(/*! ./prefer_pragmas */ "./node_modules/@abaplint/core/build/src/rules/prefer_pragmas.js"), exports);
85530
85640
  __exportStar(__webpack_require__(/*! ./prefer_abap_bool */ "./node_modules/@abaplint/core/build/src/rules/prefer_abap_bool.js"), exports);
85641
+ __exportStar(__webpack_require__(/*! ./prefer_abap_bool_values */ "./node_modules/@abaplint/core/build/src/rules/prefer_abap_bool_values.js"), exports);
85531
85642
  __exportStar(__webpack_require__(/*! ./prefer_raise_exception_new */ "./node_modules/@abaplint/core/build/src/rules/prefer_raise_exception_new.js"), exports);
85643
+ __exportStar(__webpack_require__(/*! ./prefer_string_template */ "./node_modules/@abaplint/core/build/src/rules/prefer_string_template.js"), exports);
85532
85644
  __exportStar(__webpack_require__(/*! ./prefer_returning_to_exporting */ "./node_modules/@abaplint/core/build/src/rules/prefer_returning_to_exporting.js"), exports);
85533
85645
  __exportStar(__webpack_require__(/*! ./prefer_xsdbool */ "./node_modules/@abaplint/core/build/src/rules/prefer_xsdbool.js"), exports);
85534
85646
  __exportStar(__webpack_require__(/*! ./preferred_compare_operator */ "./node_modules/@abaplint/core/build/src/rules/preferred_compare_operator.js"), exports);
@@ -85568,6 +85680,7 @@ __exportStar(__webpack_require__(/*! ./types_naming */ "./node_modules/@abaplint
85568
85680
  __exportStar(__webpack_require__(/*! ./uncaught_exception */ "./node_modules/@abaplint/core/build/src/rules/uncaught_exception.js"), exports);
85569
85681
  __exportStar(__webpack_require__(/*! ./unknown_types */ "./node_modules/@abaplint/core/build/src/rules/unknown_types.js"), exports);
85570
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);
85571
85684
  __exportStar(__webpack_require__(/*! ./unnecessary_pragma */ "./node_modules/@abaplint/core/build/src/rules/unnecessary_pragma.js"), exports);
85572
85685
  __exportStar(__webpack_require__(/*! ./unnecessary_return */ "./node_modules/@abaplint/core/build/src/rules/unnecessary_return.js"), exports);
85573
85686
  __exportStar(__webpack_require__(/*! ./unreachable_code */ "./node_modules/@abaplint/core/build/src/rules/unreachable_code.js"), exports);
@@ -85580,6 +85693,7 @@ __exportStar(__webpack_require__(/*! ./unused_variables */ "./node_modules/@abap
85580
85693
  __exportStar(__webpack_require__(/*! ./use_bool_expression */ "./node_modules/@abaplint/core/build/src/rules/use_bool_expression.js"), exports);
85581
85694
  __exportStar(__webpack_require__(/*! ./use_class_based_exceptions */ "./node_modules/@abaplint/core/build/src/rules/use_class_based_exceptions.js"), exports);
85582
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);
85583
85697
  __exportStar(__webpack_require__(/*! ./use_new */ "./node_modules/@abaplint/core/build/src/rules/use_new.js"), exports);
85584
85698
  __exportStar(__webpack_require__(/*! ./when_others_last */ "./node_modules/@abaplint/core/build/src/rules/when_others_last.js"), exports);
85585
85699
  __exportStar(__webpack_require__(/*! ./whitespace_end */ "./node_modules/@abaplint/core/build/src/rules/whitespace_end.js"), exports);
@@ -92931,6 +93045,272 @@ exports.PreferAbapBool = PreferAbapBool;
92931
93045
 
92932
93046
  /***/ },
92933
93047
 
93048
+ /***/ "./node_modules/@abaplint/core/build/src/rules/prefer_abap_bool_values.js"
93049
+ /*!********************************************************************************!*\
93050
+ !*** ./node_modules/@abaplint/core/build/src/rules/prefer_abap_bool_values.js ***!
93051
+ \********************************************************************************/
93052
+ (__unused_webpack_module, exports, __webpack_require__) {
93053
+
93054
+ "use strict";
93055
+
93056
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
93057
+ if (k2 === undefined) k2 = k;
93058
+ var desc = Object.getOwnPropertyDescriptor(m, k);
93059
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
93060
+ desc = { enumerable: true, get: function() { return m[k]; } };
93061
+ }
93062
+ Object.defineProperty(o, k2, desc);
93063
+ }) : (function(o, m, k, k2) {
93064
+ if (k2 === undefined) k2 = k;
93065
+ o[k2] = m[k];
93066
+ }));
93067
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
93068
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
93069
+ }) : function(o, v) {
93070
+ o["default"] = v;
93071
+ });
93072
+ var __importStar = (this && this.__importStar) || (function () {
93073
+ var ownKeys = function(o) {
93074
+ ownKeys = Object.getOwnPropertyNames || function (o) {
93075
+ var ar = [];
93076
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
93077
+ return ar;
93078
+ };
93079
+ return ownKeys(o);
93080
+ };
93081
+ return function (mod) {
93082
+ if (mod && mod.__esModule) return mod;
93083
+ var result = {};
93084
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
93085
+ __setModuleDefault(result, mod);
93086
+ return result;
93087
+ };
93088
+ })();
93089
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
93090
+ exports.PreferAbapBoolValues = exports.PreferAbapBoolValuesConf = void 0;
93091
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
93092
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
93093
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
93094
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js"));
93095
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
93096
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
93097
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
93098
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
93099
+ const ABAP_BOOL = "ABAP_BOOL";
93100
+ const ABAP_TRUE = "abap_true";
93101
+ const ABAP_FALSE = "abap_false";
93102
+ const VALID_VALUES = new Set(["ABAP_TRUE", "ABAP_FALSE", "ABAP_UNDEFINED"]);
93103
+ class PreferAbapBoolValuesConf extends _basic_rule_config_1.BasicRuleConfig {
93104
+ }
93105
+ exports.PreferAbapBoolValuesConf = PreferAbapBoolValuesConf;
93106
+ class PreferAbapBoolValues extends _abap_rule_1.ABAPRule {
93107
+ constructor() {
93108
+ super(...arguments);
93109
+ this.conf = new PreferAbapBoolValuesConf();
93110
+ }
93111
+ getMetadata() {
93112
+ return {
93113
+ key: "prefer_abap_bool_values",
93114
+ title: "Prefer abap_true and abap_false",
93115
+ shortDescription: `Use abap_true and abap_false instead of 'X' and ' ' for abap_bool variables`,
93116
+ // eslint-disable-next-line max-len
93117
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-abap_true-abap_false-and-abap_undefined-for-abap_bool-variables`,
93118
+ tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
93119
+ badExample: `DATA lv_flag TYPE abap_bool.\nlv_flag = 'X'.`,
93120
+ goodExample: `DATA lv_flag TYPE abap_bool.\nlv_flag = abap_true.`,
93121
+ };
93122
+ }
93123
+ getConfig() {
93124
+ return this.conf;
93125
+ }
93126
+ setConfig(conf) {
93127
+ this.conf = conf;
93128
+ }
93129
+ runParsed(file) {
93130
+ const issues = [];
93131
+ const structure = file.getStructure();
93132
+ if (structure === undefined) {
93133
+ return [];
93134
+ }
93135
+ const boolVars = this.collectBoolVars(file);
93136
+ // Check Move statements: target = source
93137
+ for (const stat of structure.findAllStatements(Statements.Move)) {
93138
+ const target = stat.findFirstExpression(Expressions.Target);
93139
+ const source = stat.findFirstExpression(Expressions.Source);
93140
+ if (target === undefined || source === undefined) {
93141
+ continue;
93142
+ }
93143
+ const targetName = target.concatTokens().toUpperCase();
93144
+ if (!boolVars.has(targetName)) {
93145
+ continue;
93146
+ }
93147
+ this.checkSourceNode(source, file, issues);
93148
+ }
93149
+ // Check comparisons: IF/ELSEIF conditions
93150
+ const compareStatements = [
93151
+ ...structure.findAllStatements(Statements.If),
93152
+ ...structure.findAllStatements(Statements.ElseIf),
93153
+ ];
93154
+ for (const stat of compareStatements) {
93155
+ const cond = stat.findFirstExpression(Expressions.Cond);
93156
+ if (cond === undefined) {
93157
+ continue;
93158
+ }
93159
+ for (const compare of cond.findAllExpressions(Expressions.Compare)) {
93160
+ this.checkCompareBoolLiteral(compare, boolVars, file, issues);
93161
+ }
93162
+ }
93163
+ return issues;
93164
+ }
93165
+ collectBoolVars(file) {
93166
+ var _a;
93167
+ const boolVars = new Set();
93168
+ const structure = file.getStructure();
93169
+ if (structure === undefined) {
93170
+ return boolVars;
93171
+ }
93172
+ const statements = [
93173
+ ...structure.findAllStatements(Statements.Data),
93174
+ ...structure.findAllStatements(Statements.ClassData),
93175
+ ...structure.findAllStatements(Statements.FieldSymbol),
93176
+ ];
93177
+ for (const stat of statements) {
93178
+ const typeNameExpr = stat.findFirstExpression(Expressions.TypeName);
93179
+ if (typeNameExpr === undefined) {
93180
+ continue;
93181
+ }
93182
+ if (typeNameExpr.concatTokens().toUpperCase() !== ABAP_BOOL) {
93183
+ continue;
93184
+ }
93185
+ const nameExpr = (_a = stat.findFirstExpression(Expressions.DefinitionName)) !== null && _a !== void 0 ? _a : stat.findFirstExpression(Expressions.FieldSymbol);
93186
+ if (nameExpr === undefined) {
93187
+ continue;
93188
+ }
93189
+ boolVars.add(nameExpr.concatTokens().toUpperCase());
93190
+ }
93191
+ return boolVars;
93192
+ }
93193
+ checkSourceNode(source, file, issues) {
93194
+ const firstToken = source.getFirstToken().getStr().toUpperCase();
93195
+ if (firstToken === "COND") {
93196
+ const condBody = source.findDirectExpression(Expressions.CondBody);
93197
+ if (condBody) {
93198
+ this.checkCondBodyBranches(condBody, file, issues);
93199
+ }
93200
+ return;
93201
+ }
93202
+ if (firstToken === "SWITCH") {
93203
+ const switchBody = source.findDirectExpression(Expressions.SwitchBody);
93204
+ if (switchBody) {
93205
+ this.checkSwitchBodyBranches(switchBody, file, issues);
93206
+ }
93207
+ return;
93208
+ }
93209
+ // Plain literal assignment
93210
+ const issue = this.checkLiteralSource(source, file);
93211
+ if (issue) {
93212
+ issues.push(issue);
93213
+ }
93214
+ }
93215
+ checkLiteralSource(source, file) {
93216
+ const constantStr = source.findFirstExpression(Expressions.ConstantString);
93217
+ if (constantStr === undefined) {
93218
+ return undefined;
93219
+ }
93220
+ const token = constantStr.getFirstToken();
93221
+ const val = token.getStr();
93222
+ if (val === "'X'") {
93223
+ const fix = edit_helper_1.EditHelper.replaceToken(file, token, ABAP_TRUE);
93224
+ return issue_1.Issue.atToken(file, token, `Use ${ABAP_TRUE} instead of 'X'`, this.getMetadata().key, this.conf.severity, fix);
93225
+ }
93226
+ if (val === "' '") {
93227
+ const fix = edit_helper_1.EditHelper.replaceToken(file, token, ABAP_FALSE);
93228
+ return issue_1.Issue.atToken(file, token, `Use ${ABAP_FALSE} instead of ' '`, this.getMetadata().key, this.conf.severity, fix);
93229
+ }
93230
+ return undefined;
93231
+ }
93232
+ checkCondBodyBranches(condBody, file, issues) {
93233
+ // CondBody: WHEN <cond> THEN <source> [WHEN <cond> THEN <source>]* [ELSE <source>]
93234
+ // Walk children; Source nodes after THEN/ELSE are the result values
93235
+ let afterThenOrElse = false;
93236
+ for (const child of condBody.getChildren()) {
93237
+ const tokenStr = child.getFirstToken().getStr().toUpperCase();
93238
+ if (tokenStr === "THEN" || tokenStr === "ELSE") {
93239
+ afterThenOrElse = true;
93240
+ continue;
93241
+ }
93242
+ if (tokenStr === "WHEN") {
93243
+ afterThenOrElse = false;
93244
+ continue;
93245
+ }
93246
+ if (afterThenOrElse && child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.Source) {
93247
+ const issue = this.checkLiteralSource(child, file);
93248
+ if (issue) {
93249
+ issues.push(issue);
93250
+ }
93251
+ afterThenOrElse = false;
93252
+ }
93253
+ }
93254
+ }
93255
+ checkSwitchBodyBranches(switchBody, file, issues) {
93256
+ // SwitchBody: <source> WHEN <val> [OR <val>]* THEN <source> [ELSE <source>]
93257
+ // First Source is the operand; Source after THEN/ELSE are result values
93258
+ let firstSourceSeen = false;
93259
+ let afterThenOrElse = false;
93260
+ for (const child of switchBody.getChildren()) {
93261
+ const tokenStr = child.getFirstToken().getStr().toUpperCase();
93262
+ if (tokenStr === "THEN" || tokenStr === "ELSE") {
93263
+ afterThenOrElse = true;
93264
+ continue;
93265
+ }
93266
+ if (tokenStr === "WHEN" || tokenStr === "OR") {
93267
+ afterThenOrElse = false;
93268
+ continue;
93269
+ }
93270
+ if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.Source) {
93271
+ if (!firstSourceSeen) {
93272
+ firstSourceSeen = true;
93273
+ continue;
93274
+ }
93275
+ if (afterThenOrElse) {
93276
+ const issue = this.checkLiteralSource(child, file);
93277
+ if (issue) {
93278
+ issues.push(issue);
93279
+ }
93280
+ afterThenOrElse = false;
93281
+ }
93282
+ }
93283
+ }
93284
+ }
93285
+ checkCompareBoolLiteral(compare, boolVars, file, issues) {
93286
+ // Compare: Source CompareOperator Source (or other forms)
93287
+ const sources = compare.findDirectExpressions(Expressions.Source);
93288
+ if (sources.length < 2) {
93289
+ return;
93290
+ }
93291
+ const [left, right] = sources;
93292
+ const leftStr = left.concatTokens().toUpperCase();
93293
+ const rightStr = right.concatTokens().toUpperCase();
93294
+ let literalSource;
93295
+ if (boolVars.has(leftStr) && !VALID_VALUES.has(rightStr)) {
93296
+ literalSource = right;
93297
+ }
93298
+ else if (boolVars.has(rightStr) && !VALID_VALUES.has(leftStr)) {
93299
+ literalSource = left;
93300
+ }
93301
+ if (literalSource) {
93302
+ const issue = this.checkLiteralSource(literalSource, file);
93303
+ if (issue) {
93304
+ issues.push(issue);
93305
+ }
93306
+ }
93307
+ }
93308
+ }
93309
+ exports.PreferAbapBoolValues = PreferAbapBoolValues;
93310
+ //# sourceMappingURL=prefer_abap_bool_values.js.map
93311
+
93312
+ /***/ },
93313
+
92934
93314
  /***/ "./node_modules/@abaplint/core/build/src/rules/prefer_corresponding.js"
92935
93315
  /*!*****************************************************************************!*\
92936
93316
  !*** ./node_modules/@abaplint/core/build/src/rules/prefer_corresponding.js ***!
@@ -93920,6 +94300,151 @@ exports.PreferReturningToExporting = PreferReturningToExporting;
93920
94300
 
93921
94301
  /***/ },
93922
94302
 
94303
+ /***/ "./node_modules/@abaplint/core/build/src/rules/prefer_string_template.js"
94304
+ /*!*******************************************************************************!*\
94305
+ !*** ./node_modules/@abaplint/core/build/src/rules/prefer_string_template.js ***!
94306
+ \*******************************************************************************/
94307
+ (__unused_webpack_module, exports, __webpack_require__) {
94308
+
94309
+ "use strict";
94310
+
94311
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
94312
+ if (k2 === undefined) k2 = k;
94313
+ var desc = Object.getOwnPropertyDescriptor(m, k);
94314
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
94315
+ desc = { enumerable: true, get: function() { return m[k]; } };
94316
+ }
94317
+ Object.defineProperty(o, k2, desc);
94318
+ }) : (function(o, m, k, k2) {
94319
+ if (k2 === undefined) k2 = k;
94320
+ o[k2] = m[k];
94321
+ }));
94322
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
94323
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
94324
+ }) : function(o, v) {
94325
+ o["default"] = v;
94326
+ });
94327
+ var __importStar = (this && this.__importStar) || (function () {
94328
+ var ownKeys = function(o) {
94329
+ ownKeys = Object.getOwnPropertyNames || function (o) {
94330
+ var ar = [];
94331
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
94332
+ return ar;
94333
+ };
94334
+ return ownKeys(o);
94335
+ };
94336
+ return function (mod) {
94337
+ if (mod && mod.__esModule) return mod;
94338
+ var result = {};
94339
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
94340
+ __setModuleDefault(result, mod);
94341
+ return result;
94342
+ };
94343
+ })();
94344
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
94345
+ exports.PreferStringTemplate = exports.PreferStringTemplateConf = void 0;
94346
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
94347
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
94348
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
94349
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
94350
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
94351
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
94352
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
94353
+ class PreferStringTemplateConf extends _basic_rule_config_1.BasicRuleConfig {
94354
+ }
94355
+ exports.PreferStringTemplateConf = PreferStringTemplateConf;
94356
+ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
94357
+ constructor() {
94358
+ super(...arguments);
94359
+ this.conf = new PreferStringTemplateConf();
94360
+ }
94361
+ getMetadata() {
94362
+ return {
94363
+ key: "prefer_string_template",
94364
+ title: "Prefer string template over &&",
94365
+ shortDescription: `Use string templates instead of && to assemble text`,
94366
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use--to-assemble-text`,
94367
+ tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
94368
+ badExample: `DATA(msg) = \`Hello \` && name && \`!\`.`,
94369
+ goodExample: `DATA(msg) = |Hello { name }!|.`,
94370
+ };
94371
+ }
94372
+ getConfig() {
94373
+ return this.conf;
94374
+ }
94375
+ setConfig(conf) {
94376
+ this.conf = conf;
94377
+ }
94378
+ runParsed(file) {
94379
+ const issues = [];
94380
+ const structure = file.getStructure();
94381
+ if (structure === undefined) {
94382
+ return [];
94383
+ }
94384
+ const allSources = structure.findAllExpressions(Expressions.Source);
94385
+ // collect all Source nodes that appear as the RHS (children[2]) of a && expression
94386
+ const rhsChildren = new Set();
94387
+ for (const source of allSources) {
94388
+ const children = source.getChildren();
94389
+ if (children.length === 3 && children[1].getFirstToken().getStr() === "&&") {
94390
+ rhsChildren.add(children[2]);
94391
+ }
94392
+ }
94393
+ for (const source of allSources) {
94394
+ const children = source.getChildren();
94395
+ if (children.length !== 3) {
94396
+ continue;
94397
+ }
94398
+ if (children[1].getFirstToken().getStr() !== "&&") {
94399
+ continue;
94400
+ }
94401
+ // only process top-level && roots (not nested RHS children)
94402
+ if (rhsChildren.has(source)) {
94403
+ continue;
94404
+ }
94405
+ const operands = this.flattenChain(source);
94406
+ if (!operands.some(op => { const c = op.getFirstToken().getStr()[0]; return c === "'" || c === "`"; })) {
94407
+ continue;
94408
+ }
94409
+ const template = this.buildTemplate(operands);
94410
+ const start = source.getFirstToken().getStart();
94411
+ const end = source.getLastToken().getEnd();
94412
+ const fix = edit_helper_1.EditHelper.replaceRange(file, start, end, template);
94413
+ const token = children[1].getFirstToken();
94414
+ issues.push(issue_1.Issue.atToken(file, token, "Use string template instead of &&", this.getMetadata().key, this.conf.severity, fix));
94415
+ }
94416
+ return issues;
94417
+ }
94418
+ flattenChain(node) {
94419
+ const children = node.getChildren();
94420
+ if (children.length === 3 && children[1].getFirstToken().getStr() === "&&") {
94421
+ return [...this.flattenChain(children[0]), ...this.flattenChain(children[2])];
94422
+ }
94423
+ if (children.length === 1 && children[0] instanceof nodes_1.ExpressionNode) {
94424
+ return this.flattenChain(children[0]);
94425
+ }
94426
+ return [node];
94427
+ }
94428
+ buildTemplate(operands) {
94429
+ let inner = "";
94430
+ for (const op of operands) {
94431
+ const raw = op.getFirstToken().getStr();
94432
+ const firstChar = raw[0];
94433
+ if (firstChar === "'" || firstChar === "`") {
94434
+ inner += raw.slice(1, -1);
94435
+ }
94436
+ else {
94437
+ inner += `{ ${op.concatTokens()} }`;
94438
+ }
94439
+ }
94440
+ return `|${inner}|`;
94441
+ }
94442
+ }
94443
+ exports.PreferStringTemplate = PreferStringTemplate;
94444
+ //# sourceMappingURL=prefer_string_template.js.map
94445
+
94446
+ /***/ },
94447
+
93923
94448
  /***/ "./node_modules/@abaplint/core/build/src/rules/prefer_xsdbool.js"
93924
94449
  /*!***********************************************************************!*\
93925
94450
  !*** ./node_modules/@abaplint/core/build/src/rules/prefer_xsdbool.js ***!
@@ -98905,6 +99430,151 @@ exports.UnnecessaryChaining = UnnecessaryChaining;
98905
99430
 
98906
99431
  /***/ },
98907
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
+
98908
99578
  /***/ "./node_modules/@abaplint/core/build/src/rules/unnecessary_pragma.js"
98909
99579
  /*!***************************************************************************!*\
98910
99580
  !*** ./node_modules/@abaplint/core/build/src/rules/unnecessary_pragma.js ***!
@@ -100979,6 +101649,103 @@ exports.UseLineExists = UseLineExists;
100979
101649
 
100980
101650
  /***/ },
100981
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
+
100982
101749
  /***/ "./node_modules/@abaplint/core/build/src/rules/use_new.js"
100983
101750
  /*!****************************************************************!*\
100984
101751
  !*** ./node_modules/@abaplint/core/build/src/rules/use_new.js ***!
@@ -104420,6 +105187,7 @@ var __importStar = (this && this.__importStar) || (function () {
104420
105187
  Object.defineProperty(exports, "__esModule", ({ value: true }));
104421
105188
  exports.AttributeNameTranspiler = void 0;
104422
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");
104423
105191
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
104424
105192
  class AttributeNameTranspiler {
104425
105193
  transpile(node, traversal) {
@@ -104430,6 +105198,16 @@ class AttributeNameTranspiler {
104430
105198
  && ref.getVisibility() === abaplint.Visibility.Private) {
104431
105199
  concat = "#" + concat;
104432
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
+ }
104433
105211
  return new chunk_1.Chunk().append(concat, node, traversal);
104434
105212
  }
104435
105213
  }
@@ -113893,6 +114671,27 @@ exports.ContinueTranspiler = ContinueTranspiler;
113893
114671
 
113894
114672
  /***/ },
113895
114673
 
114674
+ /***/ "./node_modules/@abaplint/transpiler/build/src/statements/controls.js"
114675
+ /*!****************************************************************************!*\
114676
+ !*** ./node_modules/@abaplint/transpiler/build/src/statements/controls.js ***!
114677
+ \****************************************************************************/
114678
+ (__unused_webpack_module, exports, __webpack_require__) {
114679
+
114680
+ "use strict";
114681
+
114682
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
114683
+ exports.ControlsTranspiler = void 0;
114684
+ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
114685
+ class ControlsTranspiler {
114686
+ transpile(_node, _traversal) {
114687
+ return new chunk_1.Chunk(`throw new Error("Controls, not supported, transpiler");`);
114688
+ }
114689
+ }
114690
+ exports.ControlsTranspiler = ControlsTranspiler;
114691
+ //# sourceMappingURL=controls.js.map
114692
+
114693
+ /***/ },
114694
+
113896
114695
  /***/ "./node_modules/@abaplint/transpiler/build/src/statements/convert.js"
113897
114696
  /*!***************************************************************************!*\
113898
114697
  !*** ./node_modules/@abaplint/transpiler/build/src/statements/convert.js ***!
@@ -116558,6 +117357,7 @@ __exportStar(__webpack_require__(/*! ./concatenate */ "./node_modules/@abaplint/
116558
117357
  __exportStar(__webpack_require__(/*! ./end_of_selection */ "./node_modules/@abaplint/transpiler/build/src/statements/end_of_selection.js"), exports);
116559
117358
  __exportStar(__webpack_require__(/*! ./condense */ "./node_modules/@abaplint/transpiler/build/src/statements/condense.js"), exports);
116560
117359
  __exportStar(__webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/statements/constant.js"), exports);
117360
+ __exportStar(__webpack_require__(/*! ./controls */ "./node_modules/@abaplint/transpiler/build/src/statements/controls.js"), exports);
116561
117361
  __exportStar(__webpack_require__(/*! ./continue */ "./node_modules/@abaplint/transpiler/build/src/statements/continue.js"), exports);
116562
117362
  __exportStar(__webpack_require__(/*! ./convert */ "./node_modules/@abaplint/transpiler/build/src/statements/convert.js"), exports);
116563
117363
  __exportStar(__webpack_require__(/*! ./create_data */ "./node_modules/@abaplint/transpiler/build/src/statements/create_data.js"), exports);
@@ -118974,10 +119774,22 @@ class ReadTableTranspiler {
118974
119774
  const s = traversal.traverse(source).getCode();
118975
119775
  let field = "";
118976
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 = "";
118977
119779
  if (left.get() instanceof abaplint.Expressions.Dynamic
118978
119780
  && left instanceof abaplint.Nodes.ExpressionNode) {
118979
- key = key.substring(2, key.length - 2);
118980
- 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
+ }
118981
119793
  }
118982
119794
  else if (left.get() instanceof abaplint.Expressions.ComponentChainSimple
118983
119795
  && left instanceof abaplint.Nodes.ExpressionNode) {
@@ -118989,17 +119801,18 @@ class ReadTableTranspiler {
118989
119801
  if (field === "i.table_line") {
118990
119802
  usesTableLine = true;
118991
119803
  }
119804
+ const simpleKey = keyExpression !== "" ? "[" + keyExpression + "]" : JSON.stringify(key);
118992
119805
  if (s.includes("await")) {
118993
119806
  const id = unique_identifier_1.UniqueIdentifier.get();
118994
119807
  prefix += "const " + id + " = " + s + ";\n";
118995
119808
  withKey.push("abap.compare.eq(" + field + ", " + id + ")");
118996
119809
  withKeyValue.push(`{key: (i) => {return ${field}}, value: ${id}}`);
118997
- withKeySimple.push(`${JSON.stringify(key)}: ${id}`);
119810
+ withKeySimple.push(`${simpleKey}: ${id}`);
118998
119811
  }
118999
119812
  else {
119000
119813
  withKey.push("abap.compare.eq(" + field + ", " + s + ")");
119001
119814
  withKeyValue.push(`{key: (i) => {return ${field}}, value: ${s}}`);
119002
- withKeySimple.push(`${JSON.stringify(key)}: ${s}`);
119815
+ withKeySimple.push(`${simpleKey}: ${s}`);
119003
119816
  }
119004
119817
  }
119005
119818
  extra.push("withKey: (i) => {return " + withKey.join(" && ") + ";}");
package/build/types.d.ts CHANGED
@@ -10,9 +10,18 @@ export interface ITranspilerConfig {
10
10
  * @uniqueItems true
11
11
  */
12
12
  exclude_filter?: string[];
13
+ /** @minLength 1 */
13
14
  output_folder: string;
15
+ /** experimental */
16
+ converter?: {
17
+ /** @uniqueItems true */
18
+ input_folder: string | string[];
19
+ /** @minLength 1 */
20
+ output_folder: string;
21
+ };
14
22
  libs?: {
15
23
  url?: string;
24
+ /** relative to the current working directory */
16
25
  folder?: string;
17
26
  files?: string | string[];
18
27
  /** list of regex, case insensitive
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.13.90",
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.56",
31
- "@abaplint/transpiler": "^2.13.90",
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",
package/schema.json CHANGED
@@ -61,6 +61,7 @@
61
61
  ]
62
62
  },
63
63
  "folder": {
64
+ "description": "relative to the current working directory",
64
65
  "type": "string"
65
66
  },
66
67
  "url": {
@@ -75,6 +76,7 @@
75
76
  "$ref": "#/definitions/ITranspilerOptions"
76
77
  },
77
78
  "output_folder": {
79
+ "minLength": 1,
78
80
  "type": "string"
79
81
  },
80
82
  "write_source_map": {