@abaplint/transpiler-cli 2.14.43 → 2.14.45

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 +121 -10
  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.
@@ -139514,13 +139544,47 @@ exports.DEFAULT_KEYWORDS = new Set([
139514
139544
  /*!**********************************************************************!*\
139515
139545
  !*** ./node_modules/@abaplint/transpiler/build/src/output_layout.js ***!
139516
139546
  \**********************************************************************/
139517
- (__unused_webpack_module, exports) {
139547
+ (__unused_webpack_module, exports, __webpack_require__) {
139518
139548
 
139519
139549
  "use strict";
139520
139550
 
139551
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
139552
+ if (k2 === undefined) k2 = k;
139553
+ var desc = Object.getOwnPropertyDescriptor(m, k);
139554
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
139555
+ desc = { enumerable: true, get: function() { return m[k]; } };
139556
+ }
139557
+ Object.defineProperty(o, k2, desc);
139558
+ }) : (function(o, m, k, k2) {
139559
+ if (k2 === undefined) k2 = k;
139560
+ o[k2] = m[k];
139561
+ }));
139562
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
139563
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
139564
+ }) : function(o, v) {
139565
+ o["default"] = v;
139566
+ });
139567
+ var __importStar = (this && this.__importStar) || (function () {
139568
+ var ownKeys = function(o) {
139569
+ ownKeys = Object.getOwnPropertyNames || function (o) {
139570
+ var ar = [];
139571
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
139572
+ return ar;
139573
+ };
139574
+ return ownKeys(o);
139575
+ };
139576
+ return function (mod) {
139577
+ if (mod && mod.__esModule) return mod;
139578
+ var result = {};
139579
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
139580
+ __setModuleDefault(result, mod);
139581
+ return result;
139582
+ };
139583
+ })();
139521
139584
  Object.defineProperty(exports, "__esModule", ({ value: true }));
139522
139585
  exports.OutputLayout = exports.DDIC_MODULE = exports.DDIC_TYPES = void 0;
139523
139586
  exports.importPath = importPath;
139587
+ const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
139524
139588
  /** Object types whose module only sets abap.DDIC[...] */
139525
139589
  exports.DDIC_TYPES = new Set(["DDLS", "DTEL", "TABL", "TTYP", "VIEW"]);
139526
139590
  /** Per folder module holding all its DDIC definitions. Object filenames never start
@@ -139540,10 +139604,19 @@ class OutputLayout {
139540
139604
  for (const [filename, folder] of folders) {
139541
139605
  this.sourceFolders.set(filename.toLowerCase(), folder);
139542
139606
  }
139607
+ if (reg !== undefined) {
139608
+ this.assignGeneratedObjects(reg);
139609
+ }
139543
139610
  for (const obj of reg?.getObjects() || []) {
139544
- const owners = new Set(obj.getFiles().map(f => this.sourceFolders.get(f.getFilename().toLowerCase()))
139545
- .filter((folder) => folder !== undefined));
139546
- if (owners.size !== 1) {
139611
+ const owners = this.owners(obj);
139612
+ if (owners.size === 0 && reg?.isDependency(obj) === true) {
139613
+ // In-memory dependency without a source file, eg. generated by abaplint
139614
+ owners.add("project");
139615
+ }
139616
+ if (owners.size === 0) {
139617
+ throw new Error("Missing output ownership for " + obj.getType() + " " + obj.getName());
139618
+ }
139619
+ else if (owners.size > 1) {
139547
139620
  throw new Error("Ambiguous output ownership for " + obj.getType() + " " + obj.getName());
139548
139621
  }
139549
139622
  const folder = [...owners][0];
@@ -139554,6 +139627,34 @@ class OutputLayout {
139554
139627
  }
139555
139628
  }
139556
139629
  }
139630
+ owners(obj) {
139631
+ return new Set(obj.getFiles().map(f => this.sourceFolders.get(f.getFilename().toLowerCase()))
139632
+ .filter((folder) => folder !== undefined));
139633
+ }
139634
+ /** Objects generated from a SPRX file are registry dependencies backed by in-memory
139635
+ * files, they are output in the folder of their SPRX file. */
139636
+ assignGeneratedObjects(reg) {
139637
+ for (const proxy of reg.getObjects()) {
139638
+ if (!(proxy instanceof abaplint.Objects.ProxyObject)) {
139639
+ continue;
139640
+ }
139641
+ const owners = this.owners(proxy);
139642
+ if (owners.size !== 1) {
139643
+ continue; // reported for the SPRX object itself
139644
+ }
139645
+ const folder = [...owners][0];
139646
+ for (const generated of proxy.generateABAPObjects(reg)) {
139647
+ const obj = reg.getObject(generated.getType(), generated.getName());
139648
+ // a real object with the same name takes precedence, it keeps the folder of its own files
139649
+ if (obj === undefined || reg.isDependency(obj) === false || this.owners(obj).size > 0) {
139650
+ continue;
139651
+ }
139652
+ for (const file of obj.getFiles()) {
139653
+ this.sourceFolders.set(file.getFilename().toLowerCase(), folder);
139654
+ }
139655
+ }
139656
+ }
139657
+ }
139557
139658
  key(obj) {
139558
139659
  return obj.type.toUpperCase() + ":" + obj.name.toUpperCase();
139559
139660
  }
