@abaplint/transpiler 2.7.73 → 2.7.75
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/database_table.js +5 -14
- package/build/src/expressions/sql_from_source.js +1 -1
- package/build/src/structures/case_type.d.ts +7 -0
- package/build/src/structures/case_type.js +56 -0
- package/build/src/structures/index.d.ts +1 -0
- package/build/src/structures/index.js +1 -0
- package/package.json +2 -2
|
@@ -12,32 +12,23 @@ class DatabaseTableTranspiler {
|
|
|
12
12
|
const concat = node.concatTokens();
|
|
13
13
|
let val = "";
|
|
14
14
|
if (this.prefix === true) {
|
|
15
|
-
val = `
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
val = "\"";
|
|
15
|
+
val = `abap.buildDbTableName(`;
|
|
19
16
|
}
|
|
20
17
|
const dyn = node.findDirectExpression(abaplint.Expressions.Dynamic);
|
|
21
18
|
if (dyn) {
|
|
22
19
|
if (concat.startsWith("('")) {
|
|
23
|
-
val += concat.substring(2, concat.length - 2).toLowerCase()
|
|
20
|
+
val += `"` + concat.substring(2, concat.length - 2).toLowerCase() + `"`;
|
|
24
21
|
}
|
|
25
22
|
else {
|
|
26
23
|
const foo = traversal.traverse(dyn.findDirectExpression(abaplint.Expressions.FieldChain));
|
|
27
|
-
|
|
28
|
-
return foo;
|
|
29
|
-
}
|
|
30
|
-
val += "\" + " + foo.getCode() + ".get().trimEnd().toLowerCase() + \"";
|
|
24
|
+
val += foo.getCode() + ".get().trimEnd().toLowerCase()";
|
|
31
25
|
}
|
|
32
26
|
}
|
|
33
27
|
else {
|
|
34
|
-
val += concat.toLowerCase()
|
|
28
|
+
val += `"` + concat.toLowerCase() + `"`;
|
|
35
29
|
}
|
|
36
30
|
if (this.prefix === true) {
|
|
37
|
-
val +=
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
val += "\"";
|
|
31
|
+
val += `)`;
|
|
41
32
|
}
|
|
42
33
|
return chunk.appendString(val);
|
|
43
34
|
}
|
|
@@ -14,7 +14,7 @@ class SQLFromSourceTranspiler {
|
|
|
14
14
|
chunk.appendString(concat + " ");
|
|
15
15
|
}
|
|
16
16
|
else if (c.get() instanceof abaplint.Expressions.DatabaseTable) {
|
|
17
|
-
chunk.
|
|
17
|
+
chunk.appendString(`" + ` + new database_table_1.DatabaseTableTranspiler().transpile(c, traversal).getCode() + ` + "`);
|
|
18
18
|
chunk.appendString(" ");
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { IStructureTranspiler } from "./_structure_transpiler";
|
|
3
|
+
import { Traversal } from "../traversal";
|
|
4
|
+
import { Chunk } from "../chunk";
|
|
5
|
+
export declare class CaseTypeTranspiler implements IStructureTranspiler {
|
|
6
|
+
transpile(node: abaplint.Nodes.StructureNode, traversal: Traversal): Chunk;
|
|
7
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CaseTypeTranspiler = void 0;
|
|
4
|
+
const abaplint = require("@abaplint/core");
|
|
5
|
+
const unique_identifier_1 = require("../unique_identifier");
|
|
6
|
+
const chunk_1 = require("../chunk");
|
|
7
|
+
class CaseTypeTranspiler {
|
|
8
|
+
transpile(node, traversal) {
|
|
9
|
+
var _a;
|
|
10
|
+
// does not use switch(), as it break;'s EXITs
|
|
11
|
+
const s = (_a = node.findDirectStatement(abaplint.Statements.CaseType)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(abaplint.Expressions.Source);
|
|
12
|
+
if (s === undefined) {
|
|
13
|
+
throw new Error("CASE TYPE, no Source found");
|
|
14
|
+
}
|
|
15
|
+
let first = true;
|
|
16
|
+
const u = unique_identifier_1.UniqueIdentifier.get();
|
|
17
|
+
const ret = new chunk_1.Chunk();
|
|
18
|
+
// this determines and copies the value
|
|
19
|
+
ret.append("let " + u + " = ", node, traversal);
|
|
20
|
+
ret.appendChunk(traversal.traverse(s));
|
|
21
|
+
ret.append(";\n", node, traversal);
|
|
22
|
+
for (const w of node.findDirectStructures(abaplint.Structures.WhenType)) {
|
|
23
|
+
for (const c of w.getChildren()) {
|
|
24
|
+
if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.WhenType) {
|
|
25
|
+
if (first === true) {
|
|
26
|
+
first = false;
|
|
27
|
+
ret.appendString("if (");
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
ret.appendString("} else if (");
|
|
31
|
+
}
|
|
32
|
+
const cname = c.findDirectExpression(abaplint.Expressions.ClassName);
|
|
33
|
+
const lookup = traversal.lookupClassOrInterface(cname === null || cname === void 0 ? void 0 : cname.concatTokens(), cname === null || cname === void 0 ? void 0 : cname.getFirstToken());
|
|
34
|
+
ret.appendString(u + ".get() instanceof " + lookup);
|
|
35
|
+
ret.appendString(") {\n");
|
|
36
|
+
ret.appendString(traversal.traverse(c.findDirectExpression(abaplint.Expressions.Target)).getCode() + ".set(" + u + ")\n");
|
|
37
|
+
}
|
|
38
|
+
else if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.WhenOthers) {
|
|
39
|
+
if (first === true) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
ret.appendString("} else {\n");
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
ret.appendChunk(traversal.traverse(c)); // Normal
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (first === false) {
|
|
50
|
+
ret.appendString("}\n");
|
|
51
|
+
}
|
|
52
|
+
return ret;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.CaseTypeTranspiler = CaseTypeTranspiler;
|
|
56
|
+
//# sourceMappingURL=case_type.js.map
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./case"), exports);
|
|
18
|
+
__exportStar(require("./case_type"), exports);
|
|
18
19
|
__exportStar(require("./class_definition"), exports);
|
|
19
20
|
__exportStar(require("./class_implementation"), exports);
|
|
20
21
|
__exportStar(require("./constants"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.75",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"author": "abaplint",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@abaplint/core": "^2.102.
|
|
32
|
+
"@abaplint/core": "^2.102.23",
|
|
33
33
|
"source-map": "^0.7.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|