@abaplint/transpiler-cli 2.13.90 → 2.13.91

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
@@ -54444,7 +54547,9 @@ class MethodParameters {
54444
54547
  }
54445
54548
  isPassByValue(param) {
54446
54549
  var _a;
54447
- return param.getFirstToken().getStr().toUpperCase() === "VALUE"
54550
+ // "!" is the identifier escape, generated code has eg. "IMPORTING !VALUE(iv_foo)"
54551
+ const first = param.getFirstToken().getStr().toUpperCase();
54552
+ return (first === "VALUE" || first === "!VALUE")
54448
54553
  && ((_a = param.getChildren()[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "(";
54449
54554
  }
54450
54555
  }
@@ -71132,7 +71237,7 @@ class Registry {
71132
71237
  }
71133
71238
  static abaplintVersion() {
71134
71239
  // magic, see build script "version.js"
71135
- return "2.120.56";
71240
+ return "2.120.58";
71136
71241
  }
71137
71242
  getDDICReferences() {
71138
71243
  return this.ddicReferences;
@@ -85528,7 +85633,9 @@ __exportStar(__webpack_require__(/*! ./prefer_insert_into_table */ "./node_modul
85528
85633
  __exportStar(__webpack_require__(/*! ./prefer_is_not */ "./node_modules/@abaplint/core/build/src/rules/prefer_is_not.js"), exports);
85529
85634
  __exportStar(__webpack_require__(/*! ./prefer_pragmas */ "./node_modules/@abaplint/core/build/src/rules/prefer_pragmas.js"), exports);
85530
85635
  __exportStar(__webpack_require__(/*! ./prefer_abap_bool */ "./node_modules/@abaplint/core/build/src/rules/prefer_abap_bool.js"), exports);
85636
+ __exportStar(__webpack_require__(/*! ./prefer_abap_bool_values */ "./node_modules/@abaplint/core/build/src/rules/prefer_abap_bool_values.js"), exports);
85531
85637
  __exportStar(__webpack_require__(/*! ./prefer_raise_exception_new */ "./node_modules/@abaplint/core/build/src/rules/prefer_raise_exception_new.js"), exports);
85638
+ __exportStar(__webpack_require__(/*! ./prefer_string_template */ "./node_modules/@abaplint/core/build/src/rules/prefer_string_template.js"), exports);
85532
85639
  __exportStar(__webpack_require__(/*! ./prefer_returning_to_exporting */ "./node_modules/@abaplint/core/build/src/rules/prefer_returning_to_exporting.js"), exports);
85533
85640
  __exportStar(__webpack_require__(/*! ./prefer_xsdbool */ "./node_modules/@abaplint/core/build/src/rules/prefer_xsdbool.js"), exports);
85534
85641
  __exportStar(__webpack_require__(/*! ./preferred_compare_operator */ "./node_modules/@abaplint/core/build/src/rules/preferred_compare_operator.js"), exports);
@@ -92931,6 +93038,272 @@ exports.PreferAbapBool = PreferAbapBool;
92931
93038
 
92932
93039
  /***/ },
92933
93040
 
93041
+ /***/ "./node_modules/@abaplint/core/build/src/rules/prefer_abap_bool_values.js"
93042
+ /*!********************************************************************************!*\
93043
+ !*** ./node_modules/@abaplint/core/build/src/rules/prefer_abap_bool_values.js ***!
93044
+ \********************************************************************************/
93045
+ (__unused_webpack_module, exports, __webpack_require__) {
93046
+
93047
+ "use strict";
93048
+
93049
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
93050
+ if (k2 === undefined) k2 = k;
93051
+ var desc = Object.getOwnPropertyDescriptor(m, k);
93052
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
93053
+ desc = { enumerable: true, get: function() { return m[k]; } };
93054
+ }
93055
+ Object.defineProperty(o, k2, desc);
93056
+ }) : (function(o, m, k, k2) {
93057
+ if (k2 === undefined) k2 = k;
93058
+ o[k2] = m[k];
93059
+ }));
93060
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
93061
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
93062
+ }) : function(o, v) {
93063
+ o["default"] = v;
93064
+ });
93065
+ var __importStar = (this && this.__importStar) || (function () {
93066
+ var ownKeys = function(o) {
93067
+ ownKeys = Object.getOwnPropertyNames || function (o) {
93068
+ var ar = [];
93069
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
93070
+ return ar;
93071
+ };
93072
+ return ownKeys(o);
93073
+ };
93074
+ return function (mod) {
93075
+ if (mod && mod.__esModule) return mod;
93076
+ var result = {};
93077
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
93078
+ __setModuleDefault(result, mod);
93079
+ return result;
93080
+ };
93081
+ })();
93082
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
93083
+ exports.PreferAbapBoolValues = exports.PreferAbapBoolValuesConf = void 0;
93084
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
93085
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
93086
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
93087
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js"));
93088
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
93089
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
93090
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
93091
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
93092
+ const ABAP_BOOL = "ABAP_BOOL";
93093
+ const ABAP_TRUE = "abap_true";
93094
+ const ABAP_FALSE = "abap_false";
93095
+ const VALID_VALUES = new Set(["ABAP_TRUE", "ABAP_FALSE", "ABAP_UNDEFINED"]);
93096
+ class PreferAbapBoolValuesConf extends _basic_rule_config_1.BasicRuleConfig {
93097
+ }
93098
+ exports.PreferAbapBoolValuesConf = PreferAbapBoolValuesConf;
93099
+ class PreferAbapBoolValues extends _abap_rule_1.ABAPRule {
93100
+ constructor() {
93101
+ super(...arguments);
93102
+ this.conf = new PreferAbapBoolValuesConf();
93103
+ }
93104
+ getMetadata() {
93105
+ return {
93106
+ key: "prefer_abap_bool_values",
93107
+ title: "Prefer abap_true and abap_false",
93108
+ shortDescription: `Use abap_true and abap_false instead of 'X' and ' ' for abap_bool variables`,
93109
+ // eslint-disable-next-line max-len
93110
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-abap_true-abap_false-and-abap_undefined-for-abap_bool-variables`,
93111
+ tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
93112
+ badExample: `DATA lv_flag TYPE abap_bool.\nlv_flag = 'X'.`,
93113
+ goodExample: `DATA lv_flag TYPE abap_bool.\nlv_flag = abap_true.`,
93114
+ };
93115
+ }
93116
+ getConfig() {
93117
+ return this.conf;
93118
+ }
93119
+ setConfig(conf) {
93120
+ this.conf = conf;
93121
+ }
93122
+ runParsed(file) {
93123
+ const issues = [];
93124
+ const structure = file.getStructure();
93125
+ if (structure === undefined) {
93126
+ return [];
93127
+ }
93128
+ const boolVars = this.collectBoolVars(file);
93129
+ // Check Move statements: target = source
93130
+ for (const stat of structure.findAllStatements(Statements.Move)) {
93131
+ const target = stat.findFirstExpression(Expressions.Target);
93132
+ const source = stat.findFirstExpression(Expressions.Source);
93133
+ if (target === undefined || source === undefined) {
93134
+ continue;
93135
+ }
93136
+ const targetName = target.concatTokens().toUpperCase();
93137
+ if (!boolVars.has(targetName)) {
93138
+ continue;
93139
+ }
93140
+ this.checkSourceNode(source, file, issues);
93141
+ }
93142
+ // Check comparisons: IF/ELSEIF conditions
93143
+ const compareStatements = [
93144
+ ...structure.findAllStatements(Statements.If),
93145
+ ...structure.findAllStatements(Statements.ElseIf),
93146
+ ];
93147
+ for (const stat of compareStatements) {
93148
+ const cond = stat.findFirstExpression(Expressions.Cond);
93149
+ if (cond === undefined) {
93150
+ continue;
93151
+ }
93152
+ for (const compare of cond.findAllExpressions(Expressions.Compare)) {
93153
+ this.checkCompareBoolLiteral(compare, boolVars, file, issues);
93154
+ }
93155
+ }
93156
+ return issues;
93157
+ }
93158
+ collectBoolVars(file) {
93159
+ var _a;
93160
+ const boolVars = new Set();
93161
+ const structure = file.getStructure();
93162
+ if (structure === undefined) {
93163
+ return boolVars;
93164
+ }
93165
+ const statements = [
93166
+ ...structure.findAllStatements(Statements.Data),
93167
+ ...structure.findAllStatements(Statements.ClassData),
93168
+ ...structure.findAllStatements(Statements.FieldSymbol),
93169
+ ];
93170
+ for (const stat of statements) {
93171
+ const typeNameExpr = stat.findFirstExpression(Expressions.TypeName);
93172
+ if (typeNameExpr === undefined) {
93173
+ continue;
93174
+ }
93175
+ if (typeNameExpr.concatTokens().toUpperCase() !== ABAP_BOOL) {
93176
+ continue;
93177
+ }
93178
+ const nameExpr = (_a = stat.findFirstExpression(Expressions.DefinitionName)) !== null && _a !== void 0 ? _a : stat.findFirstExpression(Expressions.FieldSymbol);
93179
+ if (nameExpr === undefined) {
93180
+ continue;
93181
+ }
93182
+ boolVars.add(nameExpr.concatTokens().toUpperCase());
93183
+ }
93184
+ return boolVars;
93185
+ }
93186
+ checkSourceNode(source, file, issues) {
93187
+ const firstToken = source.getFirstToken().getStr().toUpperCase();
93188
+ if (firstToken === "COND") {
93189
+ const condBody = source.findDirectExpression(Expressions.CondBody);
93190
+ if (condBody) {
93191
+ this.checkCondBodyBranches(condBody, file, issues);
93192
+ }
93193
+ return;
93194
+ }
93195
+ if (firstToken === "SWITCH") {
93196
+ const switchBody = source.findDirectExpression(Expressions.SwitchBody);
93197
+ if (switchBody) {
93198
+ this.checkSwitchBodyBranches(switchBody, file, issues);
93199
+ }
93200
+ return;
93201
+ }
93202
+ // Plain literal assignment
93203
+ const issue = this.checkLiteralSource(source, file);
93204
+ if (issue) {
93205
+ issues.push(issue);
93206
+ }
93207
+ }
93208
+ checkLiteralSource(source, file) {
93209
+ const constantStr = source.findFirstExpression(Expressions.ConstantString);
93210
+ if (constantStr === undefined) {
93211
+ return undefined;
93212
+ }
93213
+ const token = constantStr.getFirstToken();
93214
+ const val = token.getStr();
93215
+ if (val === "'X'") {
93216
+ const fix = edit_helper_1.EditHelper.replaceToken(file, token, ABAP_TRUE);
93217
+ return issue_1.Issue.atToken(file, token, `Use ${ABAP_TRUE} instead of 'X'`, this.getMetadata().key, this.conf.severity, fix);
93218
+ }
93219
+ if (val === "' '") {
93220
+ const fix = edit_helper_1.EditHelper.replaceToken(file, token, ABAP_FALSE);
93221
+ return issue_1.Issue.atToken(file, token, `Use ${ABAP_FALSE} instead of ' '`, this.getMetadata().key, this.conf.severity, fix);
93222
+ }
93223
+ return undefined;
93224
+ }
93225
+ checkCondBodyBranches(condBody, file, issues) {
93226
+ // CondBody: WHEN <cond> THEN <source> [WHEN <cond> THEN <source>]* [ELSE <source>]
93227
+ // Walk children; Source nodes after THEN/ELSE are the result values
93228
+ let afterThenOrElse = false;
93229
+ for (const child of condBody.getChildren()) {
93230
+ const tokenStr = child.getFirstToken().getStr().toUpperCase();
93231
+ if (tokenStr === "THEN" || tokenStr === "ELSE") {
93232
+ afterThenOrElse = true;
93233
+ continue;
93234
+ }
93235
+ if (tokenStr === "WHEN") {
93236
+ afterThenOrElse = false;
93237
+ continue;
93238
+ }
93239
+ if (afterThenOrElse && child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.Source) {
93240
+ const issue = this.checkLiteralSource(child, file);
93241
+ if (issue) {
93242
+ issues.push(issue);
93243
+ }
93244
+ afterThenOrElse = false;
93245
+ }
93246
+ }
93247
+ }
93248
+ checkSwitchBodyBranches(switchBody, file, issues) {
93249
+ // SwitchBody: <source> WHEN <val> [OR <val>]* THEN <source> [ELSE <source>]
93250
+ // First Source is the operand; Source after THEN/ELSE are result values
93251
+ let firstSourceSeen = false;
93252
+ let afterThenOrElse = false;
93253
+ for (const child of switchBody.getChildren()) {
93254
+ const tokenStr = child.getFirstToken().getStr().toUpperCase();
93255
+ if (tokenStr === "THEN" || tokenStr === "ELSE") {
93256
+ afterThenOrElse = true;
93257
+ continue;
93258
+ }
93259
+ if (tokenStr === "WHEN" || tokenStr === "OR") {
93260
+ afterThenOrElse = false;
93261
+ continue;
93262
+ }
93263
+ if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.Source) {
93264
+ if (!firstSourceSeen) {
93265
+ firstSourceSeen = true;
93266
+ continue;
93267
+ }
93268
+ if (afterThenOrElse) {
93269
+ const issue = this.checkLiteralSource(child, file);
93270
+ if (issue) {
93271
+ issues.push(issue);
93272
+ }
93273
+ afterThenOrElse = false;
93274
+ }
93275
+ }
93276
+ }
93277
+ }
93278
+ checkCompareBoolLiteral(compare, boolVars, file, issues) {
93279
+ // Compare: Source CompareOperator Source (or other forms)
93280
+ const sources = compare.findDirectExpressions(Expressions.Source);
93281
+ if (sources.length < 2) {
93282
+ return;
93283
+ }
93284
+ const [left, right] = sources;
93285
+ const leftStr = left.concatTokens().toUpperCase();
93286
+ const rightStr = right.concatTokens().toUpperCase();
93287
+ let literalSource;
93288
+ if (boolVars.has(leftStr) && !VALID_VALUES.has(rightStr)) {
93289
+ literalSource = right;
93290
+ }
93291
+ else if (boolVars.has(rightStr) && !VALID_VALUES.has(leftStr)) {
93292
+ literalSource = left;
93293
+ }
93294
+ if (literalSource) {
93295
+ const issue = this.checkLiteralSource(literalSource, file);
93296
+ if (issue) {
93297
+ issues.push(issue);
93298
+ }
93299
+ }
93300
+ }
93301
+ }
93302
+ exports.PreferAbapBoolValues = PreferAbapBoolValues;
93303
+ //# sourceMappingURL=prefer_abap_bool_values.js.map
93304
+
93305
+ /***/ },
93306
+
92934
93307
  /***/ "./node_modules/@abaplint/core/build/src/rules/prefer_corresponding.js"
92935
93308
  /*!*****************************************************************************!*\
92936
93309
  !*** ./node_modules/@abaplint/core/build/src/rules/prefer_corresponding.js ***!
@@ -93920,6 +94293,151 @@ exports.PreferReturningToExporting = PreferReturningToExporting;
93920
94293
 
93921
94294
  /***/ },
93922
94295
 
94296
+ /***/ "./node_modules/@abaplint/core/build/src/rules/prefer_string_template.js"
94297
+ /*!*******************************************************************************!*\
94298
+ !*** ./node_modules/@abaplint/core/build/src/rules/prefer_string_template.js ***!
94299
+ \*******************************************************************************/
94300
+ (__unused_webpack_module, exports, __webpack_require__) {
94301
+
94302
+ "use strict";
94303
+
94304
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
94305
+ if (k2 === undefined) k2 = k;
94306
+ var desc = Object.getOwnPropertyDescriptor(m, k);
94307
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
94308
+ desc = { enumerable: true, get: function() { return m[k]; } };
94309
+ }
94310
+ Object.defineProperty(o, k2, desc);
94311
+ }) : (function(o, m, k, k2) {
94312
+ if (k2 === undefined) k2 = k;
94313
+ o[k2] = m[k];
94314
+ }));
94315
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
94316
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
94317
+ }) : function(o, v) {
94318
+ o["default"] = v;
94319
+ });
94320
+ var __importStar = (this && this.__importStar) || (function () {
94321
+ var ownKeys = function(o) {
94322
+ ownKeys = Object.getOwnPropertyNames || function (o) {
94323
+ var ar = [];
94324
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
94325
+ return ar;
94326
+ };
94327
+ return ownKeys(o);
94328
+ };
94329
+ return function (mod) {
94330
+ if (mod && mod.__esModule) return mod;
94331
+ var result = {};
94332
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
94333
+ __setModuleDefault(result, mod);
94334
+ return result;
94335
+ };
94336
+ })();
94337
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
94338
+ exports.PreferStringTemplate = exports.PreferStringTemplateConf = void 0;
94339
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
94340
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
94341
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
94342
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
94343
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
94344
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
94345
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
94346
+ class PreferStringTemplateConf extends _basic_rule_config_1.BasicRuleConfig {
94347
+ }
94348
+ exports.PreferStringTemplateConf = PreferStringTemplateConf;
94349
+ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
94350
+ constructor() {
94351
+ super(...arguments);
94352
+ this.conf = new PreferStringTemplateConf();
94353
+ }
94354
+ getMetadata() {
94355
+ return {
94356
+ key: "prefer_string_template",
94357
+ title: "Prefer string template over &&",
94358
+ shortDescription: `Use string templates instead of && to assemble text`,
94359
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use--to-assemble-text`,
94360
+ tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
94361
+ badExample: `DATA(msg) = \`Hello \` && name && \`!\`.`,
94362
+ goodExample: `DATA(msg) = |Hello { name }!|.`,
94363
+ };
94364
+ }
94365
+ getConfig() {
94366
+ return this.conf;
94367
+ }
94368
+ setConfig(conf) {
94369
+ this.conf = conf;
94370
+ }
94371
+ runParsed(file) {
94372
+ const issues = [];
94373
+ const structure = file.getStructure();
94374
+ if (structure === undefined) {
94375
+ return [];
94376
+ }
94377
+ const allSources = structure.findAllExpressions(Expressions.Source);
94378
+ // collect all Source nodes that appear as the RHS (children[2]) of a && expression
94379
+ const rhsChildren = new Set();
94380
+ for (const source of allSources) {
94381
+ const children = source.getChildren();
94382
+ if (children.length === 3 && children[1].getFirstToken().getStr() === "&&") {
94383
+ rhsChildren.add(children[2]);
94384
+ }
94385
+ }
94386
+ for (const source of allSources) {
94387
+ const children = source.getChildren();
94388
+ if (children.length !== 3) {
94389
+ continue;
94390
+ }
94391
+ if (children[1].getFirstToken().getStr() !== "&&") {
94392
+ continue;
94393
+ }
94394
+ // only process top-level && roots (not nested RHS children)
94395
+ if (rhsChildren.has(source)) {
94396
+ continue;
94397
+ }
94398
+ const operands = this.flattenChain(source);
94399
+ if (!operands.some(op => { const c = op.getFirstToken().getStr()[0]; return c === "'" || c === "`"; })) {
94400
+ continue;
94401
+ }
94402
+ const template = this.buildTemplate(operands);
94403
+ const start = source.getFirstToken().getStart();
94404
+ const end = source.getLastToken().getEnd();
94405
+ const fix = edit_helper_1.EditHelper.replaceRange(file, start, end, template);
94406
+ const token = children[1].getFirstToken();
94407
+ issues.push(issue_1.Issue.atToken(file, token, "Use string template instead of &&", this.getMetadata().key, this.conf.severity, fix));
94408
+ }
94409
+ return issues;
94410
+ }
94411
+ flattenChain(node) {
94412
+ const children = node.getChildren();
94413
+ if (children.length === 3 && children[1].getFirstToken().getStr() === "&&") {
94414
+ return [...this.flattenChain(children[0]), ...this.flattenChain(children[2])];
94415
+ }
94416
+ if (children.length === 1 && children[0] instanceof nodes_1.ExpressionNode) {
94417
+ return this.flattenChain(children[0]);
94418
+ }
94419
+ return [node];
94420
+ }
94421
+ buildTemplate(operands) {
94422
+ let inner = "";
94423
+ for (const op of operands) {
94424
+ const raw = op.getFirstToken().getStr();
94425
+ const firstChar = raw[0];
94426
+ if (firstChar === "'" || firstChar === "`") {
94427
+ inner += raw.slice(1, -1);
94428
+ }
94429
+ else {
94430
+ inner += `{ ${op.concatTokens()} }`;
94431
+ }
94432
+ }
94433
+ return `|${inner}|`;
94434
+ }
94435
+ }
94436
+ exports.PreferStringTemplate = PreferStringTemplate;
94437
+ //# sourceMappingURL=prefer_string_template.js.map
94438
+
94439
+ /***/ },
94440
+
93923
94441
  /***/ "./node_modules/@abaplint/core/build/src/rules/prefer_xsdbool.js"