@@ -141350,6 +141451,7 @@ var __importStar = (this && this.__importStar) || (function () {
141350
141451
  Object.defineProperty(exports, "__esModule", ({ value: true }));
141351
141452
  exports.CallTranspiler = void 0;
141352
141453
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
141454
+ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
141353
141455
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
141354
141456
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
141355
141457
  class CallTranspiler {
@@ -141435,10 +141537,12 @@ class CallTranspiler {
141435
141537
  ms = ms.replace("await this.", "await this.#");
141436
141538
  }
141437
141539
  else {
141438
- if (ms.includes(".get().")) {
141540
+ const checked = traversal_1.Traversal.REF_IS_INITIAL + ").";
141541
+ if (ms.includes(".get().") || ms.includes(checked)) {
141439
141542
  let last = ms.split(".");
141440
141543
  last = last[last.length - 1];
141441
141544
  ms = ms.replace(".get()." + last, ".get().FRIENDS_ACCESS['" + last + "']");
141545
+ ms = ms.replace(checked + last, checked + "FRIENDS_ACCESS['" + last + "']");
141442
141546
  }
141443
141547
  else {
141444
141548
  throw new Error("CallTranspiler, todo, refactor CALL");
@@ -156712,6 +156816,9 @@ class Traversal {
156712
156816
  static escapeNamespace(name) {
156713
156817
  return name?.replace(/\//g, "$");
156714
156818
  }
156819
+ /** appended to "ref.get()" where a method is called through a reference which can be initial,
156820
+ * "(ref.get() ?? abap.throwRefIsInitial())" raises CX_SY_REF_IS_INITIAL instead of a TypeError */
156821
+ static REF_IS_INITIAL = " ?? abap.throwRefIsInitial()";
156715
156822
  /** the self reference "me", it is a FieldChain in eg. MethodCallChain and a SourceField in eg. MethodSource */
156716
156823
  static isMe(node) {
156717
156824
  return (node.get() instanceof abaplint.Expressions.FieldChain
@@ -158697,6 +158804,7 @@ const defaultAllowedObjectTypes = [
158697
158804
  "SMBC",
158698
158805
  "SMIM",
158699
158806
  "SPLO",
158807
+ "SPRX",
158700
158808
  "SRFC",
158701
158809
  "SRVB",
158702
158810
  "SRVD",
@@ -158781,6 +158889,9 @@ class Validation {
158781
158889
  constructor(options) {
158782
158890
  this.options = options;
158783
158891
  }
158892
+ /** Installs the transpiler configuration on the registry and runs the
158893
+ * abaplint checks. The configuration stays installed because the transpile
158894
+ * that follows depends on it; Transpiler.run() restores the caller's. */
158784
158895
  run(reg) {
158785
158896
  if (this.options?.ignoreSyntaxCheck === true) {
158786
158897
  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.45",
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.45",
32
32
  "@types/node": "^26.6.6",
33
33
  "@types/progress": "^2.0.7",
34
34
  "glob": "^14.0.6",