@abaplint/transpiler 2.6.29 → 2.6.31

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.
@@ -5,5 +5,5 @@ import { Chunk } from "../chunk";
5
5
  export declare class ClassImplementationTranspiler implements IStatementTranspiler {
6
6
  transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal): Chunk;
7
7
  private findImplementedInterface;
8
- private findImplementedClass;
8
+ private findImplementedByClass;
9
9
  }
@@ -22,8 +22,8 @@ class ClassImplementationTranspiler {
22
22
  return new chunk_1.Chunk().append(ret + ` {
23
23
  static INTERNAL_TYPE = 'CLAS';
24
24
  static INTERNAL_NAME = '${traversal.buildInternalName(token.getStr(), def)}';
25
- static IMPLEMENTED_INTERFACES = [${this.findImplementedClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
26
- static ATTRIBUTES = {${traversal.buildAttributes(def)}};`, node, traversal);
25
+ static IMPLEMENTED_INTERFACES = [${this.findImplementedByClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
26
+ static ATTRIBUTES = {${traversal.buildAttributes(def, scope).join(",\n")}};`, node, traversal);
27
27
  }
28
28
  findImplementedInterface(traversal, def, scope) {
29
29
  if (def === undefined || scope === undefined) {
@@ -36,7 +36,7 @@ static ATTRIBUTES = {${traversal.buildAttributes(def)}};`, node, traversal);
36
36
  }
37
37
  return list;
38
38
  }
39
- findImplementedClass(traversal, def, scope) {
39
+ findImplementedByClass(traversal, def, scope) {
40
40
  if (def === undefined || scope === undefined) {
41
41
  return [];
42
42
  }
@@ -48,7 +48,7 @@ static ATTRIBUTES = {${traversal.buildAttributes(def)}};`, node, traversal);
48
48
  let sup = def.getSuperClass();
49
49
  while (sup !== undefined) {
50
50
  const sdef = traversal.findClassDefinition(sup, scope);
51
- list.push(...this.findImplementedClass(traversal, sdef, scope));
51
+ list.push(...this.findImplementedByClass(traversal, sdef, scope));
52
52
  sup = sdef === null || sdef === void 0 ? void 0 : sdef.getSuperClass();
53
53
  }
54
54
  return list;
@@ -14,11 +14,12 @@ class InterfaceTranspiler {
14
14
  const def = traversal.getInterfaceDefinition(node.getFirstToken());
15
15
  for (const c of node.getChildren()) {
16
16
  if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.Interface) {
17
+ const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
17
18
  name = (_a = c.findDirectExpression(abaplint.Expressions.InterfaceName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr().toLowerCase();
18
19
  name = traversal_1.Traversal.escapeNamespace(name);
19
20
  ret += `class ${name} {\n`;
20
21
  ret += `static INTERNAL_TYPE = 'INTF';\n`;
21
- ret += `static ATTRIBUTES = {${traversal.buildAttributes(def)}};\n`;
22
+ ret += `static ATTRIBUTES = {${traversal.buildAttributes(def, scope).join(",\n")}};\n`;
22
23
  }
23
24
  else if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.EndInterface) {
24
25
  ret += "}\n";
@@ -24,7 +24,7 @@ export declare class Traversal {
24
24
  private isClassAttribute;
25
25
  prefixAndName(t: abaplint.Token, filename?: string): string;
26
26
  private isStaticClassAttribute;
27
- buildAttributes(def: abaplint.IClassDefinition | abaplint.IInterfaceDefinition | undefined): string;
27
+ buildAttributes(def: abaplint.IClassDefinition | abaplint.IInterfaceDefinition | undefined, scope: abaplint.ISpaghettiScopeNode | undefined, prefix?: string): string[];
28
28
  isBuiltinMethod(token: abaplint.Token): boolean;
29
29
  findMethodReference(token: abaplint.Token, scope: ISpaghettiScopeNode | undefined): undefined | {
30
30
  def: abaplint.Types.MethodDefinition;
@@ -169,10 +169,13 @@ class Traversal {
169
169
  }
170
170
  return undefined;
171
171
  }
172
- buildAttributes(def) {
172
+ buildAttributes(def, scope, prefix = "") {
173
173
  var _a, _b;
174
174
  const attr = [];
175
- for (const a of ((_a = def === null || def === void 0 ? void 0 : def.getAttributes()) === null || _a === void 0 ? void 0 : _a.getAll()) || []) {
175
+ if (def === undefined) {
176
+ return attr;
177
+ }
178
+ for (const a of ((_a = def.getAttributes()) === null || _a === void 0 ? void 0 : _a.getAll()) || []) {
176
179
  const type = new transpile_types_1.TranspileTypes().toType(a.getType());
177
180
  let runtime = "";
178
181
  switch (a.getVisibility()) {
@@ -185,9 +188,9 @@ class Traversal {
185
188
  default:
186
189
  runtime = "U";
187
190
  }
188
- attr.push(`"${a.getName().toUpperCase()}": {"type": () => {return ${type};}, "visibility": "${runtime}", "is_constant": " "}`);
191
+ attr.push(`"${prefix + a.getName().toUpperCase()}": {"type": () => {return ${type};}, "visibility": "${runtime}", "is_constant": " "}`);
189
192
  }
190
- for (const a of ((_b = def === null || def === void 0 ? void 0 : def.getAttributes()) === null || _b === void 0 ? void 0 : _b.getConstants()) || []) {
193
+ for (const a of ((_b = def.getAttributes()) === null || _b === void 0 ? void 0 : _b.getConstants()) || []) {
191
194
  const type = new transpile_types_1.TranspileTypes().toType(a.getType());
192
195
  let runtime = "";
193
196
  switch (a.getVisibility()) {
@@ -200,9 +203,13 @@ class Traversal {
200
203
  default:
201
204
  runtime = "U";
202
205
  }
203
- attr.push(`"${a.getName().toUpperCase()}": {"type": () => {return ${type};}, "visibility": "${runtime}", "is_constant": "X"}`);
206
+ attr.push(`"${prefix + a.getName().toUpperCase()}": {"type": () => {return ${type};}, "visibility": "${runtime}", "is_constant": "X"}`);
207
+ }
208
+ for (const impl of def.getImplementing()) {
209
+ const idef = this.findInterfaceDefinition(impl.name, scope);
210
+ attr.push(...this.buildAttributes(idef, scope, impl.name.toUpperCase() + "~"));
204
211
  }
205
- return attr.join(",\n");
212
+ return attr;
206
213
  }
207
214
  isBuiltinMethod(token) {
208
215
  const scope = this.findCurrentScopeByToken(token);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.6.29",
3
+ "version": "2.6.31",
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.16",
31
+ "@abaplint/core": "^2.97.17",
32
32
  "source-map": "^0.7.4"
33
33
  },
34
34
  "devDependencies": {