@abaplint/transpiler-cli 2.13.20 → 2.13.22

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.
Files changed (2) hide show
  1. package/build/bundle.js +92 -17
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -15511,7 +15511,7 @@ const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@a
15511
15511
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
15512
15512
  class Return {
15513
15513
  getMatcher() {
15514
- return (0, combi_1.seq)((0, combi_1.str)("RETURN"), (0, combi_1.optPrio)((0, combi_1.ver)(version_1.Version.v758, expressions_1.Source)));
15514
+ return (0, combi_1.seq)((0, combi_1.str)("RETURN"), (0, combi_1.optPrio)((0, combi_1.ver)(version_1.Version.v758, expressions_1.Source, version_1.Version.OpenABAP)));
15515
15515
  }
15516
15516
  }
15517
15517
  exports.Return = Return;
@@ -55154,7 +55154,7 @@ class Registry {
55154
55154
  }
55155
55155
  static abaplintVersion() {
55156
55156
  // magic, see build script "version.sh"
55157
- return "2.119.12";
55157
+ return "2.119.13";
55158
55158
  }
55159
55159
  getDDICReferences() {
55160
55160
  return this.ddicReferences;
@@ -77223,10 +77223,14 @@ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./
77223
77223
  const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
77224
77224
  const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
77225
77225
  const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/_statement.js");
77226
+ const objects_1 = __webpack_require__(/*! ../objects */ "./node_modules/@abaplint/core/build/src/objects/index.js");
77227
+ const ddic_1 = __webpack_require__(/*! ../ddic */ "./node_modules/@abaplint/core/build/src/ddic.js");
77226
77228
  class UnnecessaryChainingConf extends _basic_rule_config_1.BasicRuleConfig {
77227
77229
  constructor() {
77228
77230
  super(...arguments);
77229
77231
  this.maxIssuesPerFile = 10;
77232
+ /** Ignore global exception classes */
77233
+ this.ignoreExceptions = true;
77230
77234
  }
77231
77235
  }
77232
77236
  exports.UnnecessaryChainingConf = UnnecessaryChainingConf;
@@ -77252,8 +77256,15 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
77252
77256
  setConfig(conf) {
77253
77257
  this.conf = conf;
77254
77258
  }
77255
- runParsed(file) {
77259
+ runParsed(file, obj) {
77256
77260
  const issues = [];
77261
+ if (obj instanceof objects_1.Class) {
77262
+ const definition = obj.getClassDefinition();
77263
+ const ddic = new ddic_1.DDIC(this.reg);
77264
+ if (this.conf.ignoreExceptions === true && ddic.isException(definition, obj)) {
77265
+ return issues;
77266
+ }
77267
+ }
77257
77268
  let max = this.getConfig().maxIssuesPerFile;
77258
77269
  if (max === undefined || max < 1) {
77259
77270
  max = 10;
@@ -85121,6 +85132,12 @@ class TypeNameOrInfer {
85121
85132
  const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
85122
85133
  const type = traversal.lookupInferred(node, scope);
85123
85134
  if (type === undefined) {
85135
+ if (node.concatTokens() === "#") {
85136
+ const sqlType = traversal.getSQLInferredType();
85137
+ if (sqlType !== undefined) {
85138
+ return sqlType;
85139
+ }
85140
+ }
85124
85141
  throw new Error("TypeNameOrInfer, type not found: " + node.concatTokens() + ", " + traversal.getCurrentObject().getName() + " line " + node.getFirstToken().getStart().getRow());
85125
85142
  }
85126
85143
  return type;
@@ -87026,9 +87043,25 @@ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abap
87026
87043
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
87027
87044
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
87028
87045
  class AssignTranspiler {
87046
+ tableExpressionSafeSource(node, code) {
87047
+ if (node?.findFirstExpression(abaplint.Expressions.TableExpression) === undefined) {
87048
+ return code;
87049
+ }
87050
+ return `(await (async () => {
87051
+ try {
87052
+ return ${code};
87053
+ } catch (error) {
87054
+ if (abap.isLineNotFound(error)) {
87055
+ return undefined;
87056
+ }
87057
+ throw error;
87058
+ }
87059
+ })())`;
87060
+ }
87029
87061
  transpile(node, traversal) {
87030
87062
  const assignSource = node.findDirectExpression(abaplint.Expressions.AssignSource);
87031
- const sources = assignSource?.findDirectExpressionsMulti([abaplint.Expressions.Source, abaplint.Expressions.SimpleSource3]).map(e => new expressions_1.SourceTranspiler(false).transpile(e, traversal).getCode()) || [];
87063
+ const sourceExpressions = assignSource?.findDirectExpressionsMulti([abaplint.Expressions.Source, abaplint.Expressions.SimpleSource3]) || [];
87064
+ const sources = sourceExpressions.map(e => this.tableExpressionSafeSource(e, new expressions_1.SourceTranspiler(false).transpile(e, traversal).getCode()));
87032
87065
  let fsTarget = node.findDirectExpression(abaplint.Expressions.FSTarget);
87033
87066
  if (fsTarget?.getFirstChild()?.get() instanceof abaplint.Expressions.InlineFS) {
87034
87067
  fsTarget = fsTarget.findFirstExpression(abaplint.Expressions.TargetFieldSymbol);
@@ -87043,7 +87076,7 @@ class AssignTranspiler {
87043
87076
  if (sources.length !== 0
87044
87077
  && assignSource?.findDirectExpression(abaplint.Expressions.Dynamic) === undefined) {
87045
87078
  // Check for struct-(var) pattern: dynamic component access via FieldLength after -
87046
- const sourceExprForCheck = assignSource?.findDirectExpressionsMulti([abaplint.Expressions.Source, abaplint.Expressions.SimpleSource3])[0];
87079
+ const sourceExprForCheck = sourceExpressions[0];
87047
87080
  const fieldChainForCheck = sourceExprForCheck?.findFirstExpression(abaplint.Expressions.FieldChain);
87048
87081
  const fcChildren = fieldChainForCheck?.getChildren() ?? [];
87049
87082
  const lastFC = fcChildren[fcChildren.length - 1];
@@ -87105,26 +87138,26 @@ class AssignTranspiler {
87105
87138
  const firstFirst = first.getChildren()[1];
87106
87139
  if (firstFirst?.get() instanceof abaplint.Expressions.Constant) {
87107
87140
  const s = firstFirst.getFirstToken().getStr().toLowerCase().match(/\w+/)?.toString();
87108
- options.push(`dynamicSource: (() => {
87109
- try { return ${s}; } catch {}
87110
- try { return this.${s}; } catch {}
87141
+ options.push(`dynamicSource: (() => {
87142
+ try { return ${s}; } catch {}
87143
+ try { return this.${s}; } catch {}
87111
87144
  })()`);
87112
87145
  }
87113
87146
  else if (firstFirst?.get() instanceof abaplint.Expressions.FieldChain && firstFirst instanceof abaplint.Nodes.ExpressionNode) {
87114
87147
  const code = new expressions_1.FieldChainTranspiler(true).transpile(firstFirst, traversal).getCode();
87115
- options.push(`dynamicSource: (() => {
87116
- const name = ${code}.toLowerCase().replace(/[~\\/]/g, "$").match(/[\\w\\$\\/]+/)[0];
87117
- try { return eval(name); } catch {}
87118
- try { return eval("this." + name); } catch {}
87148
+ options.push(`dynamicSource: (() => {
87149
+ const name = ${code}.toLowerCase().replace(/[~\\/]/g, "$").match(/[\\w\\$\\/]+/)[0];
87150
+ try { return eval(name); } catch {}
87151
+ try { return eval("this." + name); } catch {}
87119
87152
  })()`);
87120
87153
  }
87121
87154
  }
87122
87155
  else if (first?.get() instanceof abaplint.Expressions.Source && first instanceof abaplint.Nodes.ExpressionNode) {
87123
87156
  // const name = first.concatTokens().toLowerCase();
87124
87157
  const name = new expressions_1.SourceTranspiler().transpile(first, traversal).getCode();
87125
- options.push(`dynamicSource: (() => {
87126
- try { return ${name}; } catch {}
87127
- try { return this.${name}; } catch {}
87158
+ options.push(`dynamicSource: (() => {
87159
+ try { return ${name}; } catch {}
87160
+ try { return this.${name}; } catch {}
87128
87161
  })()`);
87129
87162
  }
87130
87163
  }
@@ -89475,6 +89508,27 @@ exports.FunctionPoolTranspiler = FunctionPoolTranspiler;
89475
89508
 
89476
89509
  /***/ },
89477
89510
 
89511
+ /***/ "./node_modules/@abaplint/transpiler/build/src/statements/generate_subroutine.js"
89512
+ /*!***************************************************************************************!*\
89513
+ !*** ./node_modules/@abaplint/transpiler/build/src/statements/generate_subroutine.js ***!
89514
+ \***************************************************************************************/
89515
+ (__unused_webpack_module, exports, __webpack_require__) {
89516
+
89517
+ "use strict";
89518
+
89519
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
89520
+ exports.GenerateSubroutineTranspiler = void 0;
89521
+ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
89522
+ class GenerateSubroutineTranspiler {
89523
+ transpile(_node, _traversal) {
89524
+ return new chunk_1.Chunk(`throw new Error("GenerateSubroutine, not supported, transpiler");`);
89525
+ }
89526
+ }
89527
+ exports.GenerateSubroutineTranspiler = GenerateSubroutineTranspiler;
89528
+ //# sourceMappingURL=generate_subroutine.js.map
89529
+
89530
+ /***/ },
89531
+
89478
89532
  /***/ "./node_modules/@abaplint/transpiler/build/src/statements/get_bit.js"
89479
89533
  /*!***************************************************************************!*\
89480
89534
  !*** ./node_modules/@abaplint/transpiler/build/src/statements/get_bit.js ***!
@@ -89918,6 +89972,7 @@ __exportStar(__webpack_require__(/*! ./set_language */ "./node_modules/@abaplint
89918
89972
  __exportStar(__webpack_require__(/*! ./set_locale */ "./node_modules/@abaplint/transpiler/build/src/statements/set_locale.js"), exports);
89919
89973
  __exportStar(__webpack_require__(/*! ./set_parameter */ "./node_modules/@abaplint/transpiler/build/src/statements/set_parameter.js"), exports);
89920
89974
  __exportStar(__webpack_require__(/*! ./set_pf_status */ "./node_modules/@abaplint/transpiler/build/src/statements/set_pf_status.js"), exports);
89975
+ __exportStar(__webpack_require__(/*! ./generate_subroutine */ "./node_modules/@abaplint/transpiler/build/src/statements/generate_subroutine.js"), exports);
89921
89976
  __exportStar(__webpack_require__(/*! ./set_screen */ "./node_modules/@abaplint/transpiler/build/src/statements/set_screen.js"), exports);
89922
89977
  __exportStar(__webpack_require__(/*! ./set_titlebar */ "./node_modules/@abaplint/transpiler/build/src/statements/set_titlebar.js"), exports);
89923
89978
  __exportStar(__webpack_require__(/*! ./shift */ "./node_modules/@abaplint/transpiler/build/src/statements/shift.js"), exports);
@@ -90001,7 +90056,7 @@ class InsertDatabaseTranspiler {
90001
90056
  }
90002
90057
  const from = node.findExpressionAfterToken("FROM");
90003
90058
  if (from && from.get() instanceof abaplint.Expressions.SQLSource) {
90004
- const tvalues = traversal.traverse(from);
90059
+ const tvalues = traversal.traverseWithTableContext(dbtab.concatTokens(), from);
90005
90060
  options.push(`"values": ` + tvalues.getCode());
90006
90061
  }
90007
90062
  const fromTable = node.findExpressionAfterToken("TABLE");
@@ -90745,7 +90800,7 @@ class ModifyDatabaseTranspiler {
90745
90800
  }
90746
90801
  const from = node.findExpressionAfterToken("FROM");
90747
90802
  if (from && from.get() instanceof abaplint.Expressions.SQLSource) {
90748
- const tvalues = traversal.traverse(from);
90803
+ const tvalues = traversal.traverseWithTableContext(dbtab.concatTokens(), from);
90749
90804
  options.push(`"values": ` + tvalues.getCode());
90750
90805
  }
90751
90806
  return new chunk_1.Chunk(`await abap.statements.modifyDatabase(${table.getCode()}, {${options.join(", ")}});`);
@@ -91768,6 +91823,7 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
91768
91823
  const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
91769
91824
  class ReturnTranspiler {
91770
91825
  transpile(node, traversal) {
91826
+ const source = node.findDirectExpression(abaplint.Expressions.Source);
91771
91827
  let extra = "";
91772
91828
  const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
91773
91829
  const vars = scope?.getData().vars;
@@ -91785,6 +91841,14 @@ class ReturnTranspiler {
91785
91841
  && scope?.getIdentifier().sname.toLowerCase() === "constructor") {
91786
91842
  extra = " this";
91787
91843
  }
91844
+ // RETURN <source> assigns to the RETURNING parameter and exits immediately.
91845
+ if (source && extra !== " this") {
91846
+ return new chunk_1.Chunk().append(pre
91847
+ + extra.trimStart()
91848
+ + `.set(${traversal.traverse(source).getCode()});\nreturn`
91849
+ + extra
91850
+ + ";", node, traversal);
91851
+ }
91788
91852
  return new chunk_1.Chunk().append(pre + "return" + extra + ";", node, traversal);
91789
91853
  }
91790
91854
  }
@@ -94779,6 +94843,7 @@ class Traversal {
94779
94843
  spaghetti;
94780
94844
  file;
94781
94845
  obj;
94846
+ sqlInferredType;
94782
94847
  reg;
94783
94848
  options;
94784
94849
  constructor(spaghetti, file, obj, reg, options) {
@@ -94873,6 +94938,16 @@ class Traversal {
94873
94938
  }
94874
94939
  return undefined;
94875
94940
  }
94941
+ getSQLInferredType() {
94942
+ return this.sqlInferredType;
94943
+ }
94944
+ traverseWithTableContext(tableName, expressionNode) {
94945
+ const tabl = this.reg.getObject("TABL", tableName);
94946
+ this.sqlInferredType = tabl?.parseType(this.reg);
94947
+ const result = this.traverse(expressionNode);
94948
+ this.sqlInferredType = undefined;
94949
+ return result;
94950
+ }
94876
94951
  getInterfaceDefinition(token) {
94877
94952
  let scope = this.findCurrentScopeByToken(token);
94878
94953
  while (scope !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.13.20",
3
+ "version": "2.13.22",
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.119.12",
31
- "@abaplint/transpiler": "^2.13.20",
30
+ "@abaplint/core": "^2.119.13",
31
+ "@abaplint/transpiler": "^2.13.22",
32
32
  "@types/glob": "^8.1.0",
33
33
  "@types/node": "^24.12.2",
34
34
  "@types/progress": "^2.0.7",