@abaplint/transpiler 2.3.87 → 2.3.89
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/expressions/field_chain.js +4 -4
- package/build/src/expressions/method_call.js +1 -1
- package/build/src/expressions/method_call_chain.js +1 -1
- package/build/src/expressions/method_source.js +2 -2
- package/build/src/expressions/target.js +2 -2
- package/build/src/handlers/handle_abap.js +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 +4 -4
- 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/method_implementation.js +3 -3
- package/build/src/statements/read_table.js +1 -1
- package/build/src/statements/select.js +8 -8
- package/build/src/statements/while.js +3 -3
- package/build/src/structures/class_definition.js +8 -8
- package/build/src/structures/class_implementation.js +3 -3
- package/build/src/structures/function_module.js +4 -4
- package/build/src/structures/interface.js +3 -3
- package/build/src/traversal.d.ts +1 -1
- package/build/src/traversal.js +12 -12
- 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
|
|
@@ -17,7 +17,7 @@ class FieldChainTranspiler {
|
|
|
17
17
|
if (c.get() instanceof core_1.Expressions.SourceField
|
|
18
18
|
|| c.get() instanceof core_1.Expressions.Field) {
|
|
19
19
|
const name = traversal.prefixAndName(c.getFirstToken(), filename).replace("~", "$");
|
|
20
|
-
ret.append(name, c, traversal);
|
|
20
|
+
ret.append(traversal_1.Traversal.escapeNamespace(name), c, traversal);
|
|
21
21
|
}
|
|
22
22
|
else if (c instanceof core_1.Nodes.ExpressionNode && c.get() instanceof core_1.Expressions.SourceFieldSymbol) {
|
|
23
23
|
ret.appendChunk(new field_symbol_1.FieldSymbolTranspiler().transpile(c, traversal));
|
|
@@ -30,11 +30,11 @@ class FieldChainTranspiler {
|
|
|
30
30
|
const interfaceName = traversal.isInterfaceAttribute(c.getFirstToken());
|
|
31
31
|
let name = c.getFirstToken().getStr().toLowerCase();
|
|
32
32
|
if (prefix && interfaceName && name.startsWith(interfaceName) === false) {
|
|
33
|
-
name = traversal_1.Traversal.
|
|
34
|
-
name = traversal_1.Traversal.
|
|
33
|
+
name = traversal_1.Traversal.escapeNamespace(name).replace("~", "$");
|
|
34
|
+
name = traversal_1.Traversal.escapeNamespace(interfaceName) + "$" + name;
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
name = traversal_1.Traversal.
|
|
37
|
+
name = traversal_1.Traversal.escapeNamespace(name).replace("~", "$");
|
|
38
38
|
}
|
|
39
39
|
ret.append(name, c, traversal);
|
|
40
40
|
}
|
|
@@ -28,7 +28,7 @@ class MethodCallTranspiler {
|
|
|
28
28
|
throw new Error("MethodCallTranspiler, unexpected node");
|
|
29
29
|
}
|
|
30
30
|
const ret = new chunk_1.Chunk();
|
|
31
|
-
ret.append(traversal_1.Traversal.
|
|
31
|
+
ret.append(traversal_1.Traversal.escapeNamespace(name.replace("~", "$")), nameToken, traversal);
|
|
32
32
|
ret.appendChunk(new method_call_param_1.MethodCallParamTranspiler(m === null || m === void 0 ? void 0 : m.def).transpile(step, traversal));
|
|
33
33
|
ret.appendString(")");
|
|
34
34
|
return ret;
|
|
@@ -30,7 +30,7 @@ class MethodCallChainTranspiler {
|
|
|
30
30
|
ret = new chunk_1.Chunk().append(traversal.lookupClassOrInterface(c.getFirstToken().getStr(), c.getFirstToken()), c, traversal);
|
|
31
31
|
}
|
|
32
32
|
else if (c instanceof core_1.Nodes.ExpressionNode && c.get() instanceof core_1.Expressions.MethodName) {
|
|
33
|
-
const name = traversal_1.Traversal.
|
|
33
|
+
const name = traversal_1.Traversal.escapeNamespace(c.getFirstToken().getStr().toLowerCase().replace("~", "$"));
|
|
34
34
|
ret.append(name, c, traversal);
|
|
35
35
|
}
|
|
36
36
|
else if (c instanceof core_1.Nodes.TokenNode && c.getFirstToken().getStr() === "->") {
|
|
@@ -71,10 +71,10 @@ class MethodSourceTranspiler {
|
|
|
71
71
|
const nameToken = child.getFirstToken();
|
|
72
72
|
const m = traversal.findMethodReference(nameToken, traversal.findCurrentScopeByToken(nameToken));
|
|
73
73
|
if (m) {
|
|
74
|
-
call += traversal_1.Traversal.
|
|
74
|
+
call += traversal_1.Traversal.escapeNamespace(m.name.toLowerCase().replace("~", "$"));
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
|
-
const methodName = traversal_1.Traversal.
|
|
77
|
+
const methodName = traversal_1.Traversal.escapeNamespace(child.concatTokens().toLowerCase().replace("~", "$"));
|
|
78
78
|
call += methodName;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -32,9 +32,9 @@ class TargetTranspiler {
|
|
|
32
32
|
}
|
|
33
33
|
else if (c.get() instanceof core_1.Expressions.AttributeName) {
|
|
34
34
|
const intf = traversal.isInterfaceAttribute(c.getFirstToken());
|
|
35
|
-
let name = traversal_1.Traversal.
|
|
35
|
+
let name = traversal_1.Traversal.escapeNamespace(c.getFirstToken().getStr()).replace("~", "$").toLowerCase();
|
|
36
36
|
if (intf && name.startsWith(intf) === false) {
|
|
37
|
-
name = traversal_1.Traversal.
|
|
37
|
+
name = traversal_1.Traversal.escapeNamespace(intf) + "$" + name;
|
|
38
38
|
}
|
|
39
39
|
ret.append(name, c, traversal);
|
|
40
40
|
}
|
|
@@ -108,7 +108,7 @@ class HandleABAP {
|
|
|
108
108
|
continue;
|
|
109
109
|
}
|
|
110
110
|
if (name) {
|
|
111
|
-
contents.appendString("const {" + traversal_1.Traversal.
|
|
111
|
+
contents.appendString("const {" + traversal_1.Traversal.escapeNamespace(name) + "} = await import(\"./" + filename.replace(/#/g, "%23") + "\");\n");
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
114
114
|
contents.appendString("await import(\"./" + filename.replace(/#/g, "%23") + "\");\n");
|
|
@@ -116,7 +116,7 @@ class HandleABAP {
|
|
|
116
116
|
}
|
|
117
117
|
contents.appendChunk(output.chunk);
|
|
118
118
|
if (output.exports.length > 0) {
|
|
119
|
-
contents.appendString("\nexport {" + output.exports.map(traversal_1.Traversal.
|
|
119
|
+
contents.appendString("\nexport {" + output.exports.map(traversal_1.Traversal.escapeNamespace).join(", ") + "};");
|
|
120
120
|
}
|
|
121
121
|
return contents;
|
|
122
122
|
}
|
|
@@ -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);
|
|
@@ -9,16 +9,16 @@ class ClassImplementationTranspiler {
|
|
|
9
9
|
var _a;
|
|
10
10
|
const token = node.findFirstExpression(abaplint.Expressions.ClassName).getFirstToken();
|
|
11
11
|
const def = traversal.getClassDefinition(token);
|
|
12
|
-
let ret = "class " + traversal_1.Traversal.
|
|
12
|
+
let ret = "class " + traversal_1.Traversal.escapeNamespace(token.getStr().toLowerCase());
|
|
13
13
|
if (token.getStr().toLowerCase() === "cx_root") {
|
|
14
14
|
// special case for exceptions
|
|
15
15
|
ret += " extends Error";
|
|
16
16
|
}
|
|
17
17
|
else if (def === null || def === void 0 ? void 0 : def.getSuperClass()) {
|
|
18
|
-
ret += " extends " + traversal_1.Traversal.
|
|
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
|
}
|
|
@@ -133,12 +133,12 @@ class MethodImplementationTranspiler {
|
|
|
133
133
|
if (method && method.isStatic()) {
|
|
134
134
|
// in ABAP static methods can be called with instance arrows, "->"
|
|
135
135
|
const className = (_b = (_a = scope.getParent()) === null || _a === void 0 ? void 0 : _a.getIdentifier().sname) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
136
|
-
staticMethod = "async " + traversal_1.Traversal.
|
|
137
|
-
"return " + traversal_1.Traversal.
|
|
136
|
+
staticMethod = "async " + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ") {\n" +
|
|
137
|
+
"return " + traversal_1.Traversal.escapeNamespace(className) + "." + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ");\n" +
|
|
138
138
|
"}\n" + "static ";
|
|
139
139
|
}
|
|
140
140
|
unique_identifier_1.UniqueIdentifier.resetIndexBackup();
|
|
141
|
-
const str = staticMethod + "async " + traversal_1.Traversal.
|
|
141
|
+
const str = staticMethod + "async " + traversal_1.Traversal.escapeNamespace(methodName) + "(" + unique + ") {" + after;
|
|
142
142
|
return new chunk_1.Chunk().append(str, node, traversal);
|
|
143
143
|
}
|
|
144
144
|
/////////////////////////////
|
|
@@ -53,7 +53,7 @@ class ReadTableTranspiler {
|
|
|
53
53
|
while (field.includes("-")) {
|
|
54
54
|
field = field.replace("-", ".get().");
|
|
55
55
|
}
|
|
56
|
-
field = traversal_1.Traversal.
|
|
56
|
+
field = traversal_1.Traversal.escapeNamespace(field).replace("~", "$");
|
|
57
57
|
if (left.get() instanceof abaplint.Expressions.Dynamic
|
|
58
58
|
&& left instanceof abaplint.Nodes.ExpressionNode) {
|
|
59
59
|
const concat = left.concatTokens().toLowerCase();
|
|
@@ -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
|
}
|
|
@@ -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,7 +61,7 @@ class ClassImplementationTranspiler {
|
|
|
61
61
|
if (cdef === undefined) {
|
|
62
62
|
return "ERROR_CDEF_NOT_FOUND";
|
|
63
63
|
}
|
|
64
|
-
const prefix = traversal_1.Traversal.
|
|
64
|
+
const prefix = traversal_1.Traversal.escapeNamespace(cdef.getName().toLowerCase()) + ".";
|
|
65
65
|
let ret = "";
|
|
66
66
|
for (const ty of cdef.getTypeDefinitions().getAll()) {
|
|
67
67
|
ret += new transpile_types_1.TranspileTypes().declareStaticSkipVoid(prefix, ty.type);
|
|
@@ -85,7 +85,7 @@ class ClassImplementationTranspiler {
|
|
|
85
85
|
const clasName = node.getFirstToken().getStr().toLowerCase();
|
|
86
86
|
const staticAttributes = this.findStaticAttributes(cdef, scope);
|
|
87
87
|
for (const attr of staticAttributes) {
|
|
88
|
-
const name = traversal_1.Traversal.
|
|
88
|
+
const name = traversal_1.Traversal.escapeNamespace(clasName) + "." + attr.prefix + traversal_1.Traversal.escapeNamespace(attr.identifier.getName().toLowerCase());
|
|
89
89
|
ret += name + " = " + new transpile_types_1.TranspileTypes().toType(attr.identifier.getType()) + ";\n";
|
|
90
90
|
ret += traversal.setValues(attr.identifier, name);
|
|
91
91
|
}
|
|
@@ -99,7 +99,7 @@ class ClassImplementationTranspiler {
|
|
|
99
99
|
// this is not correct, ABAP does not invocate the class constructor at require time,
|
|
100
100
|
// but this will probably work
|
|
101
101
|
if (cdef.getMethodDefinitions().getByName("class_constructor")) {
|
|
102
|
-
ret += "await " + traversal_1.Traversal.
|
|
102
|
+
ret += "await " + traversal_1.Traversal.escapeNamespace(node.getFirstToken().getStr().toLowerCase()) + ".class_constructor();\n";
|
|
103
103
|
}
|
|
104
104
|
return ret;
|
|
105
105
|
}
|
|
@@ -17,12 +17,12 @@ class FunctionModuleTranspiler {
|
|
|
17
17
|
if (name === undefined) {
|
|
18
18
|
name = "FunctionModuleTranspilerNameNotFound";
|
|
19
19
|
}
|
|
20
|
-
r += `async function ${traversal_1.Traversal.
|
|
20
|
+
r += `async function ${traversal_1.Traversal.escapeNamespace(name)}(INPUT) {\n`;
|
|
21
21
|
r += this.findSignature(traversal, name, c);
|
|
22
22
|
}
|
|
23
23
|
else if (c.get() instanceof abaplint.Statements.EndFunction) {
|
|
24
24
|
r += "}\n";
|
|
25
|
-
r += `abap.FunctionModules['${name.toUpperCase()}'] = ${traversal_1.Traversal.
|
|
25
|
+
r += `abap.FunctionModules['${name.toUpperCase()}'] = ${traversal_1.Traversal.escapeNamespace(name)};\n`;
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
28
|
r += traversal.traverse(c).getCode();
|
|
@@ -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
|
}
|
|
@@ -15,7 +15,7 @@ class InterfaceTranspiler {
|
|
|
15
15
|
for (const c of node.getChildren()) {
|
|
16
16
|
if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.Interface) {
|
|
17
17
|
name = (_a = c.findDirectExpression(abaplint.Expressions.InterfaceName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr().toLowerCase();
|
|
18
|
-
name = traversal_1.Traversal.
|
|
18
|
+
name = traversal_1.Traversal.escapeNamespace(name);
|
|
19
19
|
ret += `class ${name} {\n`;
|
|
20
20
|
ret += `static INTERNAL_TYPE = 'INTF';\n`;
|
|
21
21
|
ret += `static IMPLEMENTED_INTERFACES = [${def === null || def === void 0 ? void 0 : def.getImplementing().map(e => `"` + e.name.toUpperCase() + `"`).join(",")}];\n`;
|
|
@@ -33,7 +33,7 @@ class InterfaceTranspiler {
|
|
|
33
33
|
if (idef === undefined) {
|
|
34
34
|
return "";
|
|
35
35
|
}
|
|
36
|
-
const prefix = traversal_1.Traversal.
|
|
36
|
+
const prefix = traversal_1.Traversal.escapeNamespace(idef.getName().toLowerCase()) + ".";
|
|
37
37
|
let ret = "";
|
|
38
38
|
for (const ty of idef.getTypeDefinitions().getAll()) {
|
|
39
39
|
ret += new transpile_types_1.TranspileTypes().declareStaticSkipVoid(prefix, ty.type);
|
|
@@ -56,7 +56,7 @@ class InterfaceTranspiler {
|
|
|
56
56
|
|| identifier.getMeta().includes("read_only" /* abaplint.IdentifierMeta.ReadOnly */) === false) {
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
|
-
const interfaceName = traversal_1.Traversal.
|
|
59
|
+
const interfaceName = traversal_1.Traversal.escapeNamespace(node.getFirstToken().getStr().toLowerCase());
|
|
60
60
|
const name = interfaceName + "." + interfaceName + "$" + n.toLowerCase();
|
|
61
61
|
ret += name + " = " + new transpile_types_1.TranspileTypes().toType(identifier.getType()) + ";\n";
|
|
62
62
|
const constantStatement = traversal.findStatementInFile(identifier.getStart());
|
package/build/src/traversal.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class Traversal {
|
|
|
8
8
|
readonly reg: abaplint.IRegistry;
|
|
9
9
|
readonly runtimeTypeError: boolean;
|
|
10
10
|
constructor(spaghetti: abaplint.ISpaghettiScope, file: abaplint.ABAPFile, obj: abaplint.ABAPObject, reg: abaplint.IRegistry, runtimeTypeError?: boolean);
|
|
11
|
-
static
|
|
11
|
+
static escapeNamespace(name: string | undefined): string | undefined;
|
|
12
12
|
getCurrentObject(): abaplint.ABAPObject;
|
|
13
13
|
traverse(node: abaplint.INode | undefined): Chunk;
|
|
14
14
|
getFilename(): string;
|
package/build/src/traversal.js
CHANGED
|
@@ -17,7 +17,7 @@ class Traversal {
|
|
|
17
17
|
this.reg = reg;
|
|
18
18
|
this.runtimeTypeError = runtimeTypeError;
|
|
19
19
|
}
|
|
20
|
-
static
|
|
20
|
+
static escapeNamespace(name) {
|
|
21
21
|
return name === null || name === void 0 ? void 0 : name.replace(/\//g, "$");
|
|
22
22
|
}
|
|
23
23
|
getCurrentObject() {
|
|
@@ -125,23 +125,23 @@ class Traversal {
|
|
|
125
125
|
const found = this.reg.findObjectForFile(file);
|
|
126
126
|
if (found) {
|
|
127
127
|
if (found instanceof abaplint.Objects.Interface) {
|
|
128
|
-
return Traversal.
|
|
128
|
+
return Traversal.escapeNamespace(this.lookupClassOrInterface(found.getName(), t)) + "." + found.getName().toLowerCase() + "$" + name;
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
|
-
return Traversal.
|
|
131
|
+
return Traversal.escapeNamespace(this.lookupClassOrInterface(found.getName(), t)) + "." + name;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
const className = this.isStaticClassAttribute(t);
|
|
137
137
|
if (className) {
|
|
138
|
-
name = Traversal.
|
|
138
|
+
name = Traversal.escapeNamespace(className) + "." + name;
|
|
139
139
|
}
|
|
140
140
|
else if (name === "super") {
|
|
141
141
|
return name;
|
|
142
142
|
}
|
|
143
143
|
else if (this.isClassAttribute(t)) {
|
|
144
|
-
name = "this." + Traversal.
|
|
144
|
+
name = "this." + Traversal.escapeNamespace(name);
|
|
145
145
|
}
|
|
146
146
|
else if (this.isBuiltinVariable(t)) {
|
|
147
147
|
name = "abap.builtin." + name;
|
|
@@ -257,14 +257,14 @@ class Traversal {
|
|
|
257
257
|
&& def.getMethodDefinitions().getByName("CONSTRUCTOR") === undefined) {
|
|
258
258
|
ret += `await super.constructor_(INPUT);\n`;
|
|
259
259
|
}
|
|
260
|
-
const cName = Traversal.
|
|
260
|
+
const cName = Traversal.escapeNamespace(def.getName().toLowerCase());
|
|
261
261
|
ret += "this.me = new abap.types.ABAPObject();\n";
|
|
262
262
|
ret += "this.me.set(this);\n";
|
|
263
263
|
for (const a of def.getAttributes().getAll()) {
|
|
264
264
|
if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
|
|
265
265
|
continue;
|
|
266
266
|
}
|
|
267
|
-
const name = "this." + a.getName().toLowerCase();
|
|
267
|
+
const name = "this." + Traversal.escapeNamespace(a.getName().toLowerCase());
|
|
268
268
|
ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
|
|
269
269
|
ret += this.setValues(a, name);
|
|
270
270
|
}
|
|
@@ -274,11 +274,11 @@ class Traversal {
|
|
|
274
274
|
}
|
|
275
275
|
// handle aliases after initialization of carrier variables
|
|
276
276
|
for (const a of def.getAliases().getAll()) {
|
|
277
|
-
ret += "this." + a.getName().toLowerCase() + " = this." + Traversal.
|
|
277
|
+
ret += "this." + a.getName().toLowerCase() + " = this." + Traversal.escapeNamespace(a.getComponent().replace("~", "$").toLowerCase()) + ";\n";
|
|
278
278
|
}
|
|
279
279
|
// constants can be accessed both statically and via reference
|
|
280
280
|
for (const c of def.getAttributes().getConstants()) {
|
|
281
|
-
ret += "this." + c.getName().toLowerCase() + " = " + cName + "." + c.getName().toLowerCase() + ";\n";
|
|
281
|
+
ret += "this." + Traversal.escapeNamespace(c.getName().toLowerCase()) + " = " + cName + "." + Traversal.escapeNamespace(c.getName().toLowerCase()) + ";\n";
|
|
282
282
|
}
|
|
283
283
|
return ret;
|
|
284
284
|
}
|
|
@@ -312,7 +312,7 @@ class Traversal {
|
|
|
312
312
|
if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
|
|
313
313
|
continue;
|
|
314
314
|
}
|
|
315
|
-
const n = Traversal.
|
|
315
|
+
const n = Traversal.escapeNamespace(name.toLowerCase()) + "$" + a.getName().toLowerCase();
|
|
316
316
|
ret += "this." + n + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
|
|
317
317
|
}
|
|
318
318
|
for (const i of (intf === null || intf === void 0 ? void 0 : intf.getImplementing()) || []) {
|
|
@@ -403,10 +403,10 @@ class Traversal {
|
|
|
403
403
|
const name = def.getName();
|
|
404
404
|
if (def.isGlobal() === false) {
|
|
405
405
|
const prefix = this.buildPrefix(def);
|
|
406
|
-
return `abap.Classes['${prefix}-${name.toUpperCase()}'] = ${Traversal.
|
|
406
|
+
return `abap.Classes['${prefix}-${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
|
|
407
407
|
}
|
|
408
408
|
else {
|
|
409
|
-
return `abap.Classes['${name.toUpperCase()}'] = ${Traversal.
|
|
409
|
+
return `abap.Classes['${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
setValues(identifier, name) {
|
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)) {
|
|
@@ -128,9 +128,9 @@ async function run() {
|
|
|
128
128
|
// todo, fix, there might be global test methods
|
|
129
129
|
continue;
|
|
130
130
|
}
|
|
131
|
-
ret += ` {
|
|
132
|
-
const {${def.name}} = await import("./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs");
|
|
133
|
-
locl = clas.addTestClass("${def.name}");
|
|
131
|
+
ret += ` {
|
|
132
|
+
const {${def.name}} = await import("./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs");
|
|
133
|
+
locl = clas.addTestClass("${def.name}");
|
|
134
134
|
if (${def.name}.class_setup) await ${def.name}.class_setup();\n`;
|
|
135
135
|
for (const m of def.methods) {
|
|
136
136
|
if (m.isForTesting === false) {
|
|
@@ -157,24 +157,24 @@ async function run() {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
ret += `// -------------------END-------------------
|
|
161
|
-
console.log(abap.console.get());
|
|
162
|
-
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
163
|
-
} catch (e) {
|
|
164
|
-
if (meth) {
|
|
165
|
-
meth.fail();
|
|
166
|
-
}
|
|
167
|
-
console.log(abap.console.get());
|
|
168
|
-
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
169
|
-
throw e;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
run().then(() => {
|
|
174
|
-
process.exit(0);
|
|
175
|
-
}).catch((err) => {
|
|
176
|
-
console.log(err);
|
|
177
|
-
process.exit(1);
|
|
160
|
+
ret += `// -------------------END-------------------
|
|
161
|
+
console.log(abap.console.get());
|
|
162
|
+
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
163
|
+
} catch (e) {
|
|
164
|
+
if (meth) {
|
|
165
|
+
meth.fail();
|
|
166
|
+
}
|
|
167
|
+
console.log(abap.console.get());
|
|
168
|
+
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
169
|
+
throw e;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
run().then(() => {
|
|
174
|
+
process.exit(0);
|
|
175
|
+
}).catch((err) => {
|
|
176
|
+
console.log(err);
|
|
177
|
+
process.exit(1);
|
|
178
178
|
});`;
|
|
179
179
|
return ret;
|
|
180
180
|
}
|
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.89",
|
|
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.7",
|
|
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
|
+
}
|