@abaplint/transpiler 2.6.26 → 2.6.28

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.
@@ -25,7 +25,7 @@ class MethodImplementationTranspiler {
25
25
  if (methodName.toUpperCase() === "CONSTRUCTOR" && classDef) {
26
26
  // note that all ABAP identifiers are lower cased, sometimes the kernel does magic, so it needs to know the method input name
27
27
  unique = "INPUT";
28
- after = traversal.buildConstructorContents(scope.getParent(), classDef);
28
+ // after = traversal.buildConstructorContents(scope.getParent(), classDef);
29
29
  methodName = "constructor_";
30
30
  }
31
31
  const methodDef = this.findMethodParameters(scope);
@@ -10,10 +10,13 @@ class ClassImplementationTranspiler {
10
10
  const ret = new chunk_1.Chunk();
11
11
  for (const c of node.getChildren()) {
12
12
  ret.appendChunk(traversal.traverse(c));
13
+ if (c.get() instanceof abaplint.Statements.ClassImplementation) {
14
+ ret.appendString(this.buildConstructor(node.getFirstStatement(), traversal));
15
+ }
13
16
  if (c instanceof abaplint.Nodes.StatementNode
14
17
  && c.get() instanceof abaplint.Statements.ClassImplementation
15
18
  && this.hasConstructor(node) === false) {
16
- ret.appendString(this.buildConstructor(c, traversal));
19
+ ret.appendString("async constructor_(INPUT) {\nif (super.constructor_) { await super.constructor_(INPUT); }\nreturn this;\n}\n");
17
20
  }
18
21
  }
19
22
  ret.appendString(this.buildStatic(node.findFirstExpression(abaplint.Expressions.ClassName), traversal));
@@ -127,6 +130,9 @@ class ClassImplementationTranspiler {
127
130
  }
128
131
  buildConstructor(node, traversal) {
129
132
  var _a;
133
+ if (node === undefined) {
134
+ throw new Error("buildConstructor node undefined");
135
+ }
130
136
  const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
131
137
  const token = (_a = node.findFirstExpression(abaplint.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
132
138
  if (token === undefined) {
@@ -140,7 +146,8 @@ class ClassImplementationTranspiler {
140
146
  if (ret === "") {
141
147
  return ret;
142
148
  }
143
- return "async constructor_(INPUT) {\n" + ret + "return this;\n}\n";
149
+ // note: for CALL TRANSFORMATION, its nice that the values are initialized by the JS constructor,
150
+ return "constructor() {\n" + ret + "}\n";
144
151
  }
145
152
  }
146
153
  exports.ClassImplementationTranspiler = ClassImplementationTranspiler;
@@ -17,15 +17,14 @@ class TranspileTypes {
17
17
  return pre + t.getName().toLowerCase() + " = " + code + ";\n";
18
18
  }
19
19
  toType(type) {
20
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
20
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
21
21
  let resolved = "";
22
22
  let extra = "";
23
23
  if (type instanceof abaplint.BasicTypes.ObjectReferenceType
24
24
  || type instanceof abaplint.BasicTypes.GenericObjectReferenceType) {
25
25
  resolved = "ABAPObject";
26
- if (type.getQualifiedName() !== undefined) {
27
- extra = "{qualifiedName: \"" + ((_a = type.getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()) + "\"}";
28
- }
26
+ extra = "{qualifiedName: " + JSON.stringify((_a = type.getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()) +
27
+ ", RTTIName: " + JSON.stringify((_b = type.getRTTIName()) === null || _b === void 0 ? void 0 : _b.toUpperCase()) + "}";
29
28
  }
30
29
  else if (type instanceof abaplint.BasicTypes.TableType) {
31
30
  resolved = "Table";
@@ -39,31 +38,31 @@ class TranspileTypes {
39
38
  else if (type instanceof abaplint.BasicTypes.IntegerType) {
40
39
  resolved = "Integer";
41
40
  if (type.getQualifiedName() !== undefined) {
42
- extra = "{qualifiedName: \"" + ((_b = type.getQualifiedName()) === null || _b === void 0 ? void 0 : _b.toUpperCase()) + "\"}";
41
+ extra = "{qualifiedName: \"" + ((_c = type.getQualifiedName()) === null || _c === void 0 ? void 0 : _c.toUpperCase()) + "\"}";
43
42
  }
44
43
  }
45
44
  else if (type instanceof abaplint.BasicTypes.StringType) {
46
45
  resolved = "String";
47
46
  if (type.getQualifiedName() !== undefined) {
48
- extra = "{qualifiedName: \"" + ((_c = type.getQualifiedName()) === null || _c === void 0 ? void 0 : _c.toUpperCase()) + "\"}";
47
+ extra = "{qualifiedName: \"" + ((_d = type.getQualifiedName()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) + "\"}";
49
48
  }
50
49
  }
51
50
  else if (type instanceof abaplint.BasicTypes.UTCLongType) {
52
51
  resolved = "UTCLong";
53
52
  if (type.getQualifiedName() !== undefined) {
54
- extra = "{qualifiedName: \"" + ((_d = type.getQualifiedName()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) + "\"}";
53
+ extra = "{qualifiedName: \"" + ((_e = type.getQualifiedName()) === null || _e === void 0 ? void 0 : _e.toUpperCase()) + "\"}";
55
54
  }
56
55
  }
57
56
  else if (type instanceof abaplint.BasicTypes.DateType) {
58
57
  resolved = "Date";
59
58
  if (type.getQualifiedName() !== undefined) {
60
- extra = "{qualifiedName: \"" + ((_e = type.getQualifiedName()) === null || _e === void 0 ? void 0 : _e.toUpperCase()) + "\"}";
59
+ extra = "{qualifiedName: \"" + ((_f = type.getQualifiedName()) === null || _f === void 0 ? void 0 : _f.toUpperCase()) + "\"}";
61
60
  }
62
61
  }
63
62
  else if (type instanceof abaplint.BasicTypes.TimeType) {
64
63
  resolved = "Time";
65
64
  if (type.getQualifiedName() !== undefined) {
66
- extra = "{qualifiedName: \"" + ((_f = type.getQualifiedName()) === null || _f === void 0 ? void 0 : _f.toUpperCase()) + "\"}";
65
+ extra = "{qualifiedName: \"" + ((_g = type.getQualifiedName()) === null || _g === void 0 ? void 0 : _g.toUpperCase()) + "\"}";
67
66
  }
68
67
  }
69
68
  else if (type instanceof abaplint.BasicTypes.DataReference) {
@@ -134,7 +133,7 @@ class TranspileTypes {
134
133
  else if (type instanceof abaplint.BasicTypes.XStringType) {
135
134
  resolved = "XString";
136
135
  if (type.getQualifiedName() !== undefined) {
137
- extra = "{qualifiedName: \"" + ((_g = type.getQualifiedName()) === null || _g === void 0 ? void 0 : _g.toUpperCase()) + "\"}";
136
+ extra = "{qualifiedName: \"" + ((_h = type.getQualifiedName()) === null || _h === void 0 ? void 0 : _h.toUpperCase()) + "\"}";
138
137
  }
139
138
  }
140
139
  else if (type instanceof abaplint.BasicTypes.XSequenceType) {
@@ -150,13 +149,13 @@ class TranspileTypes {
150
149
  else if (type instanceof abaplint.BasicTypes.FloatType) {
151
150
  resolved = "Float";
152
151
  if (type.getQualifiedName() !== undefined) {
153
- extra = "{qualifiedName: \"" + ((_h = type.getQualifiedName()) === null || _h === void 0 ? void 0 : _h.toUpperCase()) + "\"}";
152
+ extra = "{qualifiedName: \"" + ((_j = type.getQualifiedName()) === null || _j === void 0 ? void 0 : _j.toUpperCase()) + "\"}";
154
153
  }
155
154
  }
156
155
  else if (type instanceof abaplint.BasicTypes.FloatingPointType) {
157
156
  resolved = "Float";
158
157
  if (type.getQualifiedName() !== undefined) {
159
- extra = "{qualifiedName: \"" + ((_j = type.getQualifiedName()) === null || _j === void 0 ? void 0 : _j.toUpperCase()) + "\"}";
158
+ extra = "{qualifiedName: \"" + ((_k = type.getQualifiedName()) === null || _k === void 0 ? void 0 : _k.toUpperCase()) + "\"}";
160
159
  }
161
160
  }
162
161
  else if (type instanceof abaplint.BasicTypes.DecFloat34Type) {
@@ -319,10 +319,15 @@ class Traversal {
319
319
  buildConstructorContents(scope, def) {
320
320
  var _a, _b, _c;
321
321
  let ret = "";
322
- if (def.getSuperClass() !== undefined
323
- && def.getMethodDefinitions().getByName("CONSTRUCTOR") === undefined) {
324
- ret += `await super.constructor_(INPUT);\n`;
322
+ if (def.getSuperClass() !== undefined || def.getName().toUpperCase() === "CX_ROOT") {
323
+ ret += "super();\n";
325
324
  }
325
+ /*
326
+ if (def.getSuperClass() !== undefined
327
+ && def.getMethodDefinitions().getByName("CONSTRUCTOR") === undefined) {
328
+ ret += `await super.constructor_(INPUT);\n`;
329
+ }
330
+ */
326
331
  const cName = Traversal.escapeNamespace(def.getName().toLowerCase());
327
332
  ret += "this.me = new abap.types.ABAPObject();\n";
328
333
  ret += "this.me.set(this);\n";
@@ -479,14 +484,8 @@ class Traversal {
479
484
  if (def === undefined) {
480
485
  return "";
481
486
  }
482
- const name = def.getName();
483
- if (def.isGlobal() === false) {
484
- const prefix = this.buildPrefix();
485
- return `abap.Classes['${prefix}-${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
486
- }
487
- else {
488
- return `abap.Classes['${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
489
- }
487
+ const name = this.buildInternalName(def.getName(), def);
488
+ return `abap.Classes['${name}'] = ${Traversal.escapeNamespace(def.getName().toLowerCase())};`;
490
489
  }
491
490
  setValues(identifier, name) {
492
491
  return Traversal.setValues(identifier, name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.6.26",
3
+ "version": "2.6.28",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "author": "abaplint",
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@abaplint/core": "^2.97.15",
31
+ "@abaplint/core": "^2.97.16",
32
32
  "source-map": "^0.7.4"
33
33
  },
34
34
  "devDependencies": {