@abaplint/transpiler-cli 2.10.28 → 2.10.29

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 +72 -64
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -78257,6 +78257,7 @@ const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abapli
78257
78257
  const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
78258
78258
  const method_call_param_1 = __webpack_require__(/*! ./method_call_param */ "./node_modules/@abaplint/transpiler/build/src/expressions/method_call_param.js");
78259
78259
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
78260
+ const feature_flags_1 = __webpack_require__(/*! ../feature_flags */ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js");
78260
78261
  class MethodCallTranspiler {
78261
78262
  transpile(node, traversal) {
78262
78263
  const nameToken = node.findDirectExpression(core_1.Expressions.MethodName)?.getFirstToken();
@@ -78274,6 +78275,10 @@ class MethodCallTranspiler {
78274
78275
  if (m?.name && traversal.isBuiltinMethod(nameToken) === false) {
78275
78276
  name = m.name.toLowerCase() + "(";
78276
78277
  }
78278
+ if (feature_flags_1.FEATURE_FLAGS.private === true
78279
+ && m?.def.getVisibility() === core_1.Visibility.Private) {
78280
+ name = "#" + name;
78281
+ }
78277
78282
  const step = node.findDirectExpression(core_1.Expressions.MethodCallParam);
78278
78283
  if (step === undefined) {
78279
78284
  throw new Error("MethodCallTranspiler, unexpected node");
@@ -79907,6 +79912,23 @@ exports.TargetTranspiler = TargetTranspiler;
79907
79912
 
79908
79913
  /***/ }),
79909
79914
 
79915
+ /***/ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js":
79916
+ /*!**********************************************************************!*\
79917
+ !*** ./node_modules/@abaplint/transpiler/build/src/feature_flags.js ***!
79918
+ \**********************************************************************/
79919
+ /***/ ((__unused_webpack_module, exports) => {
79920
+
79921
+ "use strict";
79922
+
79923
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
79924
+ exports.FEATURE_FLAGS = void 0;
79925
+ exports.FEATURE_FLAGS = {
79926
+ private: true,
79927
+ };
79928
+ //# sourceMappingURL=feature_flags.js.map
79929
+
79930
+ /***/ }),
79931
+
79910
79932
  /***/ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js":
79911
79933
  /*!*****************************************************************************!*\
79912
79934
  !*** ./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js ***!
@@ -81762,6 +81784,7 @@ static INTERNAL_TYPE = 'CLAS';
81762
81784
  static INTERNAL_NAME = '${traversal.buildInternalName(token.getStr(), def)}';
81763
81785
  static IMPLEMENTED_INTERFACES = [${this.findImplementedByClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
81764
81786
  static ATTRIBUTES = {${traversal.buildAttributes(def, scope).join(",\n")}};
81787
+ static FRIENDS_ACCESS_STATIC = {}; // todo
81765
81788
  static METHODS = {${traversal.buildMethods(def, scope).join(",\n")}};`, node, traversal);
81766
81789
  }
81767
81790
  findImplementedInterface(traversal, def, scope) {
@@ -84373,6 +84396,7 @@ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@aba
84373
84396
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
84374
84397
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
84375
84398
  const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
84399
+ const feature_flags_1 = __webpack_require__(/*! ../feature_flags */ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js");
84376
84400
  class MethodImplementationTranspiler {
84377
84401
  transpile(node, traversal) {
84378
84402
  const token = node.findFirstExpression(abaplint.Expressions.MethodName).getFirstToken();
@@ -84481,15 +84505,21 @@ class MethodImplementationTranspiler {
84481
84505
  methodName = a.getComponent().replace("~", "$").toLowerCase();
84482
84506
  }
84483
84507
  }
84508
+ // https://github.com/tc39/proposal-class-fields
84509
+ let isPrivate = "";
84510
+ if (feature_flags_1.FEATURE_FLAGS.private === true
84511
+ && method?.getVisibility() === abaplint.Visibility.Private) {
84512
+ isPrivate = "#";
84513
+ }
84484
84514
  if (method && method.isStatic()) {
84485
84515
  // in ABAP static methods can be called with instance arrows, "->"
84486
84516
  const className = scope.getParent()?.getIdentifier().sname?.toLowerCase();
84487
- staticMethod = "async " + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ") {\n" +
84517
+ staticMethod = "async " + isPrivate + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ") {\n" +
84488
84518
  "return " + traversal_1.Traversal.escapeNamespace(className) + "." + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ");\n" +
84489
84519
  "}\n" + "static ";
84490
84520
  }
84491
84521
  unique_identifier_1.UniqueIdentifier.resetIndexBackup();
84492
- const str = staticMethod + "async " + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ") {" + after;
84522
+ const str = staticMethod + "async " + isPrivate + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ") {" + after;
84493
84523
  return new chunk_1.Chunk().append(str, node, traversal);
84494
84524
  }
84495
84525
  /////////////////////////////
@@ -86959,6 +86989,7 @@ class ${className?.toLowerCase()} {
86959
86989
  static IMPLEMENTED_INTERFACES = [];
86960
86990
  static INTERNAL_NAME = 'ABSTRACT_CLASS_INTERNAL_NAME';
86961
86991
  static ATTRIBUTES = {};
86992
+ static FRIENDS_ACCESS_STATIC = {};
86962
86993
  async constructor_() {
86963
86994
  this.me = new abap.types.ABAPObject();
86964
86995
  this.me.set(this);
@@ -88076,6 +88107,7 @@ const transpile_types_1 = __webpack_require__(/*! ./transpile_types */ "./node_m
88076
88107
  const chunk_1 = __webpack_require__(/*! ./chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
88077
88108
  const expressions_1 = __webpack_require__(/*! ./expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
88078
88109
  const keywords_1 = __webpack_require__(/*! ./keywords */ "./node_modules/@abaplint/transpiler/build/src/keywords.js");
88110
+ const feature_flags_1 = __webpack_require__(/*! ./feature_flags */ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js");
88079
88111
  class Traversal {
88080
88112
  constructor(spaghetti, file, obj, reg, options) {
88081
88113
  this.scopeCache = undefined;
@@ -88443,15 +88475,8 @@ class Traversal {
88443
88475
  }
88444
88476
  return undefined;
88445
88477
  }
88446
- buildConstructorContents(scope, def) {
88478
+ buildThisAttributes(def, cName) {
88447
88479
  let ret = "";
88448
- if (def.getSuperClass() !== undefined || def.getName().toUpperCase() === "CX_ROOT") {
88449
- ret += "super();\n";
88450
- }
88451
- const cName = Traversal.escapeNamespace(def.getName().toLowerCase());
88452
- ret += `this.me = new abap.types.ABAPObject();
88453
- this.me.set(this);
88454
- this.INTERNAL_ID = abap.internalIdCounter++;\n`;
88455
88480
  for (const a of def.getAttributes()?.getAll() || []) {
88456
88481
  const escaped = Traversal.escapeNamespace(a.getName().toLowerCase());
88457
88482
  if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
@@ -88462,6 +88487,39 @@ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
88462
88487
  ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
88463
88488
  ret += this.setValues(a, name);
88464
88489
  }
88490
+ return ret;
88491
+ }
88492
+ buildFriendsAccess(def, hasSuperClass) {
88493
+ let ret = "this.FRIENDS_ACCESS_INSTANCE = {\n";
88494
+ if (hasSuperClass === true) {
88495
+ ret += `"SUPER": sup.FRIENDS_ACCESS_INSTANCE,\n`;
88496
+ }
88497
+ for (const a of def.getMethodDefinitions()?.getAll() || []) {
88498
+ const name = a.getName().toLowerCase();
88499
+ if (name === "constructor" || a.isStatic() === true) {
88500
+ continue;
88501
+ }
88502
+ let privateHash = "";
88503
+ if (feature_flags_1.FEATURE_FLAGS.private === true && a.getVisibility() === abaplint.Visibility.Private) {
88504
+ privateHash = "#";
88505
+ }
88506
+ const methodName = privateHash + Traversal.escapeNamespace(name.replace("~", "$"));
88507
+ ret += `"${name.replace("~", "$")}": this.${methodName}.bind(this),\n`;
88508
+ }
88509
+ ret += "};\n";
88510
+ return ret;
88511
+ }
88512
+ buildConstructorContents(scope, def) {
88513
+ let ret = "";
88514
+ if (def.getSuperClass() !== undefined || def.getName().toUpperCase() === "CX_ROOT") {
88515
+ ret += "const sup = super();\n";
88516
+ }
88517
+ const cName = Traversal.escapeNamespace(def.getName().toLowerCase());
88518
+ ret += `this.me = new abap.types.ABAPObject();
88519
+ this.me.set(this);
88520
+ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
88521
+ ret += this.buildFriendsAccess(def, def.getSuperClass() !== undefined);
88522
+ ret += this.buildThisAttributes(def, cName);
88465
88523
  // attributes from directly implemented interfaces(not interfaces implemented in super classes)
88466
88524
  for (const i of def.getImplementing()) {
88467
88525
  ret += this.dataFromInterfaces(i.name, scope, cName);
@@ -89027,10 +89085,13 @@ async function run() {
89027
89085
  continue;
89028
89086
  }
89029
89087
  ret += ` {\n const test = await (new ${lc}()).constructor_();\n`;
89088
+ // todo, some refactoring here,
89030
89089
  ret += ` if (test.setup) await test.setup();\n`;
89090
+ ret += ` if (test.FRIENDS_ACCESS_INSTANCE.setup) await test.FRIENDS_ACCESS_INSTANCE.setup();\n`;
89091
+ ret += ` if (test.FRIENDS_ACCESS_INSTANCE.SUPER && test.FRIENDS_ACCESS_INSTANCE.SUPER.setup) await test.FRIENDS_ACCESS_INSTANCE.SUPER.setup();\n`;
89031
89092
  ret += ` console.log("${st.obj.getName()}: running ${lc}->${m}");\n`;
89032
89093
  ret += ` meth = locl.addMethod("${m}");\n`;
89033
- ret += ` await test.${m}();\n`;
89094
+ ret += ` await test.FRIENDS_ACCESS_INSTANCE.${m}();\n`;
89034
89095
  ret += ` meth.pass();\n`;
89035
89096
  ret += ` if (test.teardown) await test.teardown();\n`;
89036
89097
  ret += ` }\n`;
@@ -89038,59 +89099,6 @@ async function run() {
89038
89099
  ret += ` if (${lc}.class_teardown) await ${lc}.class_teardown();\n`;
89039
89100
  ret += ` }\n`;
89040
89101
  }
89041
- /*
89042
- for (const obj of reg.getObjects()) {
89043
- if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
89044
- continue;
89045
- }
89046
- ret += `// --------------------------------------------\n`;
89047
- ret += ` clas = unit.addObject("${obj.getName()}");\n`;
89048
- for (const file of obj.getABAPFiles()) {
89049
- for (const def of file.getInfo().listClassDefinitions()) {
89050
- if (def.isForTesting === false
89051
- || def.isGlobal === true
89052
- || def.methods.length === 0
89053
- || def.isAbstract === true) {
89054
- // todo, fix, there might be global test methods
89055
- continue;
89056
- }
89057
- const hasTestFile = obj.getFiles().some(f => { return f.getFilename().includes(".testclasses."); });
89058
- if (hasTestFile === false) {
89059
- break;
89060
- }
89061
- ret += ` {
89062
- const {${def.name}} = await import("./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs");
89063
- locl = clas.addTestClass("${def.name}");
89064
- if (${def.name}.class_setup) await ${def.name}.class_setup();\n`;
89065
-
89066
- for (const m of def.methods) {
89067
- if (m.isForTesting === false) {
89068
- continue;
89069
- }
89070
- const skipThis = (skip || []).some(a => a.object === obj.getName() && a.class === def.name && a.method === m.name);
89071
- if (skipThis) {
89072
- ret += ` console.log('${obj.getName()}: running ${def.name}->${m.name}, skipped');\n`;
89073
- ret += ` meth = locl.addMethod("${m.name}");\n`;
89074
- ret += ` meth.skip();\n`;
89075
- continue;
89076
- }
89077
-
89078
- ret += ` {\n const test = await (new ${def.name}()).constructor_();\n`;
89079
- ret += ` if (test.setup) await test.setup();\n`;
89080
- ret += ` console.log("${obj.getName()}: running ${def.name}->${m.name}");\n`;
89081
- ret += ` meth = locl.addMethod("${m.name}");\n`;
89082
- ret += ` await test.${m.name}();\n`;
89083
- ret += ` meth.pass();\n`;
89084
- ret += ` if (test.teardown) await test.teardown();\n`;
89085
- ret += ` }\n`;
89086
- }
89087
-
89088
- ret += ` if (${def.name}.class_teardown) await ${def.name}.class_teardown();\n`;
89089
- ret += ` }\n`;
89090
- }
89091
- }
89092
- }
89093
- */
89094
89102
  ret += `// -------------------END-------------------
89095
89103
  fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
89096
89104
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.10.28",
3
+ "version": "2.10.29",
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.107",
31
- "@abaplint/transpiler": "^2.10.28",
31
+ "@abaplint/transpiler": "^2.10.29",
32
32
  "@types/glob": "^8.1.0",
33
33
  "@types/node": "^22.13.13",
34
34
  "@types/progress": "^2.0.7",