@abaplint/transpiler 2.0.8 → 2.0.9
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.
|
@@ -3,5 +3,7 @@ import { IExpressionTranspiler } from "./_expression_transpiler";
|
|
|
3
3
|
import { Traversal } from "../traversal";
|
|
4
4
|
import { Chunk } from "../chunk";
|
|
5
5
|
export declare class SimpleSource3Transpiler implements IExpressionTranspiler {
|
|
6
|
+
private readonly addGet;
|
|
7
|
+
constructor(addGet?: boolean);
|
|
6
8
|
transpile(node: Nodes.ExpressionNode, traversal: Traversal): Chunk;
|
|
7
9
|
}
|
|
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SimpleSource3Transpiler = void 0;
|
|
4
4
|
const source_1 = require("./source");
|
|
5
5
|
class SimpleSource3Transpiler {
|
|
6
|
+
constructor(addGet = false) {
|
|
7
|
+
this.addGet = addGet;
|
|
8
|
+
}
|
|
6
9
|
transpile(node, traversal) {
|
|
7
|
-
return new source_1.SourceTranspiler().transpile(node, traversal);
|
|
10
|
+
return new source_1.SourceTranspiler(this.addGet).transpile(node, traversal);
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
13
|
exports.SimpleSource3Transpiler = SimpleSource3Transpiler;
|
|
@@ -13,7 +13,7 @@ class SelectTranspiler {
|
|
|
13
13
|
select += ((_b = node.findFirstExpression(abaplint.Expressions.SQLFrom)) === null || _b === void 0 ? void 0 : _b.concatTokens()) + " ";
|
|
14
14
|
const where = node.findFirstExpression(abaplint.Expressions.SQLCond);
|
|
15
15
|
if (where) {
|
|
16
|
-
select += "WHERE " +
|
|
16
|
+
select += "WHERE " + this.concatCond(where, traversal) + " ";
|
|
17
17
|
}
|
|
18
18
|
const orderBy = node.findFirstExpression(abaplint.Expressions.SQLOrderBy);
|
|
19
19
|
if (orderBy) {
|
|
@@ -36,6 +36,23 @@ class SelectTranspiler {
|
|
|
36
36
|
}
|
|
37
37
|
return new chunk_1.Chunk().append(`await abap.statements.select(${target}, {select: "${select.trim()}"});`, node, traversal);
|
|
38
38
|
}
|
|
39
|
+
concatCond(cond, traversal) {
|
|
40
|
+
let ret = "";
|
|
41
|
+
for (const c of cond.getChildren()) {
|
|
42
|
+
if (c.get() instanceof abaplint.Expressions.SimpleSource3
|
|
43
|
+
&& c instanceof abaplint.Nodes.ExpressionNode
|
|
44
|
+
&& c.findDirectExpression(abaplint.Expressions.Constant) === undefined) {
|
|
45
|
+
ret += " '\" + " + new expressions_1.SimpleSource3Transpiler(true).transpile(c, traversal).getCode() + " + \"'";
|
|
46
|
+
}
|
|
47
|
+
else if (c instanceof abaplint.Nodes.ExpressionNode) {
|
|
48
|
+
ret += " " + this.concatCond(c, traversal);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
ret += " " + c.concatTokens();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return ret.trim();
|
|
55
|
+
}
|
|
39
56
|
}
|
|
40
57
|
exports.SelectTranspiler = SelectTranspiler;
|
|
41
58
|
//# sourceMappingURL=select.js.map
|
|
@@ -3,22 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WaitTranspiler = void 0;
|
|
4
4
|
const abaplint = require("@abaplint/core");
|
|
5
5
|
const chunk_1 = require("../chunk");
|
|
6
|
+
const expressions_1 = require("../expressions");
|
|
6
7
|
class WaitTranspiler {
|
|
7
8
|
transpile(node, traversal) {
|
|
9
|
+
const options = [];
|
|
10
|
+
const seconds = node.findExpressionAfterToken("TO");
|
|
11
|
+
if (seconds) {
|
|
12
|
+
options.push("seconds: " + traversal.traverse(seconds).getCode());
|
|
13
|
+
}
|
|
8
14
|
const concat = node.concatTokens().toUpperCase();
|
|
9
|
-
if (concat.includes("
|
|
10
|
-
|
|
15
|
+
if (concat.includes(" UNTIL ") === false && seconds) {
|
|
16
|
+
const sec = new expressions_1.SourceTranspiler(true).transpile(seconds, traversal).getCode();
|
|
17
|
+
return new chunk_1.Chunk().appendString(`await new Promise(r => setTimeout(r, ${sec} * 1000));`);
|
|
11
18
|
}
|
|
12
19
|
const lookup = traversal.lookupClassOrInterface("KERNEL_PUSH_CHANNELS", node.getFirstToken());
|
|
13
|
-
const options = [];
|
|
14
20
|
const cond = node.findFirstExpression(abaplint.Expressions.Cond);
|
|
15
21
|
if (cond) {
|
|
16
22
|
options.push("cond: " + traversal.traverse(cond).getCode());
|
|
17
23
|
}
|
|
18
|
-
const seconds = node.findExpressionAfterToken("TO");
|
|
19
|
-
if (seconds) {
|
|
20
|
-
options.push("seconds: " + traversal.traverse(seconds).getCode());
|
|
21
|
-
}
|
|
22
24
|
const call = `await ${lookup}.wait({${options.join(",")}});`;
|
|
23
25
|
return new chunk_1.Chunk().append(`if (${lookup} === undefined) throw new Error("Wait, kernel class missing");\n${call}`, node, traversal);
|
|
24
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
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.
|
|
31
|
+
"@abaplint/core": "^2.89.0",
|
|
32
32
|
"source-map": "^0.7.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|