@abaplint/transpiler-cli 2.10.65 → 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 +75 -10
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -47305,8 +47305,12 @@ class DataElement extends _abstract_object_1.AbstractObject {
47305
47305
  references.push({ object: lookup.object });
47306
47306
  }
47307
47307
  reg.getDDICReferences().setUsing(this, references);
47308
- this.parsedType = lookup.type;
47309
- return this.parsedType;
47308
+ if (!(lookup.type instanceof Types.UnknownType)) {
47309
+ // the referenced type might not exist or contain syntax errors(for CLAS)
47310
+ // so dont cache it, expect the user to fix it
47311
+ this.parsedType = lookup.type;
47312
+ }
47313
+ return lookup.type;
47310
47314
  }
47311
47315
  parse() {
47312
47316
  var _a, _b, _c;
@@ -53581,7 +53585,7 @@ class Registry {
53581
53585
  }
53582
53586
  static abaplintVersion() {
53583
53587
  // magic, see build script "version.sh"
53584
- return "2.113.148";
53588
+ return "2.113.149";
53585
53589
  }
53586
53590
  getDDICReferences() {
53587
53591
  return this.ddicReferences;
@@ -80807,6 +80811,23 @@ exports.TargetTranspiler = TargetTranspiler;
80807
80811
 
80808
80812
  /***/ }),
80809
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
+
80810
80831
  /***/ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js":
80811
80832
  /*!*****************************************************************************!*\
80812
80833
  !*** ./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js ***!
@@ -88164,6 +88185,7 @@ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abap
88164
88185
  const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
88165
88186
  const transpile_types_1 = __webpack_require__(/*! ../transpile_types */ "./node_modules/@abaplint/transpiler/build/src/transpile_types.js");
88166
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");
88167
88189
  class ClassImplementationTranspiler {
88168
88190
  transpile(node, traversal) {
88169
88191
  const ret = new chunk_1.Chunk();
@@ -88232,6 +88254,22 @@ class ClassImplementationTranspiler {
88232
88254
  }
88233
88255
  return ret;
88234
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
+ }
88235
88273
  /** this builds the part after the class, containing the static variables/constants */
88236
88274
  buildStatic(node, traversal) {
88237
88275
  if (node === undefined) {
@@ -88303,8 +88341,9 @@ class ClassImplementationTranspiler {
88303
88341
  if (ret === "") {
88304
88342
  return ret;
88305
88343
  }
88344
+ const privates = this.buildPrivate(node.findFirstExpression(abaplint.Expressions.ClassName), traversal);
88306
88345
  // note: for CALL TRANSFORMATION, its nice that the values are initialized by the JS constructor,
88307
- return "constructor() {\n" + ret + "}\n";
88346
+ return privates + "constructor() {\n" + ret + "}\n";
88308
88347
  }
88309
88348
  }
88310
88349
  exports.ClassImplementationTranspiler = ClassImplementationTranspiler;
@@ -89297,6 +89336,7 @@ const transpile_types_1 = __webpack_require__(/*! ./transpile_types */ "./node_m
89297
89336
  const chunk_1 = __webpack_require__(/*! ./chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
89298
89337
  const expressions_1 = __webpack_require__(/*! ./expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
89299
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");
89300
89340
  class Traversal {
89301
89341
  constructor(spaghetti, file, obj, reg, options) {
89302
89342
  this.scopeCache = undefined;
@@ -89412,6 +89452,22 @@ class Traversal {
89412
89452
  }
89413
89453
  return undefined;
89414
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
+ }
89415
89471
  isClassAttribute(token) {
89416
89472
  const scope = this.findCurrentScopeByToken(token);
89417
89473
  if (scope === undefined) {
@@ -89453,7 +89509,11 @@ class Traversal {
89453
89509
  return name;
89454
89510
  }
89455
89511
  else if (this.isClassAttribute(t)) {
89456
- 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;
89457
89517
  }
89458
89518
  else if (this.isBuiltinVariable(t)) {
89459
89519
  name = "abap.builtin." + name.toLowerCase().replace("%", "$");
@@ -89668,14 +89728,19 @@ class Traversal {
89668
89728
  buildThisAttributes(def, cName) {
89669
89729
  let ret = "";
89670
89730
  for (const a of def.getAttributes()?.getAll() || []) {
89671
- const escaped = Traversal.escapeNamespace(a.getName().toLowerCase());
89731
+ let escaped = Traversal.escapeNamespace(a.getName().toLowerCase());
89672
89732
  if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
89673
89733
  ret += "this." + escaped + " = " + cName + "." + escaped + ";\n";
89674
- continue;
89675
89734
  }
89676
- const name = "this." + escaped;
89677
- ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
89678
- 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
+ }
89679
89744
  }
89680
89745
  return ret;
89681
89746
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.10.65",
3
+ "version": "2.10.67",
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.113.148",
31
- "@abaplint/transpiler": "^2.10.65",
30
+ "@abaplint/core": "^2.113.149",
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",