@abaplint/transpiler 2.0.57 → 2.0.58

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.
@@ -3,5 +3,5 @@ import { IStructureTranspiler } from "./_structure_transpiler";
3
3
  import { Traversal } from "../traversal";
4
4
  import { Chunk } from "../chunk";
5
5
  export declare class ClassDefinitionTranspiler implements IStructureTranspiler {
6
- transpile(_node: abaplint.Nodes.StructureNode, _traversal: Traversal): Chunk;
6
+ transpile(node: abaplint.Nodes.StructureNode, traversal: Traversal): Chunk;
7
7
  }
@@ -1,10 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClassDefinitionTranspiler = void 0;
4
+ const abaplint = require("@abaplint/core");
4
5
  const chunk_1 = require("../chunk");
5
6
  class ClassDefinitionTranspiler {
6
- transpile(_node, _traversal) {
7
- return new chunk_1.Chunk("");
7
+ transpile(node, traversal) {
8
+ var _a;
9
+ const className = (_a = node.findFirstExpression(abaplint.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
10
+ let found = false;
11
+ if (className !== undefined) {
12
+ for (const a of traversal.getCurrentObject().getABAPFiles()) {
13
+ if (a.getInfo().getClassImplementationByName(className) !== undefined) {
14
+ found = true;
15
+ }
16
+ }
17
+ }
18
+ if (found) {
19
+ return new chunk_1.Chunk("");
20
+ }
21
+ else {
22
+ // its an abstract class with only abstract methods
23
+ return new chunk_1.Chunk(`
24
+ class ${className === null || className === void 0 ? void 0 : className.toLowerCase()} {
25
+ async constructor_() {
26
+ this.me = new abap.types.ABAPObject();
27
+ this.me.set(this);
28
+ return this;
29
+ }
30
+ }`);
31
+ }
8
32
  }
9
33
  }
10
34
  exports.ClassDefinitionTranspiler = ClassDefinitionTranspiler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.0.57",
3
+ "version": "2.0.58",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",