@abaplint/transpiler-cli 2.10.28 → 2.10.30

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 +74 -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,11 @@ 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
+ && m?.def.isStatic() === false) {
78281
+ name = "#" + name;
78282
+ }
78277
78283
  const step = node.findDirectExpression(core_1.Expressions.MethodCallParam);
78278
78284
  if (step === undefined) {
78279
78285
  throw new Error("MethodCallTranspiler, unexpected node");
@@ -79907,6 +79913,23 @@ exports.TargetTranspiler = TargetTranspiler;
79907
79913
 
79908
79914
  /***/ }),
79909
79915
 
79916
+ /***/ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js":
79917
+ /*!**********************************************************************!*\
79918
+ !*** ./node_modules/@abaplint/transpiler/build/src/feature_flags.js ***!
79919
+ \**********************************************************************/
79920
+ /***/ ((__unused_webpack_module, exports) => {
79921
+
79922
+ "use strict";
79923
+
79924
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
79925
+ exports.FEATURE_FLAGS = void 0;
79926
+ exports.FEATURE_FLAGS = {
79927
+ private: true,
79928
+ };
79929
+ //# sourceMappingURL=feature_flags.js.map
79930
+
79931
+ /***/ }),
79932
+
79910
79933
  /***/ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js":
79911
79934
  /*!*****************************************************************************!*\
79912
79935
  !*** ./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js ***!
@@ -81762,6 +81785,7 @@ static INTERNAL_TYPE = 'CLAS';
81762
81785
  static INTERNAL_NAME = '${traversal.buildInternalName(token.getStr(), def)}';
81763
81786
  static IMPLEMENTED_INTERFACES = [${this.findImplementedByClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
81764
81787
  static ATTRIBUTES = {${traversal.buildAttributes(def, scope).join(",\n")}};
81788
+ static FRIENDS_ACCESS_STATIC = {}; // todo
81765
81789
  static METHODS = {${traversal.buildMethods(def, scope).join(",\n")}};`, node, traversal);
81766
81790
  }
81767
81791
  findImplementedInterface(traversal, def, scope) {
@@ -84373,6 +84397,7 @@ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@aba
84373
84397
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
84374
84398
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
84375
84399
  const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
84400
+ const feature_flags_1 = __webpack_require__(/*! ../feature_flags */ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js");
84376
84401
  class MethodImplementationTranspiler {
84377
84402
  transpile(node, traversal) {
84378
84403
  const token = node.findFirstExpression(abaplint.Expressions.MethodName).getFirstToken();
@@ -84481,15 +84506,22 @@ class MethodImplementationTranspiler {
84481
84506
  methodName = a.getComponent().replace("~", "$").toLowerCase();
84482
84507
  }
84483
84508
  }
84509
+ // https://github.com/tc39/proposal-class-fields
84510
+ let isPrivate = "";
84511
+ if (feature_flags_1.FEATURE_FLAGS.private === true
84512
+ && method?.getVisibility() === abaplint.Visibility.Private
84513
+ && method.isStatic() === false) {
84514
+ isPrivate = "#";
84515
+ }
84484
84516
  if (method && method.isStatic()) {
84485
84517
  // in ABAP static methods can be called with instance arrows, "->"
84486
84518
  const className = scope.getParent()?.getIdentifier().sname?.toLowerCase();
84487
- staticMethod = "async " + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ") {\n" +
84519
+ staticMethod = "async " + isPrivate + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ") {\n" +
84488
84520
  "return " + traversal_1.Traversal.escapeNamespace(className) + "." + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ");\n" +
84489
84521
  "}\n" + "static ";
84490
84522
  }
84491
84523
  unique_identifier_1.UniqueIdentifier.resetIndexBackup();
84492
- const str = staticMethod + "async " + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ") {" + after;
84524
+ const str = staticMethod + "async " + isPrivate + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ") {" + after;
84493
84525
  return new chunk_1.Chunk().append(str, node, traversal);
84494
84526
  }
84495
84527
  /////////////////////////////
