@abaplint/transpiler 2.13.81 → 2.13.83
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/statements/commit.js +45 -1
- package/build/src/statements/data.js +8 -1
- package/build/src/statements/insert_database.d.ts +1 -1
- package/build/src/statements/insert_database.js +16 -4
- package/build/src/statements/open_cursor.js +2 -2
- package/build/src/statements/rollback.js +42 -1
- package/build/src/structures/class_implementation.js +4 -2
- package/build/src/transpile_types.d.ts +3 -1
- package/build/src/transpile_types.js +4 -3
- package/package.json +1 -1
|
@@ -1,10 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.CommitTranspiler = void 0;
|
|
37
|
+
const abaplint = __importStar(require("@abaplint/core"));
|
|
4
38
|
const chunk_1 = require("../chunk");
|
|
39
|
+
const insert_database_1 = require("./insert_database");
|
|
5
40
|
class CommitTranspiler {
|
|
6
41
|
transpile(node, traversal) {
|
|
7
|
-
|
|
42
|
+
const options = [];
|
|
43
|
+
const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
|
|
44
|
+
if (connection) {
|
|
45
|
+
options.push(`"connection": ${(0, insert_database_1.findConnection)(connection, traversal)}`);
|
|
46
|
+
}
|
|
47
|
+
else if (node.findTokenSequencePosition("AND", "WAIT")) {
|
|
48
|
+
options.push(`"wait": true`);
|
|
49
|
+
}
|
|
50
|
+
const opt = options.length === 0 ? "" : `{${options.join(", ")}}`;
|
|
51
|
+
return new chunk_1.Chunk().append(`await abap.statements.commit(${opt});`, node, traversal);
|
|
8
52
|
}
|
|
9
53
|
}
|
|
10
54
|
exports.CommitTranspiler = CommitTranspiler;
|
|
@@ -92,12 +92,19 @@ class DataTranspiler {
|
|
|
92
92
|
value = "\n" + traversal_1.Traversal.prefixVariable(found.getName().toLowerCase()) + ".set(\"" + enumDefault + "\");";
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
+
let packedDecimals;
|
|
96
|
+
if (found.getType() instanceof abaplint.BasicTypes.PackedType) {
|
|
97
|
+
const decimals = node.findFirstExpression(abaplint.Expressions.Decimals)?.findFirstExpression(abaplint.Expressions.Integer);
|
|
98
|
+
if (decimals) {
|
|
99
|
+
packedDecimals = parseInt(decimals.concatTokens(), 10);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
95
102
|
this.variableName = traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(found.getName().toLowerCase()));
|
|
96
103
|
this.loopScoped = traversal.isInsideLoop(node);
|
|
97
104
|
const ret = new chunk_1.Chunk()
|
|
98
105
|
.appendString(this.loopScoped === true ? "var " : "let ")
|
|
99
106
|
.appendString(this.variableName)
|
|
100
|
-
.appendString(" = " + transpile_types_1.TranspileTypes.toType(found.getType()))
|
|
107
|
+
.appendString(" = " + transpile_types_1.TranspileTypes.toType(found.getType(), { packedDecimals }))
|
|
101
108
|
.appendString(";")
|
|
102
109
|
.appendString(value);
|
|
103
110
|
if (this.loopScoped === true && this.skipLoopScoping === false) {
|
|
@@ -5,4 +5,4 @@ import { Chunk } from "../chunk";
|
|
|
5
5
|
export declare class InsertDatabaseTranspiler implements IStatementTranspiler {
|
|
6
6
|
transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal): Chunk;
|
|
7
7
|
}
|
|
8
|
-
export declare function findConnection(connection: abaplint.Nodes.ExpressionNode): string;
|
|
8
|
+
export declare function findConnection(connection: abaplint.Nodes.ExpressionNode, traversal: Traversal): string;
|
|
@@ -63,19 +63,31 @@ class InsertDatabaseTranspiler {
|
|
|
63
63
|
}
|
|
64
64
|
const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
|
|
65
65
|
if (connection) {
|
|
66
|
-
const con = findConnection(connection);
|
|
67
|
-
options.push(`"connection":
|
|
66
|
+
const con = findConnection(connection, traversal);
|
|
67
|
+
options.push(`"connection": ${con}`);
|
|
68
68
|
}
|
|
69
69
|
return new chunk_1.Chunk(`await abap.statements.insertDatabase(${table.getCode()}, {${options.join(", ")}});`);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
exports.InsertDatabaseTranspiler = InsertDatabaseTranspiler;
|
|
73
|
-
function findConnection(connection) {
|
|
73
|
+
function findConnection(connection, traversal) {
|
|
74
|
+
const dynamic = connection.findDirectExpression(abaplint.Expressions.Dynamic);
|
|
75
|
+
if (dynamic) {
|
|
76
|
+
const field = dynamic.findFirstExpression(abaplint.Expressions.FieldChain);
|
|
77
|
+
if (field === undefined) {
|
|
78
|
+
throw new Error("findConnection: dynamic connection name not found");
|
|
79
|
+
}
|
|
80
|
+
const value = traversal.traverse(field).getCode();
|
|
81
|
+
return `${value}.get().trimEnd().toUpperCase()`;
|
|
82
|
+
}
|
|
74
83
|
let con = connection.getLastToken().getStr().toUpperCase();
|
|
84
|
+
if (con.startsWith("'") && con.endsWith("'")) {
|
|
85
|
+
con = con.substring(1, con.length - 1).replace(/''/g, "'");
|
|
86
|
+
}
|
|
75
87
|
if (con === "DEFAULT_") {
|
|
76
88
|
// todo, workaround for replacing of keywords,
|
|
77
89
|
con = "DEFAULT";
|
|
78
90
|
}
|
|
79
|
-
return con;
|
|
91
|
+
return JSON.stringify(con);
|
|
80
92
|
}
|
|
81
93
|
//# sourceMappingURL=insert_database.js.map
|
|
@@ -66,8 +66,8 @@ class OpenCursorTranspiler {
|
|
|
66
66
|
const options = [];
|
|
67
67
|
const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
|
|
68
68
|
if (connection) {
|
|
69
|
-
const con = (0, insert_database_1.findConnection)(connection);
|
|
70
|
-
options.push(`"connection":
|
|
69
|
+
const con = (0, insert_database_1.findConnection)(connection, traversal);
|
|
70
|
+
options.push(`"connection": ${con}`);
|
|
71
71
|
}
|
|
72
72
|
return new chunk_1.Chunk().append(`await abap.statements.openCursor(${target}, "${select}", {${options.join(", ")}});`, node, traversal);
|
|
73
73
|
}
|
|
@@ -1,10 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.RollbackTranspiler = void 0;
|
|
37
|
+
const abaplint = __importStar(require("@abaplint/core"));
|
|
4
38
|
const chunk_1 = require("../chunk");
|
|
39
|
+
const insert_database_1 = require("./insert_database");
|
|
5
40
|
class RollbackTranspiler {
|
|
6
41
|
transpile(node, traversal) {
|
|
7
|
-
|
|
42
|
+
const options = [];
|
|
43
|
+
const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
|
|
44
|
+
if (connection) {
|
|
45
|
+
options.push(`"connection": ${(0, insert_database_1.findConnection)(connection, traversal)}`);
|
|
46
|
+
}
|
|
47
|
+
const opt = options.length === 0 ? "" : `{${options.join(", ")}}`;
|
|
48
|
+
return new chunk_1.Chunk().append(`await abap.statements.rollback(${opt});`, node, traversal);
|
|
8
49
|
}
|
|
9
50
|
}
|
|
10
51
|
exports.RollbackTranspiler = RollbackTranspiler;
|
|
@@ -144,11 +144,13 @@ class ClassImplementationTranspiler {
|
|
|
144
144
|
ret += traversal.setValues(attr.identifier, name);
|
|
145
145
|
}
|
|
146
146
|
for (const alias of cdef.getAliases()) {
|
|
147
|
-
|
|
147
|
+
// note: the component is the raw source casing, so compare case insensitive
|
|
148
|
+
const component = alias.getComponent().toLowerCase();
|
|
149
|
+
const isStatic = staticAttributes.some(s => (s.prefix.replace("$", "~") + s.identifier.getName()).toLowerCase() === component);
|
|
148
150
|
if (isStatic === false) {
|
|
149
151
|
continue;
|
|
150
152
|
}
|
|
151
|
-
ret += traversal_1.Traversal.escapeNamespace(clasName) + "." + alias.getName().toLowerCase() + " = " + traversal_1.Traversal.escapeNamespace(clasName) + "." + traversal_1.Traversal.escapeNamespace(
|
|
153
|
+
ret += traversal_1.Traversal.escapeNamespace(clasName) + "." + alias.getName().toLowerCase() + " = " + traversal_1.Traversal.escapeNamespace(clasName) + "." + traversal_1.Traversal.escapeNamespace(component.replace("~", "$")) + ";\n";
|
|
152
154
|
}
|
|
153
155
|
for (const e of cdef.getEvents()) {
|
|
154
156
|
if (e.isStatic() === false) {
|
|
@@ -4,5 +4,7 @@ export declare class TranspileTypes {
|
|
|
4
4
|
static declareStaticSkipVoid(pre: string, t: abaplint.TypedIdentifier): string;
|
|
5
5
|
/** this returns a function, so it doesnt throw when loading the code, only when running */
|
|
6
6
|
static toTypeFunction(type: abaplint.AbstractType): string;
|
|
7
|
-
static toType(type: abaplint.AbstractType
|
|
7
|
+
static toType(type: abaplint.AbstractType, options?: {
|
|
8
|
+
packedDecimals?: number;
|
|
9
|
+
}): string;
|
|
8
10
|
}
|
|
@@ -62,7 +62,7 @@ class TranspileTypes {
|
|
|
62
62
|
// return singleton,
|
|
63
63
|
return "(() => { let _t; return () => (_t ??= " + this.toType(type) + "); })()";
|
|
64
64
|
}
|
|
65
|
-
static toType(type) {
|
|
65
|
+
static toType(type, options) {
|
|
66
66
|
let resolved = "";
|
|
67
67
|
let extra = "";
|
|
68
68
|
if (type instanceof abaplint.BasicTypes.ObjectReferenceType
|
|
@@ -185,11 +185,12 @@ class TranspileTypes {
|
|
|
185
185
|
}
|
|
186
186
|
else if (type instanceof abaplint.BasicTypes.PackedType) {
|
|
187
187
|
resolved = "Packed";
|
|
188
|
+
const decimals = options?.packedDecimals ?? type.getDecimals();
|
|
188
189
|
if (type.getQualifiedName()) {
|
|
189
|
-
extra = "{length: " + type.getLength() + ", decimals: " +
|
|
190
|
+
extra = "{length: " + type.getLength() + ", decimals: " + decimals + ", qualifiedName: \"" + type.getQualifiedName() + "\"}";
|
|
190
191
|
}
|
|
191
192
|
else {
|
|
192
|
-
extra = "{length: " + type.getLength() + ", decimals: " +
|
|
193
|
+
extra = "{length: " + type.getLength() + ", decimals: " + decimals + "}";
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
else if (type instanceof abaplint.BasicTypes.NumericGenericType) {
|