@abaplint/transpiler-cli 2.13.21 → 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 +51 -15
  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;
@@ -87032,9 +87043,25 @@ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abap
87032
87043
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
87033
87044
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
87034
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
+ }
87035
87061
  transpile(node, traversal) {
87036
87062
  const assignSource = node.findDirectExpression(abaplint.Expressions.AssignSource);
87037
- 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()));
87038
87065
  let fsTarget = node.findDirectExpression(abaplint.Expressions.FSTarget);
87039
87066
  if (fsTarget?.getFirstChild()?.get() instanceof abaplint.Expressions.InlineFS) {
87040
87067
  fsTarget = fsTarget.findFirstExpression(abaplint.Expressions.TargetFieldSymbol);
@@ -87049,7 +87076,7 @@ class AssignTranspiler {
87049
87076
  if (sources.length !== 0
87050
87077
  && assignSource?.findDirectExpression(abaplint.Expressions.Dynamic) === undefined) {
87051
87078
  // Check for struct-(var) pattern: dynamic component access via FieldLength after -
87052
- const sourceExprForCheck = assignSource?.findDirectExpressionsMulti([abaplint.Expressions.Source, abaplint.Expressions.SimpleSource3])[0];
87079
+ const sourceExprForCheck = sourceExpressions[0];
87053
87080
  const fieldChainForCheck = sourceExprForCheck?.findFirstExpression(abaplint.Expressions.FieldChain);
87054
87081
  const fcChildren = fieldChainForCheck?.getChildren() ?? [];
87055
87082
  const lastFC = fcChildren[fcChildren.length - 1];
@@ -87111,26 +87138,26 @@ class AssignTranspiler {
87111
87138
  const firstFirst = first.getChildren()[1];
87112
87139
  if (firstFirst?.get() instanceof abaplint.Expressions.Constant) {
87113
87140
  const s = firstFirst.getFirstToken().getStr().toLowerCase().match(/\w+/)?.toString();
87114
- options.push(`dynamicSource: (() => {
87115
- try { return ${s}; } catch {}
87116
- try { return this.${s}; } catch {}
87141
+ options.push(`dynamicSource: (() => {
87142
+ try { return ${s}; } catch {}
87143
+ try { return this.${s}; } catch {}
87117
87144
  })()`);
87118
87145
  }
87119
87146
  else if (firstFirst?.get() instanceof abaplint.Expressions.FieldChain && firstFirst instanceof abaplint.Nodes.ExpressionNode) {
87120
87147
  const code = new expressions_1.FieldChainTranspiler(true).transpile(firstFirst, traversal).getCode();
87121
- options.push(`dynamicSource: (() => {
87122
- const name = ${code}.toLowerCase().replace(/[~\\/]/g, "$").match(/[\\w\\$\\/]+/)[0];
87123
- try { return eval(name); } catch {}
87124
- 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 {}
87125
87152
  })()`);
87126
87153
  }
87127
87154
  }
87128
87155
  else if (first?.get() instanceof abaplint.Expressions.Source && first instanceof abaplint.Nodes.ExpressionNode) {
87129
87156
  // const name = first.concatTokens().toLowerCase();
87130
87157
  const name = new expressions_1.SourceTranspiler().transpile(first, traversal).getCode();
87131
- options.push(`dynamicSource: (() => {
87132
- try { return ${name}; } catch {}
87133
- try { return this.${name}; } catch {}
87158
+ options.push(`dynamicSource: (() => {
87159
+ try { return ${name}; } catch {}
87160
+ try { return this.${name}; } catch {}
87134
87161
  })()`);
87135
87162
  }
87136
87163
  }
@@ -91796,6 +91823,7 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
91796
91823
  const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
91797
91824
  class ReturnTranspiler {
91798
91825
  transpile(node, traversal) {
91826
+ const source = node.findDirectExpression(abaplint.Expressions.Source);
91799
91827
  let extra = "";
91800
91828
  const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
91801
91829
  const vars = scope?.getData().vars;
@@ -91813,6 +91841,14 @@ class ReturnTranspiler {
91813
91841
  && scope?.getIdentifier().sname.toLowerCase() === "constructor") {
91814
91842
  extra = " this";
91815
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
+ }
91816
91852
  return new chunk_1.Chunk().append(pre + "return" + extra + ";", node, traversal);
91817
91853
  }
91818
91854
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.13.21",
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.21",
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",