@abaplint/transpiler 2.3.92 → 2.3.94
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/README.md +2 -2
- package/build/src/handlers/handle_data_element.js +5 -5
- package/build/src/handlers/handle_enqu.js +14 -14
- package/build/src/handlers/handle_table.js +4 -4
- package/build/src/handlers/handle_table_type.js +3 -3
- package/build/src/handlers/handle_view.js +3 -3
- package/build/src/statements/call.js +7 -7
- package/build/src/statements/class_implementation.js +2 -2
- package/build/src/statements/do.js +6 -6
- package/build/src/statements/end_do.js +1 -1
- package/build/src/statements/end_while.js +1 -1
- package/build/src/statements/index.d.ts +2 -1
- package/build/src/statements/index.js +2 -1
- package/build/src/statements/select.js +8 -8
- package/build/src/statements/selection_screen.d.ts +7 -0
- package/build/src/statements/selection_screen.js +11 -0
- package/build/src/statements/while.js +3 -3
- package/build/src/structures/class_definition.js +8 -8
- package/build/src/structures/function_module.js +2 -2
- package/build/src/unit_test.js +68 -68
- package/package.json +42 -42
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# @abaplint/transpiler
|
|
2
|
-
|
|
1
|
+
# @abaplint/transpiler
|
|
2
|
+
|
|
3
3
|
Transpiler
|
|
@@ -18,11 +18,11 @@ class HandleDataElement {
|
|
|
18
18
|
fixedValues = doma.getFixedValues();
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
22
|
-
"objectType": "DTEL",
|
|
23
|
-
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
24
|
-
"domain": ${JSON.stringify(obj.getDomainName())},
|
|
25
|
-
"fixedValues": ${JSON.stringify(fixedValues)},
|
|
21
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
22
|
+
"objectType": "DTEL",
|
|
23
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
24
|
+
"domain": ${JSON.stringify(obj.getDomainName())},
|
|
25
|
+
"fixedValues": ${JSON.stringify(fixedValues)},
|
|
26
26
|
};`);
|
|
27
27
|
const output = {
|
|
28
28
|
object: {
|
|
@@ -10,20 +10,20 @@ class HandleEnqu {
|
|
|
10
10
|
if (filename === undefined) {
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
13
|
-
const chunk = new chunk_1.Chunk().appendString(`// enqueue object
|
|
14
|
-
abap.FunctionModules["ENQUEUE_${obj.getName().toUpperCase()}"] = async (INPUT) => {
|
|
15
|
-
const lookup = abap.Classes["KERNEL_LOCK"];
|
|
16
|
-
if (lookup === undefined) {
|
|
17
|
-
throw new Error("Lock, kernel class missing");
|
|
18
|
-
}
|
|
19
|
-
await lookup.enqueue(INPUT);
|
|
20
|
-
};
|
|
21
|
-
abap.FunctionModules["DEQUEUE_${obj.getName().toUpperCase()}"] = async (INPUT) => {
|
|
22
|
-
const lookup = abap.Classes["KERNEL_LOCK"];
|
|
23
|
-
if (lookup === undefined) {
|
|
24
|
-
throw new Error("Lock, kernel class missing");
|
|
25
|
-
}
|
|
26
|
-
await lookup.dequeue(INPUT);
|
|
13
|
+
const chunk = new chunk_1.Chunk().appendString(`// enqueue object
|
|
14
|
+
abap.FunctionModules["ENQUEUE_${obj.getName().toUpperCase()}"] = async (INPUT) => {
|
|
15
|
+
const lookup = abap.Classes["KERNEL_LOCK"];
|
|
16
|
+
if (lookup === undefined) {
|
|
17
|
+
throw new Error("Lock, kernel class missing");
|
|
18
|
+
}
|
|
19
|
+
await lookup.enqueue(INPUT);
|
|
20
|
+
};
|
|
21
|
+
abap.FunctionModules["DEQUEUE_${obj.getName().toUpperCase()}"] = async (INPUT) => {
|
|
22
|
+
const lookup = abap.Classes["KERNEL_LOCK"];
|
|
23
|
+
if (lookup === undefined) {
|
|
24
|
+
throw new Error("Lock, kernel class missing");
|
|
25
|
+
}
|
|
26
|
+
await lookup.dequeue(INPUT);
|
|
27
27
|
};`);
|
|
28
28
|
const output = {
|
|
29
29
|
object: {
|
|
@@ -12,10 +12,10 @@ class HandleTable {
|
|
|
12
12
|
return [];
|
|
13
13
|
}
|
|
14
14
|
const type = obj.parseType(reg);
|
|
15
|
-
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
16
|
-
"objectType": "TABL",
|
|
17
|
-
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
18
|
-
"keyFields": ${JSON.stringify(obj.listKeys(reg))},
|
|
15
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
16
|
+
"objectType": "TABL",
|
|
17
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
18
|
+
"keyFields": ${JSON.stringify(obj.listKeys(reg))},
|
|
19
19
|
};`);
|
|
20
20
|
const output = {
|
|
21
21
|
object: {
|
|
@@ -11,9 +11,9 @@ class HandleTableType {
|
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
13
13
|
const type = obj.parseType(reg);
|
|
14
|
-
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
15
|
-
"objectType": "TTYP",
|
|
16
|
-
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
14
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
15
|
+
"objectType": "TTYP",
|
|
16
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
17
17
|
};`);
|
|
18
18
|
const output = {
|
|
19
19
|
object: {
|
|
@@ -12,9 +12,9 @@ class HandleView {
|
|
|
12
12
|
return [];
|
|
13
13
|
}
|
|
14
14
|
const type = obj.parseType(reg);
|
|
15
|
-
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
16
|
-
"objectType": "VIEW",
|
|
17
|
-
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
15
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
16
|
+
"objectType": "VIEW",
|
|
17
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
18
18
|
};`);
|
|
19
19
|
// todo, "keyFields": ${JSON.stringify(obj.listKeys())},
|
|
20
20
|
const output = {
|
|
@@ -22,9 +22,9 @@ class CallTranspiler {
|
|
|
22
22
|
}
|
|
23
23
|
post += ";";
|
|
24
24
|
if (exceptions) {
|
|
25
|
-
post += `\nabap.builtin.sy.get().subrc.set(0);
|
|
26
|
-
} catch (e) {
|
|
27
|
-
if (e.classic) {
|
|
25
|
+
post += `\nabap.builtin.sy.get().subrc.set(0);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
if (e.classic) {
|
|
28
28
|
switch (e.classic.toUpperCase()) {\n`;
|
|
29
29
|
for (const e of exceptions.findAllExpressions(abaplint.Expressions.ParameterException)) {
|
|
30
30
|
const name = e.getFirstToken().getStr().toUpperCase();
|
|
@@ -39,10 +39,10 @@ if (e.classic) {
|
|
|
39
39
|
post += `case "${name}": abap.builtin.sy.get().subrc.set(${value}); break;\n`;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
post += ` }
|
|
43
|
-
} else {
|
|
44
|
-
throw e;
|
|
45
|
-
}
|
|
42
|
+
post += ` }
|
|
43
|
+
} else {
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
46
|
}`;
|
|
47
47
|
}
|
|
48
48
|
const chainChunk = traversal.traverse(chain);
|
|
@@ -17,8 +17,8 @@ class ClassImplementationTranspiler {
|
|
|
17
17
|
else if (def === null || def === void 0 ? void 0 : def.getSuperClass()) {
|
|
18
18
|
ret += " extends " + traversal_1.Traversal.escapeNamespace((_a = def === null || def === void 0 ? void 0 : def.getSuperClass()) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
19
19
|
}
|
|
20
|
-
return new chunk_1.Chunk().append(ret + ` {
|
|
21
|
-
static INTERNAL_TYPE = 'CLAS';
|
|
20
|
+
return new chunk_1.Chunk().append(ret + ` {
|
|
21
|
+
static INTERNAL_TYPE = 'CLAS';
|
|
22
22
|
static IMPLEMENTED_INTERFACES = [${def === null || def === void 0 ? void 0 : def.getImplementing().map(e => `"` + e.name.toUpperCase() + `"`).join(",")}];`, node, traversal);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -15,16 +15,16 @@ class DoTranspiler {
|
|
|
15
15
|
const source = new expressions_1.SourceTranspiler(true).transpile(found, traversal).getCode();
|
|
16
16
|
const idSource = unique_identifier_1.UniqueIdentifier.get();
|
|
17
17
|
const id = unique_identifier_1.UniqueIdentifier.get();
|
|
18
|
-
return new chunk_1.Chunk(`const ${this.syIndexBackup} = abap.builtin.sy.get().index.get();
|
|
19
|
-
const ${idSource} = ${source};
|
|
20
|
-
for (let ${id} = 0; ${id} < ${idSource}; ${id}++) {
|
|
18
|
+
return new chunk_1.Chunk(`const ${this.syIndexBackup} = abap.builtin.sy.get().index.get();
|
|
19
|
+
const ${idSource} = ${source};
|
|
20
|
+
for (let ${id} = 0; ${id} < ${idSource}; ${id}++) {
|
|
21
21
|
abap.builtin.sy.get().index.set(${id} + 1);`);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
const unique = unique_identifier_1.UniqueIdentifier.get();
|
|
25
|
-
return new chunk_1.Chunk(`const ${this.syIndexBackup} = abap.builtin.sy.get().index.get();
|
|
26
|
-
let ${unique} = 1;
|
|
27
|
-
while (true) {
|
|
25
|
+
return new chunk_1.Chunk(`const ${this.syIndexBackup} = abap.builtin.sy.get().index.get();
|
|
26
|
+
let ${unique} = 1;
|
|
27
|
+
while (true) {
|
|
28
28
|
abap.builtin.sy.get().index.set(${unique}++);`);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -7,7 +7,7 @@ class EndDoTranspiler {
|
|
|
7
7
|
this.syIndexBackup = syIndexBackup;
|
|
8
8
|
}
|
|
9
9
|
transpile(node, traversal) {
|
|
10
|
-
return new chunk_1.Chunk().append(`}
|
|
10
|
+
return new chunk_1.Chunk().append(`}
|
|
11
11
|
abap.builtin.sy.get().index.set(${this.syIndexBackup});\n`, node, traversal);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -7,7 +7,7 @@ class EndWhileTranspiler {
|
|
|
7
7
|
this.syIndexBackup = syIndexBackup;
|
|
8
8
|
}
|
|
9
9
|
transpile(node, traversal) {
|
|
10
|
-
return new chunk_1.Chunk().append(`}
|
|
10
|
+
return new chunk_1.Chunk().append(`}
|
|
11
11
|
abap.builtin.sy.get().index.set(${this.syIndexBackup});\n`, node, traversal);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -19,7 +19,6 @@ export * from "./class_definition_load";
|
|
|
19
19
|
export * from "./class_implementation";
|
|
20
20
|
export * from "./class_local_friends";
|
|
21
21
|
export * from "./clear";
|
|
22
|
-
export * from "./initialization";
|
|
23
22
|
export * from "./close_dataset";
|
|
24
23
|
export * from "./collect";
|
|
25
24
|
export * from "./commit";
|
|
@@ -70,6 +69,7 @@ export * from "./get_time";
|
|
|
70
69
|
export * from "./if";
|
|
71
70
|
export * from "./import";
|
|
72
71
|
export * from "./include";
|
|
72
|
+
export * from "./initialization";
|
|
73
73
|
export * from "./insert_database";
|
|
74
74
|
export * from "./insert_internal";
|
|
75
75
|
export * from "./insert_report";
|
|
@@ -107,6 +107,7 @@ export * from "./rollback";
|
|
|
107
107
|
export * from "./scan";
|
|
108
108
|
export * from "./search";
|
|
109
109
|
export * from "./select";
|
|
110
|
+
export * from "./selection_screen";
|
|
110
111
|
export * from "./set_bit";
|
|
111
112
|
export * from "./set_dataset";
|
|
112
113
|
export * from "./set_handler";
|
|
@@ -35,7 +35,6 @@ __exportStar(require("./class_definition_load"), exports);
|
|
|
35
35
|
__exportStar(require("./class_implementation"), exports);
|
|
36
36
|
__exportStar(require("./class_local_friends"), exports);
|
|
37
37
|
__exportStar(require("./clear"), exports);
|
|
38
|
-
__exportStar(require("./initialization"), exports);
|
|
39
38
|
__exportStar(require("./close_dataset"), exports);
|
|
40
39
|
__exportStar(require("./collect"), exports);
|
|
41
40
|
__exportStar(require("./commit"), exports);
|
|
@@ -86,6 +85,7 @@ __exportStar(require("./get_time"), exports);
|
|
|
86
85
|
__exportStar(require("./if"), exports);
|
|
87
86
|
__exportStar(require("./import"), exports);
|
|
88
87
|
__exportStar(require("./include"), exports);
|
|
88
|
+
__exportStar(require("./initialization"), exports);
|
|
89
89
|
__exportStar(require("./insert_database"), exports);
|
|
90
90
|
__exportStar(require("./insert_internal"), exports);
|
|
91
91
|
__exportStar(require("./insert_report"), exports);
|
|
@@ -123,6 +123,7 @@ __exportStar(require("./rollback"), exports);
|
|
|
123
123
|
__exportStar(require("./scan"), exports);
|
|
124
124
|
__exportStar(require("./search"), exports);
|
|
125
125
|
__exportStar(require("./select"), exports);
|
|
126
|
+
__exportStar(require("./selection_screen"), exports);
|
|
126
127
|
__exportStar(require("./set_bit"), exports);
|
|
127
128
|
__exportStar(require("./set_dataset"), exports);
|
|
128
129
|
__exportStar(require("./set_handler"), exports);
|
|
@@ -80,14 +80,14 @@ class SelectTranspiler {
|
|
|
80
80
|
const faeTranspiled = new expressions_1.SQLSourceTranspiler().transpile(fn, traversal).getCode();
|
|
81
81
|
select = select.replace(new RegExp(" " + faeTranspiled, "g"), " " + unique);
|
|
82
82
|
select = select.replace(unique + ".get().table_line.get()", unique + ".get()"); // there can be only one?
|
|
83
|
-
const code = `if (${faeTranspiled}.array().length === 0) {
|
|
84
|
-
throw "FAE, todo, empty table";
|
|
85
|
-
} else {
|
|
86
|
-
abap.statements.clear(${target});
|
|
87
|
-
for await (const ${unique} of abap.statements.loop(${faeTranspiled})) {
|
|
88
|
-
await abap.statements.select(${target}, {select: "${select.trim()}"${extra}}, {appending: true});
|
|
89
|
-
}
|
|
90
|
-
abap.builtin.sy.get().dbcnt.set(${target}.array().length);
|
|
83
|
+
const code = `if (${faeTranspiled}.array().length === 0) {
|
|
84
|
+
throw "FAE, todo, empty table";
|
|
85
|
+
} else {
|
|
86
|
+
abap.statements.clear(${target});
|
|
87
|
+
for await (const ${unique} of abap.statements.loop(${faeTranspiled})) {
|
|
88
|
+
await abap.statements.select(${target}, {select: "${select.trim()}"${extra}}, {appending: true});
|
|
89
|
+
}
|
|
90
|
+
abap.builtin.sy.get().dbcnt.set(${target}.array().length);
|
|
91
91
|
}`;
|
|
92
92
|
return new chunk_1.Chunk().append(code, node, traversal);
|
|
93
93
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { IStatementTranspiler } from "./_statement_transpiler";
|
|
3
|
+
import { Traversal } from "../traversal";
|
|
4
|
+
import { Chunk } from "../chunk";
|
|
5
|
+
export declare class SelectionScreenTranspiler implements IStatementTranspiler {
|
|
6
|
+
transpile(_node: abaplint.Nodes.StatementNode, _traversal: Traversal): Chunk;
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SelectionScreenTranspiler = void 0;
|
|
4
|
+
const chunk_1 = require("../chunk");
|
|
5
|
+
class SelectionScreenTranspiler {
|
|
6
|
+
transpile(_node, _traversal) {
|
|
7
|
+
return new chunk_1.Chunk(`throw new Error("SelectionScreen, transpiler todo");`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.SelectionScreenTranspiler = SelectionScreenTranspiler;
|
|
11
|
+
//# sourceMappingURL=selection_screen.js.map
|
|
@@ -13,11 +13,11 @@ class WhileTranspiler {
|
|
|
13
13
|
const cond = new expressions_1.CondTranspiler().transpile(node.findFirstExpression(abaplint.Expressions.Cond), traversal);
|
|
14
14
|
const unique = unique_identifier_1.UniqueIdentifier.get();
|
|
15
15
|
return new chunk_1.Chunk()
|
|
16
|
-
.append(`const ${this.syIndexBackup} = abap.builtin.sy.get().index.get();
|
|
17
|
-
let ${unique} = 1;
|
|
16
|
+
.append(`const ${this.syIndexBackup} = abap.builtin.sy.get().index.get();
|
|
17
|
+
let ${unique} = 1;
|
|
18
18
|
while (`, node, traversal)
|
|
19
19
|
.appendChunk(cond)
|
|
20
|
-
.appendString(`) {
|
|
20
|
+
.appendString(`) {
|
|
21
21
|
abap.builtin.sy.get().index.set(${unique}++);`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -20,14 +20,14 @@ class ClassDefinitionTranspiler {
|
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
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
|
-
static INTERNAL_TYPE = 'CLAS';
|
|
26
|
-
async constructor_() {
|
|
27
|
-
this.me = new abap.types.ABAPObject();
|
|
28
|
-
this.me.set(this);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
23
|
+
return new chunk_1.Chunk(`
|
|
24
|
+
class ${className === null || className === void 0 ? void 0 : className.toLowerCase()} {
|
|
25
|
+
static INTERNAL_TYPE = 'CLAS';
|
|
26
|
+
async constructor_() {
|
|
27
|
+
this.me = new abap.types.ABAPObject();
|
|
28
|
+
this.me.set(this);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
31
|
}`);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -61,8 +61,8 @@ class FunctionModuleTranspiler {
|
|
|
61
61
|
if (type !== undefined) {
|
|
62
62
|
// todo, set DEFAULT value
|
|
63
63
|
// todo, check for OPTIONALness and raise exceptions and stuff
|
|
64
|
-
ret += `if (${name} === undefined) {
|
|
65
|
-
${name} = ${new transpile_types_1.TranspileTypes().toType(type)};
|
|
64
|
+
ret += `if (${name} === undefined) {
|
|
65
|
+
${name} = ${new transpile_types_1.TranspileTypes().toType(type)};
|
|
66
66
|
}\n`;
|
|
67
67
|
}
|
|
68
68
|
}
|
package/build/src/unit_test.js
CHANGED
|
@@ -8,16 +8,16 @@ class UnitTest {
|
|
|
8
8
|
initializationScript(reg, dbSetup, extraSetup, useImport) {
|
|
9
9
|
let ret = "";
|
|
10
10
|
if (useImport === true) {
|
|
11
|
-
ret = `/* eslint-disable import/newline-after-import */
|
|
11
|
+
ret = `/* eslint-disable import/newline-after-import */
|
|
12
12
|
import "./_top.mjs";\n`;
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
|
-
ret = `/* eslint-disable import/newline-after-import */
|
|
16
|
-
import runtime from "@abaplint/runtime";
|
|
15
|
+
ret = `/* eslint-disable import/newline-after-import */
|
|
16
|
+
import runtime from "@abaplint/runtime";
|
|
17
17
|
globalThis.abap = new runtime.ABAP();\n`;
|
|
18
18
|
}
|
|
19
|
-
ret += `${this.buildImports(reg, useImport)}
|
|
20
|
-
|
|
19
|
+
ret += `${this.buildImports(reg, useImport)}
|
|
20
|
+
|
|
21
21
|
export async function initializeABAP() {\n`;
|
|
22
22
|
ret += ` const sqlite = [];\n`;
|
|
23
23
|
for (const i of dbSetup.schemas.sqlite) {
|
|
@@ -45,19 +45,19 @@ export async function initializeABAP() {\n`;
|
|
|
45
45
|
return filename.replace(/\//g, "%23");
|
|
46
46
|
}
|
|
47
47
|
unitTestScriptOpen(reg, _skip, _only) {
|
|
48
|
-
let ret = `/* eslint-disable curly */
|
|
49
|
-
import fs from "fs";
|
|
50
|
-
import path from "path";
|
|
51
|
-
import {fileURLToPath} from "url";
|
|
52
|
-
import {initializeABAP} from "./init.mjs";
|
|
53
|
-
|
|
54
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
55
|
-
|
|
56
|
-
async function run() {
|
|
57
|
-
await initializeABAP();
|
|
58
|
-
let lt_input = new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30)}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]});
|
|
59
|
-
let ls_input = new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30)});
|
|
60
|
-
let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String(), console: new abap.types.String()}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]}), json: new abap.types.String()});
|
|
48
|
+
let ret = `/* eslint-disable curly */
|
|
49
|
+
import fs from "fs";
|
|
50
|
+
import path from "path";
|
|
51
|
+
import {fileURLToPath} from "url";
|
|
52
|
+
import {initializeABAP} from "./init.mjs";
|
|
53
|
+
|
|
54
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
55
|
+
|
|
56
|
+
async function run() {
|
|
57
|
+
await initializeABAP();
|
|
58
|
+
let lt_input = new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30)}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]});
|
|
59
|
+
let ls_input = new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30)});
|
|
60
|
+
let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String(), console: new abap.types.String()}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]}), json: new abap.types.String()});
|
|
61
61
|
`;
|
|
62
62
|
for (const obj of reg.getObjects()) {
|
|
63
63
|
if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
|
|
@@ -77,44 +77,44 @@ async function run() {
|
|
|
77
77
|
if (m.isForTesting === false) {
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
80
|
-
ret += ` ls_input.get().class_name.set("${obj.getName()}");
|
|
81
|
-
ls_input.get().testclass_name.set("${def.name.toUpperCase()}");
|
|
82
|
-
ls_input.get().method_name.set("${m.name.toUpperCase()}");
|
|
80
|
+
ret += ` ls_input.get().class_name.set("${obj.getName()}");
|
|
81
|
+
ls_input.get().testclass_name.set("${def.name.toUpperCase()}");
|
|
82
|
+
ls_input.get().method_name.set("${m.name.toUpperCase()}");
|
|
83
83
|
abap.statements.append({source: ls_input, target: lt_input});\n`;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
ret += `
|
|
89
|
-
|
|
90
|
-
ls_result.set(await abap.Classes["KERNEL_UNIT_RUNNER"].run({it_input: lt_input}));
|
|
91
|
-
fs.writeFileSync(__dirname + path.sep + "output.json", ls_result.get().json.get());
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
run().then(() => {
|
|
95
|
-
process.exit(0);
|
|
96
|
-
}).catch((err) => {
|
|
97
|
-
console.log(err);
|
|
98
|
-
process.exit(1);
|
|
88
|
+
ret += `
|
|
89
|
+
|
|
90
|
+
ls_result.set(await abap.Classes["KERNEL_UNIT_RUNNER"].run({it_input: lt_input}));
|
|
91
|
+
fs.writeFileSync(__dirname + path.sep + "output.json", ls_result.get().json.get());
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
run().then(() => {
|
|
95
|
+
process.exit(0);
|
|
96
|
+
}).catch((err) => {
|
|
97
|
+
console.log(err);
|
|
98
|
+
process.exit(1);
|
|
99
99
|
});`;
|
|
100
100
|
return ret;
|
|
101
101
|
}
|
|
102
102
|
unitTestScript(reg, skip, _only) {
|
|
103
|
-
let ret = `/* eslint-disable curly */
|
|
104
|
-
import fs from "fs";
|
|
105
|
-
import path from "path";
|
|
106
|
-
import {fileURLToPath} from "url";
|
|
107
|
-
import {initializeABAP} from "./init.mjs";
|
|
108
|
-
import runtime from "@abaplint/runtime";
|
|
109
|
-
|
|
110
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
111
|
-
|
|
112
|
-
async function run() {
|
|
113
|
-
await initializeABAP();
|
|
114
|
-
const unit = new runtime.UnitTestResult();
|
|
115
|
-
let clas;
|
|
116
|
-
let locl;
|
|
117
|
-
let meth;
|
|
103
|
+
let ret = `/* eslint-disable curly */
|
|
104
|
+
import fs from "fs";
|
|
105
|
+
import path from "path";
|
|
106
|
+
import {fileURLToPath} from "url";
|
|
107
|
+
import {initializeABAP} from "./init.mjs";
|
|
108
|
+
import runtime from "@abaplint/runtime";
|
|
109
|
+
|
|
110
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
111
|
+
|
|
112
|
+
async function run() {
|
|
113
|
+
await initializeABAP();
|
|
114
|
+
const unit = new runtime.UnitTestResult();
|
|
115
|
+
let clas;
|
|
116
|
+
let locl;
|
|
117
|
+
let meth;
|
|
118
118
|
try {\n`;
|
|
119
119
|
for (const obj of reg.getObjects()) {
|
|
120
120
|
if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
|
|
@@ -132,9 +132,9 @@ async function run() {
|
|
|
132
132
|
if (hasTestFile === false) {
|
|
133
133
|
break;
|
|
134
134
|
}
|
|
135
|
-
ret += ` {
|
|
136
|
-
const {${def.name}} = await import("./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs");
|
|
137
|
-
locl = clas.addTestClass("${def.name}");
|
|
135
|
+
ret += ` {
|
|
136
|
+
const {${def.name}} = await import("./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs");
|
|
137
|
+
locl = clas.addTestClass("${def.name}");
|
|
138
138
|
if (${def.name}.class_setup) await ${def.name}.class_setup();\n`;
|
|
139
139
|
for (const m of def.methods) {
|
|
140
140
|
if (m.isForTesting === false) {
|
|
@@ -161,24 +161,24 @@ async function run() {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
ret += `// -------------------END-------------------
|
|
165
|
-
console.log(abap.console.get());
|
|
166
|
-
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
167
|
-
} catch (e) {
|
|
168
|
-
if (meth) {
|
|
169
|
-
meth.fail();
|
|
170
|
-
}
|
|
171
|
-
console.log(abap.console.get());
|
|
172
|
-
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
173
|
-
throw e;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
run().then(() => {
|
|
178
|
-
process.exit(0);
|
|
179
|
-
}).catch((err) => {
|
|
180
|
-
console.log(err);
|
|
181
|
-
process.exit(1);
|
|
164
|
+
ret += `// -------------------END-------------------
|
|
165
|
+
console.log(abap.console.get());
|
|
166
|
+
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
167
|
+
} catch (e) {
|
|
168
|
+
if (meth) {
|
|
169
|
+
meth.fail();
|
|
170
|
+
}
|
|
171
|
+
console.log(abap.console.get());
|
|
172
|
+
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
173
|
+
throw e;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
run().then(() => {
|
|
178
|
+
process.exit(0);
|
|
179
|
+
}).catch((err) => {
|
|
180
|
+
console.log(err);
|
|
181
|
+
process.exit(1);
|
|
182
182
|
});`;
|
|
183
183
|
return ret;
|
|
184
184
|
}
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.3.
|
|
4
|
-
"description": "Transpiler",
|
|
5
|
-
"main": "build/src/index.js",
|
|
6
|
-
"typings": "build/src/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"compile": "tsc",
|
|
13
|
-
"publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
-
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
-
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
16
|
-
"test": "npm run compile && mocha"
|
|
17
|
-
},
|
|
18
|
-
"mocha": {
|
|
19
|
-
"recursive": true,
|
|
20
|
-
"reporter": "progress",
|
|
21
|
-
"spec": "build/test/**/*.js",
|
|
22
|
-
"require": "source-map-support/register"
|
|
23
|
-
},
|
|
24
|
-
"keywords": [
|
|
25
|
-
"ABAP",
|
|
26
|
-
"abaplint"
|
|
27
|
-
],
|
|
28
|
-
"author": "abaplint",
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"@abaplint/core": "^2.94.
|
|
32
|
-
"source-map": "^0.7.4"
|
|
33
|
-
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@types/chai": "^4.3.4",
|
|
36
|
-
"@types/mocha": "^10.0.1",
|
|
37
|
-
"chai": "^4.3.7",
|
|
38
|
-
"mocha": "^10.2.0",
|
|
39
|
-
"source-map-support": "^0.5.21",
|
|
40
|
-
"typescript": "^4.8.4"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@abaplint/transpiler",
|
|
3
|
+
"version": "2.3.94",
|
|
4
|
+
"description": "Transpiler",
|
|
5
|
+
"main": "build/src/index.js",
|
|
6
|
+
"typings": "build/src/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"compile": "tsc",
|
|
13
|
+
"publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
+
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
+
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
16
|
+
"test": "npm run compile && mocha"
|
|
17
|
+
},
|
|
18
|
+
"mocha": {
|
|
19
|
+
"recursive": true,
|
|
20
|
+
"reporter": "progress",
|
|
21
|
+
"spec": "build/test/**/*.js",
|
|
22
|
+
"require": "source-map-support/register"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"ABAP",
|
|
26
|
+
"abaplint"
|
|
27
|
+
],
|
|
28
|
+
"author": "abaplint",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@abaplint/core": "^2.94.12",
|
|
32
|
+
"source-map": "^0.7.4"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/chai": "^4.3.4",
|
|
36
|
+
"@types/mocha": "^10.0.1",
|
|
37
|
+
"chai": "^4.3.7",
|
|
38
|
+
"mocha": "^10.2.0",
|
|
39
|
+
"source-map-support": "^0.5.21",
|
|
40
|
+
"typescript": "^4.8.4"
|
|
41
|
+
}
|
|
42
|
+
}
|