@abaplint/transpiler 1.7.15 → 1.7.16
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.
|
@@ -10,8 +10,9 @@ class ConstantTranspiler {
|
|
|
10
10
|
transpile(node, traversal) {
|
|
11
11
|
const int = node.findFirstExpression(core_1.Expressions.Integer);
|
|
12
12
|
if (int) {
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const concat = int.concatTokens().trim();
|
|
14
|
+
const post = concat.startsWith("-") ? "minus_" : "";
|
|
15
|
+
let ret = "constant_" + post + int.getLastToken().getStr();
|
|
15
16
|
if (this.addGet === true) {
|
|
16
17
|
ret += ".get()";
|
|
17
18
|
}
|
package/build/src/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export declare class Transpiler {
|
|
|
55
55
|
runRaw(files: IFile[]): Promise<IOutput>;
|
|
56
56
|
run(reg: abaplint.IRegistry, progress?: IProgress): Promise<IOutput>;
|
|
57
57
|
protected handleConstants(obj: abaplint.ABAPObject, file: abaplint.ABAPFile, reg: abaplint.IRegistry): string;
|
|
58
|
-
protected findConstants(obj: abaplint.ABAPObject, file: abaplint.ABAPFile, reg: abaplint.IRegistry): Set<
|
|
58
|
+
protected findConstants(obj: abaplint.ABAPObject, file: abaplint.ABAPFile, reg: abaplint.IRegistry): Set<string>;
|
|
59
59
|
protected runObject(obj: abaplint.ABAPObject, reg: abaplint.IRegistry): IOutputFile[];
|
|
60
60
|
/** merges the locals def and imp into one mjs file */
|
|
61
61
|
private rearrangeClassLocals;
|
package/build/src/index.js
CHANGED
|
@@ -62,9 +62,9 @@ class Transpiler {
|
|
|
62
62
|
let result = "";
|
|
63
63
|
const constants = this.findConstants(obj, file, reg);
|
|
64
64
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.skipConstants) === false || ((_b = this.options) === null || _b === void 0 ? void 0 : _b.skipConstants) === undefined) {
|
|
65
|
-
for (const
|
|
66
|
-
const post =
|
|
67
|
-
result += `const constant_${post}${
|
|
65
|
+
for (const concat of Array.from(constants).sort()) {
|
|
66
|
+
const post = concat.startsWith("-") ? "minus_" : "";
|
|
67
|
+
result += `const constant_${post}${concat.replace("-", "")} = new abap.types.Integer().set(${concat});\n`;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
return result;
|
|
@@ -73,8 +73,7 @@ class Transpiler {
|
|
|
73
73
|
var _a, _b;
|
|
74
74
|
let constants = new Set();
|
|
75
75
|
for (const i of ((_a = file.getStructure()) === null || _a === void 0 ? void 0 : _a.findAllExpressions(abaplint.Expressions.Integer)) || []) {
|
|
76
|
-
|
|
77
|
-
constants.add(j);
|
|
76
|
+
constants.add(i.concatTokens().replace(" ", ""));
|
|
78
77
|
}
|
|
79
78
|
// extra constants from interfaces, used for default values
|
|
80
79
|
if (obj.getType() === "CLAS") {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SelectTranspiler = 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 SelectTranspiler {
|
|
7
8
|
transpile(node, traversal) {
|
|
8
9
|
var _a, _b;
|
|
@@ -10,6 +11,14 @@ class SelectTranspiler {
|
|
|
10
11
|
let select = "SELECT ";
|
|
11
12
|
select += ((_a = node.findFirstExpression(abaplint.Expressions.SQLFieldList)) === null || _a === void 0 ? void 0 : _a.concatTokens()) + " ";
|
|
12
13
|
select += ((_b = node.findFirstExpression(abaplint.Expressions.SQLFrom)) === null || _b === void 0 ? void 0 : _b.concatTokens()) + " ";
|
|
14
|
+
for (const d of node.findAllExpressionsRecursive(abaplint.Expressions.Dynamic)) {
|
|
15
|
+
const chain = d.findFirstExpression(abaplint.Expressions.FieldChain);
|
|
16
|
+
if (chain) {
|
|
17
|
+
const code = new expressions_1.FieldChainTranspiler(true).transpile(chain, traversal).getCode();
|
|
18
|
+
const search = d.concatTokens();
|
|
19
|
+
select = select.replace(search, `" + ${code} + "`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
13
22
|
if (node.concatTokens().toUpperCase().startsWith("SELECT SINGLE ")) {
|
|
14
23
|
select += "LIMIT 1";
|
|
15
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.16",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@types/chai": "^4.3.0",
|
|
35
35
|
"@types/mocha": "^9.0.0",
|
|
36
36
|
"chai": "^4.3.4",
|
|
37
|
-
"mocha": "^9.1.
|
|
37
|
+
"mocha": "^9.1.4",
|
|
38
38
|
"source-map-support": "^0.5.21",
|
|
39
39
|
"typescript": "^4.5.4"
|
|
40
40
|
}
|