93924
94442
  /*!***********************************************************************!*\
93925
94443
  !*** ./node_modules/@abaplint/core/build/src/rules/prefer_xsdbool.js ***!
@@ -113893,6 +114411,27 @@ exports.ContinueTranspiler = ContinueTranspiler;
113893
114411
 
113894
114412
  /***/ },
113895
114413
 
114414
+ /***/ "./node_modules/@abaplint/transpiler/build/src/statements/controls.js"
114415
+ /*!****************************************************************************!*\
114416
+ !*** ./node_modules/@abaplint/transpiler/build/src/statements/controls.js ***!
114417
+ \****************************************************************************/
114418
+ (__unused_webpack_module, exports, __webpack_require__) {
114419
+
114420
+ "use strict";
114421
+
114422
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
114423
+ exports.ControlsTranspiler = void 0;
114424
+ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
114425
+ class ControlsTranspiler {
114426
+ transpile(_node, _traversal) {
114427
+ return new chunk_1.Chunk(`throw new Error("Controls, not supported, transpiler");`);
114428
+ }
114429
+ }
114430
+ exports.ControlsTranspiler = ControlsTranspiler;
114431
+ //# sourceMappingURL=controls.js.map
114432
+
114433
+ /***/ },
114434
+
113896
114435
  /***/ "./node_modules/@abaplint/transpiler/build/src/statements/convert.js"
