@abaplint/transpiler-cli 2.14.43 → 2.14.44

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 +46 -6
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -133799,7 +133799,8 @@ class MethodCallChainTranspiler {
133799
133799
  const children = node.getChildren();
133800
133800
  const calls = node.findDirectExpressions(core_1.Expressions.MethodCall);
133801
133801
  const lastCall = calls[calls.length - 1];
133802
- for (const c of children) {
133802
+ for (let i = 0; i < children.length; i++) {
133803
+ const c = children[i];
133803
133804
  if (c instanceof core_1.Nodes.ExpressionNode && c.get() instanceof core_1.Expressions.MethodCall) {
133804
133805
  const isFirst = c === node.getFirstChild();
133805
133806
  // "me->name( )" has the same semantics as the unqualified "name( )",
@@ -133853,12 +133854,18 @@ class MethodCallChainTranspiler {
133853
133854
  ret.append(name, c, traversal);
133854
133855
  }
133855
133856
  else if (c instanceof core_1.Nodes.TokenNode && c.getFirstToken().getStr() === "->") {
133857
+ const previous = children[i - 1];
133856
133858
  if (ret.getCode() === "super") {
133857
133859
  ret.append(".", c, traversal);
133858
133860
  }
133859
- else {
133861
+ else if (traversal_1.Traversal.isMe(previous) || previous.get() instanceof core_1.Expressions.NewObject) {
133862
+ // the reference cannot be initial
133860
133863
  ret.append(".get().", c, traversal);
133861
133864
  }
133865
+ else {
133866
+ // a call through an initial reference raises CX_SY_REF_IS_INITIAL
133867
+ ret = new chunk_1.Chunk().appendString("(").appendChunk(ret).append(".get()" + traversal_1.Traversal.REF_IS_INITIAL + ").", c, traversal);
133868
+ }
133862
133869
  }
133863
133870
  else if (c instanceof core_1.Nodes.TokenNode && c.getFirstToken().getStr() === "=>") {
133864
133871
  ret.append(".", c, traversal);
@@ -134147,11 +134154,19 @@ class MethodSourceTranspiler {
134147
134154
  call += ".";
134148
134155
  }
134149
134156
  else if (child.concatTokens() === "->") {
134150
- if (ret.getCode() !== "super") {
134157
+ if (nextChild.get() instanceof core_1.Expressions.Dynamic) {
134158
+ // abap.dynamicCallLookup() raises CX_SY_REF_IS_INITIAL for an initial reference
134151
134159
  call += ".get()";
134152
134160
  }
134153
- if (!(nextChild.get() instanceof core_1.Expressions.Dynamic)) {
134154
- call += ".";
134161
+ else if (this.staticConstructorCall === false
134162
+ || call === "super"
134163
+ || traversal_1.Traversal.isMe(children[i - 1])) {
134164
+ // SET HANDLER only registers the method without calling it, and "me" or "super" cannot be initial
134165
+ call += ".get().";
134166
+ }
134167
+ else {
134168
+ // a call through an initial reference raises CX_SY_REF_IS_INITIAL
134169
+ call = "(" + call + ".get()" + traversal_1.Traversal.REF_IS_INITIAL + ").";
134155
134170
  }
134156
134171
  }
134157
134172
  else if (child.get() instanceof core_1.Expressions.FieldChain
@@ -139045,7 +139060,22 @@ class Transpiler {
139045
139060
  const reg = new abaplint.Registry().addFiles(memory);
139046
139061
  return this.run(reg);
139047
139062
  }
139063
+ /** Transpiles the registry. The transpiler installs its own abaplint
139064
+ * configuration (OpenABAP syntax, its rule set) on the registry for the
139065
+ * duration of the run and puts the caller's configuration back before
139066
+ * returning, also when it throws. setConfig() marks every object dirty, so
139067
+ * the registry is left unparsed: abaplint parses it again with the restored
139068
+ * configuration on the next findIssues() or parse(). */
139048
139069
  async run(reg, progress, folders) {
139070
+ const previousConfig = reg.getConfig();
139071
+ try {
139072
+ return await this.runWithTranspilerConfig(reg, progress, folders);
139073
+ }
139074
+ finally {
139075
+ reg.setConfig(previousConfig);
139076
+ }
139077
+ }
139078
+ async runWithTranspilerConfig(reg, progress, folders) {
139049
139079
  // Validation installs the transpiler configuration and findIssues() parses
139050
139080
  // dirty registries. Parsing before that would be wasted because setConfig()
139051
139081
  // marks every registry object dirty again.
@@ -141350,6 +141380,7 @@ var __importStar = (this && this.__importStar) || (function () {
141350
141380
  Object.defineProperty(exports, "__esModule", ({ value: true }));
141351
141381
  exports.CallTranspiler = void 0;
141352
141382
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
141383
+ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
141353
141384
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
141354
141385
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
141355
141386
  class CallTranspiler {
@@ -141435,10 +141466,12 @@ class CallTranspiler {
141435
141466
  ms = ms.replace("await this.", "await this.#");
141436
141467
  }
141437
141468
  else {
141438
- if (ms.includes(".get().")) {
141469
+ const checked = traversal_1.Traversal.REF_IS_INITIAL + ").";
141470
+ if (ms.includes(".get().") || ms.includes(checked)) {
141439
141471
  let last = ms.split(".");
141440
141472
  last = last[last.length - 1];
141441
141473
  ms = ms.replace(".get()." + last, ".get().FRIENDS_ACCESS['" + last + "']");
141474
+ ms = ms.replace(checked + last, checked + "FRIENDS_ACCESS['" + last + "']");
141442
141475
  }
141443
141476
  else {
141444
141477
  throw new Error("CallTranspiler, todo, refactor CALL");
@@ -156712,6 +156745,9 @@ class Traversal {
156712
156745
  static escapeNamespace(name) {
156713
156746
  return name?.replace(/\//g, "$");
156714
156747
  }
156748
+ /** appended to "ref.get()" where a method is called through a reference which can be initial,
156749
+ * "(ref.get() ?? abap.throwRefIsInitial())" raises CX_SY_REF_IS_INITIAL instead of a TypeError */
156750
+ static REF_IS_INITIAL = " ?? abap.throwRefIsInitial()";
156715
156751
  /** the self reference "me", it is a FieldChain in eg. MethodCallChain and a SourceField in eg. MethodSource */
156716
156752
  static isMe(node) {
156717
156753
  return (node.get() instanceof abaplint.Expressions.FieldChain
@@ -158697,6 +158733,7 @@ const defaultAllowedObjectTypes = [
158697
158733
  "SMBC",
158698
158734
  "SMIM",
158699
158735
  "SPLO",
158736
+ "SPRX",
158700
158737
  "SRFC",
158701
158738
  "SRVB",
158702
158739
  "SRVD",
@@ -158781,6 +158818,9 @@ class Validation {
158781
158818
  constructor(options) {
158782
158819
  this.options = options;
158783
158820
  }
158821
+ /** Installs the transpiler configuration on the registry and runs the
158822
+ * abaplint checks. The configuration stays installed because the transpile
158823
+ * that follows depends on it; Transpiler.run() restores the caller's. */
158784
158824
  run(reg) {
158785
158825
  if (this.options?.ignoreSyntaxCheck === true) {
158786
158826
  exports.config.rules.check_syntax = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.14.43",
3
+ "version": "2.14.44",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -28,7 +28,7 @@
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
30
  "@abaplint/core": "^2.120.133",
31
- "@abaplint/transpiler": "^2.14.43",
31
+ "@abaplint/transpiler": "^2.14.44",
32
32
  "@types/node": "^26.6.6",
33
33
  "@types/progress": "^2.0.7",
34
34
  "glob": "^14.0.6",