@abaplint/transpiler 2.7.165 → 2.8.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/src/db/index.js +2 -3
- package/build/src/db/schema_generation/pg_database_schema.js +1 -1
- package/build/src/db/schema_generation/snowflake_database_schema.js +1 -1
- package/build/src/db/schema_generation/sqlite_database_schema.js +1 -1
- package/build/src/expressions/call_transformation_parameters.js +1 -2
- package/build/src/expressions/compare.js +2 -3
- package/build/src/expressions/component_compare.js +2 -2
- package/build/src/expressions/constant.js +6 -1
- package/build/src/expressions/method_call.js +3 -4
- package/build/src/expressions/method_call_param.js +2 -3
- package/build/src/expressions/method_source.js +1 -1
- package/build/src/expressions/parameter_s.js +2 -3
- package/build/src/expressions/parameter_t.js +2 -3
- package/build/src/expressions/sql_cond.js +2 -3
- package/build/src/expressions/sql_source.js +1 -1
- package/build/src/handlers/handle_abap.js +6 -9
- package/build/src/handlers/handle_data_element.js +1 -2
- package/build/src/handlers/handle_enqu.js +1 -2
- package/build/src/handlers/handle_msag.js +1 -2
- package/build/src/handlers/handle_oa2p.js +1 -2
- package/build/src/handlers/handle_smim.js +4 -5
- package/build/src/handlers/handle_table.js +1 -2
- package/build/src/handlers/handle_table_type.js +1 -2
- package/build/src/handlers/handle_type_pool.js +3 -4
- package/build/src/handlers/handle_view.js +1 -2
- package/build/src/handlers/handle_w3mi.js +4 -5
- package/build/src/index.js +7 -8
- package/build/src/requires.js +6 -7
- package/build/src/statements/assign.js +10 -11
- package/build/src/statements/call.js +5 -7
- package/build/src/statements/call_function.js +2 -3
- package/build/src/statements/call_transformation.js +1 -2
- package/build/src/statements/class_implementation.js +3 -4
- package/build/src/statements/concatenate.js +1 -2
- package/build/src/statements/convert.js +8 -8
- package/build/src/statements/create_data.js +3 -4
- package/build/src/statements/create_object.js +5 -7
- package/build/src/statements/data.js +1 -2
- package/build/src/statements/end_method.js +6 -7
- package/build/src/statements/field_symbol.js +1 -1
- package/build/src/statements/find.js +3 -4
- package/build/src/statements/form.js +4 -4
- package/build/src/statements/loop.js +7 -8
- package/build/src/statements/method_implementation.js +9 -11
- package/build/src/statements/move.js +1 -2
- package/build/src/statements/open_cursor.js +4 -4
- package/build/src/statements/perform.js +7 -8
- package/build/src/statements/raise.js +4 -5
- package/build/src/statements/read_table.js +3 -3
- package/build/src/statements/receive.js +1 -2
- package/build/src/statements/replace.js +1 -1
- package/build/src/statements/return.js +3 -3
- package/build/src/statements/select.js +1 -2
- package/build/src/statements/tables.js +1 -2
- package/build/src/statements/write.js +1 -2
- package/build/src/structures/at.js +7 -5
- package/build/src/structures/case.js +1 -2
- package/build/src/structures/case_type.js +2 -3
- package/build/src/structures/class_definition.js +2 -3
- package/build/src/structures/class_implementation.js +3 -5
- package/build/src/structures/constants.js +2 -3
- package/build/src/structures/data.js +2 -3
- package/build/src/structures/function_module.js +3 -5
- package/build/src/structures/interface.js +5 -6
- package/build/src/structures/loop.js +1 -2
- package/build/src/structures/select.js +2 -3
- package/build/src/structures/try.js +1 -1
- package/build/src/transpile_types.js +11 -12
- package/build/src/traversal.js +33 -38
- package/build/src/unit_test.js +2 -3
- package/build/src/validation.js +3 -4
- package/package.json +1 -1
package/build/src/traversal.js
CHANGED
|
@@ -18,7 +18,7 @@ class Traversal {
|
|
|
18
18
|
this.options = options;
|
|
19
19
|
}
|
|
20
20
|
static escapeNamespace(name) {
|
|
21
|
-
return name
|
|
21
|
+
return name?.replace(/\//g, "$");
|
|
22
22
|
}
|
|
23
23
|
getCurrentObject() {
|
|
24
24
|
return this.obj;
|
|
@@ -83,7 +83,7 @@ class Traversal {
|
|
|
83
83
|
let scope = this.findCurrentScopeByToken(token);
|
|
84
84
|
while (scope !== undefined) {
|
|
85
85
|
if (scope.getIdentifier().stype === abaplint.ScopeType.Interface) {
|
|
86
|
-
return scope.findInterfaceDefinition(scope
|
|
86
|
+
return scope.findInterfaceDefinition(scope?.getIdentifier().sname);
|
|
87
87
|
}
|
|
88
88
|
scope = scope.getParent();
|
|
89
89
|
}
|
|
@@ -94,7 +94,7 @@ class Traversal {
|
|
|
94
94
|
while (scope !== undefined) {
|
|
95
95
|
if (scope.getIdentifier().stype === abaplint.ScopeType.ClassImplementation
|
|
96
96
|
|| scope.getIdentifier().stype === abaplint.ScopeType.ClassDefinition) {
|
|
97
|
-
return scope.findClassDefinition(scope
|
|
97
|
+
return scope.findClassDefinition(scope?.getIdentifier().sname);
|
|
98
98
|
}
|
|
99
99
|
scope = scope.getParent();
|
|
100
100
|
}
|
|
@@ -201,18 +201,17 @@ class Traversal {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
buildAttributes(def, scope, prefix = "") {
|
|
204
|
-
var _a, _b;
|
|
205
204
|
const attr = [];
|
|
206
205
|
if (def === undefined) {
|
|
207
206
|
return attr;
|
|
208
207
|
}
|
|
209
|
-
for (const a of
|
|
208
|
+
for (const a of def.getAttributes()?.getAll() || []) {
|
|
210
209
|
const type = new transpile_types_1.TranspileTypes().toType(a.getType());
|
|
211
210
|
const runtime = this.mapVisibility(a.getVisibility());
|
|
212
211
|
const isClass = a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) ? "X" : " ";
|
|
213
212
|
attr.push(`"${prefix + a.getName().toUpperCase()}": {"type": () => {return ${type};}, "visibility": "${runtime}", "is_constant": " ", "is_class": "${isClass}"}`);
|
|
214
213
|
}
|
|
215
|
-
for (const a of
|
|
214
|
+
for (const a of def.getAttributes()?.getConstants() || []) {
|
|
216
215
|
const type = new transpile_types_1.TranspileTypes().toType(a.getType());
|
|
217
216
|
let runtime = "";
|
|
218
217
|
switch (a.getVisibility()) {
|
|
@@ -248,7 +247,7 @@ class Traversal {
|
|
|
248
247
|
}
|
|
249
248
|
isSQLConversion(token) {
|
|
250
249
|
const scope = this.findCurrentScopeByToken(token);
|
|
251
|
-
for (const s of
|
|
250
|
+
for (const s of scope?.getData().sqlConversion || []) {
|
|
252
251
|
if (s.token.getStart().equals(token.getStart())) {
|
|
253
252
|
return s.fieldName;
|
|
254
253
|
}
|
|
@@ -256,7 +255,6 @@ class Traversal {
|
|
|
256
255
|
return undefined;
|
|
257
256
|
}
|
|
258
257
|
findMethodReference(token, scope) {
|
|
259
|
-
var _a, _b;
|
|
260
258
|
let candidate = undefined;
|
|
261
259
|
if (scope === undefined) {
|
|
262
260
|
return undefined;
|
|
@@ -266,7 +264,7 @@ class Traversal {
|
|
|
266
264
|
&& r.position.getStart().equals(token.getStart())
|
|
267
265
|
&& r.resolved instanceof abaplint.Types.MethodDefinition) {
|
|
268
266
|
let name = r.resolved.getName();
|
|
269
|
-
if (
|
|
267
|
+
if (r.extra?.ooName && r.extra?.ooType === "INTF") {
|
|
270
268
|
name = r.extra.ooName + "$" + name;
|
|
271
269
|
}
|
|
272
270
|
candidate = { def: r.resolved, name };
|
|
@@ -300,13 +298,13 @@ class Traversal {
|
|
|
300
298
|
}
|
|
301
299
|
isTypePool(token) {
|
|
302
300
|
const ref = this.findReadOrWriteReference(token);
|
|
303
|
-
if (ref
|
|
301
|
+
if (ref?.getFilename().endsWith(".type.abap")) {
|
|
304
302
|
const file = this.reg.getFileByName(ref.getFilename());
|
|
305
303
|
if (file === undefined) {
|
|
306
304
|
return undefined;
|
|
307
305
|
}
|
|
308
306
|
const obj = this.reg.findObjectForFile(file);
|
|
309
|
-
return obj
|
|
307
|
+
return obj?.getName();
|
|
310
308
|
}
|
|
311
309
|
return undefined;
|
|
312
310
|
}
|
|
@@ -319,8 +317,8 @@ class Traversal {
|
|
|
319
317
|
// local
|
|
320
318
|
if (ref.getFilename() === this.getFilename()) {
|
|
321
319
|
const scope = this.findCurrentScopeByToken(ref.getToken());
|
|
322
|
-
if (
|
|
323
|
-
return scope
|
|
320
|
+
if (scope?.getIdentifier().stype === abaplint.ScopeType.Interface) {
|
|
321
|
+
return scope?.getIdentifier().sname;
|
|
324
322
|
}
|
|
325
323
|
}
|
|
326
324
|
// global
|
|
@@ -355,7 +353,6 @@ class Traversal {
|
|
|
355
353
|
return undefined;
|
|
356
354
|
}
|
|
357
355
|
buildConstructorContents(scope, def) {
|
|
358
|
-
var _a, _b, _c;
|
|
359
356
|
let ret = "";
|
|
360
357
|
if (def.getSuperClass() !== undefined || def.getName().toUpperCase() === "CX_ROOT") {
|
|
361
358
|
ret += "super();\n";
|
|
@@ -363,7 +360,7 @@ class Traversal {
|
|
|
363
360
|
const cName = Traversal.escapeNamespace(def.getName().toLowerCase());
|
|
364
361
|
ret += "this.me = new abap.types.ABAPObject();\n";
|
|
365
362
|
ret += "this.me.set(this);\n";
|
|
366
|
-
for (const a of
|
|
363
|
+
for (const a of def.getAttributes()?.getAll() || []) {
|
|
367
364
|
const escaped = Traversal.escapeNamespace(a.getName().toLowerCase());
|
|
368
365
|
if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
|
|
369
366
|
ret += "this." + escaped + " = " + cName + "." + escaped + ";\n";
|
|
@@ -379,20 +376,20 @@ class Traversal {
|
|
|
379
376
|
ret += this.aliasesFromInterfaces(i.name, scope, cName);
|
|
380
377
|
}
|
|
381
378
|
// handle aliases after initialization of carrier variables
|
|
382
|
-
for (const a of
|
|
379
|
+
for (const a of def.getAliases()?.getAll() || []) {
|
|
383
380
|
ret += "this." + a.getName().toLowerCase() + " = this." + Traversal.escapeNamespace(a.getComponent().replace("~", "$").toLowerCase()) + ";\n";
|
|
384
381
|
}
|
|
385
382
|
// constants can be accessed both statically and via reference
|
|
386
|
-
for (const c of
|
|
383
|
+
for (const c of def.getAttributes()?.getConstants() || []) {
|
|
387
384
|
ret += "this." + Traversal.escapeNamespace(c.getName().toLowerCase()) + " = " + cName + "." + Traversal.escapeNamespace(c.getName().toLowerCase()) + ";\n";
|
|
388
385
|
}
|
|
389
386
|
return ret;
|
|
390
387
|
}
|
|
391
388
|
findInterfaceDefinition(name, scope) {
|
|
392
|
-
let intf = scope
|
|
389
|
+
let intf = scope?.findInterfaceDefinition(name);
|
|
393
390
|
if (intf === undefined) {
|
|
394
391
|
const iglobal = this.reg.getObject("INTF", name);
|
|
395
|
-
intf = iglobal
|
|
392
|
+
intf = iglobal?.getDefinition();
|
|
396
393
|
}
|
|
397
394
|
return intf;
|
|
398
395
|
}
|
|
@@ -407,24 +404,24 @@ class Traversal {
|
|
|
407
404
|
let clas = scope.findClassDefinition(name);
|
|
408
405
|
if (clas === undefined) {
|
|
409
406
|
const iglobal = this.reg.getObject("CLAS", name);
|
|
410
|
-
clas = iglobal
|
|
407
|
+
clas = iglobal?.getDefinition();
|
|
411
408
|
}
|
|
412
409
|
return clas;
|
|
413
410
|
}
|
|
414
411
|
dataFromInterfaces(name, scope, cname) {
|
|
415
412
|
let ret = "";
|
|
416
413
|
const intf = this.findInterfaceDefinition(name, scope);
|
|
417
|
-
for (const a of
|
|
414
|
+
for (const a of intf?.getAttributes().getConstants() || []) {
|
|
418
415
|
const fname = Traversal.escapeNamespace(a.getName().toLowerCase());
|
|
419
|
-
const iname = Traversal.escapeNamespace(intf
|
|
420
|
-
if (
|
|
421
|
-
ret += "this." + iname + "$" + fname + " = abap.Classes['" +
|
|
416
|
+
const iname = Traversal.escapeNamespace(intf?.getName().toLowerCase());
|
|
417
|
+
if (intf?.isGlobal() === true) {
|
|
418
|
+
ret += "this." + iname + "$" + fname + " = abap.Classes['" + intf?.getName().toUpperCase() + "']." + iname + "$" + fname + ";\n";
|
|
422
419
|
}
|
|
423
420
|
else {
|
|
424
421
|
ret += "this." + iname + "$" + fname + " = " + iname + "." + iname + "$" + fname + ";\n";
|
|
425
422
|
}
|
|
426
423
|
}
|
|
427
|
-
for (const a of
|
|
424
|
+
for (const a of intf?.getAttributes().getAll() || []) {
|
|
428
425
|
const n = Traversal.escapeNamespace(name.toLowerCase()) + "$" + a.getName().toLowerCase();
|
|
429
426
|
// note: interface inheritenace and super inheritance might be strange,
|
|
430
427
|
if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
|
|
@@ -434,7 +431,7 @@ class Traversal {
|
|
|
434
431
|
ret += "if (this." + n + " === undefined) this." + n + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
|
|
435
432
|
}
|
|
436
433
|
}
|
|
437
|
-
for (const i of
|
|
434
|
+
for (const i of intf?.getImplementing() || []) {
|
|
438
435
|
ret += this.dataFromInterfaces(i.name, scope, cname);
|
|
439
436
|
}
|
|
440
437
|
return ret;
|
|
@@ -442,19 +439,18 @@ class Traversal {
|
|
|
442
439
|
aliasesFromInterfaces(name, scope, cname) {
|
|
443
440
|
let ret = "";
|
|
444
441
|
const intf = this.findInterfaceDefinition(name, scope);
|
|
445
|
-
for (const a of
|
|
446
|
-
const iname = Traversal.escapeNamespace(intf
|
|
442
|
+
for (const a of intf?.getAliases().getAll() || []) {
|
|
443
|
+
const iname = Traversal.escapeNamespace(intf?.getName().toLowerCase());
|
|
447
444
|
const aname = Traversal.escapeNamespace(a.getName().toLowerCase());
|
|
448
445
|
const cname = Traversal.escapeNamespace(a.getComponent().toLowerCase().replace("~", "$"));
|
|
449
446
|
ret += "this." + iname + "$" + aname + " = this." + cname + ";\n";
|
|
450
447
|
}
|
|
451
|
-
for (const i of
|
|
448
|
+
for (const i of intf?.getImplementing() || []) {
|
|
452
449
|
ret += this.aliasesFromInterfaces(i.name, scope, cname);
|
|
453
450
|
}
|
|
454
451
|
return ret;
|
|
455
452
|
}
|
|
456
453
|
determineType(node, scope) {
|
|
457
|
-
var _a, _b, _c;
|
|
458
454
|
if (scope === undefined) {
|
|
459
455
|
return undefined;
|
|
460
456
|
}
|
|
@@ -465,7 +461,7 @@ class Traversal {
|
|
|
465
461
|
let context = undefined;
|
|
466
462
|
for (const c of found.getChildren()) {
|
|
467
463
|
if (context === undefined) {
|
|
468
|
-
context =
|
|
464
|
+
context = scope.findVariable(c.getFirstToken().getStr())?.getType();
|
|
469
465
|
}
|
|
470
466
|
else if (c.get() instanceof abaplint.Expressions.ComponentName
|
|
471
467
|
&& context instanceof abaplint.BasicTypes.StructureType) {
|
|
@@ -479,10 +475,10 @@ class Traversal {
|
|
|
479
475
|
if (concat.includes("~")) {
|
|
480
476
|
const [iname, aname] = concat.split("~");
|
|
481
477
|
const intf = this.findInterfaceDefinition(iname, scope);
|
|
482
|
-
context =
|
|
478
|
+
context = intf?.getAttributes().findByName(aname)?.getType();
|
|
483
479
|
}
|
|
484
480
|
else {
|
|
485
|
-
context =
|
|
481
|
+
context = id.getAttributes().findByName(concat)?.getType();
|
|
486
482
|
}
|
|
487
483
|
}
|
|
488
484
|
}
|
|
@@ -569,14 +565,13 @@ class Traversal {
|
|
|
569
565
|
return ret;
|
|
570
566
|
}
|
|
571
567
|
buildInternalName(name, def) {
|
|
572
|
-
var _a, _b;
|
|
573
568
|
if (def) {
|
|
574
569
|
if (def.isGlobal() === false) {
|
|
575
570
|
const prefix = this.buildPrefix();
|
|
576
|
-
return `${prefix}${
|
|
571
|
+
return `${prefix}${def?.getName()?.toUpperCase()}`;
|
|
577
572
|
}
|
|
578
573
|
else {
|
|
579
|
-
return
|
|
574
|
+
return def?.getName()?.toUpperCase();
|
|
580
575
|
}
|
|
581
576
|
}
|
|
582
577
|
// assume global
|
|
@@ -590,9 +585,9 @@ class Traversal {
|
|
|
590
585
|
return "abap.Classes[" + name + ".trimEnd()]";
|
|
591
586
|
}
|
|
592
587
|
const scope = this.findCurrentScopeByToken(token);
|
|
593
|
-
let def = scope
|
|
588
|
+
let def = scope?.findClassDefinition(name);
|
|
594
589
|
if (def === undefined) {
|
|
595
|
-
def = scope
|
|
590
|
+
def = scope?.findInterfaceDefinition(name);
|
|
596
591
|
}
|
|
597
592
|
const internalName = this.buildInternalName(name, def);
|
|
598
593
|
return "abap.Classes['" + internalName + "']";
|
package/build/src/unit_test.js
CHANGED
|
@@ -357,11 +357,10 @@ run().then(() => {
|
|
|
357
357
|
// class constructors might make early use of eg. constants from interfaces
|
|
358
358
|
// sub classes will import() super classes and trigger a class constructor of the super
|
|
359
359
|
hasClassConstructor(reg, clas) {
|
|
360
|
-
|
|
361
|
-
if (((_a = clas.getDefinition()) === null || _a === void 0 ? void 0 : _a.getMethodDefinitions().getByName("CLASS_CONSTRUCTOR")) !== undefined) {
|
|
360
|
+
if (clas.getDefinition()?.getMethodDefinitions().getByName("CLASS_CONSTRUCTOR") !== undefined) {
|
|
362
361
|
return true;
|
|
363
362
|
}
|
|
364
|
-
const sup =
|
|
363
|
+
const sup = clas.getDefinition()?.getSuperClass();
|
|
365
364
|
if (sup !== undefined) {
|
|
366
365
|
const superClass = reg.getObject("CLAS", sup);
|
|
367
366
|
if (superClass) {
|
package/build/src/validation.js
CHANGED
|
@@ -112,15 +112,14 @@ class Validation {
|
|
|
112
112
|
this.options = options;
|
|
113
113
|
}
|
|
114
114
|
run(reg) {
|
|
115
|
-
|
|
116
|
-
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.ignoreSyntaxCheck) === true) {
|
|
115
|
+
if (this.options?.ignoreSyntaxCheck === true) {
|
|
117
116
|
exports.config.rules["check_syntax"] = false;
|
|
118
117
|
}
|
|
119
118
|
else {
|
|
120
119
|
exports.config.rules["check_syntax"] = true;
|
|
121
120
|
}
|
|
122
121
|
exports.config.rules["forbidden_identifier"]["check"] = ["^unique\\d+$"];
|
|
123
|
-
if (
|
|
122
|
+
if (this.options?.keywords === undefined) {
|
|
124
123
|
for (const d of keywords_1.defaultKeywords) {
|
|
125
124
|
const add = "^" + d + "$";
|
|
126
125
|
exports.config.rules["forbidden_identifier"]["check"].push(add);
|
|
@@ -132,7 +131,7 @@ class Validation {
|
|
|
132
131
|
exports.config.rules["forbidden_identifier"]["check"].push(add);
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
|
-
if (
|
|
134
|
+
if (this.options?.unknownTypes === types_1.UnknownTypesEnum.runtimeError) {
|
|
136
135
|
// this is not a constant, just a regex that happens to not match anything
|
|
137
136
|
exports.config.syntax.errorNamespace = "VOID_EVERYTHING";
|
|
138
137
|
}
|