113897
114436
  /*!***************************************************************************!*\
113898
114437
  !*** ./node_modules/@abaplint/transpiler/build/src/statements/convert.js ***!
@@ -116558,6 +117097,7 @@ __exportStar(__webpack_require__(/*! ./concatenate */ "./node_modules/@abaplint/
116558
117097
  __exportStar(__webpack_require__(/*! ./end_of_selection */ "./node_modules/@abaplint/transpiler/build/src/statements/end_of_selection.js"), exports);
116559
117098
  __exportStar(__webpack_require__(/*! ./condense */ "./node_modules/@abaplint/transpiler/build/src/statements/condense.js"), exports);
116560
117099
  __exportStar(__webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/statements/constant.js"), exports);
117100
+ __exportStar(__webpack_require__(/*! ./controls */ "./node_modules/@abaplint/transpiler/build/src/statements/controls.js"), exports);
116561
117101
  __exportStar(__webpack_require__(/*! ./continue */ "./node_modules/@abaplint/transpiler/build/src/statements/continue.js"), exports);
116562
117102
  __exportStar(__webpack_require__(/*! ./convert */ "./node_modules/@abaplint/transpiler/build/src/statements/convert.js"), exports);
116563
117103
  __exportStar(__webpack_require__(/*! ./create_data */ "./node_modules/@abaplint/transpiler/build/src/statements/create_data.js"), exports);
package/build/types.d.ts CHANGED
@@ -10,9 +10,11 @@ export interface ITranspilerConfig {
10
10
  * @uniqueItems true
11
11
  */
12
12
  exclude_filter?: string[];
13
+ /** @minLength 1 */
13
14
  output_folder: string;
14
15
  libs?: {
15
16
  url?: string;
17
+ /** relative to the current working directory */
16
18
  folder?: string;
17
19
  files?: string | string[];
18
20
  /** 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.91",
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.58",
31
+ "@abaplint/transpiler": "^2.13.91",
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": {