@abaplint/transpiler 2.0.50 → 2.0.53
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.
|
@@ -51,9 +51,15 @@ class SQLiteDatabaseSchema {
|
|
|
51
51
|
// it will be fine, the runtime representation of xstring is also text
|
|
52
52
|
return `TEXT`;
|
|
53
53
|
}
|
|
54
|
+
else if (type instanceof abaplint.BasicTypes.HexType) {
|
|
55
|
+
return `NCHAR(${type.getLength() * 2})`;
|
|
56
|
+
}
|
|
54
57
|
else if (type instanceof abaplint.BasicTypes.IntegerType) {
|
|
55
58
|
return `INT`;
|
|
56
59
|
}
|
|
60
|
+
else if (type instanceof abaplint.BasicTypes.PackedType) {
|
|
61
|
+
return `DECIMAL(${type.getLength()},${type.getDecimals()})`;
|
|
62
|
+
}
|
|
57
63
|
else if (type instanceof abaplint.BasicTypes.VoidType) {
|
|
58
64
|
throw `Type of ${table}-${fieldname} is VoidType(${type.getVoided()}), make sure the type is know, enable strict syntax checking`;
|
|
59
65
|
}
|
package/build/src/index.js
CHANGED
|
@@ -28,7 +28,7 @@ class Transpiler {
|
|
|
28
28
|
return new Transpiler().run(reg);
|
|
29
29
|
}
|
|
30
30
|
async run(reg, progress) {
|
|
31
|
-
var _a, _b, _c, _d, _e;
|
|
31
|
+
var _a, _b, _c, _d, _e, _f;
|
|
32
32
|
reg.parse();
|
|
33
33
|
new keywords_1.Keywords().handle(reg);
|
|
34
34
|
this.validate(reg);
|
|
@@ -38,6 +38,7 @@ class Transpiler {
|
|
|
38
38
|
unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, (_a = this.options) === null || _a === void 0 ? void 0 : _a.skip, (_b = this.options) === null || _b === void 0 ? void 0 : _b.only),
|
|
39
39
|
unitTestScriptOpen: new unit_test_1.UnitTest().unitTestScriptOpen(reg, (_c = this.options) === null || _c === void 0 ? void 0 : _c.skip, (_d = this.options) === null || _d === void 0 ? void 0 : _d.only),
|
|
40
40
|
initializationScript: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, (_e = this.options) === null || _e === void 0 ? void 0 : _e.extraSetup),
|
|
41
|
+
initializationScript2: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, (_f = this.options) === null || _f === void 0 ? void 0 : _f.extraSetup, true),
|
|
41
42
|
databaseSetup: dbSetup,
|
|
42
43
|
reg: reg,
|
|
43
44
|
};
|
|
@@ -13,7 +13,7 @@ class MethodImplementationTranspiler {
|
|
|
13
13
|
let methodName = token.getStr();
|
|
14
14
|
const scope = traversal.findCurrentScopeByToken(token);
|
|
15
15
|
if (scope === undefined) {
|
|
16
|
-
throw new Error("MethodTranspiler, scope not found");
|
|
16
|
+
throw new Error("MethodTranspiler, scope not found, " + methodName);
|
|
17
17
|
}
|
|
18
18
|
else if (scope.getIdentifier().sname !== methodName) {
|
|
19
19
|
throw new Error("MethodTranspiler, wrong scope found, " + scope.getIdentifier().sname);
|
package/build/src/types.d.ts
CHANGED
package/build/src/unit_test.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare type TestMethodList = {
|
|
|
6
6
|
method: string;
|
|
7
7
|
}[];
|
|
8
8
|
export declare class UnitTest {
|
|
9
|
-
initializationScript(reg: abaplint.IRegistry, dbSetup: DatabaseSetupResult, extraSetup?: string): string;
|
|
9
|
+
initializationScript(reg: abaplint.IRegistry, dbSetup: DatabaseSetupResult, extraSetup?: string, useImport?: boolean): string;
|
|
10
10
|
private escapeNamespace;
|
|
11
11
|
unitTestScriptOpen(reg: abaplint.IRegistry, _skip?: TestMethodList, _only?: TestMethodList): string;
|
|
12
12
|
unitTestScript(reg: abaplint.IRegistry, skip?: TestMethodList, _only?: TestMethodList): string;
|
package/build/src/unit_test.js
CHANGED
|
@@ -5,11 +5,18 @@ exports.UnitTest = void 0;
|
|
|
5
5
|
const abaplint = require("@abaplint/core");
|
|
6
6
|
class UnitTest {
|
|
7
7
|
// todo, move this method somewhere else, its much more than just unit test relevant
|
|
8
|
-
initializationScript(reg, dbSetup, extraSetup) {
|
|
9
|
-
let ret =
|
|
8
|
+
initializationScript(reg, dbSetup, extraSetup, useImport) {
|
|
9
|
+
let ret = "";
|
|
10
|
+
if (useImport === true) {
|
|
11
|
+
ret = `/* eslint-disable import/newline-after-import */
|
|
12
|
+
import "./_top.mjs";\n`;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
ret = `/* eslint-disable import/newline-after-import */
|
|
10
16
|
import runtime from "@abaplint/runtime";
|
|
11
|
-
globalThis.abap = new runtime.ABAP()
|
|
12
|
-
|
|
17
|
+
globalThis.abap = new runtime.ABAP();\n`;
|
|
18
|
+
}
|
|
19
|
+
ret += `${this.buildImports(reg, useImport)}
|
|
13
20
|
|
|
14
21
|
export async function initializeABAP() {\n`;
|
|
15
22
|
ret += ` const sqlite = \`${dbSetup.schemas.sqlite}\`;\n`;
|
|
@@ -165,37 +172,38 @@ run().then(() => {
|
|
|
165
172
|
});`;
|
|
166
173
|
return ret;
|
|
167
174
|
}
|
|
168
|
-
buildImports(reg) {
|
|
169
|
-
// note: ES modules are hoised, so use the dynamic import()
|
|
175
|
+
buildImports(reg, useImport) {
|
|
176
|
+
// note: ES modules are hoised, so use the dynamic import(), due to setting of globalThis.abap
|
|
170
177
|
// todo, some sorting might be required? eg. a class constructor using constant from interface?
|
|
171
178
|
// temporary sorting: by filename
|
|
172
179
|
const list = [];
|
|
173
|
-
|
|
174
|
-
if (
|
|
175
|
-
|
|
180
|
+
const imp = (filename) => {
|
|
181
|
+
if (useImport === true) {
|
|
182
|
+
return `import "./${filename}.mjs";`;
|
|
176
183
|
}
|
|
177
|
-
else
|
|
178
|
-
|
|
184
|
+
else {
|
|
185
|
+
return `await import("./${filename}.mjs");`;
|
|
179
186
|
}
|
|
180
|
-
|
|
181
|
-
|
|
187
|
+
};
|
|
188
|
+
for (const obj of reg.getObjects()) {
|
|
189
|
+
if (obj instanceof abaplint.Objects.Table
|
|
190
|
+
|| obj instanceof abaplint.Objects.DataElement
|
|
191
|
+
|| obj instanceof abaplint.Objects.TableType) {
|
|
192
|
+
list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));
|
|
182
193
|
}
|
|
183
194
|
}
|
|
184
195
|
for (const obj of reg.getObjects()) {
|
|
185
196
|
if (obj instanceof abaplint.Objects.FunctionGroup) {
|
|
186
197
|
for (const m of obj.getModules()) {
|
|
187
|
-
list.push(
|
|
198
|
+
list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.fugr.${m.getName().toLowerCase()}`));
|
|
188
199
|
}
|
|
189
200
|
}
|
|
190
|
-
else if (obj instanceof abaplint.Objects.Class
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
else if (obj instanceof abaplint.Objects.Interface) {
|
|
194
|
-
list.push(`await import("./${this.escapeNamespace(obj.getName().toLowerCase())}.intf.mjs");`);
|
|
201
|
+
else if (obj instanceof abaplint.Objects.Class
|
|
202
|
+
|| obj instanceof abaplint.Objects.Interface) {
|
|
203
|
+
list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));
|
|
195
204
|
}
|
|
196
205
|
}
|
|
197
|
-
list.sort();
|
|
198
|
-
return list.join("\n");
|
|
206
|
+
return list.sort().join("\n");
|
|
199
207
|
}
|
|
200
208
|
}
|
|
201
209
|
exports.UnitTest = UnitTest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.53",
|
|
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.91.
|
|
31
|
+
"@abaplint/core": "^2.91.6",
|
|
32
32
|
"source-map": "^0.7.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|