@abaplint/transpiler-cli 2.10.66 → 2.10.67

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 +68 -7
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -80811,6 +80811,23 @@ exports.TargetTranspiler = TargetTranspiler;
80811
80811
 
80812
80812
  /***/ }),
80813
80813
 
80814
+ /***/ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js":
80815
+ /*!**********************************************************************!*\
80816
+ !*** ./node_modules/@abaplint/transpiler/build/src/feature_flags.js ***!
80817
+ \**********************************************************************/
80818
+ /***/ ((__unused_webpack_module, exports) => {
80819
+
80820
+ "use strict";
80821
+
80822
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
80823
+ exports.FEATURE_FLAGS = void 0;
80824
+ exports.FEATURE_FLAGS = {
80825
+ PRIVATE_ATTRIBUTES: true,
80826
+ };
80827
+ //# sourceMappingURL=feature_flags.js.map
80828
+
80829
+ /***/ }),
80830
+
80814
80831
  /***/ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js":
80815
80832
  /*!*****************************************************************************!*\
80816
80833
  !*** ./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js ***!
@@ -88168,6 +88185,7 @@ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abap
88168
88185
  const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
88169
88186
  const transpile_types_1 = __webpack_require__(/*! ../transpile_types */ "./node_modules/@abaplint/transpiler/build/src/transpile_types.js");
88170
88187
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
88188
+ const feature_flags_1 = __webpack_require__(/*! ../feature_flags */ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js");
88171
88189
  class ClassImplementationTranspiler {
88172
88190
  transpile(node, traversal) {
88173
88191
  const ret = new chunk_1.Chunk();
@@ -88236,6 +88254,22 @@ class ClassImplementationTranspiler {
88236
88254
  }
88237
88255
  return ret;
88238
88256
  }
88257
+ buildPrivate(node, traversal) {
88258
+ if (node === undefined || feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === false) {
88259
+ return "";
88260
+ }
88261
+ const cdef = traversal.getClassDefinition(node.getFirstToken());
88262
+ if (cdef === undefined) {
88263
+ return "ERROR_CDEF_NOT_FOUND";
88264
+ }
88265
+ let ret = "";
88266
+ for (const attr of cdef.getAttributes().getAll()) {
88267
+ if (attr.getVisibility() === abaplint.Visibility.Private) {
88268
+ ret += "#" + traversal_1.Traversal.escapeNamespace(attr.getName().toLowerCase()) + ";\n";
88269
+ }
88270
+ }
88271
+ return ret;
88272
+ }
88239
88273
  /** this builds the part after the class, containing the static variables/constants */
88240
88274
  buildStatic(node, traversal) {
88241
88275
  if (node === undefined) {
@@ -88307,8 +88341,9 @@ class ClassImplementationTranspiler {
88307
88341
  if (ret === "") {
88308
88342
  return ret;
88309
88343
  }
88344
+ const privates = this.buildPrivate(node.findFirstExpression(abaplint.Expressions.ClassName), traversal);
88310
88345
  // note: for CALL TRANSFORMATION, its nice that the values are initialized by the JS constructor,
88311
- return "constructor() {\n" + ret + "}\n";
88346
+ return privates + "constructor() {\n" + ret + "}\n";
88312
88347
  }
88313
88348
  }
88314
88349
  exports.ClassImplementationTranspiler = ClassImplementationTranspiler;
@@ -89301,6 +89336,7 @@ const transpile_types_1 = __webpack_require__(/*! ./transpile_types */ "./node_m
89301
89336
  const chunk_1 = __webpack_require__(/*! ./chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
89302
89337
  const expressions_1 = __webpack_require__(/*! ./expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
89303
89338
  const keywords_1 = __webpack_require__(/*! ./keywords */ "./node_modules/@abaplint/transpiler/build/src/keywords.js");
89339
+ const feature_flags_1 = __webpack_require__(/*! ./feature_flags */ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js");
89304
89340
  class Traversal {
89305
89341
  constructor(spaghetti, file, obj, reg, options) {
89306
89342
  this.scopeCache = undefined;
@@ -89416,6 +89452,22 @@ class Traversal {
89416
89452
  }
89417
89453
  return undefined;
89418
89454
  }
89455
+ isPrivateAttribute(token) {
89456
+ const scope = this.findCurrentScopeByToken(token);
89457
+ if (scope === undefined) {
89458
+ throw new Error("isPrivateAttribute, unable to lookup position");
89459
+ }
89460
+ const name = token.getStr();
89461
+ if (name.toLowerCase() === "me") {
89462
+ return false;
89463
+ }
89464
+ const found = scope.findVariable(name);
89465
+ if (found instanceof abaplint.Types.ClassAttribute
89466
+ && found.getVisibility() === abaplint.Visibility.Private) {
89467
+ return true;
89468
+ }
89469
+ return false;
89470
+ }
89419
89471
  isClassAttribute(token) {
89420
89472
  const scope = this.findCurrentScopeByToken(token);
89421
89473
  if (scope === undefined) {
@@ -89457,7 +89509,11 @@ class Traversal {
89457
89509
  return name;
89458
89510
  }
89459
89511
  else if (this.isClassAttribute(t)) {
89460
- name = "this." + Traversal.escapeNamespace(name);
89512
+ let escaped = Traversal.escapeNamespace(name);
89513
+ if (feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === true && this.isPrivateAttribute(t)) {
89514
+ escaped = "#" + escaped;
89515
+ }
89516
+ name = "this." + escaped;
89461
89517
  }
89462
89518
  else if (this.isBuiltinVariable(t)) {
89463
89519
  name = "abap.builtin." + name.toLowerCase().replace("%", "$");
@@ -89672,14 +89728,19 @@ class Traversal {
89672
89728
  buildThisAttributes(def, cName) {
89673
89729
  let ret = "";
89674
89730
  for (const a of def.getAttributes()?.getAll() || []) {
89675
- const escaped = Traversal.escapeNamespace(a.getName().toLowerCase());
89731
+ let escaped = Traversal.escapeNamespace(a.getName().toLowerCase());
89676
89732
  if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
89677
89733
  ret += "this." + escaped + " = " + cName + "." + escaped + ";\n";
89678
- continue;
89679
89734
  }
89680
- const name = "this." + escaped;
89681
- ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
89682
- ret += this.setValues(a, name);
89735
+ else {
89736
+ if (feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === true
89737
+ && a.getVisibility() === abaplint.Visibility.Private) {
89738
+ escaped = "#" + escaped;
89739
+ }
89740
+ const name = "this." + escaped;
89741
+ ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
89742
+ ret += this.setValues(a, name);
89743
+ }
89683
89744
  }
89684
89745
  return ret;
89685
89746
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.10.66",
3
+ "version": "2.10.67",
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.113.149",
31
- "@abaplint/transpiler": "^2.10.66",
31
+ "@abaplint/transpiler": "^2.10.67",
32
32
  "@types/glob": "^8.1.0",
33
33
  "@types/node": "^22.16.5",
34
34
  "@types/progress": "^2.0.7",