@abaplint/transpiler 2.1.84 → 2.1.86
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.
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TargetTranspiler = void 0;
|
|
4
4
|
const core_1 = require("@abaplint/core");
|
|
5
|
+
const traversal_1 = require("../traversal");
|
|
5
6
|
const _1 = require(".");
|
|
6
7
|
const chunk_1 = require("../chunk");
|
|
7
8
|
class TargetTranspiler {
|
|
@@ -22,9 +23,9 @@ class TargetTranspiler {
|
|
|
22
23
|
}
|
|
23
24
|
else if (c.get() instanceof core_1.Expressions.AttributeName) {
|
|
24
25
|
const intf = traversal.isInterfaceAttribute(c.getFirstToken());
|
|
25
|
-
let name = c.getFirstToken().getStr().replace("~", "$").toLowerCase();
|
|
26
|
+
let name = traversal_1.Traversal.escapeClassName(c.getFirstToken().getStr()).replace("~", "$").toLowerCase();
|
|
26
27
|
if (intf && name.startsWith(intf) === false) {
|
|
27
|
-
name = intf + "$" + name;
|
|
28
|
+
name = traversal_1.Traversal.escapeClassName(intf) + "$" + name;
|
|
28
29
|
}
|
|
29
30
|
ret.append(name, c, traversal);
|
|
30
31
|
}
|
package/build/src/requires.js
CHANGED
|
@@ -8,7 +8,7 @@ class Requires {
|
|
|
8
8
|
}
|
|
9
9
|
// todo, refactor this method
|
|
10
10
|
find(obj, _node, filename) {
|
|
11
|
-
var _a, _b, _c, _d, _e, _f;
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
12
12
|
const ret = [];
|
|
13
13
|
if (obj.getType() === "INTF") {
|
|
14
14
|
return [];
|
|
@@ -28,18 +28,18 @@ class Requires {
|
|
|
28
28
|
if (obj.getType() === "CLAS") {
|
|
29
29
|
// add the superclass
|
|
30
30
|
const clas = obj;
|
|
31
|
-
const sup = (_b = (_a = clas.getDefinition()) === null || _a === void 0 ? void 0 : _a.getSuperClass()) === null || _b === void 0 ? void 0 : _b.toLowerCase().replace(/\//g, "
|
|
31
|
+
const sup = (_b = (_a = clas.getDefinition()) === null || _a === void 0 ? void 0 : _a.getSuperClass()) === null || _b === void 0 ? void 0 : _b.toLowerCase().replace(/\//g, "#");
|
|
32
32
|
if (sup) {
|
|
33
|
-
add({ filename: sup + ".clas.abap", name:
|
|
33
|
+
add({ filename: sup + ".clas.abap", name: (_d = (_c = clas.getDefinition()) === null || _c === void 0 ? void 0 : _c.getSuperClass()) === null || _d === void 0 ? void 0 : _d.toLowerCase() });
|
|
34
34
|
}
|
|
35
35
|
for (const f of clas.getSequencedFiles()) {
|
|
36
36
|
if (filename.endsWith(".testclasses.abap")) {
|
|
37
37
|
// add the global class, in case its inherited by a local testclass
|
|
38
|
-
add({ filename: ((
|
|
38
|
+
add({ filename: ((_e = clas.getMainABAPFile()) === null || _e === void 0 ? void 0 : _e.getFilename()) || "", name: obj.getName().toLowerCase() });
|
|
39
39
|
}
|
|
40
40
|
if (f.getFilename() === filename
|
|
41
41
|
|| f.getFilename().endsWith(".clas.testclasses.abap")
|
|
42
|
-
|| f.getFilename() === ((
|
|
42
|
+
|| f.getFilename() === ((_f = clas.getMainABAPFile()) === null || _f === void 0 ? void 0 : _f.getFilename())) {
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
45
|
let foo = f.getFilename();
|
|
@@ -77,7 +77,7 @@ class Requires {
|
|
|
77
77
|
if (obj.getType() !== "INTF") {
|
|
78
78
|
const cx = this.reg.getObject("CLAS", "CX_ROOT");
|
|
79
79
|
if (cx && cx instanceof abaplint.ABAPObject) {
|
|
80
|
-
const main = (
|
|
80
|
+
const main = (_g = cx.getMainABAPFile()) === null || _g === void 0 ? void 0 : _g.getFilename();
|
|
81
81
|
if (main) {
|
|
82
82
|
add({
|
|
83
83
|
filename: main,
|
|
@@ -93,7 +93,7 @@ class Requires {
|
|
|
93
93
|
}
|
|
94
94
|
const found = this.reg.getObject("CLAS", c.superClassName);
|
|
95
95
|
if (found && found instanceof abaplint.ABAPObject) {
|
|
96
|
-
const main = (
|
|
96
|
+
const main = (_h = found.getMainABAPFile()) === null || _h === void 0 ? void 0 : _h.getFilename();
|
|
97
97
|
if (main) {
|
|
98
98
|
add({
|
|
99
99
|
filename: main,
|
|
@@ -15,7 +15,7 @@ class ClassImplementationTranspiler {
|
|
|
15
15
|
ret += " extends Error";
|
|
16
16
|
}
|
|
17
17
|
else if (def === null || def === void 0 ? void 0 : def.getSuperClass()) {
|
|
18
|
-
ret += " extends " + ((_a = def === null || def === void 0 ? void 0 : def.getSuperClass()) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
18
|
+
ret += " extends " + traversal_1.Traversal.escapeClassName((_a = def === null || def === void 0 ? void 0 : def.getSuperClass()) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
19
19
|
}
|
|
20
20
|
return new chunk_1.Chunk().append(ret + ` {
|
|
21
21
|
static INTERNAL_TYPE = 'CLAS';
|
package/build/src/unit_test.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ export declare class UnitTest {
|
|
|
11
11
|
unitTestScriptOpen(reg: abaplint.IRegistry, _skip?: TestMethodList, _only?: TestMethodList): string;
|
|
12
12
|
unitTestScript(reg: abaplint.IRegistry, skip?: TestMethodList, _only?: TestMethodList): string;
|
|
13
13
|
private buildImports;
|
|
14
|
+
private hasClassConstructor;
|
|
14
15
|
}
|
package/build/src/unit_test.js
CHANGED
|
@@ -181,7 +181,6 @@ run().then(() => {
|
|
|
181
181
|
buildImports(reg, useImport) {
|
|
182
182
|
// note: ES modules are hoised, so use the dynamic import(), due to setting of globalThis.abap
|
|
183
183
|
// some sorting required: eg. a class constructor using constant from interface
|
|
184
|
-
var _a;
|
|
185
184
|
const list = [];
|
|
186
185
|
const late = [];
|
|
187
186
|
const imp = (filename) => {
|
|
@@ -207,7 +206,7 @@ run().then(() => {
|
|
|
207
206
|
}
|
|
208
207
|
else if (obj instanceof abaplint.Objects.Class) {
|
|
209
208
|
if (obj.getName().toUpperCase() !== "CL_ABAP_CHAR_UTILITIES"
|
|
210
|
-
&& (
|
|
209
|
+
&& this.hasClassConstructor(reg, obj)) {
|
|
211
210
|
// this will not solve all problems with class constors 100%, but probably good enough
|
|
212
211
|
late.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));
|
|
213
212
|
}
|
|
@@ -221,6 +220,22 @@ run().then(() => {
|
|
|
221
220
|
}
|
|
222
221
|
return [...list.sort(), ...late].join("\n");
|
|
223
222
|
}
|
|
223
|
+
// class constructors might make early use of eg. constants from interfaces
|
|
224
|
+
// sub classes will import() super classes and trigger a class constructor of the super
|
|
225
|
+
hasClassConstructor(reg, clas) {
|
|
226
|
+
var _a, _b;
|
|
227
|
+
if (((_a = clas.getDefinition()) === null || _a === void 0 ? void 0 : _a.getMethodDefinitions().getByName("CLASS_CONSTRUCTOR")) !== undefined) {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
const sup = (_b = clas.getDefinition()) === null || _b === void 0 ? void 0 : _b.getSuperClass();
|
|
231
|
+
if (sup !== undefined) {
|
|
232
|
+
const superClass = reg.getObject("CLAS", sup);
|
|
233
|
+
if (superClass) {
|
|
234
|
+
return this.hasClassConstructor(reg, superClass);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
224
239
|
}
|
|
225
240
|
exports.UnitTest = UnitTest;
|
|
226
241
|
//# sourceMappingURL=unit_test.js.map
|