@abaplint/transpiler-cli 2.14.19 → 2.14.21
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/README.md +2 -1
- package/build/bundle.js +891 -123
- package/package.json +3 -3
package/build/bundle.js
CHANGED
|
@@ -1091,6 +1091,8 @@ exports.collectObjectFiles = collectObjectFiles;
|
|
|
1091
1091
|
const path = __importStar(__webpack_require__(/*! path */ "path"));
|
|
1092
1092
|
const url_1 = __webpack_require__(/*! url */ "url");
|
|
1093
1093
|
const transpiler_1 = __webpack_require__(/*! @abaplint/transpiler */ "./node_modules/@abaplint/transpiler/build/src/index.js");
|
|
1094
|
+
/** the exported function of a program module running the program, see HandleABAP in the transpiler */
|
|
1095
|
+
const PROGRAM_MAIN = "$main";
|
|
1094
1096
|
function collectObjectFiles(outputFiles, config, files) {
|
|
1095
1097
|
const root = path.resolve(config.output_folder);
|
|
1096
1098
|
const filesToWrite = [];
|
|
@@ -1105,6 +1107,11 @@ function collectObjectFiles(outputFiles, config, files) {
|
|
|
1105
1107
|
if (type === "PROG") {
|
|
1106
1108
|
contents = 'if (!globalThis.abap) await import("' + (0, transpiler_1.importPath)(output.filename, "_init.mjs") + '");\n' + contents;
|
|
1107
1109
|
generatedLineOffset = 1;
|
|
1110
|
+
if (output.exports.includes(PROGRAM_MAIN)) {
|
|
1111
|
+
// run the program when executed directly, "node zapp.prog.mjs", not when imported eg. for unit testing
|
|
1112
|
+
contents += "\nif (process.argv[1] !== undefined"
|
|
1113
|
+
+ ` && import.meta.url === (await import("url")).pathToFileURL(process.argv[1]).href) await ${PROGRAM_MAIN}();`;
|
|
1114
|
+
}
|
|
1108
1115
|
}
|
|
1109
1116
|
if (config.write_source_map === true && (type === "PROG" || type === "FUGR" || type === "CLAS")) {
|
|
1110
1117
|
const name = output.filename + ".map";
|
|
@@ -28200,8 +28207,11 @@ class ObjectOriented {
|
|
|
28200
28207
|
}
|
|
28201
28208
|
return ret;
|
|
28202
28209
|
}
|
|
28203
|
-
addAliasedAttributes(classDefinition) {
|
|
28210
|
+
addAliasedAttributes(classDefinition, inherited = false) {
|
|
28204
28211
|
for (const alias of classDefinition.getAliases() || []) {
|
|
28212
|
+
if (inherited === true && alias.getVisibility() === visibility_1.Visibility.Private) {
|
|
28213
|
+
continue;
|
|
28214
|
+
}
|
|
28205
28215
|
const comp = alias.getComponent();
|
|
28206
28216
|
const idef = this.scope.findInterfaceDefinition(comp.split("~")[0]);
|
|
28207
28217
|
if (idef) {
|
|
@@ -28215,12 +28225,15 @@ class ObjectOriented {
|
|
|
28215
28225
|
if (superName !== undefined) {
|
|
28216
28226
|
const def = this.scope.findClassDefinition(superName);
|
|
28217
28227
|
if (def) {
|
|
28218
|
-
this.addAliasedAttributes(def);
|
|
28228
|
+
this.addAliasedAttributes(def, true);
|
|
28219
28229
|
}
|
|
28220
28230
|
}
|
|
28221
28231
|
}
|
|
28222
|
-
addAliasedTypes(classDefinition) {
|
|
28232
|
+
addAliasedTypes(classDefinition, inherited = false) {
|
|
28223
28233
|
for (const alias of classDefinition.getAliases() || []) {
|
|
28234
|
+
if (inherited === true && alias.getVisibility() === visibility_1.Visibility.Private) {
|
|
28235
|
+
continue;
|
|
28236
|
+
}
|
|
28224
28237
|
const comp = alias.getComponent();
|
|
28225
28238
|
const idef = this.scope.findInterfaceDefinition(comp.split("~")[0]);
|
|
28226
28239
|
if (idef) {
|
|
@@ -28234,7 +28247,7 @@ class ObjectOriented {
|
|
|
28234
28247
|
if (superName !== undefined) {
|
|
28235
28248
|
const def = this.scope.findClassDefinition(superName);
|
|
28236
28249
|
if (def) {
|
|
28237
|
-
this.addAliasedTypes(def);
|
|
28250
|
+
this.addAliasedTypes(def, true);
|
|
28238
28251
|
}
|
|
28239
28252
|
}
|
|
28240
28253
|
}
|
|
@@ -37237,9 +37250,10 @@ class Source {
|
|
|
37237
37250
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
37238
37251
|
}
|
|
37239
37252
|
if ((foundType === null || foundType === void 0 ? void 0 : foundType.isGeneric()) && bodyType !== undefined) {
|
|
37240
|
-
this.
|
|
37253
|
+
const derived = this.inferGenericConv(foundType, input) || bodyType;
|
|
37254
|
+
this.addIfInferred(node, input, derived);
|
|
37241
37255
|
this.traverseRemainingChildren(children, input);
|
|
37242
|
-
return
|
|
37256
|
+
return derived;
|
|
37243
37257
|
}
|
|
37244
37258
|
this.addIfInferred(node, input, foundType);
|
|
37245
37259
|
this.traverseRemainingChildren(children, input);
|
|
@@ -37541,6 +37555,19 @@ class Source {
|
|
|
37541
37555
|
}
|
|
37542
37556
|
}
|
|
37543
37557
|
}
|
|
37558
|
+
/** CONV #( ) at a generic operand position, the type ABAP derives for the # */
|
|
37559
|
+
static inferGenericConv(foundType, input) {
|
|
37560
|
+
if (foundType instanceof basic_1.CLikeType || foundType instanceof basic_1.CSequenceType) {
|
|
37561
|
+
return input.scope.getDDIC().lookupBuiltinType("STRING");
|
|
37562
|
+
}
|
|
37563
|
+
else if (foundType instanceof basic_1.XSequenceType) {
|
|
37564
|
+
return input.scope.getDDIC().lookupBuiltinType("XSTRING");
|
|
37565
|
+
}
|
|
37566
|
+
else if (foundType instanceof basic_1.NumericGenericType || foundType instanceof basic_1.DecFloatType) {
|
|
37567
|
+
return input.scope.getDDIC().lookupBuiltinType("DECFLOAT34", undefined, undefined, "DECFLOAT34");
|
|
37568
|
+
}
|
|
37569
|
+
return undefined;
|
|
37570
|
+
}
|
|
37544
37571
|
static determineType(node, input, targetType) {
|
|
37545
37572
|
const basic = new basic_types_1.BasicTypes(input);
|
|
37546
37573
|
const typeExpression = node.findDirectExpression(Expressions.TypeNameOrInfer);
|
|
@@ -57014,6 +57041,8 @@ class MethodParameters {
|
|
|
57014
57041
|
|| concat.includes(" FOR FEATURES ")
|
|
57015
57042
|
|| concat.includes(" FOR INSTANCE FEATURES ")
|
|
57016
57043
|
|| concat.includes(" FOR GLOBAL AUTHORIZATION ")
|
|
57044
|
+
|| concat.includes(" FOR INSTANCE AUTHORIZATION ")
|
|
57045
|
+
|| concat.includes(" FOR AUTHORIZATION ")
|
|
57017
57046
|
|| concat.includes(" FOR PRECHECK ")
|
|
57018
57047
|
|| concat.includes(" FOR NUMBERING ")
|
|
57019
57048
|
|| concat.includes(" FOR READ ")
|
|
@@ -74232,7 +74261,7 @@ class Registry {
|
|
|
74232
74261
|
}
|
|
74233
74262
|
static abaplintVersion() {
|
|
74234
74263
|
// magic, see build script "version.js"
|
|
74235
|
-
return "2.120.
|
|
74264
|
+
return "2.120.96";
|
|
74236
74265
|
}
|
|
74237
74266
|
getDDICReferences() {
|
|
74238
74267
|
return this.ddicReferences;
|
|
@@ -89160,8 +89189,12 @@ ${indentation} output = ${uniqueName}.\n`;
|
|
|
89160
89189
|
const indent = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
89161
89190
|
// the CONV type might just be a component of the row type, so prefer the row type
|
|
89162
89191
|
const rowOf = this.findRowTypeOf(high, i);
|
|
89192
|
+
const type = rowOf === undefined ? this.findType(i, lowFile, highSyntax) : undefined;
|
|
89193
|
+
if (rowOf === undefined && type === undefined) {
|
|
89194
|
+
return issue_1.Issue.atToken(lowFile, i.getFirstToken(), "Downport CONV, type of # not known", this.getMetadata().key, this.conf.severity);
|
|
89195
|
+
}
|
|
89163
89196
|
const declaration = rowOf === undefined
|
|
89164
|
-
? `DATA ${uniqueName} TYPE ${
|
|
89197
|
+
? `DATA ${uniqueName} TYPE ${type}.`
|
|
89165
89198
|
: `DATA ${uniqueName} LIKE LINE OF ${rowOf}.`;
|
|
89166
89199
|
const abap = declaration + "\n" +
|
|
89167
89200
|
indent + `${uniqueName} = ${body}.\n` +
|
|
@@ -114403,6 +114436,7 @@ class XMLConsistency {
|
|
|
114403
114436
|
* Transparent TABL objects have delivery class and size category set
|
|
114404
114437
|
* TABL fields with a built-in type carry the INTTYPE abapGit serializes for it, for the confirmed pairs
|
|
114405
114438
|
* Lock parameter names in ENQU objects are max 16 characters
|
|
114439
|
+
* DEVC objects are serialized as package.devc.xml
|
|
114406
114440
|
* Texts and translations do not exceed maximum allowed length.`,
|
|
114407
114441
|
tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.Syntax],
|
|
114408
114442
|
};
|
|
@@ -114463,6 +114497,9 @@ class XMLConsistency {
|
|
|
114463
114497
|
else if (obj instanceof Objects.LockObject) {
|
|
114464
114498
|
issues.push(...this.runLockObject(obj, file));
|
|
114465
114499
|
}
|
|
114500
|
+
else if (obj instanceof Objects.Package) {
|
|
114501
|
+
issues.push(...this.runPackage(obj, file));
|
|
114502
|
+
}
|
|
114466
114503
|
if (obj instanceof _abap_object_1.ABAPObject) {
|
|
114467
114504
|
issues.push(...this.runTextPool(obj, file));
|
|
114468
114505
|
}
|
|
@@ -114488,14 +114525,26 @@ class XMLConsistency {
|
|
|
114488
114525
|
return issues;
|
|
114489
114526
|
}
|
|
114490
114527
|
checkClearedFields(obj, file, structure, fields) {
|
|
114491
|
-
var _a
|
|
114528
|
+
var _a;
|
|
114492
114529
|
const issues = [];
|
|
114493
|
-
const
|
|
114494
|
-
|
|
114530
|
+
const xml = obj.getXML();
|
|
114531
|
+
const start = (_a = xml === null || xml === void 0 ? void 0 : xml.indexOf(`<${structure}>`)) !== null && _a !== void 0 ? _a : -1;
|
|
114532
|
+
if (xml === undefined || start < 0) {
|
|
114533
|
+
return issues;
|
|
114534
|
+
}
|
|
114535
|
+
const end = xml.indexOf(`</${structure}>`, start);
|
|
114536
|
+
if (end < 0) {
|
|
114495
114537
|
return issues;
|
|
114496
114538
|
}
|
|
114539
|
+
const present = new Set();
|
|
114540
|
+
const tag = /<([A-Z0-9_]+)[\s/>]/g;
|
|
114541
|
+
tag.lastIndex = start + structure.length + 2;
|
|
114542
|
+
let match;
|
|
114543
|
+
while ((match = tag.exec(xml)) !== null && match.index < end) {
|
|
114544
|
+
present.add(match[1]);
|
|
114545
|
+
}
|
|
114497
114546
|
for (const field of fields) {
|
|
114498
|
-
if (
|
|
114547
|
+
if (present.has(field)) {
|
|
114499
114548
|
const message = `Field ${field} in ${structure} is cleared by abapGit and should not be in the XML`;
|
|
114500
114549
|
issues.push(issue_1.Issue.atRow(file, 1, message, this.getMetadata().key, this.conf.severity));
|
|
114501
114550
|
}
|
|
@@ -114663,6 +114712,15 @@ class XMLConsistency {
|
|
|
114663
114712
|
}
|
|
114664
114713
|
return issues;
|
|
114665
114714
|
}
|
|
114715
|
+
runPackage(obj, file) {
|
|
114716
|
+
// abapGit always serializes DEVC as package.devc.xml, the package name comes from the folder;
|
|
114717
|
+
// the object name is taken from the filename, so it must be PACKAGE
|
|
114718
|
+
if (obj.getName().toUpperCase() !== "PACKAGE") {
|
|
114719
|
+
const message = `DEVC file must be named "package.devc.xml", found "${obj.getName().toLowerCase()}.devc.xml"`;
|
|
114720
|
+
return [issue_1.Issue.atRow(file, 1, message, this.getMetadata().key, this.conf.severity)];
|
|
114721
|
+
}
|
|
114722
|
+
return [];
|
|
114723
|
+
}
|
|
114666
114724
|
runLockObject(obj, file) {
|
|
114667
114725
|
var _a;
|
|
114668
114726
|
const maxParameterLength = 16;
|
|
@@ -121749,7 +121807,7 @@ class SQLCondTranspiler {
|
|
|
121749
121807
|
if (found) {
|
|
121750
121808
|
let name = traversal.prefixAndName(alias.getFirstToken(), filename).replace("~", "$");
|
|
121751
121809
|
name = traversal_1.Traversal.escapeNamespace(name);
|
|
121752
|
-
ret += "'\" + " + name + ".get() + \"'";
|
|
121810
|
+
ret += "'\" + abap.sqlEscape(" + name + ".get()) + \"'";
|
|
121753
121811
|
}
|
|
121754
121812
|
else {
|
|
121755
121813
|
let concat = source.concatTokens();
|
|
@@ -121764,10 +121822,10 @@ class SQLCondTranspiler {
|
|
|
121764
121822
|
const conversionField = traversal.isSQLConversion(source.getFirstToken());
|
|
121765
121823
|
if (conversionField) {
|
|
121766
121824
|
const field = (table?.parseType(traversal.reg)).getComponentByName(conversionField);
|
|
121767
|
-
ret += "'\" + " + traversal.toType(field) + ".set(" + concat + ").get() + \"'";
|
|
121825
|
+
ret += "'\" + abap.sqlEscape(" + traversal.toType(field) + ".set(" + concat + ").get()) + \"'";
|
|
121768
121826
|
}
|
|
121769
121827
|
else if (concat.startsWith("`")) {
|
|
121770
|
-
ret += "'" + concat.substring(1, concat.length - 1) + "'";
|
|
121828
|
+
ret += "'" + concat.substring(1, concat.length - 1).replace(/'/g, "''") + "'";
|
|
121771
121829
|
}
|
|
121772
121830
|
else {
|
|
121773
121831
|
ret += concat;
|
|
@@ -121777,9 +121835,10 @@ class SQLCondTranspiler {
|
|
|
121777
121835
|
}
|
|
121778
121836
|
sqlHost(code, numericHost) {
|
|
121779
121837
|
if (numericHost) {
|
|
121780
|
-
return `" + ((value) => typeof value === "number" || typeof value === "bigint" ? value
|
|
121838
|
+
return `" + ((value) => typeof value === "number" || typeof value === "bigint" ? value `
|
|
121839
|
+
+ `: "'" + abap.sqlEscape(value) + "'")(${code}) + "`;
|
|
121781
121840
|
}
|
|
121782
|
-
return "'\" + " + code + " + \"'";
|
|
121841
|
+
return "'\" + abap.sqlEscape(" + code + ") + \"'";
|
|
121783
121842
|
}
|
|
121784
121843
|
basicConditionNew(node, traversal, filename, table) {
|
|
121785
121844
|
const sourceWithComponents = this.sourceWithComponents(node, traversal);
|
|
@@ -121800,7 +121859,7 @@ class SQLCondTranspiler {
|
|
|
121800
121859
|
&& child instanceof abaplint.Nodes.ExpressionNode
|
|
121801
121860
|
&& child.get() instanceof abaplint.Expressions.SimpleSource3) {
|
|
121802
121861
|
const code = new simple_source3_1.SimpleSource3Transpiler(true).transpile(child, traversal).getCode();
|
|
121803
|
-
ret += `'" + ${code} + "'`;
|
|
121862
|
+
ret += `'" + abap.sqlEscape(${code}) + "'`;
|
|
121804
121863
|
hostExpression = false;
|
|
121805
121864
|
}
|
|
121806
121865
|
else if ((child.get() instanceof abaplint.Expressions.SQLFieldName
|
|
@@ -121809,7 +121868,7 @@ class SQLCondTranspiler {
|
|
|
121809
121868
|
if (hostExpression) {
|
|
121810
121869
|
let name = traversal.prefixAndName(child.getFirstToken(), filename).replace("~", "$");
|
|
121811
121870
|
name = traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(name));
|
|
121812
|
-
ret += `'" + ${name}.get() + "'`;
|
|
121871
|
+
ret += `'" + abap.sqlEscape(${name}.get()) + "'`;
|
|
121813
121872
|
hostExpression = false;
|
|
121814
121873
|
}
|
|
121815
121874
|
else {
|
|
@@ -121872,7 +121931,7 @@ class SQLCondTranspiler {
|
|
|
121872
121931
|
}
|
|
121873
121932
|
code += ".get()";
|
|
121874
121933
|
const field = new sql_field_name_1.SQLFieldNameTranspiler().transpile(fieldName, traversal).getCode();
|
|
121875
|
-
return `${field} ${this.sqlOperator(operator.concatTokens())} '" + ${code} + "'`;
|
|
121934
|
+
return `${field} ${this.sqlOperator(operator.concatTokens())} '" + abap.sqlEscape(${code}) + "'`;
|
|
121876
121935
|
}
|
|
121877
121936
|
sqlOperator(op) {
|
|
121878
121937
|
if (op.toUpperCase() === "EQ") {
|
|
@@ -121952,7 +122011,7 @@ class SQLFieldTranspiler {
|
|
|
121952
122011
|
chunk.appendChunk(new sql_field_name_1.SQLFieldNameTranspiler().transpile(c, traversal));
|
|
121953
122012
|
}
|
|
121954
122013
|
else if (c.get() instanceof abaplint.Expressions.SimpleFieldChain2) {
|
|
121955
|
-
chunk.appendString(`'" + ` + new field_chain_1.FieldChainTranspiler().transpile(c, traversal).getCode() + `.get() + "' `);
|
|
122014
|
+
chunk.appendString(`'" + abap.sqlEscape(` + new field_chain_1.FieldChainTranspiler().transpile(c, traversal).getCode() + `.get()) + "' `);
|
|
121956
122015
|
}
|
|
121957
122016
|
else {
|
|
121958
122017
|
chunk.appendString(c.concatTokens() + " ");
|
|
@@ -122028,7 +122087,7 @@ class SQLFieldAndValueTranspiler {
|
|
|
122028
122087
|
const source = traversal.traverse(n);
|
|
122029
122088
|
// todo: value conversion? abap vs db, traversal.isSQLConversion
|
|
122030
122089
|
// todo: integers?
|
|
122031
|
-
chunk.appendString("'\" + " + source.getCode() + ".get() + \"'");
|
|
122090
|
+
chunk.appendString("'\" + abap.sqlEscape(" + source.getCode() + ".get()) + \"'");
|
|
122032
122091
|
}
|
|
122033
122092
|
else if (n instanceof abaplint.Nodes.TokenNode) {
|
|
122034
122093
|
// operators/keywords, eg. the "+" in "field = field + value"
|
|
@@ -123789,9 +123848,18 @@ const rearranger_1 = __webpack_require__(/*! ../rearranger */ "./node_modules/@a
|
|
|
123789
123848
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
123790
123849
|
const output_layout_1 = __webpack_require__(/*! ../output_layout */ "./node_modules/@abaplint/transpiler/build/src/output_layout.js");
|
|
123791
123850
|
const type_factory_registry_1 = __webpack_require__(/*! ../type_factory_registry */ "./node_modules/@abaplint/transpiler/build/src/type_factory_registry.js");
|
|
123851
|
+
const program_includes_1 = __webpack_require__(/*! ../program_includes */ "./node_modules/@abaplint/transpiler/build/src/program_includes.js");
|
|
123792
123852
|
class HandleABAP {
|
|
123793
123853
|
layout;
|
|
123854
|
+
/** the function running the program, not a name a FORM or variable can be transpiled to */
|
|
123855
|
+
static PROGRAM_MAIN = "$main";
|
|
123794
123856
|
options;
|
|
123857
|
+
/** executable programs as modules, their event blocks and other executable code are wrapped in a function */
|
|
123858
|
+
static wrapsMain(obj, options) {
|
|
123859
|
+
return options?.addCommonJS === true
|
|
123860
|
+
&& obj instanceof abaplint.Objects.Program
|
|
123861
|
+
&& obj.isInclude() === false;
|
|
123862
|
+
}
|
|
123795
123863
|
constructor(options, layout = new output_layout_1.OutputLayout()) {
|
|
123796
123864
|
this.layout = layout;
|
|
123797
123865
|
this.options = options;
|
|
@@ -123831,13 +123899,33 @@ class HandleABAP {
|
|
|
123831
123899
|
throw new Error("HandleABAP, file has no structure, probably a syntax error: " + file.getFilename());
|
|
123832
123900
|
}
|
|
123833
123901
|
const rearranged = new rearranger_1.Rearranger().run(obj.getType(), file.getStructure());
|
|
123834
|
-
const
|
|
123902
|
+
const traversal = new traversal_1.Traversal(spaghetti, file, obj, reg, this.options, typeFactory);
|
|
123903
|
+
const wrapMain = HandleABAP.wrapsMain(obj, this.options);
|
|
123904
|
+
if (wrapMain) {
|
|
123905
|
+
traversal.programMain = new chunk_1.Chunk();
|
|
123906
|
+
}
|
|
123907
|
+
const contents = traversal.traverse(rearranged);
|
|
123835
123908
|
chunk.appendChunk(contents);
|
|
123909
|
+
if (wrapMain) {
|
|
123910
|
+
// the program runs when main is called, importing the module eg. for unit testing does not run it
|
|
123911
|
+
chunk.appendString(`async function ${HandleABAP.PROGRAM_MAIN}() {\n`);
|
|
123912
|
+
chunk.appendChunk(traversal.programMain);
|
|
123913
|
+
chunk.appendString("}\n");
|
|
123914
|
+
}
|
|
123836
123915
|
chunk.stripLastNewline();
|
|
123837
123916
|
if (this.options?.sharedTypeFactories !== true) {
|
|
123838
123917
|
chunk.runIndentationLogic(this.options?.ignoreSourceMap);
|
|
123839
123918
|
}
|
|
123840
123919
|
const exports = this.findExports(file.getStructure());
|
|
123920
|
+
if (obj instanceof abaplint.Objects.Program) {
|
|
123921
|
+
// INCLUDEs are expanded into the program, so export their contents too
|
|
123922
|
+
for (const include of (0, program_includes_1.findProgramIncludes)(file, reg)) {
|
|
123923
|
+
exports.push(...this.findExports(include.getStructure()).filter(e => exports.includes(e) === false));
|
|
123924
|
+
}
|
|
123925
|
+
}
|
|
123926
|
+
if (wrapMain) {
|
|
123927
|
+
exports.push(HandleABAP.PROGRAM_MAIN);
|
|
123928
|
+
}
|
|
123841
123929
|
const output = {
|
|
123842
123930
|
object: {
|
|
123843
123931
|
name: obj.getName(),
|
|
@@ -123953,9 +124041,9 @@ class HandleABAP {
|
|
|
123953
124041
|
}
|
|
123954
124042
|
}
|
|
123955
124043
|
for (const c of node?.findAllStatements(abaplint.Statements.Form) || []) {
|
|
123956
|
-
const e = c.findFirstExpression(abaplint.Expressions.FormName)
|
|
124044
|
+
const e = c.findFirstExpression(abaplint.Expressions.FormName);
|
|
123957
124045
|
if (e) {
|
|
123958
|
-
res.push(
|
|
124046
|
+
res.push(traversal_1.Traversal.formName(e));
|
|
123959
124047
|
}
|
|
123960
124048
|
}
|
|
123961
124049
|
return res;
|
|
@@ -125235,6 +125323,84 @@ function importPath(from, to) {
|
|
|
125235
125323
|
|
|
125236
125324
|
/***/ },
|
|
125237
125325
|
|
|
125326
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/program_includes.js"
|
|
125327
|
+
/*!*************************************************************************!*\
|
|
125328
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/program_includes.js ***!
|
|
125329
|
+
\*************************************************************************/
|
|
125330
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
125331
|
+
|
|
125332
|
+
"use strict";
|
|
125333
|
+
|
|
125334
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
125335
|
+
if (k2 === undefined) k2 = k;
|
|
125336
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
125337
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
125338
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
125339
|
+
}
|
|
125340
|
+
Object.defineProperty(o, k2, desc);
|
|
125341
|
+
}) : (function(o, m, k, k2) {
|
|
125342
|
+
if (k2 === undefined) k2 = k;
|
|
125343
|
+
o[k2] = m[k];
|
|
125344
|
+
}));
|
|
125345
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
125346
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
125347
|
+
}) : function(o, v) {
|
|
125348
|
+
o["default"] = v;
|
|
125349
|
+
});
|
|
125350
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
125351
|
+
var ownKeys = function(o) {
|
|
125352
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
125353
|
+
var ar = [];
|
|
125354
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
125355
|
+
return ar;
|
|
125356
|
+
};
|
|
125357
|
+
return ownKeys(o);
|
|
125358
|
+
};
|
|
125359
|
+
return function (mod) {
|
|
125360
|
+
if (mod && mod.__esModule) return mod;
|
|
125361
|
+
var result = {};
|
|
125362
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
125363
|
+
__setModuleDefault(result, mod);
|
|
125364
|
+
return result;
|
|
125365
|
+
};
|
|
125366
|
+
})();
|
|
125367
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
125368
|
+
exports.filesWithProgramIncludes = filesWithProgramIncludes;
|
|
125369
|
+
exports.findProgramIncludes = findProgramIncludes;
|
|
125370
|
+
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
125371
|
+
/** the files of the object, for programs also the files of the include programs expanded into it */
|
|
125372
|
+
function filesWithProgramIncludes(obj, reg) {
|
|
125373
|
+
const files = obj.getSequencedFiles();
|
|
125374
|
+
if (!(obj instanceof abaplint.Objects.Program) || obj.isInclude() === true) {
|
|
125375
|
+
return files;
|
|
125376
|
+
}
|
|
125377
|
+
const ret = [...files];
|
|
125378
|
+
const visited = new Set();
|
|
125379
|
+
for (const file of files) {
|
|
125380
|
+
ret.push(...findProgramIncludes(file, reg, visited));
|
|
125381
|
+
}
|
|
125382
|
+
return ret;
|
|
125383
|
+
}
|
|
125384
|
+
/** include programs referenced by INCLUDE statements in the file, recursively, each returned once */
|
|
125385
|
+
function findProgramIncludes(file, reg, visited = new Set()) {
|
|
125386
|
+
const ret = [];
|
|
125387
|
+
for (const statement of file.getStructure()?.findAllStatements(abaplint.Statements.Include) || []) {
|
|
125388
|
+
const name = statement.findDirectExpression(abaplint.Expressions.IncludeName)?.concatTokens().toUpperCase();
|
|
125389
|
+
if (name === undefined || visited.has(name)) {
|
|
125390
|
+
continue;
|
|
125391
|
+
}
|
|
125392
|
+
visited.add(name);
|
|
125393
|
+
const include = reg.getObject("PROG", name)?.getMainABAPFile();
|
|
125394
|
+
if (include !== undefined) {
|
|
125395
|
+
ret.push(include, ...findProgramIncludes(include, reg, visited));
|
|
125396
|
+
}
|
|
125397
|
+
}
|
|
125398
|
+
return ret;
|
|
125399
|
+
}
|
|
125400
|
+
//# sourceMappingURL=program_includes.js.map
|
|
125401
|
+
|
|
125402
|
+
/***/ },
|
|
125403
|
+
|
|
125238
125404
|
/***/ "./node_modules/@abaplint/transpiler/build/src/rearranger.js"
|
|
125239
125405
|
/*!*******************************************************************!*\
|
|
125240
125406
|
!*** ./node_modules/@abaplint/transpiler/build/src/rearranger.js ***!
|
|
@@ -125503,6 +125669,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
125503
125669
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
125504
125670
|
exports.Requires = void 0;
|
|
125505
125671
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
125672
|
+
const program_includes_1 = __webpack_require__(/*! ./program_includes */ "./node_modules/@abaplint/transpiler/build/src/program_includes.js");
|
|
125506
125673
|
class Requires {
|
|
125507
125674
|
reg;
|
|
125508
125675
|
constructor(reg) {
|
|
@@ -125585,7 +125752,7 @@ class Requires {
|
|
|
125585
125752
|
}
|
|
125586
125753
|
}
|
|
125587
125754
|
// include global super classes for local class definitions
|
|
125588
|
-
for (const f of obj.
|
|
125755
|
+
for (const f of (0, program_includes_1.filesWithProgramIncludes)(obj, this.reg)) {
|
|
125589
125756
|
for (const c of f.getInfo().listClassDefinitions()) {
|
|
125590
125757
|
if (c.superClassName === undefined) {
|
|
125591
125758
|
continue;
|
|
@@ -125703,6 +125870,150 @@ exports.DatasetOperands = DatasetOperands;
|
|
|
125703
125870
|
|
|
125704
125871
|
/***/ },
|
|
125705
125872
|
|
|
125873
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/statements/_eml.js"
|
|
125874
|
+
/*!************************************************************************!*\
|
|
125875
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/statements/_eml.js ***!
|
|
125876
|
+
\************************************************************************/
|
|
125877
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
125878
|
+
|
|
125879
|
+
"use strict";
|
|
125880
|
+
|
|
125881
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
125882
|
+
if (k2 === undefined) k2 = k;
|
|
125883
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
125884
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
125885
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
125886
|
+
}
|
|
125887
|
+
Object.defineProperty(o, k2, desc);
|
|
125888
|
+
}) : (function(o, m, k, k2) {
|
|
125889
|
+
if (k2 === undefined) k2 = k;
|
|
125890
|
+
o[k2] = m[k];
|
|
125891
|
+
}));
|
|
125892
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
125893
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
125894
|
+
}) : function(o, v) {
|
|
125895
|
+
o["default"] = v;
|
|
125896
|
+
});
|
|
125897
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
125898
|
+
var ownKeys = function(o) {
|
|
125899
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
125900
|
+
var ar = [];
|
|
125901
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
125902
|
+
return ar;
|
|
125903
|
+
};
|
|
125904
|
+
return ownKeys(o);
|
|
125905
|
+
};
|
|
125906
|
+
return function (mod) {
|
|
125907
|
+
if (mod && mod.__esModule) return mod;
|
|
125908
|
+
var result = {};
|
|
125909
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
125910
|
+
__setModuleDefault(result, mod);
|
|
125911
|
+
return result;
|
|
125912
|
+
};
|
|
125913
|
+
})();
|
|
125914
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
125915
|
+
exports.EMLWalker = exports.KERNEL_RAP_EML = void 0;
|
|
125916
|
+
exports.abapString = abapString;
|
|
125917
|
+
exports.abapFlag = abapFlag;
|
|
125918
|
+
exports.unsupportedAddition = unsupportedAddition;
|
|
125919
|
+
exports.emitCalls = emitCalls;
|
|
125920
|
+
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
125921
|
+
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
125922
|
+
/** The kernel class the EML statements are lowered to. One call per
|
|
125923
|
+
* operation of a statement; the names travel as strings, the FROM / WITH
|
|
125924
|
+
* table and the MAPPED, FAILED, REPORTED and RESULT targets as they are,
|
|
125925
|
+
* and only the targets the statement names are passed, the kernel binds
|
|
125926
|
+
* the rest. */
|
|
125927
|
+
exports.KERNEL_RAP_EML = "KERNEL_RAP_EML";
|
|
125928
|
+
function abapString(value) {
|
|
125929
|
+
return `new abap.types.String().set(${JSON.stringify(value)})`;
|
|
125930
|
+
}
|
|
125931
|
+
function abapFlag() {
|
|
125932
|
+
return `abap.CharacterFactory.get(1, 'X')`;
|
|
125933
|
+
}
|
|
125934
|
+
/** the EML forms this lowering does not handle, named in the statement */
|
|
125935
|
+
function unsupportedAddition(node, additions) {
|
|
125936
|
+
const tokens = node.getChildren().filter(c => c instanceof abaplint.Nodes.TokenNode).map(c => c.getFirstToken().getStr().toUpperCase());
|
|
125937
|
+
const text = " " + tokens.join(" ") + " ";
|
|
125938
|
+
for (const addition of additions) {
|
|
125939
|
+
if (text.includes(" " + addition + " ")) {
|
|
125940
|
+
return addition;
|
|
125941
|
+
}
|
|
125942
|
+
}
|
|
125943
|
+
if (node.findAllExpressions(abaplint.Expressions.EMLEntityPath).length > 0
|
|
125944
|
+
|| node.findAllExpressions(abaplint.Expressions.EntityAssociation).length > 0) {
|
|
125945
|
+
return "BY";
|
|
125946
|
+
}
|
|
125947
|
+
return undefined;
|
|
125948
|
+
}
|
|
125949
|
+
function emitCalls(name, lookup, calls, node, traversal) {
|
|
125950
|
+
const ret = `if (${lookup} === undefined) throw new Error("${name}, kernel class missing");\n` + calls.join("\n");
|
|
125951
|
+
return new chunk_1.Chunk().append(ret, node, traversal);
|
|
125952
|
+
}
|
|
125953
|
+
/** a walker over the flat token and expression sequence of an EML statement */
|
|
125954
|
+
class EMLWalker {
|
|
125955
|
+
children;
|
|
125956
|
+
index = 0;
|
|
125957
|
+
constructor(node) {
|
|
125958
|
+
this.children = node.getChildren();
|
|
125959
|
+
}
|
|
125960
|
+
done() {
|
|
125961
|
+
return this.index >= this.children.length;
|
|
125962
|
+
}
|
|
125963
|
+
/** the next child as an upper case keyword, or undefined for an expression */
|
|
125964
|
+
peekKeyword() {
|
|
125965
|
+
const child = this.children[this.index];
|
|
125966
|
+
if (child instanceof abaplint.Nodes.TokenNode) {
|
|
125967
|
+
return child.getFirstToken().getStr().toUpperCase();
|
|
125968
|
+
}
|
|
125969
|
+
return undefined;
|
|
125970
|
+
}
|
|
125971
|
+
takeKeyword() {
|
|
125972
|
+
const keyword = this.peekKeyword();
|
|
125973
|
+
if (keyword !== undefined) {
|
|
125974
|
+
this.index++;
|
|
125975
|
+
}
|
|
125976
|
+
return keyword;
|
|
125977
|
+
}
|
|
125978
|
+
/** consume the keywords in order, or nothing when they are not next */
|
|
125979
|
+
accept(...keywords) {
|
|
125980
|
+
for (let i = 0; i < keywords.length; i++) {
|
|
125981
|
+
const child = this.children[this.index + i];
|
|
125982
|
+
if (!(child instanceof abaplint.Nodes.TokenNode) || child.getFirstToken().getStr().toUpperCase() !== keywords[i]) {
|
|
125983
|
+
return false;
|
|
125984
|
+
}
|
|
125985
|
+
}
|
|
125986
|
+
this.index += keywords.length;
|
|
125987
|
+
return true;
|
|
125988
|
+
}
|
|
125989
|
+
takeExpression() {
|
|
125990
|
+
const child = this.children[this.index];
|
|
125991
|
+
if (!(child instanceof abaplint.Nodes.ExpressionNode)) {
|
|
125992
|
+
throw new Error("EML: expected an expression, got " + (child?.concatTokens() ?? "the end of the statement"));
|
|
125993
|
+
}
|
|
125994
|
+
this.index++;
|
|
125995
|
+
return child;
|
|
125996
|
+
}
|
|
125997
|
+
/** an entity, action or behavior definition name, upper case */
|
|
125998
|
+
takeName() {
|
|
125999
|
+
return this.takeExpression().concatTokens().toUpperCase();
|
|
126000
|
+
}
|
|
126001
|
+
/** the SimpleNames of FIELDS ( a b ) up to the closing parenthesis, upper case */
|
|
126002
|
+
takeFieldList() {
|
|
126003
|
+
const names = [];
|
|
126004
|
+
this.accept("(");
|
|
126005
|
+
while (!this.done() && this.peekKeyword() !== ")") {
|
|
126006
|
+
names.push(this.takeName());
|
|
126007
|
+
}
|
|
126008
|
+
this.accept(")");
|
|
126009
|
+
return names;
|
|
126010
|
+
}
|
|
126011
|
+
}
|
|
126012
|
+
exports.EMLWalker = EMLWalker;
|
|
126013
|
+
//# sourceMappingURL=_eml.js.map
|
|
126014
|
+
|
|
126015
|
+
/***/ },
|
|
126016
|
+
|
|
125706
126017
|
/***/ "./node_modules/@abaplint/transpiler/build/src/statements/_selection.js"
|
|
125707
126018
|
/*!******************************************************************************!*\
|
|
125708
126019
|
!*** ./node_modules/@abaplint/transpiler/build/src/statements/_selection.js ***!
|
|
@@ -127171,6 +127482,11 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
|
|
|
127171
127482
|
class ClassImplementationTranspiler {
|
|
127172
127483
|
transpile(node, traversal) {
|
|
127173
127484
|
const token = node.findFirstExpression(abaplint.Expressions.ClassName).getFirstToken();
|
|
127485
|
+
return new chunk_1.Chunk().append(this.buildHeader(token, traversal), node, traversal);
|
|
127486
|
+
}
|
|
127487
|
+
/** the class header with the static metadata, up to and including the opening brace,
|
|
127488
|
+
* token is the class name in the CLASS ... IMPLEMENTATION or CLASS ... DEFINITION statement */
|
|
127489
|
+
buildHeader(token, traversal) {
|
|
127174
127490
|
const def = traversal.getClassDefinition(token);
|
|
127175
127491
|
let ret = "class " + traversal_1.Traversal.escapeNamespace(token.getStr().toLowerCase());
|
|
127176
127492
|
if (token.getStr().toLowerCase() === "cx_root") {
|
|
@@ -127181,13 +127497,13 @@ class ClassImplementationTranspiler {
|
|
|
127181
127497
|
ret += " extends " + traversal_1.Traversal.escapeNamespace(def?.getSuperClass()?.toLowerCase());
|
|
127182
127498
|
}
|
|
127183
127499
|
const scope = traversal.findCurrentScopeByToken(token);
|
|
127184
|
-
return
|
|
127500
|
+
return ret + ` {
|
|
127185
127501
|
static STATIC_SUPER = ${traversal_1.Traversal.escapeNamespace(def?.getSuperClass()?.toLowerCase())};
|
|
127186
127502
|
static INTERNAL_TYPE = 'CLAS';
|
|
127187
127503
|
static INTERNAL_NAME = '${traversal.buildInternalName(token.getStr(), def)}';
|
|
127188
127504
|
static IMPLEMENTED_INTERFACES = [${this.findImplementedByClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
|
|
127189
127505
|
static ATTRIBUTES = {${Array.from(traversal.buildAttributes(def, scope)).join(",\n")}};
|
|
127190
|
-
static METHODS = {${traversal.buildMethods(def, scope).join(",\n")}}
|
|
127506
|
+
static METHODS = {${traversal.buildMethods(def, scope).join(",\n")}};`;
|
|
127191
127507
|
}
|
|
127192
127508
|
findImplementedInterface(traversal, def, scope) {
|
|
127193
127509
|
if (def === undefined || scope === undefined) {
|
|
@@ -127561,6 +127877,54 @@ exports.CommitTranspiler = CommitTranspiler;
|
|
|
127561
127877
|
|
|
127562
127878
|
/***/ },
|
|
127563
127879
|
|
|
127880
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/statements/commit_entities.js"
|
|
127881
|
+
/*!***********************************************************************************!*\
|
|
127882
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/statements/commit_entities.js ***!
|
|
127883
|
+
\***********************************************************************************/
|
|
127884
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
127885
|
+
|
|
127886
|
+
"use strict";
|
|
127887
|
+
|
|
127888
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
127889
|
+
exports.CommitEntitiesTranspiler = void 0;
|
|
127890
|
+
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
127891
|
+
const _eml_1 = __webpack_require__(/*! ./_eml */ "./node_modules/@abaplint/transpiler/build/src/statements/_eml.js");
|
|
127892
|
+
/** COMMIT ENTITIES [RESPONSE OF bdef FAILED f REPORTED r] [RESPONSES FAILED f REPORTED r]
|
|
127893
|
+
*
|
|
127894
|
+
* lowered to KERNEL_RAP_EML.commit with the behavior definition of
|
|
127895
|
+
* RESPONSE OF and the targets named; the kernel sets sy-subrc. Not
|
|
127896
|
+
* lowered: IN SIMULATION MODE. */
|
|
127897
|
+
class CommitEntitiesTranspiler {
|
|
127898
|
+
transpile(node, traversal) {
|
|
127899
|
+
const unsupported = (0, _eml_1.unsupportedAddition)(node, ["SIMULATION"]);
|
|
127900
|
+
if (unsupported !== undefined) {
|
|
127901
|
+
return new chunk_1.Chunk(`throw new Error("CommitEntities ${unsupported}, not supported, transpiler");`);
|
|
127902
|
+
}
|
|
127903
|
+
const lookup = traversal.lookupClassOrInterface(_eml_1.KERNEL_RAP_EML, node.getFirstToken());
|
|
127904
|
+
const walker = new _eml_1.EMLWalker(node);
|
|
127905
|
+
const options = [];
|
|
127906
|
+
while (!walker.done()) {
|
|
127907
|
+
const keyword = walker.takeKeyword();
|
|
127908
|
+
switch (keyword) {
|
|
127909
|
+
case "OF":
|
|
127910
|
+
options.push(`bdef: ${(0, _eml_1.abapString)(walker.takeName())}`);
|
|
127911
|
+
break;
|
|
127912
|
+
case "FAILED":
|
|
127913
|
+
case "REPORTED":
|
|
127914
|
+
options.push(`${keyword.toLowerCase()}: ${traversal.traverse(walker.takeExpression()).getCode()}`);
|
|
127915
|
+
break;
|
|
127916
|
+
default:
|
|
127917
|
+
break;
|
|
127918
|
+
}
|
|
127919
|
+
}
|
|
127920
|
+
return (0, _eml_1.emitCalls)("CommitEntities", lookup, [`await ${lookup}.commit({${options.join(", ")}});`], node, traversal);
|
|
127921
|
+
}
|
|
127922
|
+
}
|
|
127923
|
+
exports.CommitEntitiesTranspiler = CommitEntitiesTranspiler;
|
|
127924
|
+
//# sourceMappingURL=commit_entities.js.map
|
|
127925
|
+
|
|
127926
|
+
/***/ },
|
|
127927
|
+
|
|
127564
127928
|
/***/ "./node_modules/@abaplint/transpiler/build/src/statements/compute.js"
|
|
127565
127929
|
/*!***************************************************************************!*\
|
|
127566
127930
|
!*** ./node_modules/@abaplint/transpiler/build/src/statements/compute.js ***!
|
|
@@ -129806,10 +130170,10 @@ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@aba
|
|
|
129806
130170
|
class FormTranspiler {
|
|
129807
130171
|
transpile(node, traversal) {
|
|
129808
130172
|
unique_identifier_1.UniqueIdentifier.resetIndexBackup();
|
|
129809
|
-
const
|
|
130173
|
+
const formName = node.findFirstExpression(abaplint.Expressions.FormName);
|
|
129810
130174
|
const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
|
|
129811
|
-
const def = scope?.findFormDefinition(
|
|
129812
|
-
const ret = new chunk_1.Chunk("async function " +
|
|
130175
|
+
const def = scope?.findFormDefinition(formName.concatTokens());
|
|
130176
|
+
const ret = new chunk_1.Chunk("async function " + traversal_1.Traversal.formName(formName) + "(INPUT) {");
|
|
129813
130177
|
const params = [];
|
|
129814
130178
|
for (const p of def?.getChangingParameters() || []) {
|
|
129815
130179
|
params.push(`let ${traversal_1.Traversal.prefixVariable(p.getName())} = INPUT.${p.getName()};`);
|
|
@@ -130583,6 +130947,21 @@ class IncludeTranspiler {
|
|
|
130583
130947
|
return chunk;
|
|
130584
130948
|
}
|
|
130585
130949
|
}
|
|
130950
|
+
if (obj instanceof abaplint.Objects.Program) {
|
|
130951
|
+
const prog = traversal.reg.getObject("PROG", includeName);
|
|
130952
|
+
const file = prog?.getMainABAPFile();
|
|
130953
|
+
if (file !== undefined) {
|
|
130954
|
+
// traversed with the spaghetti of the main program, the include can use its types and data
|
|
130955
|
+
const sub = new traversal_1.Traversal(traversal.getSpaghetti(), file, obj, traversal.reg, traversal.options, traversal.typeFactories);
|
|
130956
|
+
sub.programMain = traversal.programMain;
|
|
130957
|
+
const rearranged = new rearranger_1.Rearranger().run(obj.getType(), file.getStructure());
|
|
130958
|
+
const chunk = new chunk_1.Chunk();
|
|
130959
|
+
if (traversal.options?.addFilenames === true) {
|
|
130960
|
+
chunk.appendString("// " + file.getFilename() + "\n");
|
|
130961
|
+
}
|
|
130962
|
+
return chunk.appendChunk(sub.traverse(rearranged));
|
|
130963
|
+
}
|
|
130964
|
+
}
|
|
130586
130965
|
// todo, this will not work
|
|
130587
130966
|
return new chunk_1.Chunk("// transpiler TODO: INCLUDE " + includeName + "\n");
|
|
130588
130967
|
}
|
|
@@ -130645,6 +131024,7 @@ __exportStar(__webpack_require__(/*! ./close_cursor */ "./node_modules/@abaplint
|
|
|
130645
131024
|
__exportStar(__webpack_require__(/*! ./close_dataset */ "./node_modules/@abaplint/transpiler/build/src/statements/close_dataset.js"), exports);
|
|
130646
131025
|
__exportStar(__webpack_require__(/*! ./collect */ "./node_modules/@abaplint/transpiler/build/src/statements/collect.js"), exports);
|
|
130647
131026
|
__exportStar(__webpack_require__(/*! ./commit */ "./node_modules/@abaplint/transpiler/build/src/statements/commit.js"), exports);
|
|
131027
|
+
__exportStar(__webpack_require__(/*! ./commit_entities */ "./node_modules/@abaplint/transpiler/build/src/statements/commit_entities.js"), exports);
|
|
130648
131028
|
__exportStar(__webpack_require__(/*! ./compute */ "./node_modules/@abaplint/transpiler/build/src/statements/compute.js"), exports);
|
|
130649
131029
|
__exportStar(__webpack_require__(/*! ./concatenate */ "./node_modules/@abaplint/transpiler/build/src/statements/concatenate.js"), exports);
|
|
130650
131030
|
__exportStar(__webpack_require__(/*! ./end_of_selection */ "./node_modules/@abaplint/transpiler/build/src/statements/end_of_selection.js"), exports);
|
|
@@ -130747,6 +131127,7 @@ __exportStar(__webpack_require__(/*! ./reserve */ "./node_modules/@abaplint/tran
|
|
|
130747
131127
|
__exportStar(__webpack_require__(/*! ./retry */ "./node_modules/@abaplint/transpiler/build/src/statements/retry.js"), exports);
|
|
130748
131128
|
__exportStar(__webpack_require__(/*! ./return */ "./node_modules/@abaplint/transpiler/build/src/statements/return.js"), exports);
|
|
130749
131129
|
__exportStar(__webpack_require__(/*! ./rollback */ "./node_modules/@abaplint/transpiler/build/src/statements/rollback.js"), exports);
|
|
131130
|
+
__exportStar(__webpack_require__(/*! ./rollback_entities */ "./node_modules/@abaplint/transpiler/build/src/statements/rollback_entities.js"), exports);
|
|
130750
131131
|
__exportStar(__webpack_require__(/*! ./scan */ "./node_modules/@abaplint/transpiler/build/src/statements/scan.js"), exports);
|
|
130751
131132
|
__exportStar(__webpack_require__(/*! ./search */ "./node_modules/@abaplint/transpiler/build/src/statements/search.js"), exports);
|
|
130752
131133
|
__exportStar(__webpack_require__(/*! ./select_option */ "./node_modules/@abaplint/transpiler/build/src/statements/select_option.js"), exports);
|
|
@@ -131878,9 +132259,125 @@ exports.ModifyDatabaseTranspiler = ModifyDatabaseTranspiler;
|
|
|
131878
132259
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
131879
132260
|
exports.ModifyEntitiesTranspiler = void 0;
|
|
131880
132261
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
132262
|
+
const _eml_1 = __webpack_require__(/*! ./_eml */ "./node_modules/@abaplint/transpiler/build/src/statements/_eml.js");
|
|
132263
|
+
/** MODIFY ENTITIES OF bdef ENTITY e CREATE|UPDATE|DELETE|EXECUTE ... MAPPED m FAILED f REPORTED r
|
|
132264
|
+
*
|
|
132265
|
+
* lowered to KERNEL_RAP_EML.begin with the MAPPED / FAILED / REPORTED
|
|
132266
|
+
* targets the statement names (the statement boundary: the kernel clears
|
|
132267
|
+
* them and binds scratch for the rest), then one modify / execute call per
|
|
132268
|
+
* operation in the order of the statement. Not lowered: the dynamic form (OPERATIONS), create by association (BY),
|
|
132269
|
+
* RELATING TO, AUGMENTING, and the deep forms. */
|
|
131881
132270
|
class ModifyEntitiesTranspiler {
|
|
131882
|
-
transpile(
|
|
131883
|
-
|
|
132271
|
+
transpile(node, traversal) {
|
|
132272
|
+
const unsupported = (0, _eml_1.unsupportedAddition)(node, ["OPERATIONS", "RELATING", "AUGMENTING"]);
|
|
132273
|
+
if (unsupported !== undefined) {
|
|
132274
|
+
return new chunk_1.Chunk(`throw new Error("ModifyEntities ${unsupported}, not supported, transpiler");`);
|
|
132275
|
+
}
|
|
132276
|
+
const lookup = traversal.lookupClassOrInterface(_eml_1.KERNEL_RAP_EML, node.getFirstToken());
|
|
132277
|
+
const walker = new _eml_1.EMLWalker(node);
|
|
132278
|
+
const operations = [];
|
|
132279
|
+
const targets = {};
|
|
132280
|
+
let bdef = "";
|
|
132281
|
+
let entity = "";
|
|
132282
|
+
let current = undefined;
|
|
132283
|
+
walker.accept("MODIFY");
|
|
132284
|
+
if (walker.accept("ENTITIES", "OF")) {
|
|
132285
|
+
bdef = walker.takeName();
|
|
132286
|
+
}
|
|
132287
|
+
else if (walker.accept("ENTITY")) {
|
|
132288
|
+
// the short form names the root entity by its behavior definition
|
|
132289
|
+
walker.accept("IN", "LOCAL", "MODE");
|
|
132290
|
+
bdef = walker.takeName();
|
|
132291
|
+
entity = bdef;
|
|
132292
|
+
}
|
|
132293
|
+
while (!walker.done()) {
|
|
132294
|
+
const keyword = walker.takeKeyword();
|
|
132295
|
+
switch (keyword) {
|
|
132296
|
+
case "ENTITY":
|
|
132297
|
+
entity = walker.takeName();
|
|
132298
|
+
break;
|
|
132299
|
+
case "CREATE":
|
|
132300
|
+
case "UPDATE":
|
|
132301
|
+
case "DELETE":
|
|
132302
|
+
current = { kind: keyword, entity };
|
|
132303
|
+
operations.push(current);
|
|
132304
|
+
break;
|
|
132305
|
+
case "EXECUTE":
|
|
132306
|
+
current = { kind: "EXECUTE", entity, action: walker.takeName() };
|
|
132307
|
+
operations.push(current);
|
|
132308
|
+
break;
|
|
132309
|
+
case "FROM":
|
|
132310
|
+
if (current) {
|
|
132311
|
+
current.rows = traversal.traverse(walker.takeExpression()).getCode();
|
|
132312
|
+
}
|
|
132313
|
+
break;
|
|
132314
|
+
case "FIELDS":
|
|
132315
|
+
if (current) {
|
|
132316
|
+
current.fields = walker.takeFieldList();
|
|
132317
|
+
}
|
|
132318
|
+
break;
|
|
132319
|
+
case "SET":
|
|
132320
|
+
// SET FIELDS WITH
|
|
132321
|
+
walker.accept("FIELDS");
|
|
132322
|
+
if (current) {
|
|
132323
|
+
current.setFields = true;
|
|
132324
|
+
}
|
|
132325
|
+
break;
|
|
132326
|
+
case "WITH":
|
|
132327
|
+
if (current) {
|
|
132328
|
+
current.rows = traversal.traverse(walker.takeExpression()).getCode();
|
|
132329
|
+
}
|
|
132330
|
+
break;
|
|
132331
|
+
case "AUTO":
|
|
132332
|
+
walker.accept("FILL", "CID");
|
|
132333
|
+
if (current) {
|
|
132334
|
+
current.autoFillCid = true;
|
|
132335
|
+
}
|
|
132336
|
+
break;
|
|
132337
|
+
case "MAPPED":
|
|
132338
|
+
case "FAILED":
|
|
132339
|
+
case "REPORTED":
|
|
132340
|
+
case "RESULT":
|
|
132341
|
+
targets[keyword.toLowerCase()] = traversal.traverse(walker.takeExpression()).getCode();
|
|
132342
|
+
break;
|
|
132343
|
+
default:
|
|
132344
|
+
// IN LOCAL MODE, PRIVILEGED, FORWARDING, the final period
|
|
132345
|
+
break;
|
|
132346
|
+
}
|
|
132347
|
+
}
|
|
132348
|
+
const calls = [];
|
|
132349
|
+
const statement = [`bdef: ${(0, _eml_1.abapString)(bdef)}`];
|
|
132350
|
+
for (const name of ["mapped", "failed", "reported"]) {
|
|
132351
|
+
if (targets[name] !== undefined) {
|
|
132352
|
+
statement.push(`${name}: ${targets[name]}`);
|
|
132353
|
+
}
|
|
132354
|
+
}
|
|
132355
|
+
calls.push(`await ${lookup}.begin({${statement.join(", ")}});`);
|
|
132356
|
+
for (const op of operations) {
|
|
132357
|
+
const options = [`bdef: ${(0, _eml_1.abapString)(bdef)}`, `entity: ${(0, _eml_1.abapString)(op.entity)}`];
|
|
132358
|
+
if (op.kind === "EXECUTE") {
|
|
132359
|
+
options.push(`action: ${(0, _eml_1.abapString)(op.action ?? "")}`);
|
|
132360
|
+
}
|
|
132361
|
+
else {
|
|
132362
|
+
options.push(`operation: ${(0, _eml_1.abapString)(op.kind)}`);
|
|
132363
|
+
}
|
|
132364
|
+
options.push(`rows: ${op.rows ?? "undefined"}`);
|
|
132365
|
+
if (op.fields !== undefined) {
|
|
132366
|
+
options.push(`fields: ${(0, _eml_1.abapString)(op.fields.join(","))}`);
|
|
132367
|
+
}
|
|
132368
|
+
if (op.setFields === true) {
|
|
132369
|
+
options.push(`set_fields: ${(0, _eml_1.abapFlag)()}`);
|
|
132370
|
+
}
|
|
132371
|
+
if (op.autoFillCid === true) {
|
|
132372
|
+
options.push(`auto_fill_cid: ${(0, _eml_1.abapFlag)()}`);
|
|
132373
|
+
}
|
|
132374
|
+
if (op.kind === "EXECUTE" && targets["result"] !== undefined) {
|
|
132375
|
+
options.push(`result: ${targets["result"]}`);
|
|
132376
|
+
}
|
|
132377
|
+
const method = op.kind === "EXECUTE" ? "execute" : "modify";
|
|
132378
|
+
calls.push(`await ${lookup}.${method}({${options.join(", ")}});`);
|
|
132379
|
+
}
|
|
132380
|
+
return (0, _eml_1.emitCalls)("ModifyEntities", lookup, calls, node, traversal);
|
|
131884
132381
|
}
|
|
131885
132382
|
}
|
|
131886
132383
|
exports.ModifyEntitiesTranspiler = ModifyEntitiesTranspiler;
|
|
@@ -132674,6 +133171,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
132674
133171
|
exports.PerformTranspiler = void 0;
|
|
132675
133172
|
/* eslint-disable max-len */
|
|
132676
133173
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
133174
|
+
const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
|
|
132677
133175
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
132678
133176
|
class PerformTranspiler {
|
|
132679
133177
|
transpile(node, traversal) {
|
|
@@ -132757,7 +133255,7 @@ class PerformTranspiler {
|
|
|
132757
133255
|
params.push(`"${name}": ` + traversal.traverse(c).getCode());
|
|
132758
133256
|
index++;
|
|
132759
133257
|
}
|
|
132760
|
-
return new chunk_1.Chunk("await " + formName
|
|
133258
|
+
return new chunk_1.Chunk("await " + traversal_1.Traversal.formName(formName) + `({${params.join(",")}});`);
|
|
132761
133259
|
}
|
|
132762
133260
|
}
|
|
132763
133261
|
}
|
|
@@ -133111,9 +133609,89 @@ exports.ReadDatasetTranspiler = ReadDatasetTranspiler;
|
|
|
133111
133609
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
133112
133610
|
exports.ReadEntitiesTranspiler = void 0;
|
|
133113
133611
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
133612
|
+
const _eml_1 = __webpack_require__(/*! ./_eml */ "./node_modules/@abaplint/transpiler/build/src/statements/_eml.js");
|
|
133613
|
+
/** READ ENTITIES OF bdef ENTITY e FROM|ALL FIELDS WITH|FIELDS ( ) WITH keys RESULT r FAILED f REPORTED r
|
|
133614
|
+
*
|
|
133615
|
+
* lowered to KERNEL_RAP_EML.begin with the FAILED / REPORTED targets the
|
|
133616
|
+
* statement names (the statement boundary), then one read call per read in
|
|
133617
|
+
* the order of the statement. Not lowered: read by association (BY), LINK, and EXECUTE
|
|
133618
|
+
* (functions). */
|
|
133114
133619
|
class ReadEntitiesTranspiler {
|
|
133115
|
-
transpile(
|
|
133116
|
-
|
|
133620
|
+
transpile(node, traversal) {
|
|
133621
|
+
const unsupported = (0, _eml_1.unsupportedAddition)(node, ["LINK", "EXECUTE"]);
|
|
133622
|
+
if (unsupported !== undefined) {
|
|
133623
|
+
return new chunk_1.Chunk(`throw new Error("ReadEntities ${unsupported}, not supported, transpiler");`);
|
|
133624
|
+
}
|
|
133625
|
+
const lookup = traversal.lookupClassOrInterface(_eml_1.KERNEL_RAP_EML, node.getFirstToken());
|
|
133626
|
+
const walker = new _eml_1.EMLWalker(node);
|
|
133627
|
+
const reads = [];
|
|
133628
|
+
const targets = {};
|
|
133629
|
+
let bdef = "";
|
|
133630
|
+
let entity = "";
|
|
133631
|
+
let current = undefined;
|
|
133632
|
+
walker.accept("READ");
|
|
133633
|
+
if (walker.accept("ENTITIES", "OF")) {
|
|
133634
|
+
bdef = walker.takeName();
|
|
133635
|
+
}
|
|
133636
|
+
else if (walker.accept("ENTITY")) {
|
|
133637
|
+
walker.accept("IN", "LOCAL", "MODE");
|
|
133638
|
+
bdef = walker.takeName();
|
|
133639
|
+
entity = bdef;
|
|
133640
|
+
}
|
|
133641
|
+
while (!walker.done()) {
|
|
133642
|
+
const keyword = walker.takeKeyword();
|
|
133643
|
+
switch (keyword) {
|
|
133644
|
+
case "ENTITY":
|
|
133645
|
+
entity = walker.takeName();
|
|
133646
|
+
break;
|
|
133647
|
+
case "FROM":
|
|
133648
|
+
current = { entity, keys: traversal.traverse(walker.takeExpression()).getCode() };
|
|
133649
|
+
reads.push(current);
|
|
133650
|
+
break;
|
|
133651
|
+
case "ALL":
|
|
133652
|
+
walker.accept("FIELDS", "WITH");
|
|
133653
|
+
current = { entity, fields: "*", keys: traversal.traverse(walker.takeExpression()).getCode() };
|
|
133654
|
+
reads.push(current);
|
|
133655
|
+
break;
|
|
133656
|
+
case "FIELDS":
|
|
133657
|
+
current = { entity, fields: walker.takeFieldList().join(",") };
|
|
133658
|
+
walker.accept("WITH");
|
|
133659
|
+
current.keys = traversal.traverse(walker.takeExpression()).getCode();
|
|
133660
|
+
reads.push(current);
|
|
133661
|
+
break;
|
|
133662
|
+
case "RESULT":
|
|
133663
|
+
if (current) {
|
|
133664
|
+
current.result = traversal.traverse(walker.takeExpression()).getCode();
|
|
133665
|
+
}
|
|
133666
|
+
break;
|
|
133667
|
+
case "FAILED":
|
|
133668
|
+
case "REPORTED":
|
|
133669
|
+
targets[keyword.toLowerCase()] = traversal.traverse(walker.takeExpression()).getCode();
|
|
133670
|
+
break;
|
|
133671
|
+
default:
|
|
133672
|
+
// IN LOCAL MODE, the final period
|
|
133673
|
+
break;
|
|
133674
|
+
}
|
|
133675
|
+
}
|
|
133676
|
+
const calls = [];
|
|
133677
|
+
const statement = [`bdef: ${(0, _eml_1.abapString)(bdef)}`];
|
|
133678
|
+
for (const name of ["failed", "reported"]) {
|
|
133679
|
+
if (targets[name] !== undefined) {
|
|
133680
|
+
statement.push(`${name}: ${targets[name]}`);
|
|
133681
|
+
}
|
|
133682
|
+
}
|
|
133683
|
+
calls.push(`await ${lookup}.begin({${statement.join(", ")}});`);
|
|
133684
|
+
for (const read of reads) {
|
|
133685
|
+
const options = [`bdef: ${(0, _eml_1.abapString)(bdef)}`, `entity: ${(0, _eml_1.abapString)(read.entity)}`, `keys: ${read.keys ?? "undefined"}`];
|
|
133686
|
+
if (read.fields !== undefined) {
|
|
133687
|
+
options.push(`fields: ${(0, _eml_1.abapString)(read.fields)}`);
|
|
133688
|
+
}
|
|
133689
|
+
if (read.result !== undefined) {
|
|
133690
|
+
options.push(`result: ${read.result}`);
|
|
133691
|
+
}
|
|
133692
|
+
calls.push(`await ${lookup}.read({${options.join(", ")}});`);
|
|
133693
|
+
}
|
|
133694
|
+
return (0, _eml_1.emitCalls)("ReadEntities", lookup, calls, node, traversal);
|
|
133117
133695
|
}
|
|
133118
133696
|
}
|
|
133119
133697
|
exports.ReadEntitiesTranspiler = ReadEntitiesTranspiler;
|
|
@@ -133767,6 +134345,29 @@ exports.RollbackTranspiler = RollbackTranspiler;
|
|
|
133767
134345
|
|
|
133768
134346
|
/***/ },
|
|
133769
134347
|
|
|
134348
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/statements/rollback_entities.js"
|
|
134349
|
+
/*!*************************************************************************************!*\
|
|
134350
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/statements/rollback_entities.js ***!
|
|
134351
|
+
\*************************************************************************************/
|
|
134352
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
134353
|
+
|
|
134354
|
+
"use strict";
|
|
134355
|
+
|
|
134356
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
134357
|
+
exports.RollbackEntitiesTranspiler = void 0;
|
|
134358
|
+
const _eml_1 = __webpack_require__(/*! ./_eml */ "./node_modules/@abaplint/transpiler/build/src/statements/_eml.js");
|
|
134359
|
+
/** ROLLBACK ENTITIES, lowered to KERNEL_RAP_EML.rollback */
|
|
134360
|
+
class RollbackEntitiesTranspiler {
|
|
134361
|
+
transpile(node, traversal) {
|
|
134362
|
+
const lookup = traversal.lookupClassOrInterface(_eml_1.KERNEL_RAP_EML, node.getFirstToken());
|
|
134363
|
+
return (0, _eml_1.emitCalls)("RollbackEntities", lookup, [`await ${lookup}.rollback();`], node, traversal);
|
|
134364
|
+
}
|
|
134365
|
+
}
|
|
134366
|
+
exports.RollbackEntitiesTranspiler = RollbackEntitiesTranspiler;
|
|
134367
|
+
//# sourceMappingURL=rollback_entities.js.map
|
|
134368
|
+
|
|
134369
|
+
/***/ },
|
|
134370
|
+
|
|
133770
134371
|
/***/ "./node_modules/@abaplint/transpiler/build/src/statements/scan.js"
|
|
133771
134372
|
/*!************************************************************************!*\
|
|
133772
134373
|
!*** ./node_modules/@abaplint/transpiler/build/src/statements/scan.js ***!
|
|
@@ -134063,7 +134664,8 @@ class SelectTranspiler {
|
|
|
134063
134664
|
// ABAP semantics: with an empty driving table the whole WHERE condition is ignored
|
|
134064
134665
|
const selectEmpty = select.replace(whereClause, "");
|
|
134065
134666
|
const bindRow = (text) => text
|
|
134066
|
-
|
|
134667
|
+
// the row reference follows a blank, or the parenthesis of abap.sqlEscape(
|
|
134668
|
+
.replace(new RegExp("([ (])" + escapeRegExp(faeTranspiled), "g"), "$1" + unique)
|
|
134067
134669
|
.replace(unique + ".get().table_line.get()", unique + ".get()"); // there can be only one?
|
|
134068
134670
|
select = bindRow(select);
|
|
134069
134671
|
const where = bindRow(whereClause);
|
|
@@ -134289,12 +134891,62 @@ exports.SelectOptionTranspiler = SelectOptionTranspiler;
|
|
|
134289
134891
|
|
|
134290
134892
|
"use strict";
|
|
134291
134893
|
|
|
134894
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
134895
|
+
if (k2 === undefined) k2 = k;
|
|
134896
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
134897
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
134898
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
134899
|
+
}
|
|
134900
|
+
Object.defineProperty(o, k2, desc);
|
|
134901
|
+
}) : (function(o, m, k, k2) {
|
|
134902
|
+
if (k2 === undefined) k2 = k;
|
|
134903
|
+
o[k2] = m[k];
|
|
134904
|
+
}));
|
|
134905
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
134906
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
134907
|
+
}) : function(o, v) {
|
|
134908
|
+
o["default"] = v;
|
|
134909
|
+
});
|
|
134910
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
134911
|
+
var ownKeys = function(o) {
|
|
134912
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
134913
|
+
var ar = [];
|
|
134914
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
134915
|
+
return ar;
|
|
134916
|
+
};
|
|
134917
|
+
return ownKeys(o);
|
|
134918
|
+
};
|
|
134919
|
+
return function (mod) {
|
|
134920
|
+
if (mod && mod.__esModule) return mod;
|
|
134921
|
+
var result = {};
|
|
134922
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
134923
|
+
__setModuleDefault(result, mod);
|
|
134924
|
+
return result;
|
|
134925
|
+
};
|
|
134926
|
+
})();
|
|
134292
134927
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
134293
134928
|
exports.SelectionScreenTranspiler = void 0;
|
|
134929
|
+
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
134930
|
+
const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
|
|
134294
134931
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
134932
|
+
/** SELECTION-SCREEN is screen layout, there is no screen, so nothing runs. The statement declares
|
|
134933
|
+
* a field for COMMENT, PUSHBUTTON and TAB, and a structure for BEGIN OF TABBED BLOCK, those are
|
|
134934
|
+
* declared as they can be referenced, eg. setting the text of a comment in INITIALIZATION */
|
|
134295
134935
|
class SelectionScreenTranspiler {
|
|
134296
|
-
transpile(
|
|
134297
|
-
|
|
134936
|
+
transpile(node, traversal) {
|
|
134937
|
+
let token = node.findFirstExpression(abaplint.Expressions.InlineField)?.getFirstToken();
|
|
134938
|
+
if (token === undefined && node.concatTokens().toUpperCase().includes("BEGIN OF TABBED BLOCK")) {
|
|
134939
|
+
token = node.findFirstExpression(abaplint.Expressions.BlockName)?.getFirstToken();
|
|
134940
|
+
}
|
|
134941
|
+
if (token === undefined) {
|
|
134942
|
+
return new chunk_1.Chunk("");
|
|
134943
|
+
}
|
|
134944
|
+
const found = traversal.findCurrentScopeByToken(token)?.findVariable(token.getStr());
|
|
134945
|
+
if (found === undefined) {
|
|
134946
|
+
return new chunk_1.Chunk("");
|
|
134947
|
+
}
|
|
134948
|
+
const name = traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(found.getName().toLowerCase()));
|
|
134949
|
+
return new chunk_1.Chunk("let " + name + " = " + traversal.toType(found.getType()) + ";");
|
|
134298
134950
|
}
|
|
134299
134951
|
}
|
|
134300
134952
|
exports.SelectionScreenTranspiler = SelectionScreenTranspiler;
|
|
@@ -135804,7 +136456,7 @@ class UpdateDatabaseTranspiler {
|
|
|
135804
136456
|
const where = [];
|
|
135805
136457
|
const set = [];
|
|
135806
136458
|
for (const fieldName of allFields) {
|
|
135807
|
-
const cond = `\\"${fieldName}\\" = '\" + ${sqlSource}.${fieldName}.get() + \"'`;
|
|
136459
|
+
const cond = `\\"${fieldName}\\" = '\" + abap.sqlEscape(${sqlSource}.${fieldName}.get()) + \"'`;
|
|
135808
136460
|
if (keys.includes(fieldName) === true) {
|
|
135809
136461
|
where.push(cond);
|
|
135810
136462
|
}
|
|
@@ -136606,35 +137258,26 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
136606
137258
|
exports.ClassDefinitionTranspiler = void 0;
|
|
136607
137259
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
136608
137260
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
137261
|
+
const program_includes_1 = __webpack_require__(/*! ../program_includes */ "./node_modules/@abaplint/transpiler/build/src/program_includes.js");
|
|
137262
|
+
const class_implementation_1 = __webpack_require__(/*! ./class_implementation */ "./node_modules/@abaplint/transpiler/build/src/structures/class_implementation.js");
|
|
136609
137263
|
class ClassDefinitionTranspiler {
|
|
136610
137264
|
transpile(node, traversal) {
|
|
136611
137265
|
const className = node.findFirstExpression(abaplint.Expressions.ClassName)?.concatTokens().toUpperCase();
|
|
136612
|
-
|
|
136613
|
-
|
|
136614
|
-
|
|
136615
|
-
|
|
136616
|
-
|
|
136617
|
-
|
|
136618
|
-
|
|
136619
|
-
|
|
137266
|
+
// all files of the object, not getSequencedFiles(): for function groups that only lists the main
|
|
137267
|
+
// program and the function modules, an IMPLEMENTATION in eg. the F01 include must also be found.
|
|
137268
|
+
// Programs additionally have their INCLUDE programs expanded into them
|
|
137269
|
+
const obj = traversal.getCurrentObject();
|
|
137270
|
+
const files = obj instanceof abaplint.Objects.Program
|
|
137271
|
+
? (0, program_includes_1.filesWithProgramIncludes)(obj, traversal.reg)
|
|
137272
|
+
: obj.getABAPFiles();
|
|
137273
|
+
const found = className !== undefined
|
|
137274
|
+
&& files.some(a => a.getInfo().getClassImplementationByName(className) !== undefined);
|
|
136620
137275
|
if (found) {
|
|
136621
137276
|
return new chunk_1.Chunk("");
|
|
136622
137277
|
}
|
|
136623
137278
|
else {
|
|
136624
|
-
//
|
|
136625
|
-
|
|
136626
|
-
return new chunk_1.Chunk(`
|
|
136627
|
-
class ${className?.toLowerCase()} {
|
|
136628
|
-
static INTERNAL_TYPE = 'CLAS';
|
|
136629
|
-
static IMPLEMENTED_INTERFACES = [];
|
|
136630
|
-
static INTERNAL_NAME = 'ABSTRACT_CLASS_INTERNAL_NAME';
|
|
136631
|
-
static ATTRIBUTES = {};
|
|
136632
|
-
async constructor_() {
|
|
136633
|
-
this.me = new abap.types.ABAPObject();
|
|
136634
|
-
this.me.set(this);
|
|
136635
|
-
return this;
|
|
136636
|
-
}
|
|
136637
|
-
}`);
|
|
137279
|
+
// no IMPLEMENTATION, eg. an exception class or an abstract class with only abstract methods
|
|
137280
|
+
return new class_implementation_1.ClassImplementationTranspiler().transpileWithoutImplementation(node, traversal);
|
|
136638
137281
|
}
|
|
136639
137282
|
}
|
|
136640
137283
|
}
|
|
@@ -136689,25 +137332,48 @@ exports.ClassImplementationTranspiler = void 0;
|
|
|
136689
137332
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
136690
137333
|
const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
|
|
136691
137334
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
137335
|
+
const class_implementation_1 = __webpack_require__(/*! ../statements/class_implementation */ "./node_modules/@abaplint/transpiler/build/src/statements/class_implementation.js");
|
|
137336
|
+
const DEFAULT_CONSTRUCTOR = "async constructor_(INPUT) {\nif (super.constructor_) { await super.constructor_(INPUT); }\nreturn this;\n}\n";
|
|
136692
137337
|
class ClassImplementationTranspiler {
|
|
136693
137338
|
transpile(node, traversal) {
|
|
137339
|
+
const token = node.findFirstExpression(abaplint.Expressions.ClassName)?.getFirstToken();
|
|
137340
|
+
if (token === undefined) {
|
|
137341
|
+
throw new Error("ClassImplementationTranspiler, class name not found");
|
|
137342
|
+
}
|
|
137343
|
+
const methods = node.findAllStatements(abaplint.Statements.MethodImplementation);
|
|
136694
137344
|
const ret = new chunk_1.Chunk();
|
|
136695
137345
|
for (const c of node.getChildren()) {
|
|
136696
137346
|
if (c.get() instanceof abaplint.Statements.EndClass) {
|
|
136697
|
-
ret.appendString(this.buildPartiallyImplementedStubs(
|
|
137347
|
+
ret.appendString(this.buildPartiallyImplementedStubs(token, methods, traversal));
|
|
136698
137348
|
}
|
|
136699
137349
|
ret.appendChunk(traversal.traverse(c));
|
|
136700
137350
|
if (c.get() instanceof abaplint.Statements.ClassImplementation) {
|
|
136701
|
-
ret.appendString(this.buildConstructor(
|
|
136702
|
-
|
|
136703
|
-
|
|
136704
|
-
|
|
136705
|
-
&& this.hasConstructor(node) === false) {
|
|
136706
|
-
ret.appendString("async constructor_(INPUT) {\nif (super.constructor_) { await super.constructor_(INPUT); }\nreturn this;\n}\n");
|
|
137351
|
+
ret.appendString(this.buildConstructor(token, traversal));
|
|
137352
|
+
if (this.hasConstructor(methods) === false) {
|
|
137353
|
+
ret.appendString(DEFAULT_CONSTRUCTOR);
|
|
137354
|
+
}
|
|
136707
137355
|
}
|
|
136708
137356
|
}
|
|
136709
|
-
ret.appendString(this.buildStatic(
|
|
136710
|
-
ret.appendString(this.buildTypes(
|
|
137357
|
+
ret.appendString(this.buildStatic(token, traversal));
|
|
137358
|
+
ret.appendString(this.buildTypes(token, traversal));
|
|
137359
|
+
return ret;
|
|
137360
|
+
}
|
|
137361
|
+
/** a class with a DEFINITION and no IMPLEMENTATION, valid ABAP when the class has no
|
|
137362
|
+
* methods to implement, eg. an exception class or an abstract class with only abstract
|
|
137363
|
+
* methods: the same output as for an empty CLASS ... IMPLEMENTATION. ENDCLASS. */
|
|
137364
|
+
transpileWithoutImplementation(node, traversal) {
|
|
137365
|
+
const token = node.findFirstExpression(abaplint.Expressions.ClassName)?.getFirstToken();
|
|
137366
|
+
if (token === undefined) {
|
|
137367
|
+
throw new Error("ClassImplementationTranspiler, class name not found");
|
|
137368
|
+
}
|
|
137369
|
+
const ret = new chunk_1.Chunk();
|
|
137370
|
+
ret.append(new class_implementation_1.ClassImplementationTranspiler().buildHeader(token, traversal) + "\n", node, traversal);
|
|
137371
|
+
ret.appendString(this.buildConstructor(token, traversal));
|
|
137372
|
+
ret.appendString(DEFAULT_CONSTRUCTOR);
|
|
137373
|
+
ret.appendString(this.buildPartiallyImplementedStubs(token, [], traversal));
|
|
137374
|
+
ret.append("}\n" + traversal.registerClassOrInterface(traversal.getClassDefinition(token)) + "\n", node.getLastToken(), traversal);
|
|
137375
|
+
ret.appendString(this.buildStatic(token, traversal));
|
|
137376
|
+
ret.appendString(this.buildTypes(token, traversal));
|
|
136711
137377
|
return ret;
|
|
136712
137378
|
}
|
|
136713
137379
|
///////////////////////////////
|
|
@@ -136715,11 +137381,7 @@ class ClassImplementationTranspiler {
|
|
|
136715
137381
|
* does not implement exist on a system and raise CX_SY_DYN_CALL_ILLEGAL_METHOD
|
|
136716
137382
|
* when called. Emits a method of that shape under the name the implementation
|
|
136717
137383
|
* would have had, so the call ends in that exception and not in a TypeError */
|
|
136718
|
-
buildPartiallyImplementedStubs(
|
|
136719
|
-
const token = node.findFirstExpression(abaplint.Expressions.ClassName)?.getFirstToken();
|
|
136720
|
-
if (token === undefined) {
|
|
136721
|
-
return "";
|
|
136722
|
-
}
|
|
137384
|
+
buildPartiallyImplementedStubs(token, methods, traversal) {
|
|
136723
137385
|
const cdef = traversal.getClassDefinition(token);
|
|
136724
137386
|
const scope = traversal.findCurrentScopeByToken(token);
|
|
136725
137387
|
if (cdef === undefined || scope === undefined) {
|
|
@@ -136731,7 +137393,7 @@ class ClassImplementationTranspiler {
|
|
|
136731
137393
|
}
|
|
136732
137394
|
// the methods the class implements itself, by the emitted name
|
|
136733
137395
|
const implemented = new Set();
|
|
136734
|
-
for (const m of
|
|
137396
|
+
for (const m of methods) {
|
|
136735
137397
|
const name = m.findFirstExpression(abaplint.Expressions.MethodName)?.getFirstToken().getStr();
|
|
136736
137398
|
if (name !== undefined) {
|
|
136737
137399
|
implemented.add(traversal_1.Traversal.escapeNamespace(name.replace("~", "$").toLowerCase()));
|
|
@@ -136808,8 +137470,8 @@ class ClassImplementationTranspiler {
|
|
|
136808
137470
|
ret += "async " + emitted + "(" + unique + ") {\n" + body + "}\n";
|
|
136809
137471
|
return ret;
|
|
136810
137472
|
}
|
|
136811
|
-
hasConstructor(
|
|
136812
|
-
for (const m of
|
|
137473
|
+
hasConstructor(methods) {
|
|
137474
|
+
for (const m of methods) {
|
|
136813
137475
|
const name = m.findFirstExpression(abaplint.Expressions.MethodName)?.getFirstToken().getStr();
|
|
136814
137476
|
if (name?.toUpperCase() === "CONSTRUCTOR") {
|
|
136815
137477
|
return true;
|
|
@@ -136842,11 +137504,8 @@ class ClassImplementationTranspiler {
|
|
|
136842
137504
|
}
|
|
136843
137505
|
return ret;
|
|
136844
137506
|
}
|
|
136845
|
-
buildTypes(
|
|
136846
|
-
|
|
136847
|
-
return "";
|
|
136848
|
-
}
|
|
136849
|
-
const cdef = traversal.getClassDefinition(node.getFirstToken());
|
|
137507
|
+
buildTypes(token, traversal) {
|
|
137508
|
+
const cdef = traversal.getClassDefinition(token);
|
|
136850
137509
|
if (cdef === undefined) {
|
|
136851
137510
|
return "ERROR_CDEF_NOT_FOUND";
|
|
136852
137511
|
}
|
|
@@ -136857,11 +137516,8 @@ class ClassImplementationTranspiler {
|
|
|
136857
137516
|
}
|
|
136858
137517
|
return ret;
|
|
136859
137518
|
}
|
|
136860
|
-
buildPrivate(
|
|
136861
|
-
|
|
136862
|
-
return "";
|
|
136863
|
-
}
|
|
136864
|
-
const cdef = traversal.getClassDefinition(node.getFirstToken());
|
|
137519
|
+
buildPrivate(token, traversal) {
|
|
137520
|
+
const cdef = traversal.getClassDefinition(token);
|
|
136865
137521
|
if (cdef === undefined) {
|
|
136866
137522
|
return "ERROR_CDEF_NOT_FOUND";
|
|
136867
137523
|
}
|
|
@@ -136874,20 +137530,17 @@ class ClassImplementationTranspiler {
|
|
|
136874
137530
|
return ret;
|
|
136875
137531
|
}
|
|
136876
137532
|
/** this builds the part after the class, containing the static variables/constants */
|
|
136877
|
-
buildStatic(
|
|
136878
|
-
|
|
136879
|
-
return "";
|
|
136880
|
-
}
|
|
136881
|
-
const cdef = traversal.getClassDefinition(node.getFirstToken());
|
|
137533
|
+
buildStatic(token, traversal) {
|
|
137534
|
+
const cdef = traversal.getClassDefinition(token);
|
|
136882
137535
|
if (cdef === undefined) {
|
|
136883
137536
|
return "ERROR_CDEF_NOT_FOUND";
|
|
136884
137537
|
}
|
|
136885
|
-
const scope = traversal.findCurrentScopeByToken(
|
|
137538
|
+
const scope = traversal.findCurrentScopeByToken(token);
|
|
136886
137539
|
if (scope === undefined) {
|
|
136887
137540
|
return "ERROR_SCOPE_NOT_FOUND";
|
|
136888
137541
|
}
|
|
136889
137542
|
let ret = "";
|
|
136890
|
-
const clasName =
|
|
137543
|
+
const clasName = token.getStr().toLowerCase();
|
|
136891
137544
|
const staticAttributes = this.findStaticAttributes(cdef, scope, traversal);
|
|
136892
137545
|
for (const attr of staticAttributes) {
|
|
136893
137546
|
const name = traversal_1.Traversal.escapeNamespace(clasName) + "." + traversal_1.Traversal.escapeNamespace(attr.prefix) + traversal_1.Traversal.escapeNamespace(attr.identifier.getName().toLowerCase());
|
|
@@ -136923,29 +137576,22 @@ class ClassImplementationTranspiler {
|
|
|
136923
137576
|
continue;
|
|
136924
137577
|
}
|
|
136925
137578
|
else if (def.methods.some(m => m.name.toLowerCase() === "class_constructor")) {
|
|
136926
|
-
ret += "await " + traversal.lookupClassOrInterface(def.name,
|
|
137579
|
+
ret += "await " + traversal.lookupClassOrInterface(def.name, token) + ".class_constructor();\n";
|
|
136927
137580
|
}
|
|
136928
137581
|
}
|
|
136929
137582
|
}
|
|
136930
137583
|
}
|
|
136931
137584
|
if (cdef.isGlobal() === false && cdef.isForTesting() === true && cdef.getMethodDefinitions().getByName("class_constructor")) {
|
|
136932
|
-
ret += "await " + traversal_1.Traversal.escapeNamespace(
|
|
137585
|
+
ret += "await " + traversal_1.Traversal.escapeNamespace(clasName) + ".class_constructor();\n";
|
|
136933
137586
|
}
|
|
136934
137587
|
}
|
|
136935
137588
|
else if (cdef.getMethodDefinitions().getByName("class_constructor")) {
|
|
136936
|
-
ret += "await " + traversal_1.Traversal.escapeNamespace(
|
|
137589
|
+
ret += "await " + traversal_1.Traversal.escapeNamespace(clasName) + ".class_constructor();\n";
|
|
136937
137590
|
}
|
|
136938
137591
|
return ret;
|
|
136939
137592
|
}
|
|
136940
|
-
buildConstructor(
|
|
136941
|
-
|
|
136942
|
-
throw new Error("buildConstructor node undefined");
|
|
136943
|
-
}
|
|
136944
|
-
const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
|
|
136945
|
-
const token = node.findFirstExpression(abaplint.Expressions.ClassName)?.getFirstToken();
|
|
136946
|
-
if (token === undefined) {
|
|
136947
|
-
throw "buildConstructorTokenNotFound";
|
|
136948
|
-
}
|
|
137593
|
+
buildConstructor(token, traversal) {
|
|
137594
|
+
const scope = traversal.findCurrentScopeByToken(token);
|
|
136949
137595
|
const cdef = traversal.getClassDefinition(token);
|
|
136950
137596
|
if (cdef === undefined) {
|
|
136951
137597
|
throw "buildConstructorCDEFNotFound, " + token.getStr();
|
|
@@ -136954,7 +137600,7 @@ class ClassImplementationTranspiler {
|
|
|
136954
137600
|
if (ret === "") {
|
|
136955
137601
|
return ret;
|
|
136956
137602
|
}
|
|
136957
|
-
const privates = this.buildPrivate(
|
|
137603
|
+
const privates = this.buildPrivate(token, traversal);
|
|
136958
137604
|
// note: for CALL TRANSFORMATION, its nice that the values are initialized by the JS constructor,
|
|
136959
137605
|
return privates + "constructor() {\n" + ret + "}\n";
|
|
136960
137606
|
}
|
|
@@ -137259,12 +137905,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
137259
137905
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
137260
137906
|
exports.FormTranspiler = void 0;
|
|
137261
137907
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
137908
|
+
const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
|
|
137262
137909
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
137263
137910
|
const inline_1 = __webpack_require__(/*! ../inline */ "./node_modules/@abaplint/transpiler/build/src/inline.js");
|
|
137264
137911
|
class FormTranspiler {
|
|
137265
137912
|
transpile(node, traversal) {
|
|
137266
137913
|
const formName = node.findFirstStatement(abaplint.Statements.Form)
|
|
137267
|
-
?.findDirectExpression(abaplint.Expressions.FormName)?.concatTokens()
|
|
137914
|
+
?.findDirectExpression(abaplint.Expressions.FormName)?.concatTokens().toUpperCase();
|
|
137268
137915
|
const ret = new chunk_1.Chunk();
|
|
137269
137916
|
for (const c of node.getChildren()) {
|
|
137270
137917
|
ret.appendChunk(traversal.traverse(c));
|
|
@@ -137274,7 +137921,7 @@ class FormTranspiler {
|
|
|
137274
137921
|
}
|
|
137275
137922
|
}
|
|
137276
137923
|
if (formName && traversal.getCurrentObject().getType() === "PROG") {
|
|
137277
|
-
ret.appendString(`abap.Forms['PROG-${traversal.getCurrentObject().getName().toUpperCase()}-${formName}'] = ${formName
|
|
137924
|
+
ret.appendString(`abap.Forms['PROG-${traversal.getCurrentObject().getName().toUpperCase()}-${formName}'] = ${traversal_1.Traversal.formName(formName)};`);
|
|
137278
137925
|
}
|
|
137279
137926
|
return ret;
|
|
137280
137927
|
}
|
|
@@ -138744,6 +139391,9 @@ class Traversal {
|
|
|
138744
139391
|
reg;
|
|
138745
139392
|
options;
|
|
138746
139393
|
typeFactories;
|
|
139394
|
+
/** set when the executable program level code is collected into the program's main function,
|
|
139395
|
+
* shared with the traversals of its INCLUDEs, see traverseProgramLevel */
|
|
139396
|
+
programMain = undefined;
|
|
138747
139397
|
constructor(spaghetti, file, obj, reg, options, typeFactories) {
|
|
138748
139398
|
this.spaghetti = spaghetti;
|
|
138749
139399
|
this.file = file;
|
|
@@ -138813,12 +139463,27 @@ class Traversal {
|
|
|
138813
139463
|
}
|
|
138814
139464
|
return name + "";
|
|
138815
139465
|
}
|
|
139466
|
+
/** the javascript function name of a FORM, from the FormName expression or the ABAP name. FORM names
|
|
139467
|
+
* can contain dashes, eg. "top-of-page", and namespaces, all references must use this */
|
|
139468
|
+
static formName(name) {
|
|
139469
|
+
const abap = typeof name === "string" ? name : name.concatTokens();
|
|
139470
|
+
return Traversal.prefixVariable(Traversal.escapeNamespace(abap.toLowerCase()).replace(/-/g, "$"));
|
|
139471
|
+
}
|
|
138816
139472
|
static isBracketComponent(name) {
|
|
138817
139473
|
return name.match(/^\d/) !== null || name.includes("/") || name.startsWith("%");
|
|
138818
139474
|
}
|
|
138819
139475
|
getCurrentObject() {
|
|
138820
139476
|
return this.obj;
|
|
138821
139477
|
}
|
|
139478
|
+
/** true if the file is part of the current object, include programs are inlined into the object using them */
|
|
139479
|
+
isCurrentObjectFile(filename) {
|
|
139480
|
+
if (this.getCurrentObject().getABAPFileByName(filename) !== undefined) {
|
|
139481
|
+
return true;
|
|
139482
|
+
}
|
|
139483
|
+
const file = this.reg.getFileByName(filename);
|
|
139484
|
+
const found = file ? this.reg.findObjectForFile(file) : undefined;
|
|
139485
|
+
return found instanceof abaplint.Objects.Program && found.isInclude();
|
|
139486
|
+
}
|
|
138822
139487
|
traverse(node) {
|
|
138823
139488
|
if (node instanceof abaplint.Nodes.StructureNode) {
|
|
138824
139489
|
return this.traverseStructure(node);
|
|
@@ -138888,6 +139553,13 @@ class Traversal {
|
|
|
138888
139553
|
// workaround for INCLUDEs in function groups
|
|
138889
139554
|
return this.fuctionGroupWorkaround(token);
|
|
138890
139555
|
}
|
|
139556
|
+
if (node === undefined
|
|
139557
|
+
&& this.obj instanceof abaplint.Objects.Program
|
|
139558
|
+
&& this.obj.getABAPFileByName(filename) === undefined
|
|
139559
|
+
&& this.isCurrentObjectFile(filename)) {
|
|
139560
|
+
// INCLUDE in program, the program level scope only covers the main file
|
|
139561
|
+
return this.spaghetti.getFirstChild()?.getFirstChild();
|
|
139562
|
+
}
|
|
138891
139563
|
return node;
|
|
138892
139564
|
}
|
|
138893
139565
|
fuctionGroupWorkaround(token) {
|
|
@@ -138964,7 +139636,7 @@ class Traversal {
|
|
|
138964
139636
|
}
|
|
138965
139637
|
prefixAndName(t, filename) {
|
|
138966
139638
|
let name = t.getStr().toLowerCase().replace(/^!/, "");
|
|
138967
|
-
if (filename && this.
|
|
139639
|
+
if (filename && this.isCurrentObjectFile(filename) === false) {
|
|
138968
139640
|
// the prefix is from a different object
|
|
138969
139641
|
const file = this.reg.getFileByName(filename);
|
|
138970
139642
|
if (file) {
|
|
@@ -139301,7 +139973,7 @@ class Traversal {
|
|
|
139301
139973
|
return scope?.getIdentifier().sname;
|
|
139302
139974
|
}
|
|
139303
139975
|
}
|
|
139304
|
-
else if (this.
|
|
139976
|
+
else if (this.isCurrentObjectFile(ref.getFilename())) {
|
|
139305
139977
|
const scope = this.spaghetti.lookupPosition(ref.getStart(), ref.getFilename());
|
|
139306
139978
|
if (scope?.getIdentifier().stype === abaplint.ScopeType.Interface) {
|
|
139307
139979
|
return scope?.getIdentifier().sname;
|
|
@@ -139845,10 +140517,76 @@ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
|
|
|
139845
140517
|
}
|
|
139846
140518
|
}
|
|
139847
140519
|
}
|
|
140520
|
+
static PROGRAM_LEVEL_DECLARATIONS = [
|
|
140521
|
+
abaplint.Statements.Data, abaplint.Statements.DataBegin, abaplint.Statements.DataEnd,
|
|
140522
|
+
abaplint.Statements.Constant, abaplint.Statements.ConstantBegin,
|
|
140523
|
+
abaplint.Statements.Type, abaplint.Statements.TypeBegin, abaplint.Statements.TypeEnum,
|
|
140524
|
+
abaplint.Statements.FieldSymbol, abaplint.Statements.Static, abaplint.Statements.StaticBegin,
|
|
140525
|
+
abaplint.Statements.Tables, abaplint.Statements.TypePools, abaplint.Statements.Ranges, abaplint.Statements.Nodes,
|
|
140526
|
+
abaplint.Statements.Parameter, abaplint.Statements.SelectOption, abaplint.Statements.SelectionScreen,
|
|
140527
|
+
abaplint.Statements.ClassDeferred, abaplint.Statements.InterfaceDeferred,
|
|
140528
|
+
abaplint.Statements.ClassDefinitionLoad, abaplint.Statements.InterfaceLoad,
|
|
140529
|
+
abaplint.Statements.Define, abaplint.Statements.Include, abaplint.Statements.Report, abaplint.Statements.Program,
|
|
140530
|
+
];
|
|
140531
|
+
static isProgramLevelDeclaration(node) {
|
|
140532
|
+
const get = node.get();
|
|
140533
|
+
if (node instanceof abaplint.Nodes.StatementNode) {
|
|
140534
|
+
return Traversal.PROGRAM_LEVEL_DECLARATIONS.some(d => get instanceof d);
|
|
140535
|
+
}
|
|
140536
|
+
else if (node instanceof abaplint.Nodes.StructureNode) {
|
|
140537
|
+
return get instanceof abaplint.Structures.Data
|
|
140538
|
+
|| get instanceof abaplint.Structures.Constants
|
|
140539
|
+
|| get instanceof abaplint.Structures.Types
|
|
140540
|
+
|| get instanceof abaplint.Structures.TypeEnum
|
|
140541
|
+
|| get instanceof abaplint.Structures.Statics
|
|
140542
|
+
|| get instanceof abaplint.Structures.Define;
|
|
140543
|
+
}
|
|
140544
|
+
return false;
|
|
140545
|
+
}
|
|
140546
|
+
/** Splits the top level of a program, or of an INCLUDE expanded into it: declarations, classes and FORMs
|
|
140547
|
+
* stay on module level and are returned, the executable statements and event blocks are appended to
|
|
140548
|
+
* programMain. Declarations nested in executable blocks are global in ABAP, they stay on module level */
|
|
140549
|
+
traverseProgramLevel(node, main) {
|
|
140550
|
+
const ret = new chunk_1.Chunk();
|
|
140551
|
+
for (const c of node.getChildren()) {
|
|
140552
|
+
if (c instanceof abaplint.Nodes.StatementNode) {
|
|
140553
|
+
// event statements like INITIALIZATION are executable, REPORT, PARAMETERS etc. are declarations
|
|
140554
|
+
(Traversal.isProgramLevelDeclaration(c) ? ret : main).appendChunk(this.traverse(c));
|
|
140555
|
+
continue;
|
|
140556
|
+
}
|
|
140557
|
+
else if (!(c.get() instanceof abaplint.Structures.Normal)) {
|
|
140558
|
+
// classes, interfaces, FORMs
|
|
140559
|
+
ret.appendChunk(this.traverse(c));
|
|
140560
|
+
continue;
|
|
140561
|
+
}
|
|
140562
|
+
for (const n of c.getChildren()) {
|
|
140563
|
+
if (Traversal.isProgramLevelDeclaration(n)) {
|
|
140564
|
+
ret.appendChunk(this.traverse(n));
|
|
140565
|
+
}
|
|
140566
|
+
else if (n instanceof abaplint.Nodes.StructureNode) {
|
|
140567
|
+
ret.appendChunk(this.declareNestedEarly(n));
|
|
140568
|
+
this.blockDepth++;
|
|
140569
|
+
try {
|
|
140570
|
+
main.appendChunk(this.traverseStructure(n));
|
|
140571
|
+
}
|
|
140572
|
+
finally {
|
|
140573
|
+
this.blockDepth--;
|
|
140574
|
+
}
|
|
140575
|
+
}
|
|
140576
|
+
else {
|
|
140577
|
+
main.appendChunk(this.traverse(n));
|
|
140578
|
+
}
|
|
140579
|
+
}
|
|
140580
|
+
}
|
|
140581
|
+
return ret;
|
|
140582
|
+
}
|
|
139848
140583
|
traverseStructure(node) {
|
|
139849
140584
|
if (this.declaredEarly.has(node) && this.emittingEarly === false) {
|
|
139850
140585
|
return new chunk_1.Chunk();
|
|
139851
140586
|
}
|
|
140587
|
+
else if (this.programMain !== undefined && node.get() instanceof abaplint.Structures.Any) {
|
|
140588
|
+
return this.traverseProgramLevel(node, this.programMain);
|
|
140589
|
+
}
|
|
139852
140590
|
else if (this.blockDepth === 0 && node.get() instanceof abaplint.Structures.Normal) {
|
|
139853
140591
|
return this.traverseProcedureLevel(node);
|
|
139854
140592
|
}
|
|
@@ -140169,6 +140907,7 @@ exports.UnitTest = void 0;
|
|
|
140169
140907
|
/* eslint-disable max-len */
|
|
140170
140908
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
140171
140909
|
const output_layout_1 = __webpack_require__(/*! ./output_layout */ "./node_modules/@abaplint/transpiler/build/src/output_layout.js");
|
|
140910
|
+
const program_includes_1 = __webpack_require__(/*! ./program_includes */ "./node_modules/@abaplint/transpiler/build/src/program_includes.js");
|
|
140172
140911
|
class UnitTest {
|
|
140173
140912
|
layout;
|
|
140174
140913
|
constructor(layout = new output_layout_1.OutputLayout()) {
|
|
@@ -140190,14 +140929,29 @@ async function run() {
|
|
|
140190
140929
|
let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String(), console: new abap.types.String()}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]}), json: new abap.types.String()});
|
|
140191
140930
|
`;
|
|
140192
140931
|
for (const obj of reg.getObjects()) {
|
|
140193
|
-
if (reg.isDependency(obj)
|
|
140932
|
+
if (reg.isDependency(obj)) {
|
|
140194
140933
|
continue;
|
|
140195
140934
|
}
|
|
140196
|
-
|
|
140197
|
-
if (
|
|
140198
|
-
|
|
140935
|
+
let files = [];
|
|
140936
|
+
if (obj instanceof abaplint.Objects.Class) {
|
|
140937
|
+
const hasTestFile = obj.getFiles().some(f => { return f.getFilename().includes(".testclasses."); });
|
|
140938
|
+
if (hasTestFile === true) {
|
|
140939
|
+
ret += ` await import("${(0, output_layout_1.importPath)("index.mjs", this.layout.objectModule(obj, ".testclasses"))}");\n`;
|
|
140940
|
+
}
|
|
140941
|
+
files = obj.getABAPFiles();
|
|
140942
|
+
}
|
|
140943
|
+
else if (obj instanceof abaplint.Objects.Program && obj.isInclude() === false) {
|
|
140944
|
+
// KERNEL_UNIT_RUNNER finds local classes of programs as "PROG-<program>-<class>",
|
|
140945
|
+
// importing the program module registers them, its main function is not run
|
|
140946
|
+
files = (0, program_includes_1.filesWithProgramIncludes)(obj, reg);
|
|
140947
|
+
if (files.some(f => f.getInfo().listClassDefinitions().some(d => d.isForTesting === true && d.isGlobal === false))) {
|
|
140948
|
+
ret += ` await import("${(0, output_layout_1.importPath)("index.mjs", this.layout.objectModule(obj))}");\n`;
|
|
140949
|
+
}
|
|
140199
140950
|
}
|
|
140200
|
-
|
|
140951
|
+
else {
|
|
140952
|
+
continue;
|
|
140953
|
+
}
|
|
140954
|
+
for (const file of files) {
|
|
140201
140955
|
for (const def of file.getInfo().listClassDefinitions()) {
|
|
140202
140956
|
if (def.isForTesting === false || def.isGlobal === true || def.methods.length === 0) {
|
|
140203
140957
|
// todo, fix, there might be global test methods
|
|
@@ -140232,14 +140986,28 @@ run().then(() => {
|
|
|
140232
140986
|
getSortedTests(reg) {
|
|
140233
140987
|
const tests = [];
|
|
140234
140988
|
for (const obj of reg.getObjects()) {
|
|
140235
|
-
if (reg.isDependency(obj)
|
|
140989
|
+
if (reg.isDependency(obj)) {
|
|
140236
140990
|
continue;
|
|
140237
140991
|
}
|
|
140238
|
-
|
|
140239
|
-
|
|
140992
|
+
let files = [];
|
|
140993
|
+
let filename = "";
|
|
140994
|
+
if (obj instanceof abaplint.Objects.Class) {
|
|
140995
|
+
const hasTestFile = obj.getFiles().some(f => { return f.getFilename().includes(".testclasses."); });
|
|
140996
|
+
if (hasTestFile === false) {
|
|
140997
|
+
continue;
|
|
140998
|
+
}
|
|
140999
|
+
files = obj.getABAPFiles();
|
|
141000
|
+
filename = (0, output_layout_1.importPath)("index.mjs", this.layout.objectModule(obj, ".testclasses"));
|
|
141001
|
+
}
|
|
141002
|
+
else if (obj instanceof abaplint.Objects.Program && obj.isInclude() === false) {
|
|
141003
|
+
// local test classes are in the program or its includes, the includes are expanded into the program module
|
|
141004
|
+
files = (0, program_includes_1.filesWithProgramIncludes)(obj, reg);
|
|
141005
|
+
filename = (0, output_layout_1.importPath)("index.mjs", this.layout.objectModule(obj));
|
|
141006
|
+
}
|
|
141007
|
+
else {
|
|
140240
141008
|
continue;
|
|
140241
141009
|
}
|
|
140242
|
-
for (const file of
|
|
141010
|
+
for (const file of files) {
|
|
140243
141011
|
for (const def of file.getInfo().listClassDefinitions()) {
|
|
140244
141012
|
if (def.isForTesting === false
|
|
140245
141013
|
|| def.isGlobal === true
|
|
@@ -140262,7 +141030,7 @@ run().then(() => {
|
|
|
140262
141030
|
}
|
|
140263
141031
|
tests.push({
|
|
140264
141032
|
obj,
|
|
140265
|
-
filename:
|
|
141033
|
+
filename: filename,
|
|
140266
141034
|
localClass: def.name.toLowerCase(),
|
|
140267
141035
|
riskLevel: def.riskLevel,
|
|
140268
141036
|
duration: def.duration,
|