@abaplint/transpiler 2.6.44 → 2.7.1
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.
|
@@ -134,6 +134,11 @@ class MethodImplementationTranspiler {
|
|
|
134
134
|
const method = this.findMethod(methodName, classDef, traversal);
|
|
135
135
|
let staticMethod = "";
|
|
136
136
|
methodName = methodName.replace("~", "$").toLowerCase();
|
|
137
|
+
if (methodName === "then") {
|
|
138
|
+
// todo, this should be a checked in the validation step, but no abaplint rule for it?
|
|
139
|
+
// it messes up promises when "this" is returned
|
|
140
|
+
throw new Error(`Method name "then" not allowed`);
|
|
141
|
+
}
|
|
137
142
|
const superDef = traversal.findClassDefinition(classDef === null || classDef === void 0 ? void 0 : classDef.getSuperClass(), scope);
|
|
138
143
|
for (const a of (superDef === null || superDef === void 0 ? void 0 : superDef.getAliases().getAll()) || []) {
|
|
139
144
|
if (a.getName().toLowerCase() === methodName) {
|
|
@@ -15,6 +15,7 @@ class SelectTranspiler {
|
|
|
15
15
|
var _a;
|
|
16
16
|
let target = "undefined";
|
|
17
17
|
if (targetOverride) {
|
|
18
|
+
// SelectLoop structure uses override
|
|
18
19
|
target = targetOverride;
|
|
19
20
|
}
|
|
20
21
|
else if (node.findFirstExpression(abaplint.Expressions.SQLIntoTable)) {
|
|
@@ -76,8 +77,12 @@ class SelectTranspiler {
|
|
|
76
77
|
select += "UP TO 1 ROWS";
|
|
77
78
|
}
|
|
78
79
|
let runtimeOptions = "";
|
|
80
|
+
const runtimeOptionsList = [];
|
|
79
81
|
if (node.concatTokens().toUpperCase().includes(" APPENDING TABLE ")) {
|
|
80
|
-
|
|
82
|
+
runtimeOptionsList.push(`appending: true`);
|
|
83
|
+
}
|
|
84
|
+
if (runtimeOptionsList.length > 0) {
|
|
85
|
+
runtimeOptions = `, {` + runtimeOptionsList.join(", ") + `}`;
|
|
81
86
|
}
|
|
82
87
|
let extra = "";
|
|
83
88
|
const keys = this.findKeys(node, traversal);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SelectTranspiler = void 0;
|
|
4
|
+
/* eslint-disable max-len */
|
|
4
5
|
const abaplint = require("@abaplint/core");
|
|
5
6
|
const select_1 = require("../statements/select");
|
|
6
7
|
const chunk_1 = require("../chunk");
|
|
@@ -8,7 +9,7 @@ const unique_identifier_1 = require("../unique_identifier");
|
|
|
8
9
|
const expressions_1 = require("../expressions");
|
|
9
10
|
class SelectTranspiler {
|
|
10
11
|
transpile(node, traversal) {
|
|
11
|
-
var _a;
|
|
12
|
+
var _a, _b;
|
|
12
13
|
const ret = new chunk_1.Chunk();
|
|
13
14
|
const selectStatement = node.findFirstStatement(abaplint.Statements.SelectLoop);
|
|
14
15
|
if (selectStatement === undefined) {
|
|
@@ -22,11 +23,21 @@ class SelectTranspiler {
|
|
|
22
23
|
const loopName = unique_identifier_1.UniqueIdentifier.get();
|
|
23
24
|
ret.appendString(`let ${targetName} = new abap.types.Table(abap.DDIC["${from}"].type);\n`);
|
|
24
25
|
ret.appendChunk(new select_1.SelectTranspiler().transpile(selectStatement, traversal, targetName));
|
|
25
|
-
|
|
26
|
-
if (
|
|
26
|
+
const packageSize = (_b = node.findFirstExpression(abaplint.Expressions.SelectLoop)) === null || _b === void 0 ? void 0 : _b.findExpressionAfterToken("SIZE");
|
|
27
|
+
if (packageSize) {
|
|
28
|
+
const getSize = new expressions_1.SQLSourceTranspiler().transpile(packageSize, traversal).getCode() + ".get()";
|
|
29
|
+
ret.appendString(`if (${targetName}.array().length > ${getSize}) {
|
|
30
|
+
throw new Error("PACKAGE SIZED loop larger than package size not supported");
|
|
31
|
+
};
|
|
32
|
+
abap.statements.append({source: ${targetName}, target: ${intoName}, lines: true});
|
|
33
|
+
{\n`);
|
|
34
|
+
}
|
|
35
|
+
else if (concat.includes(" INTO CORRESPONDING FIELDS OF ")) {
|
|
36
|
+
ret.appendString(`\nfor (const ${loopName} of ${targetName}.array()) {\n`);
|
|
27
37
|
ret.appendString(`abap.statements.moveCorresponding(${loopName}, ${intoName});\n`);
|
|
28
38
|
}
|
|
29
39
|
else {
|
|
40
|
+
ret.appendString(`\nfor (const ${loopName} of ${targetName}.array()) {\n`);
|
|
30
41
|
ret.appendString(`${intoName}.set(${loopName});\n`);
|
|
31
42
|
}
|
|
32
43
|
const body = node.findDirectStructure(abaplint.Structures.Body);
|
package/build/src/traversal.js
CHANGED
|
@@ -340,10 +340,12 @@ class Traversal {
|
|
|
340
340
|
ret += "this.me = new abap.types.ABAPObject();\n";
|
|
341
341
|
ret += "this.me.set(this);\n";
|
|
342
342
|
for (const a of ((_a = def.getAttributes()) === null || _a === void 0 ? void 0 : _a.getAll()) || []) {
|
|
343
|
+
const escaped = Traversal.escapeNamespace(a.getName().toLowerCase());
|
|
343
344
|
if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
|
|
345
|
+
ret += "this." + escaped + " = " + cName + "." + escaped + ";\n";
|
|
344
346
|
continue;
|
|
345
347
|
}
|
|
346
|
-
const name = "this." +
|
|
348
|
+
const name = "this." + escaped;
|
|
347
349
|
ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
|
|
348
350
|
ret += this.setValues(a, name);
|
|
349
351
|
}
|
package/build/src/unit_test.js
CHANGED
|
@@ -165,13 +165,11 @@ async function run() {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
ret += `// -------------------END-------------------
|
|
168
|
-
console.log(abap.console.get());
|
|
169
168
|
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
170
169
|
} catch (e) {
|
|
171
170
|
if (meth) {
|
|
172
171
|
meth.fail();
|
|
173
172
|
}
|
|
174
|
-
console.log(abap.console.get());
|
|
175
173
|
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
176
174
|
throw e;
|
|
177
175
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
7
|
+
"funding": "https://github.com/sponsors/larshp",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
"author": "abaplint",
|
|
29
30
|
"license": "MIT",
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@abaplint/core": "^2.
|
|
32
|
+
"@abaplint/core": "^2.100.3",
|
|
32
33
|
"source-map": "^0.7.4"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|