@abaplint/transpiler 1.7.22 → 1.7.26
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/expressions/method_source.js +13 -1
- package/build/src/handle_data_element.d.ts +5 -0
- package/build/src/handle_data_element.js +31 -0
- package/build/src/handle_table_type.d.ts +5 -0
- package/build/src/handle_table_type.js +31 -0
- package/build/src/index.js +8 -0
- package/build/src/statements/create_data.js +9 -1
- package/build/src/transpile_types.js +3 -0
- package/build/src/unit_test.js +6 -0
- package/package.json +2 -2
|
@@ -13,7 +13,7 @@ class MethodSourceTranspiler {
|
|
|
13
13
|
if (child.get() instanceof core_1.Expressions.ClassName) {
|
|
14
14
|
ret.appendString(traversal.lookupClassOrInterface(child.concatTokens(), child.getFirstToken()));
|
|
15
15
|
}
|
|
16
|
-
else if (child.get() instanceof core_1.Expressions.Dynamic && nextChild.concatTokens() === "=>") {
|
|
16
|
+
else if (child.get() instanceof core_1.Expressions.Dynamic && (nextChild === null || nextChild === void 0 ? void 0 : nextChild.concatTokens()) === "=>") {
|
|
17
17
|
const second = child.getChildren()[1];
|
|
18
18
|
if (second.get() instanceof core_1.Expressions.FieldChain) {
|
|
19
19
|
ret.appendChunk(traversal.traverse(second));
|
|
@@ -30,6 +30,18 @@ class MethodSourceTranspiler {
|
|
|
30
30
|
ret.appendString("MethodSourceTranspiler-Unexpected");
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
else if (child.get() instanceof core_1.Expressions.Dynamic) {
|
|
34
|
+
const second = child.getChildren()[1];
|
|
35
|
+
if (second.get() instanceof core_1.Expressions.FieldChain) {
|
|
36
|
+
ret.appendChunk(traversal.traverse(second));
|
|
37
|
+
}
|
|
38
|
+
else if (second.get() instanceof core_1.Expressions.Constant) {
|
|
39
|
+
ret.appendString(second.getFirstToken().getStr().replace(/\'/g, "").toLowerCase().replace("~", "$"));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
ret.appendString("MethodSourceTranspiler-Unexpected");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
33
45
|
else if (child.get() instanceof core_1.Expressions.MethodName) {
|
|
34
46
|
const methodName = child.concatTokens().toLowerCase().replace("~", "$");
|
|
35
47
|
ret.append(methodName, child.getFirstToken().getStart(), traversal);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HandleDataElement = void 0;
|
|
4
|
+
const chunk_1 = require("./chunk");
|
|
5
|
+
const transpile_types_1 = require("./transpile_types");
|
|
6
|
+
class HandleDataElement {
|
|
7
|
+
runObject(obj, reg) {
|
|
8
|
+
var _a;
|
|
9
|
+
const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
|
|
10
|
+
if (filename === undefined) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const type = obj.parseType(reg);
|
|
14
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
15
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
16
|
+
};`);
|
|
17
|
+
const output = {
|
|
18
|
+
object: {
|
|
19
|
+
name: obj.getName(),
|
|
20
|
+
type: obj.getType(),
|
|
21
|
+
},
|
|
22
|
+
filename: filename,
|
|
23
|
+
chunk: chunk,
|
|
24
|
+
requires: [],
|
|
25
|
+
exports: [],
|
|
26
|
+
};
|
|
27
|
+
return [output];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.HandleDataElement = HandleDataElement;
|
|
31
|
+
//# sourceMappingURL=handle_data_element.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HandleTableType = void 0;
|
|
4
|
+
const chunk_1 = require("./chunk");
|
|
5
|
+
const transpile_types_1 = require("./transpile_types");
|
|
6
|
+
class HandleTableType {
|
|
7
|
+
runObject(obj, reg) {
|
|
8
|
+
var _a;
|
|
9
|
+
const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
|
|
10
|
+
if (filename === undefined) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const type = obj.parseType(reg);
|
|
14
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
15
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
16
|
+
};`);
|
|
17
|
+
const output = {
|
|
18
|
+
object: {
|
|
19
|
+
name: obj.getName(),
|
|
20
|
+
type: obj.getType(),
|
|
21
|
+
},
|
|
22
|
+
filename: filename,
|
|
23
|
+
chunk: chunk,
|
|
24
|
+
requires: [],
|
|
25
|
+
exports: [],
|
|
26
|
+
};
|
|
27
|
+
return [output];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.HandleTableType = HandleTableType;
|
|
31
|
+
//# sourceMappingURL=handle_table_type.js.map
|
package/build/src/index.js
CHANGED
|
@@ -9,6 +9,8 @@ const keywords_1 = require("./keywords");
|
|
|
9
9
|
const database_setup_1 = require("./database_setup");
|
|
10
10
|
const handle_table_1 = require("./handle_table");
|
|
11
11
|
const handle_abap_1 = require("./handle_abap");
|
|
12
|
+
const handle_data_element_1 = require("./handle_data_element");
|
|
13
|
+
const handle_table_type_1 = require("./handle_table_type");
|
|
12
14
|
class Transpiler {
|
|
13
15
|
constructor(options) {
|
|
14
16
|
this.options = options;
|
|
@@ -55,6 +57,12 @@ class Transpiler {
|
|
|
55
57
|
else if (obj instanceof abaplint.Objects.Table) {
|
|
56
58
|
output.objects.push(...new handle_table_1.HandleTable().runObject(obj, reg));
|
|
57
59
|
}
|
|
60
|
+
else if (obj instanceof abaplint.Objects.DataElement) {
|
|
61
|
+
output.objects.push(...new handle_data_element_1.HandleDataElement().runObject(obj, reg));
|
|
62
|
+
}
|
|
63
|
+
else if (obj instanceof abaplint.Objects.TableType) {
|
|
64
|
+
output.objects.push(...new handle_table_type_1.HandleTableType().runObject(obj, reg));
|
|
65
|
+
}
|
|
58
66
|
}
|
|
59
67
|
return output;
|
|
60
68
|
}
|
|
@@ -4,9 +4,10 @@ exports.CreateDataTranspiler = void 0;
|
|
|
4
4
|
const abaplint = require("@abaplint/core");
|
|
5
5
|
const chunk_1 = require("../chunk");
|
|
6
6
|
const expressions_1 = require("../expressions");
|
|
7
|
+
const transpile_types_1 = require("../transpile_types");
|
|
7
8
|
class CreateDataTranspiler {
|
|
8
9
|
transpile(node, traversal) {
|
|
9
|
-
var _a, _b;
|
|
10
|
+
var _a, _b, _c;
|
|
10
11
|
const targetNode = node.findDirectExpression(abaplint.Expressions.Target);
|
|
11
12
|
const target = traversal.traverse(targetNode);
|
|
12
13
|
const options = [];
|
|
@@ -20,6 +21,13 @@ class CreateDataTranspiler {
|
|
|
20
21
|
options.push(`"name": ` + new expressions_1.FieldChainTranspiler(true).transpile(dynamic, traversal).getCode());
|
|
21
22
|
}
|
|
22
23
|
}
|
|
24
|
+
const typeNameNode = node.findDirectExpression(abaplint.Expressions.TypeName);
|
|
25
|
+
if (typeNameNode) {
|
|
26
|
+
const id = (_c = traversal.findCurrentScopeByToken(typeNameNode.getFirstToken())) === null || _c === void 0 ? void 0 : _c.findType(typeNameNode.concatTokens());
|
|
27
|
+
if (id) {
|
|
28
|
+
options.push(`"type": ` + new transpile_types_1.TranspileTypes().toType(id.getType()));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
23
31
|
if (node.findDirectTokenByText("TABLE")) {
|
|
24
32
|
options.push(`"table": true`);
|
|
25
33
|
}
|
|
@@ -42,6 +42,9 @@ class TranspileTypes {
|
|
|
42
42
|
list.push(c.name.toLowerCase() + ": " + this.toType(c.type));
|
|
43
43
|
}
|
|
44
44
|
extra = "{" + list.join(", ") + "}";
|
|
45
|
+
if (type.getQualifiedName() !== undefined) {
|
|
46
|
+
extra += ", \"" + type.getQualifiedName() + "\"";
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
else if (type instanceof abaplint.BasicTypes.CLikeType
|
|
47
50
|
|| type instanceof abaplint.BasicTypes.CSequenceType) {
|
package/build/src/unit_test.js
CHANGED
|
@@ -106,6 +106,12 @@ run().then(() => {
|
|
|
106
106
|
if (obj instanceof abaplint.Objects.Table) {
|
|
107
107
|
list.push(`await import("./${obj.getName().toLowerCase()}.tabl.mjs");`);
|
|
108
108
|
}
|
|
109
|
+
else if (obj instanceof abaplint.Objects.DataElement) {
|
|
110
|
+
list.push(`await import("./${obj.getName().toLowerCase()}.dtel.mjs");`);
|
|
111
|
+
}
|
|
112
|
+
else if (obj instanceof abaplint.Objects.TableType) {
|
|
113
|
+
list.push(`await import("./${obj.getName().toLowerCase()}.ttyp.mjs");`);
|
|
114
|
+
}
|
|
109
115
|
}
|
|
110
116
|
for (const obj of reg.getObjects()) {
|
|
111
117
|
if (obj instanceof abaplint.Objects.FunctionGroup) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.26",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"chai": "^4.3.4",
|
|
37
37
|
"mocha": "^9.1.4",
|
|
38
38
|
"source-map-support": "^0.5.21",
|
|
39
|
-
"typescript": "^4.5.
|
|
39
|
+
"typescript": "^4.5.5"
|
|
40
40
|
}
|
|
41
41
|
}
|