@abaplint/transpiler-cli 2.11.0 → 2.11.2
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 +95 -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,54 @@ const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/
|
|
|
87092
87119
|
class SetHandlerTranspiler {
|
|
87093
87120
|
transpile(node, traversal) {
|
|
87094
87121
|
const methods = [];
|
|
87122
|
+
let eventClass = 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 (eventClass === 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
|
+
eventName = method.def.getEventName();
|
|
87134
|
+
eventClass = this.findEventClass(method.def, traversal, scope);
|
|
87135
|
+
// className = method.def.getEventClass();
|
|
87136
|
+
// this.findEventClass(def, eventName, traversal, scope);
|
|
87137
|
+
}
|
|
87097
87138
|
}
|
|
87098
87139
|
let f = undefined;
|
|
87099
87140
|
const forExpression = node.findExpressionAfterToken("FOR");
|
|
87100
|
-
if (forExpression) {
|
|
87141
|
+
if (forExpression instanceof abaplint.Expressions.Source) {
|
|
87101
87142
|
f = new expressions_1.SourceTranspiler().transpile(forExpression, traversal).getCode();
|
|
87102
87143
|
}
|
|
87103
|
-
|
|
87144
|
+
else {
|
|
87145
|
+
f = `"ALL"`;
|
|
87146
|
+
}
|
|
87147
|
+
let activation = "";
|
|
87104
87148
|
const activationExpression = node.findExpressionAfterToken("ACTIVATION");
|
|
87105
87149
|
if (activationExpression) {
|
|
87106
|
-
activation = new expressions_1.SourceTranspiler().transpile(activationExpression, traversal).getCode();
|
|
87150
|
+
activation = ", " + new expressions_1.SourceTranspiler().transpile(activationExpression, traversal).getCode();
|
|
87107
87151
|
}
|
|
87108
|
-
return new chunk_1.Chunk().append(`abap.statements.setHandler([${methods.join(",")}], ${f}
|
|
87152
|
+
return new chunk_1.Chunk().append(`abap.statements.setHandler({EVENT_NAME: "${eventName}", EVENT_CLASS: "${eventClass}"}, [${methods.join(",")}], ${f}${activation});`, node, traversal);
|
|
87153
|
+
}
|
|
87154
|
+
findEventClass(mdef, traversal, scope) {
|
|
87155
|
+
let def = traversal.findClassDefinition(mdef.getEventClass(), scope);
|
|
87156
|
+
if (def === undefined) {
|
|
87157
|
+
def = traversal.findInterfaceDefinition(mdef.getEventClass(), scope);
|
|
87158
|
+
}
|
|
87159
|
+
// look through super classes
|
|
87160
|
+
while (def?.getSuperClass() !== undefined) {
|
|
87161
|
+
if (def.getEvents().find(e => e.getName().toUpperCase() === mdef.getEventName()?.toUpperCase())) {
|
|
87162
|
+
break;
|
|
87163
|
+
}
|
|
87164
|
+
def = traversal.findClassDefinition(def.getSuperClass(), scope);
|
|
87165
|
+
}
|
|
87166
|
+
if (def === undefined) {
|
|
87167
|
+
throw new Error(`SetHandlerTranspiler: findEventClass "${mdef.getEventClass()}" not found`);
|
|
87168
|
+
}
|
|
87169
|
+
return traversal.buildInternalName(def.getName(), def);
|
|
87109
87170
|
}
|
|
87110
87171
|
}
|
|
87111
87172
|
exports.SetHandlerTranspiler = SetHandlerTranspiler;
|
|
@@ -89901,6 +89962,7 @@ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
|
|
|
89901
89962
|
for (const i of def.getImplementing()) {
|
|
89902
89963
|
ret += this.dataFromInterfaces(i.name, scope, cName);
|
|
89903
89964
|
ret += this.aliasesFromInterfaces(i.name, scope, cName);
|
|
89965
|
+
ret += this.eventsFromInterfaces(i.name, scope);
|
|
89904
89966
|
}
|
|
89905
89967
|
// handle aliases after initialization of carrier variables
|
|
89906
89968
|
for (const a of def.getAliases() || []) {
|
|
@@ -89910,6 +89972,27 @@ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
|
|
|
89910
89972
|
for (const c of def.getAttributes()?.getConstants() || []) {
|
|
89911
89973
|
ret += "this." + Traversal.escapeNamespace(c.getName().toLowerCase()) + " = " + cName + "." + Traversal.escapeNamespace(c.getName().toLowerCase()) + ";\n";
|
|
89912
89974
|
}
|
|
89975
|
+
for (const e of def.getEvents() || []) {
|
|
89976
|
+
const name = this.buildInternalName(def.getName(), def);
|
|
89977
|
+
ret += "this." + Traversal.escapeNamespace(e.getName().toLowerCase()) + " = {\"EVENT_NAME\": \"" + e.getName().toUpperCase() + "\", \"EVENT_CLASS\": \"" + name + "\"};\n";
|
|
89978
|
+
}
|
|
89979
|
+
return ret;
|
|
89980
|
+
}
|
|
89981
|
+
eventsFromInterfaces(name, scope) {
|
|
89982
|
+
let ret = "";
|
|
89983
|
+
const intf = this.findInterfaceDefinition(name, scope);
|
|
89984
|
+
if (intf === undefined) {
|
|
89985
|
+
return ret;
|
|
89986
|
+
}
|
|
89987
|
+
for (const e of intf.getEvents() || []) {
|
|
89988
|
+
const fname = Traversal.escapeNamespace(e.getName().toLowerCase());
|
|
89989
|
+
const iname = Traversal.escapeNamespace(intf?.getName().toLowerCase());
|
|
89990
|
+
const name = this.buildInternalName(intf.getName(), intf);
|
|
89991
|
+
ret += "this." + iname + "$" + fname + " = {\"EVENT_NAME\": \"" + e.getName().toUpperCase() + "\", \"EVENT_CLASS\": \"" + name + "\"};\n";
|
|
89992
|
+
}
|
|
89993
|
+
for (const i of intf.getImplementing() || []) {
|
|
89994
|
+
ret += this.eventsFromInterfaces(i.name, scope);
|
|
89995
|
+
}
|
|
89913
89996
|
return ret;
|
|
89914
89997
|
}
|
|
89915
89998
|
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.2",
|
|
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.2",
|
|
32
32
|
"@types/glob": "^8.1.0",
|
|
33
33
|
"@types/node": "^22.17.0",
|
|
34
34
|
"@types/progress": "^2.0.7",
|