@abaplint/transpiler-cli 2.11.0 → 2.11.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.
- package/build/bundle.js +103 -12
- package/package.json +3 -3
package/build/bundle.js
CHANGED
|
@@ -19800,6 +19800,12 @@ class BuiltInMethod extends _identifier_1.Identifier {
|
|
|
19800
19800
|
getAll() {
|
|
19801
19801
|
throw new Error("BuiltInMethod->getAll, Method not implemented");
|
|
19802
19802
|
}
|
|
19803
|
+
getEventName() {
|
|
19804
|
+
return undefined;
|
|
19805
|
+
}
|
|
19806
|
+
getEventClass() {
|
|
19807
|
+
return undefined;
|
|
19808
|
+
}
|
|
19803
19809
|
getImporting() {
|
|
19804
19810
|
const ret = [];
|
|
19805
19811
|
for (const i in this.method.mandatory) {
|
|
@@ -38747,10 +38753,14 @@ class EventDefinition extends _identifier_1.Identifier {
|
|
|
38747
38753
|
super(found.getFirstToken(), input.filename);
|
|
38748
38754
|
this.parameters = [];
|
|
38749
38755
|
this.parse(node, input);
|
|
38756
|
+
this.is_static = node.getFirstToken().getStr().toUpperCase() === "CLASS";
|
|
38750
38757
|
}
|
|
38751
38758
|
getParameters() {
|
|
38752
38759
|
return this.parameters;
|
|
38753
38760
|
}
|
|
38761
|
+
isStatic() {
|
|
38762
|
+
return this.is_static;
|
|
38763
|
+
}
|
|
38754
38764
|
///////////////
|
|
38755
38765
|
parse(node, input) {
|
|
38756
38766
|
for (const e of node.findAllExpressions(expressions_1.MethodParam)) {
|
|
@@ -39170,7 +39180,7 @@ const _reference_1 = __webpack_require__(/*! ../5_syntax/_reference */ "./node_m
|
|
|
39170
39180
|
class MethodDefinition extends _identifier_1.Identifier {
|
|
39171
39181
|
// todo: final flag
|
|
39172
39182
|
constructor(node, visibility, input) {
|
|
39173
|
-
var _a, _b;
|
|
39183
|
+
var _a, _b, _c, _d;
|
|
39174
39184
|
if (!(node.get() instanceof statements_1.MethodDef)) {
|
|
39175
39185
|
throw new Error("MethodDefinition, expected MethodDef as part of input node");
|
|
39176
39186
|
}
|
|
@@ -39192,8 +39202,11 @@ class MethodDefinition extends _identifier_1.Identifier {
|
|
|
39192
39202
|
}
|
|
39193
39203
|
}
|
|
39194
39204
|
this.eventHandler = false;
|
|
39195
|
-
|
|
39205
|
+
const handler = node.findDirectExpression(Expressions.EventHandler);
|
|
39206
|
+
if (handler) {
|
|
39196
39207
|
this.eventHandler = true;
|
|
39208
|
+
this.eventName = (_a = handler.findDirectExpression(Expressions.EventName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
39209
|
+
this.eventClass = (_b = handler.findDirectExpression(Expressions.ClassName)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase();
|
|
39197
39210
|
}
|
|
39198
39211
|
this.abstract = false;
|
|
39199
39212
|
if (node.findDirectExpression(Expressions.Abstract)) {
|
|
@@ -39205,7 +39218,7 @@ class MethodDefinition extends _identifier_1.Identifier {
|
|
|
39205
39218
|
this.static = true;
|
|
39206
39219
|
}
|
|
39207
39220
|
this.raising = [];
|
|
39208
|
-
for (const r of ((
|
|
39221
|
+
for (const r of ((_c = node.findDirectExpression(Expressions.MethodDefRaising)) === null || _c === void 0 ? void 0 : _c.findAllExpressions(Expressions.ClassName)) || []) {
|
|
39209
39222
|
const token = r.getFirstToken();
|
|
39210
39223
|
const name = token.getStr();
|
|
39211
39224
|
this.raising.push(name);
|
|
@@ -39221,7 +39234,7 @@ class MethodDefinition extends _identifier_1.Identifier {
|
|
|
39221
39234
|
}
|
|
39222
39235
|
}
|
|
39223
39236
|
this.exceptions = [];
|
|
39224
|
-
for (const r of ((
|
|
39237
|
+
for (const r of ((_d = node.findDirectExpression(Expressions.MethodDefExceptions)) === null || _d === void 0 ? void 0 : _d.findAllExpressions(Expressions.NamespaceSimpleName)) || []) {
|
|
39225
39238
|
const token = r.getFirstToken();
|
|
39226
39239
|
const name = token.getStr();
|
|
39227
39240
|
this.exceptions.push(name);
|
|
@@ -39247,6 +39260,12 @@ class MethodDefinition extends _identifier_1.Identifier {
|
|
|
39247
39260
|
isEventHandler() {
|
|
39248
39261
|
return this.eventHandler;
|
|
39249
39262
|
}
|
|
39263
|
+
getEventName() {
|
|
39264
|
+
return this.eventName;
|
|
39265
|
+
}
|
|
39266
|
+
getEventClass() {
|
|
39267
|
+
return this.eventClass;
|
|
39268
|
+
}
|
|
39250
39269
|
getParameters() {
|
|
39251
39270
|
return this.parameters;
|
|
39252
39271
|
}
|
|
@@ -53585,7 +53604,7 @@ class Registry {
|
|
|
53585
53604
|
}
|
|
53586
53605
|
static abaplintVersion() {
|
|
53587
53606
|
// magic, see build script "version.sh"
|
|
53588
|
-
return "2.113.
|
|
53607
|
+
return "2.113.151";
|
|
53589
53608
|
}
|
|
53590
53609
|
getDDICReferences() {
|
|
53591
53610
|
return this.ddicReferences;
|
|
@@ -86259,11 +86278,19 @@ exports.RaiseTranspiler = RaiseTranspiler;
|
|
|
86259
86278
|
|
|
86260
86279
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
86261
86280
|
exports.RaiseEventTranspiler = void 0;
|
|
86281
|
+
const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
|
|
86282
|
+
const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
|
|
86262
86283
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
86284
|
+
const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
|
|
86263
86285
|
class RaiseEventTranspiler {
|
|
86264
86286
|
transpile(node, traversal) {
|
|
86265
|
-
|
|
86266
|
-
|
|
86287
|
+
const eventName = traversal_1.Traversal.escapeNamespace(node.findFirstExpression(abaplint.Expressions.EventName)?.concatTokens())?.toLowerCase().replace("~", "$");
|
|
86288
|
+
const parameters = node.findFirstExpression(abaplint.Expressions.ParameterListS);
|
|
86289
|
+
let extra = "";
|
|
86290
|
+
if (parameters) {
|
|
86291
|
+
extra = "," + new expressions_1.ParameterListSTranspiler().transpile(parameters, traversal).getCode();
|
|
86292
|
+
}
|
|
86293
|
+
return new chunk_1.Chunk().append(`await abap.statements.raiseEvent(this.${eventName}, this.me${extra});`, node, traversal);
|
|
86267
86294
|
}
|
|
86268
86295
|
}
|
|
86269
86296
|
exports.RaiseEventTranspiler = RaiseEventTranspiler;
|
|
@@ -87092,20 +87119,62 @@ const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/
|
|
|
87092
87119
|
class SetHandlerTranspiler {
|
|
87093
87120
|
transpile(node, traversal) {
|
|
87094
87121
|
const methods = [];
|
|
87122
|
+
let className = undefined;
|
|
87123
|
+
let eventName = undefined;
|
|
87095
87124
|
for (const m of node.findDirectExpressions(abaplint.Expressions.MethodSource)) {
|
|
87096
|
-
methods.push(new expressions_1.MethodSourceTranspiler().transpile(m, traversal).getCode());
|
|
87125
|
+
methods.push(new expressions_1.MethodSourceTranspiler().transpile(m, traversal).getCode().replace("await ", ""));
|
|
87126
|
+
if (className === undefined) {
|
|
87127
|
+
const nameToken = m.getFirstToken();
|
|
87128
|
+
const scope = traversal.findCurrentScopeByToken(nameToken);
|
|
87129
|
+
const method = traversal.findMethodReference(nameToken, scope);
|
|
87130
|
+
if (method?.def.isEventHandler() !== true) {
|
|
87131
|
+
throw new Error(`SetHandlerTranspiler: Method "${nameToken.getStr()}" is not an event handler`);
|
|
87132
|
+
}
|
|
87133
|
+
const def = traversal.findClassDefinition(method.def.getClassName(), scope);
|
|
87134
|
+
if (def === undefined) {
|
|
87135
|
+
throw new Error(`SetHandlerTranspiler: Class "${method.def.getClassName()}" not found`);
|
|
87136
|
+
}
|
|
87137
|
+
eventName = method.def.getEventName();
|
|
87138
|
+
className = this.findEventClass(def, eventName, traversal, scope);
|
|
87139
|
+
}
|
|
87097
87140
|
}
|
|
87098
87141
|
let f = undefined;
|
|
87099
87142
|
const forExpression = node.findExpressionAfterToken("FOR");
|
|
87100
|
-
if (forExpression) {
|
|
87143
|
+
if (forExpression instanceof abaplint.Expressions.Source) {
|
|
87101
87144
|
f = new expressions_1.SourceTranspiler().transpile(forExpression, traversal).getCode();
|
|
87102
87145
|
}
|
|
87103
|
-
|
|
87146
|
+
else {
|
|
87147
|
+
f = `"ALL"`;
|
|
87148
|
+
}
|
|
87149
|
+
let activation = "";
|
|
87104
87150
|
const activationExpression = node.findExpressionAfterToken("ACTIVATION");
|
|
87105
87151
|
if (activationExpression) {
|
|
87106
|
-
activation = new expressions_1.SourceTranspiler().transpile(activationExpression, traversal).getCode();
|
|
87152
|
+
activation = ", " + new expressions_1.SourceTranspiler().transpile(activationExpression, traversal).getCode();
|
|
87153
|
+
}
|
|
87154
|
+
return new chunk_1.Chunk().append(`abap.statements.setHandler({EVENT_NAME: "${eventName}", EVENT_CLASS: "${className}"}, [${methods.join(",")}], ${f}${activation});`, node, traversal);
|
|
87155
|
+
}
|
|
87156
|
+
findEventClass(def, eventName, traversal, scope) {
|
|
87157
|
+
let current = def;
|
|
87158
|
+
while (current !== undefined) {
|
|
87159
|
+
for (const event of current.getEvents()) {
|
|
87160
|
+
if (event.getName().toUpperCase() === eventName?.toUpperCase()) {
|
|
87161
|
+
return traversal.buildInternalName(current.getName(), current);
|
|
87162
|
+
}
|
|
87163
|
+
}
|
|
87164
|
+
for (const implementing of current.getImplementing()) {
|
|
87165
|
+
const idef = traversal.findInterfaceDefinition(implementing.name, scope);
|
|
87166
|
+
if (idef === undefined) {
|
|
87167
|
+
continue;
|
|
87168
|
+
}
|
|
87169
|
+
for (const event of idef.getEvents()) {
|
|
87170
|
+
if (event.getName().toUpperCase() === eventName?.toUpperCase()) {
|
|
87171
|
+
return traversal.buildInternalName(idef.getName(), idef);
|
|
87172
|
+
}
|
|
87173
|
+
}
|
|
87174
|
+
}
|
|
87175
|
+
current = traversal.findClassDefinition(current.getSuperClass(), scope);
|
|
87107
87176
|
}
|
|
87108
|
-
|
|
87177
|
+
throw new Error(`Transpiler: Event "${eventName}" not found in class "${def.getName()}"`);
|
|
87109
87178
|
}
|
|
87110
87179
|
}
|
|
87111
87180
|
exports.SetHandlerTranspiler = SetHandlerTranspiler;
|
|
@@ -89901,6 +89970,7 @@ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
|
|
|
89901
89970
|
for (const i of def.getImplementing()) {
|
|
89902
89971
|
ret += this.dataFromInterfaces(i.name, scope, cName);
|
|
89903
89972
|
ret += this.aliasesFromInterfaces(i.name, scope, cName);
|
|
89973
|
+
ret += this.eventsFromInterfaces(i.name, scope);
|
|
89904
89974
|
}
|
|
89905
89975
|
// handle aliases after initialization of carrier variables
|
|
89906
89976
|
for (const a of def.getAliases() || []) {
|
|
@@ -89910,6 +89980,27 @@ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
|
|
|
89910
89980
|
for (const c of def.getAttributes()?.getConstants() || []) {
|
|
89911
89981
|
ret += "this." + Traversal.escapeNamespace(c.getName().toLowerCase()) + " = " + cName + "." + Traversal.escapeNamespace(c.getName().toLowerCase()) + ";\n";
|
|
89912
89982
|
}
|
|
89983
|
+
for (const e of def.getEvents() || []) {
|
|
89984
|
+
const name = this.buildInternalName(def.getName(), def);
|
|
89985
|
+
ret += "this." + Traversal.escapeNamespace(e.getName().toLowerCase()) + " = {\"EVENT_NAME\": \"" + e.getName().toUpperCase() + "\", \"EVENT_CLASS\": \"" + name + "\"};\n";
|
|
89986
|
+
}
|
|
89987
|
+
return ret;
|
|
89988
|
+
}
|
|
89989
|
+
eventsFromInterfaces(name, scope) {
|
|
89990
|
+
let ret = "";
|
|
89991
|
+
const intf = this.findInterfaceDefinition(name, scope);
|
|
89992
|
+
if (intf === undefined) {
|
|
89993
|
+
return ret;
|
|
89994
|
+
}
|
|
89995
|
+
for (const e of intf.getEvents() || []) {
|
|
89996
|
+
const fname = Traversal.escapeNamespace(e.getName().toLowerCase());
|
|
89997
|
+
const iname = Traversal.escapeNamespace(intf?.getName().toLowerCase());
|
|
89998
|
+
const name = this.buildInternalName(intf.getName(), intf);
|
|
89999
|
+
ret += "this." + iname + "$" + fname + " = {\"EVENT_NAME\": \"" + e.getName().toUpperCase() + "\", \"EVENT_CLASS\": \"" + name + "\"};\n";
|
|
90000
|
+
}
|
|
90001
|
+
for (const i of intf.getImplementing() || []) {
|
|
90002
|
+
ret += this.eventsFromInterfaces(i.name, scope);
|
|
90003
|
+
}
|
|
89913
90004
|
return ret;
|
|
89914
90005
|
}
|
|
89915
90006
|
findInterfaceDefinition(name, scope) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.1",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"author": "abaplint",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@abaplint/core": "^2.113.
|
|
31
|
-
"@abaplint/transpiler": "^2.11.
|
|
30
|
+
"@abaplint/core": "^2.113.151",
|
|
31
|
+
"@abaplint/transpiler": "^2.11.1",
|
|
32
32
|
"@types/glob": "^8.1.0",
|
|
33
33
|
"@types/node": "^22.17.0",
|
|
34
34
|
"@types/progress": "^2.0.7",
|