@@ -86959,6 +86991,7 @@ class ${className?.toLowerCase()} {
86959
86991
  static IMPLEMENTED_INTERFACES = [];
86960
86992
  static INTERNAL_NAME = 'ABSTRACT_CLASS_INTERNAL_NAME';
86961
86993
  static ATTRIBUTES = {};
86994
+ static FRIENDS_ACCESS_STATIC = {};
86962
86995
  async constructor_() {
86963
86996
  this.me = new abap.types.ABAPObject();
86964
86997
  this.me.set(this);
@@ -88076,6 +88109,7 @@ const transpile_types_1 = __webpack_require__(/*! ./transpile_types */ "./node_m
88076
88109
  const chunk_1 = __webpack_require__(/*! ./chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
88077
88110
  const expressions_1 = __webpack_require__(/*! ./expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
88078
88111
  const keywords_1 = __webpack_require__(/*! ./keywords */ "./node_modules/@abaplint/transpiler/build/src/keywords.js");
88112
+ const feature_flags_1 = __webpack_require__(/*! ./feature_flags */ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js");
88079
88113
  class Traversal {
88080
88114
  constructor(spaghetti, file, obj, reg, options) {
88081
88115
  this.scopeCache = undefined;
@@ -88443,15 +88477,8 @@ class Traversal {
88443
88477
  }
88444
88478
  return undefined;
88445
88479
  }
88446
- buildConstructorContents(scope, def) {
88480
+ buildThisAttributes(def, cName) {
88447
88481
  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
88482
  for (const a of def.getAttributes()?.getAll() || []) {
88456
88483
  const escaped = Traversal.escapeNamespace(a.getName().toLowerCase());
88457
88484
  if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
@@ -88462,6 +88489,39 @@ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
88462
88489
  ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
88463
88490
  ret += this.setValues(a, name);
88464
88491
  }
88492
+ return ret;
88493
+ }
88494
+ buildFriendsAccess(def, hasSuperClass) {
88495
+ let ret = "this.FRIENDS_ACCESS_INSTANCE = {\n";
88496
+ if (hasSuperClass === true) {
88497
+ ret += `"SUPER": sup.FRIENDS_ACCESS_INSTANCE,\n`;
88498
+ }
88499
+ for (const a of def.getMethodDefinitions()?.getAll() || []) {
88500
+ const name = a.getName().toLowerCase();
88501
+ if (name === "constructor" || a.isStatic() === true) {
88502
+ continue;
88503
+ }
88504
+ let privateHash = "";
88505
+ if (feature_flags_1.FEATURE_FLAGS.private === true && a.getVisibility() === abaplint.Visibility.Private) {
88506
+ privateHash = "#";
88507
+ }
88508
+ const methodName = privateHash + Traversal.escapeNamespace(name.replace("~", "$"));
88509
+ ret += `"${name.replace("~", "$")}": this.${methodName}.bind(this),\n`;
88510
+ }
88511
+ ret += "};\n";
88512
+ return ret;
88513
+ }
88514
+ buildConstructorContents(scope, def) {
88515
+ let ret = "";
88516
+ if (def.getSuperClass() !== undefined || def.getName().toUpperCase() === "CX_ROOT") {
88517
+ ret += "const sup = super();\n";
88518
+ }
88519
+ const cName = Traversal.escapeNamespace(def.getName().toLowerCase());
88520
+ ret += `this.me = new abap.types.ABAPObject();
88521
+ this.me.set(this);
88522
+ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
88523
+ ret += this.buildFriendsAccess(def, def.getSuperClass() !== undefined);
88524
+ ret += this.buildThisAttributes(def, cName);
88465
88525
  // attributes from directly implemented interfaces(not interfaces implemented in super classes)
88466
88526
  for (const i of def.getImplementing()) {
88467
88527
  ret += this.dataFromInterfaces(i.name, scope, cName);
@@ -89027,10 +89087,13 @@ async function run() {
89027
89087
  continue;
89028
89088
  }
89029
89089
  ret += ` {\n const test = await (new ${lc}()).constructor_();\n`;
89090
+ // todo, some refactoring here,
89030
89091
  ret += ` if (test.setup) await test.setup();\n`;
89092
+ ret += ` if (test.FRIENDS_ACCESS_INSTANCE.setup) await test.FRIENDS_ACCESS_INSTANCE.setup();\n`;
89093
+ ret += ` if (test.FRIENDS_ACCESS_INSTANCE.SUPER && test.FRIENDS_ACCESS_INSTANCE.SUPER.setup) await test.FRIENDS_ACCESS_INSTANCE.SUPER.setup();\n`;
89031
89094
  ret += ` console.log("${st.obj.getName()}: running ${lc}->${m}");\n`;
89032
89095
  ret += ` meth = locl.addMethod("${m}");\n`;
89033
- ret += ` await test.${m}();\n`;
89096
+ ret += ` await test.FRIENDS_ACCESS_INSTANCE.${m}();\n`;
89034
89097
  ret += ` meth.pass();\n`;
89035
89098
  ret += ` if (test.teardown) await test.teardown();\n`;
89036
89099
  ret += ` }\n`;
@@ -89038,59 +89101,6 @@ async function run() {
89038
89101
  ret += ` if (${lc}.class_teardown) await ${lc}.class_teardown();\n`;
89039
89102
  ret += ` }\n`;
89040
89103
  }
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
89104
  ret += `// -------------------END-------------------
89095
89105
  fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
89096
89106
  } 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.30",
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.30",
32
32
  "@types/glob": "^8.1.0",
33
33
  "@types/node": "^22.13.13",
34
34
  "@types/progress": "^2.0.7",