@abaplint/transpiler 2.5.65 → 2.5.67

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.
@@ -21,7 +21,8 @@ class ClassImplementationTranspiler {
21
21
  const scope = traversal.findCurrentScopeByToken(token);
22
22
  return new chunk_1.Chunk().append(ret + ` {
23
23
  static INTERNAL_TYPE = 'CLAS';
24
- static IMPLEMENTED_INTERFACES = [${this.findImplementedClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];`, node, traversal);
24
+ static IMPLEMENTED_INTERFACES = [${this.findImplementedClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
25
+ static ATTRIBUTES = {${traversal.buildAttributes(def)}};`, node, traversal);
25
26
  }
26
27
  findImplementedInterface(traversal, def, scope) {
27
28
  if (def === undefined || scope === undefined) {
@@ -23,6 +23,7 @@ class ClassDefinitionTranspiler {
23
23
  return new chunk_1.Chunk(`
24
24
  class ${className === null || className === void 0 ? void 0 : className.toLowerCase()} {
25
25
  static INTERNAL_TYPE = 'CLAS';
26
+ static ATTRIBUTES = {};
26
27
  async constructor_() {
27
28
  this.me = new abap.types.ABAPObject();
28
29
  this.me.set(this);
@@ -18,6 +18,7 @@ class InterfaceTranspiler {
18
18
  name = traversal_1.Traversal.escapeNamespace(name);
19
19
  ret += `class ${name} {\n`;
20
20
  ret += `static INTERNAL_TYPE = 'INTF';\n`;
21
+ ret += `static ATTRIBUTES = {${traversal.buildAttributes(def)}};\n`;
21
22
  }
22
23
  else if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.EndInterface) {
23
24
  ret += "}\n";
@@ -24,6 +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
28
  isBuiltinMethod(token: abaplint.Token): boolean;
28
29
  findMethodReference(token: abaplint.Token, scope: ISpaghettiScopeNode | undefined): undefined | {
29
30
  def: abaplint.Types.MethodDefinition;
@@ -169,6 +169,19 @@ class Traversal {
169
169
  }
170
170
  return undefined;
171
171
  }
172
+ buildAttributes(def) {
173
+ const attr = [];
174
+ // TODO: visibility is wrong for classes
175
+ for (const a of (def === null || def === void 0 ? void 0 : def.getAttributes().getAll()) || []) {
176
+ const type = new transpile_types_1.TranspileTypes().toType(a.getType());
177
+ attr.push(`"${a.getName().toUpperCase()}": {"type": ${type}, "visibility": "U", "is_constant": " "}`);
178
+ }
179
+ for (const a of (def === null || def === void 0 ? void 0 : def.getAttributes().getConstants()) || []) {
180
+ const type = new transpile_types_1.TranspileTypes().toType(a.getType());
181
+ attr.push(`"${a.getName().toUpperCase()}": {"type": ${type}, "visibility": "U", "is_constant": "X"}`);
182
+ }
183
+ return attr.join(",\n");
184
+ }
172
185
  isBuiltinMethod(token) {
173
186
  const scope = this.findCurrentScopeByToken(token);
174
187
  if (scope === undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.5.65",
3
+ "version": "2.5.67",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",