@abaplint/transpiler 2.1.85 → 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.
- package/build/src/unit_test.d.ts +1 -0
- package/build/src/unit_test.js +17 -2
- package/package.json +1 -1
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
|