@abaplint/transpiler 2.3.23 → 2.3.24

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.
@@ -7,6 +7,7 @@ export declare class ClassImplementationTranspiler implements IStructureTranspil
7
7
  private hasConstructor;
8
8
  /** Finds static attributes + constants including those from interfaces (from superclass is ingored) */
9
9
  private findStaticAttributes;
10
+ private buildTypes;
10
11
  /** this builds the part after the class, containing the static variables/constants */
11
12
  private buildStatic;
12
13
  private buildConstructor;
@@ -18,6 +18,7 @@ class ClassImplementationTranspiler {
18
18
  }
19
19
  }
20
20
  ret.appendString(this.buildStatic(node.findFirstExpression(abaplint.Expressions.ClassName), traversal));
21
+ ret.appendString(this.buildTypes(node.findFirstExpression(abaplint.Expressions.ClassName), traversal));
21
22
  return ret;
22
23
  }
23
24
  ///////////////////////////////
@@ -53,6 +54,21 @@ class ClassImplementationTranspiler {
53
54
  }
54
55
  return ret;
55
56
  }
57
+ buildTypes(node, traversal) {
58
+ if (node === undefined) {
59
+ return "";
60
+ }
61
+ const cdef = traversal.getClassDefinition(node.getFirstToken());
62
+ if (cdef === undefined) {
63
+ return "ERROR_CDEF_NOT_FOUND";
64
+ }
65
+ const prefix = traversal_1.Traversal.escapeClassName(cdef.getName()) + ".";
66
+ let ret = "";
67
+ for (const ty of cdef.getTypeDefinitions().getAll()) {
68
+ ret += new transpile_types_1.TranspileTypes().declareStatic(prefix, ty.type);
69
+ }
70
+ return ret;
71
+ }
56
72
  /** this builds the part after the class, containing the static variables/constants */
57
73
  buildStatic(node, traversal) {
58
74
  if (node === undefined) {
@@ -4,5 +4,6 @@ import { Traversal } from "../traversal";
4
4
  import { Chunk } from "../chunk";
5
5
  export declare class InterfaceTranspiler implements IStructureTranspiler {
6
6
  transpile(node: abaplint.Nodes.StructureNode, traversal: Traversal): Chunk;
7
+ private buildTypes;
7
8
  private buildConstants;
8
9
  }
@@ -11,8 +11,8 @@ class InterfaceTranspiler {
11
11
  var _a;
12
12
  let ret = "";
13
13
  let name;
14
+ const def = traversal.getInterfaceDefinition(node.getFirstToken());
14
15
  for (const c of node.getChildren()) {
15
- const def = traversal.getInterfaceDefinition(node.getFirstToken());
16
16
  if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.Interface) {
17
17
  name = (_a = c.findDirectExpression(abaplint.Expressions.InterfaceName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr().toLowerCase();
18
18
  name = traversal_1.Traversal.escapeClassName(name);
@@ -26,8 +26,20 @@ class InterfaceTranspiler {
26
26
  }
27
27
  }
28
28
  ret += this.buildConstants(node.findFirstExpression(abaplint.Expressions.InterfaceName), traversal);
29
+ ret += this.buildTypes(def);
29
30
  return new chunk_1.Chunk(ret);
30
31
  }
32
+ buildTypes(idef) {
33
+ if (idef === undefined) {
34
+ return "";
35
+ }
36
+ const prefix = traversal_1.Traversal.escapeClassName(idef.getName()) + ".";
37
+ let ret = "";
38
+ for (const ty of idef.getTypeDefinitions().getAll()) {
39
+ ret += new transpile_types_1.TranspileTypes().declareStatic(prefix, ty.type);
40
+ }
41
+ return ret;
42
+ }
31
43
  buildConstants(node, traversal) {
32
44
  if (node === undefined) {
33
45
  return "";
@@ -1,5 +1,6 @@
1
1
  import * as abaplint from "@abaplint/core";
2
2
  export declare class TranspileTypes {
3
3
  declare(t: abaplint.TypedIdentifier): string;
4
+ declareStatic(pre: string, t: abaplint.TypedIdentifier): string;
4
5
  toType(type: abaplint.AbstractType): string;
5
6
  }
@@ -7,6 +7,10 @@ class TranspileTypes {
7
7
  const type = t.getType();
8
8
  return "let " + t.getName().toLowerCase() + " = " + this.toType(type) + ";";
9
9
  }
10
+ declareStatic(pre, t) {
11
+ const type = t.getType();
12
+ return pre + t.getName().toLowerCase() + " = " + this.toType(type) + ";";
13
+ }
10
14
  toType(type) {
11
15
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
12
16
  let resolved = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.3.23",
3
+ "version": "2.3.24",
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.93.56",
31
+ "@abaplint/core": "^2.93.57",
32
32
  "source-map": "^0.7.4"
33
33
  },
34
34
  "devDependencies": {