@abaplint/transpiler-cli 2.14.20 → 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/build/bundle.js +198 -93
- package/package.json +3 -3
package/build/bundle.js
CHANGED
|
@@ -28207,8 +28207,11 @@ class ObjectOriented {
|
|
|
28207
28207
|
}
|
|
28208
28208
|
return ret;
|
|
28209
28209
|
}
|
|
28210
|
-
addAliasedAttributes(classDefinition) {
|
|
28210
|
+
addAliasedAttributes(classDefinition, inherited = false) {
|
|
28211
28211
|
for (const alias of classDefinition.getAliases() || []) {
|
|
28212
|
+
if (inherited === true && alias.getVisibility() === visibility_1.Visibility.Private) {
|
|
28213
|
+
continue;
|
|
28214
|
+
}
|
|
28212
28215
|
const comp = alias.getComponent();
|
|
28213
28216
|
const idef = this.scope.findInterfaceDefinition(comp.split("~")[0]);
|
|
28214
28217
|
if (idef) {
|
|
@@ -28222,12 +28225,15 @@ class ObjectOriented {
|
|
|
28222
28225
|
if (superName !== undefined) {
|
|
28223
28226
|
const def = this.scope.findClassDefinition(superName);
|
|
28224
28227
|
if (def) {
|
|
28225
|
-
this.addAliasedAttributes(def);
|
|
28228
|
+
this.addAliasedAttributes(def, true);
|
|
28226
28229
|
}
|
|
28227
28230
|
}
|
|
28228
28231
|
}
|
|
28229
|
-
addAliasedTypes(classDefinition) {
|
|
28232
|
+
addAliasedTypes(classDefinition, inherited = false) {
|
|
28230
28233
|
for (const alias of classDefinition.getAliases() || []) {
|
|
28234
|
+
if (inherited === true && alias.getVisibility() === visibility_1.Visibility.Private) {
|
|
28235
|
+
continue;
|
|
28236
|
+
}
|
|
28231
28237
|
const comp = alias.getComponent();
|
|
28232
28238
|
const idef = this.scope.findInterfaceDefinition(comp.split("~")[0]);
|
|
28233
28239
|
if (idef) {
|
|
@@ -28241,7 +28247,7 @@ class ObjectOriented {
|
|
|
28241
28247
|
if (superName !== undefined) {
|
|
28242
28248
|
const def = this.scope.findClassDefinition(superName);
|
|
28243
28249
|
if (def) {
|
|
28244
|
-
this.addAliasedTypes(def);
|
|
28250
|
+
this.addAliasedTypes(def, true);
|
|
28245
28251
|
}
|
|
28246
28252
|
}
|
|
28247
28253
|
}
|
|
@@ -37244,9 +37250,10 @@ class Source {
|
|
|
37244
37250
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
37245
37251
|
}
|
|
37246
37252
|
if ((foundType === null || foundType === void 0 ? void 0 : foundType.isGeneric()) && bodyType !== undefined) {
|
|
37247
|
-
this.
|
|
37253
|
+
const derived = this.inferGenericConv(foundType, input) || bodyType;
|
|
37254
|
+
this.addIfInferred(node, input, derived);
|
|
37248
37255
|
this.traverseRemainingChildren(children, input);
|
|
37249
|
-
return
|
|
37256
|
+
return derived;
|
|
37250
37257
|
}
|
|
37251
37258
|
this.addIfInferred(node, input, foundType);
|
|
37252
37259
|
this.traverseRemainingChildren(children, input);
|
|
@@ -37548,6 +37555,19 @@ class Source {
|
|
|
37548
37555
|
}
|
|
37549
37556
|
}
|
|
37550
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
|
+
}
|
|
37551
37571
|
static determineType(node, input, targetType) {
|
|
37552
37572
|
const basic = new basic_types_1.BasicTypes(input);
|
|
37553
37573
|
const typeExpression = node.findDirectExpression(Expressions.TypeNameOrInfer);
|
|
@@ -74241,7 +74261,7 @@ class Registry {
|
|
|
74241
74261
|
}
|
|
74242
74262
|
static abaplintVersion() {
|
|
74243
74263
|
// magic, see build script "version.js"
|
|
74244
|
-
return "2.120.
|
|
74264
|
+
return "2.120.96";
|
|
74245
74265
|
}
|
|
74246
74266
|
getDDICReferences() {
|
|
74247
74267
|
return this.ddicReferences;
|
|
@@ -89169,8 +89189,12 @@ ${indentation} output = ${uniqueName}.\n`;
|
|
|
89169
89189
|
const indent = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
89170
89190
|
// the CONV type might just be a component of the row type, so prefer the row type
|
|
89171
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
|
+
}
|
|
89172
89196
|
const declaration = rowOf === undefined
|
|
89173
|
-
? `DATA ${uniqueName} TYPE ${
|
|
89197
|
+
? `DATA ${uniqueName} TYPE ${type}.`
|
|
89174
89198
|
: `DATA ${uniqueName} LIKE LINE OF ${rowOf}.`;
|
|
89175
89199
|
const abap = declaration + "\n" +
|
|
89176
89200
|
indent + `${uniqueName} = ${body}.\n` +
|
|
@@ -114412,6 +114436,7 @@ class XMLConsistency {
|
|
|
114412
114436
|
* Transparent TABL objects have delivery class and size category set
|
|
114413
114437
|
* TABL fields with a built-in type carry the INTTYPE abapGit serializes for it, for the confirmed pairs
|
|
114414
114438
|
* Lock parameter names in ENQU objects are max 16 characters
|
|
114439
|
+
* DEVC objects are serialized as package.devc.xml
|
|
114415
114440
|
* Texts and translations do not exceed maximum allowed length.`,
|
|
114416
114441
|
tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.Syntax],
|
|
114417
114442
|
};
|
|
@@ -114472,6 +114497,9 @@ class XMLConsistency {
|
|
|
114472
114497
|
else if (obj instanceof Objects.LockObject) {
|
|
114473
114498
|
issues.push(...this.runLockObject(obj, file));
|
|
114474
114499
|
}
|
|
114500
|
+
else if (obj instanceof Objects.Package) {
|
|
114501
|
+
issues.push(...this.runPackage(obj, file));
|
|
114502
|
+
}
|
|
114475
114503
|
if (obj instanceof _abap_object_1.ABAPObject) {
|
|
114476
114504
|
issues.push(...this.runTextPool(obj, file));
|
|
114477
114505
|
}
|
|
@@ -114497,14 +114525,26 @@ class XMLConsistency {
|
|
|
114497
114525
|
return issues;
|
|
114498
114526
|
}
|
|
114499
114527
|
checkClearedFields(obj, file, structure, fields) {
|
|
114500
|
-
var _a
|
|
114528
|
+
var _a;
|
|
114501
114529
|
const issues = [];
|
|
114502
|
-
const
|
|
114503
|
-
|
|
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) {
|
|
114504
114537
|
return issues;
|
|
114505
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
|
+
}
|
|
114506
114546
|
for (const field of fields) {
|
|
114507
|
-
if (
|
|
114547
|
+
if (present.has(field)) {
|
|
114508
114548
|
const message = `Field ${field} in ${structure} is cleared by abapGit and should not be in the XML`;
|
|
114509
114549
|
issues.push(issue_1.Issue.atRow(file, 1, message, this.getMetadata().key, this.conf.severity));
|
|
114510
114550
|
}
|
|
@@ -114672,6 +114712,15 @@ class XMLConsistency {
|
|
|
114672
114712
|
}
|
|
114673
114713
|
return issues;
|
|
114674
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
|
+
}
|
|
114675
114724
|
runLockObject(obj, file) {
|
|
114676
114725
|
var _a;
|
|
114677
114726
|
const maxParameterLength = 16;
|
|
@@ -123992,9 +124041,9 @@ class HandleABAP {
|
|
|
123992
124041
|
}
|
|
123993
124042
|
}
|
|
123994
124043
|
for (const c of node?.findAllStatements(abaplint.Statements.Form) || []) {
|
|
123995
|
-
const e = c.findFirstExpression(abaplint.Expressions.FormName)
|
|
124044
|
+
const e = c.findFirstExpression(abaplint.Expressions.FormName);
|
|
123996
124045
|
if (e) {
|
|
123997
|
-
res.push(
|
|
124046
|
+
res.push(traversal_1.Traversal.formName(e));
|
|
123998
124047
|
}
|
|
123999
124048
|
}
|
|
124000
124049
|
return res;
|
|
@@ -127433,6 +127482,11 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
|
|
|
127433
127482
|
class ClassImplementationTranspiler {
|
|
127434
127483
|
transpile(node, traversal) {
|
|
127435
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) {
|
|
127436
127490
|
const def = traversal.getClassDefinition(token);
|
|
127437
127491
|
let ret = "class " + traversal_1.Traversal.escapeNamespace(token.getStr().toLowerCase());
|
|
127438
127492
|
if (token.getStr().toLowerCase() === "cx_root") {
|
|
@@ -127443,13 +127497,13 @@ class ClassImplementationTranspiler {
|
|
|
127443
127497
|
ret += " extends " + traversal_1.Traversal.escapeNamespace(def?.getSuperClass()?.toLowerCase());
|
|
127444
127498
|
}
|
|
127445
127499
|
const scope = traversal.findCurrentScopeByToken(token);
|
|
127446
|
-
return
|
|
127500
|
+
return ret + ` {
|
|
127447
127501
|
static STATIC_SUPER = ${traversal_1.Traversal.escapeNamespace(def?.getSuperClass()?.toLowerCase())};
|
|
127448
127502
|
static INTERNAL_TYPE = 'CLAS';
|
|
127449
127503
|
static INTERNAL_NAME = '${traversal.buildInternalName(token.getStr(), def)}';
|
|
127450
127504
|
static IMPLEMENTED_INTERFACES = [${this.findImplementedByClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
|
|
127451
127505
|
static ATTRIBUTES = {${Array.from(traversal.buildAttributes(def, scope)).join(",\n")}};
|
|
127452
|
-
static METHODS = {${traversal.buildMethods(def, scope).join(",\n")}}
|
|
127506
|
+
static METHODS = {${traversal.buildMethods(def, scope).join(",\n")}};`;
|
|
127453
127507
|
}
|
|
127454
127508
|
findImplementedInterface(traversal, def, scope) {
|
|
127455
127509
|
if (def === undefined || scope === undefined) {
|
|
@@ -130116,10 +130170,10 @@ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@aba
|
|
|
130116
130170
|
class FormTranspiler {
|
|
130117
130171
|
transpile(node, traversal) {
|
|
130118
130172
|
unique_identifier_1.UniqueIdentifier.resetIndexBackup();
|
|
130119
|
-
const
|
|
130173
|
+
const formName = node.findFirstExpression(abaplint.Expressions.FormName);
|
|
130120
130174
|
const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
|
|
130121
|
-
const def = scope?.findFormDefinition(
|
|
130122
|
-
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) {");
|
|
130123
130177
|
const params = [];
|
|
130124
130178
|
for (const p of def?.getChangingParameters() || []) {
|
|
130125
130179
|
params.push(`let ${traversal_1.Traversal.prefixVariable(p.getName())} = INPUT.${p.getName()};`);
|
|
@@ -133117,6 +133171,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
133117
133171
|
exports.PerformTranspiler = void 0;
|
|
133118
133172
|
/* eslint-disable max-len */
|
|
133119
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");
|
|
133120
133175
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
133121
133176
|
class PerformTranspiler {
|
|
133122
133177
|
transpile(node, traversal) {
|
|
@@ -133200,7 +133255,7 @@ class PerformTranspiler {
|
|
|
133200
133255
|
params.push(`"${name}": ` + traversal.traverse(c).getCode());
|
|
133201
133256
|
index++;
|
|
133202
133257
|
}
|
|
133203
|
-
return new chunk_1.Chunk("await " + formName
|
|
133258
|
+
return new chunk_1.Chunk("await " + traversal_1.Traversal.formName(formName) + `({${params.join(",")}});`);
|
|
133204
133259
|
}
|
|
133205
133260
|
}
|
|
133206
133261
|
}
|
|
@@ -134836,12 +134891,62 @@ exports.SelectOptionTranspiler = SelectOptionTranspiler;
|
|
|
134836
134891
|
|
|
134837
134892
|
"use strict";
|
|
134838
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
|
+
})();
|
|
134839
134927
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
134840
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");
|
|
134841
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 */
|
|
134842
134935
|
class SelectionScreenTranspiler {
|
|
134843
|
-
transpile(
|
|
134844
|
-
|
|
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()) + ";");
|
|
134845
134950
|
}
|
|
134846
134951
|
}
|
|
134847
134952
|
exports.SelectionScreenTranspiler = SelectionScreenTranspiler;
|
|
@@ -137154,35 +137259,25 @@ exports.ClassDefinitionTranspiler = void 0;
|
|
|
137154
137259
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
137155
137260
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
137156
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");
|
|
137157
137263
|
class ClassDefinitionTranspiler {
|
|
137158
137264
|
transpile(node, traversal) {
|
|
137159
137265
|
const className = node.findFirstExpression(abaplint.Expressions.ClassName)?.concatTokens().toUpperCase();
|
|
137160
|
-
|
|
137161
|
-
|
|
137162
|
-
|
|
137163
|
-
|
|
137164
|
-
|
|
137165
|
-
|
|
137166
|
-
|
|
137167
|
-
|
|
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);
|
|
137168
137275
|
if (found) {
|
|
137169
137276
|
return new chunk_1.Chunk("");
|
|
137170
137277
|
}
|
|
137171
137278
|
else {
|
|
137172
|
-
//
|
|
137173
|
-
|
|
137174
|
-
return new chunk_1.Chunk(`
|
|
137175
|
-
class ${className?.toLowerCase()} {
|
|
137176
|
-
static INTERNAL_TYPE = 'CLAS';
|
|
137177
|
-
static IMPLEMENTED_INTERFACES = [];
|
|
137178
|
-
static INTERNAL_NAME = 'ABSTRACT_CLASS_INTERNAL_NAME';
|
|
137179
|
-
static ATTRIBUTES = {};
|
|
137180
|
-
async constructor_() {
|
|
137181
|
-
this.me = new abap.types.ABAPObject();
|
|
137182
|
-
this.me.set(this);
|
|
137183
|
-
return this;
|
|
137184
|
-
}
|
|
137185
|
-
}`);
|
|
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);
|
|
137186
137281
|
}
|
|
137187
137282
|
}
|
|
137188
137283
|
}
|
|
@@ -137237,25 +137332,48 @@ exports.ClassImplementationTranspiler = void 0;
|
|
|
137237
137332
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
137238
137333
|
const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
|
|
137239
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";
|
|
137240
137337
|
class ClassImplementationTranspiler {
|
|
137241
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);
|
|
137242
137344
|
const ret = new chunk_1.Chunk();
|
|
137243
137345
|
for (const c of node.getChildren()) {
|
|
137244
137346
|
if (c.get() instanceof abaplint.Statements.EndClass) {
|
|
137245
|
-
ret.appendString(this.buildPartiallyImplementedStubs(
|
|
137347
|
+
ret.appendString(this.buildPartiallyImplementedStubs(token, methods, traversal));
|
|
137246
137348
|
}
|
|
137247
137349
|
ret.appendChunk(traversal.traverse(c));
|
|
137248
137350
|
if (c.get() instanceof abaplint.Statements.ClassImplementation) {
|
|
137249
|
-
ret.appendString(this.buildConstructor(
|
|
137250
|
-
|
|
137251
|
-
|
|
137252
|
-
|
|
137253
|
-
&& this.hasConstructor(node) === false) {
|
|
137254
|
-
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
|
+
}
|
|
137255
137355
|
}
|
|
137256
137356
|
}
|
|
137257
|
-
ret.appendString(this.buildStatic(
|
|
137258
|
-
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));
|
|
137259
137377
|
return ret;
|
|
137260
137378
|
}
|
|
137261
137379
|
///////////////////////////////
|
|
@@ -137263,11 +137381,7 @@ class ClassImplementationTranspiler {
|
|
|
137263
137381
|
* does not implement exist on a system and raise CX_SY_DYN_CALL_ILLEGAL_METHOD
|
|
137264
137382
|
* when called. Emits a method of that shape under the name the implementation
|
|
137265
137383
|
* would have had, so the call ends in that exception and not in a TypeError */
|
|
137266
|
-
buildPartiallyImplementedStubs(
|
|
137267
|
-
const token = node.findFirstExpression(abaplint.Expressions.ClassName)?.getFirstToken();
|
|
137268
|
-
if (token === undefined) {
|
|
137269
|
-
return "";
|
|
137270
|
-
}
|
|
137384
|
+
buildPartiallyImplementedStubs(token, methods, traversal) {
|
|
137271
137385
|
const cdef = traversal.getClassDefinition(token);
|
|
137272
137386
|
const scope = traversal.findCurrentScopeByToken(token);
|
|
137273
137387
|
if (cdef === undefined || scope === undefined) {
|
|
@@ -137279,7 +137393,7 @@ class ClassImplementationTranspiler {
|
|
|
137279
137393
|
}
|
|
137280
137394
|
// the methods the class implements itself, by the emitted name
|
|
137281
137395
|
const implemented = new Set();
|
|
137282
|
-
for (const m of
|
|
137396
|
+
for (const m of methods) {
|
|
137283
137397
|
const name = m.findFirstExpression(abaplint.Expressions.MethodName)?.getFirstToken().getStr();
|
|
137284
137398
|
if (name !== undefined) {
|
|
137285
137399
|
implemented.add(traversal_1.Traversal.escapeNamespace(name.replace("~", "$").toLowerCase()));
|
|
@@ -137356,8 +137470,8 @@ class ClassImplementationTranspiler {
|
|
|
137356
137470
|
ret += "async " + emitted + "(" + unique + ") {\n" + body + "}\n";
|
|
137357
137471
|
return ret;
|
|
137358
137472
|
}
|
|
137359
|
-
hasConstructor(
|
|
137360
|
-
for (const m of
|
|
137473
|
+
hasConstructor(methods) {
|
|
137474
|
+
for (const m of methods) {
|
|
137361
137475
|
const name = m.findFirstExpression(abaplint.Expressions.MethodName)?.getFirstToken().getStr();
|
|
137362
137476
|
if (name?.toUpperCase() === "CONSTRUCTOR") {
|
|
137363
137477
|
return true;
|
|
@@ -137390,11 +137504,8 @@ class ClassImplementationTranspiler {
|
|
|
137390
137504
|
}
|
|
137391
137505
|
return ret;
|
|
137392
137506
|
}
|
|
137393
|
-
buildTypes(
|
|
137394
|
-
|
|
137395
|
-
return "";
|
|
137396
|
-
}
|
|
137397
|
-
const cdef = traversal.getClassDefinition(node.getFirstToken());
|
|
137507
|
+
buildTypes(token, traversal) {
|
|
137508
|
+
const cdef = traversal.getClassDefinition(token);
|
|
137398
137509
|
if (cdef === undefined) {
|
|
137399
137510
|
return "ERROR_CDEF_NOT_FOUND";
|
|
137400
137511
|
}
|
|
@@ -137405,11 +137516,8 @@ class ClassImplementationTranspiler {
|
|
|
137405
137516
|
}
|
|
137406
137517
|
return ret;
|
|
137407
137518
|
}
|
|
137408
|
-
buildPrivate(
|
|
137409
|
-
|
|
137410
|
-
return "";
|
|
137411
|
-
}
|
|
137412
|
-
const cdef = traversal.getClassDefinition(node.getFirstToken());
|
|
137519
|
+
buildPrivate(token, traversal) {
|
|
137520
|
+
const cdef = traversal.getClassDefinition(token);
|
|
137413
137521
|
if (cdef === undefined) {
|
|
137414
137522
|
return "ERROR_CDEF_NOT_FOUND";
|
|
137415
137523
|
}
|
|
@@ -137422,20 +137530,17 @@ class ClassImplementationTranspiler {
|
|
|
137422
137530
|
return ret;
|
|
137423
137531
|
}
|
|
137424
137532
|
/** this builds the part after the class, containing the static variables/constants */
|
|
137425
|
-
buildStatic(
|
|
137426
|
-
|
|
137427
|
-
return "";
|
|
137428
|
-
}
|
|
137429
|
-
const cdef = traversal.getClassDefinition(node.getFirstToken());
|
|
137533
|
+
buildStatic(token, traversal) {
|
|
137534
|
+
const cdef = traversal.getClassDefinition(token);
|
|
137430
137535
|
if (cdef === undefined) {
|
|
137431
137536
|
return "ERROR_CDEF_NOT_FOUND";
|
|
137432
137537
|
}
|
|
137433
|
-
const scope = traversal.findCurrentScopeByToken(
|
|
137538
|
+
const scope = traversal.findCurrentScopeByToken(token);
|
|
137434
137539
|
if (scope === undefined) {
|
|
137435
137540
|
return "ERROR_SCOPE_NOT_FOUND";
|
|
137436
137541
|
}
|
|
137437
137542
|
let ret = "";
|
|
137438
|
-
const clasName =
|
|
137543
|
+
const clasName = token.getStr().toLowerCase();
|
|
137439
137544
|
const staticAttributes = this.findStaticAttributes(cdef, scope, traversal);
|
|
137440
137545
|
for (const attr of staticAttributes) {
|
|
137441
137546
|
const name = traversal_1.Traversal.escapeNamespace(clasName) + "." + traversal_1.Traversal.escapeNamespace(attr.prefix) + traversal_1.Traversal.escapeNamespace(attr.identifier.getName().toLowerCase());
|
|
@@ -137471,29 +137576,22 @@ class ClassImplementationTranspiler {
|
|
|
137471
137576
|
continue;
|
|
137472
137577
|
}
|
|
137473
137578
|
else if (def.methods.some(m => m.name.toLowerCase() === "class_constructor")) {
|
|
137474
|
-
ret += "await " + traversal.lookupClassOrInterface(def.name,
|
|
137579
|
+
ret += "await " + traversal.lookupClassOrInterface(def.name, token) + ".class_constructor();\n";
|
|
137475
137580
|
}
|
|
137476
137581
|
}
|
|
137477
137582
|
}
|
|
137478
137583
|
}
|
|
137479
137584
|
if (cdef.isGlobal() === false && cdef.isForTesting() === true && cdef.getMethodDefinitions().getByName("class_constructor")) {
|
|
137480
|
-
ret += "await " + traversal_1.Traversal.escapeNamespace(
|
|
137585
|
+
ret += "await " + traversal_1.Traversal.escapeNamespace(clasName) + ".class_constructor();\n";
|
|
137481
137586
|
}
|
|
137482
137587
|
}
|
|
137483
137588
|
else if (cdef.getMethodDefinitions().getByName("class_constructor")) {
|
|
137484
|
-
ret += "await " + traversal_1.Traversal.escapeNamespace(
|
|
137589
|
+
ret += "await " + traversal_1.Traversal.escapeNamespace(clasName) + ".class_constructor();\n";
|
|
137485
137590
|
}
|
|
137486
137591
|
return ret;
|
|
137487
137592
|
}
|
|
137488
|
-
buildConstructor(
|
|
137489
|
-
|
|
137490
|
-
throw new Error("buildConstructor node undefined");
|
|
137491
|
-
}
|
|
137492
|
-
const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
|
|
137493
|
-
const token = node.findFirstExpression(abaplint.Expressions.ClassName)?.getFirstToken();
|
|
137494
|
-
if (token === undefined) {
|
|
137495
|
-
throw "buildConstructorTokenNotFound";
|
|
137496
|
-
}
|
|
137593
|
+
buildConstructor(token, traversal) {
|
|
137594
|
+
const scope = traversal.findCurrentScopeByToken(token);
|
|
137497
137595
|
const cdef = traversal.getClassDefinition(token);
|
|
137498
137596
|
if (cdef === undefined) {
|
|
137499
137597
|
throw "buildConstructorCDEFNotFound, " + token.getStr();
|
|
@@ -137502,7 +137600,7 @@ class ClassImplementationTranspiler {
|
|
|
137502
137600
|
if (ret === "") {
|
|
137503
137601
|
return ret;
|
|
137504
137602
|
}
|
|
137505
|
-
const privates = this.buildPrivate(
|
|
137603
|
+
const privates = this.buildPrivate(token, traversal);
|
|
137506
137604
|
// note: for CALL TRANSFORMATION, its nice that the values are initialized by the JS constructor,
|
|
137507
137605
|
return privates + "constructor() {\n" + ret + "}\n";
|
|
137508
137606
|
}
|
|
@@ -137807,12 +137905,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
137807
137905
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
137808
137906
|
exports.FormTranspiler = void 0;
|
|
137809
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");
|
|
137810
137909
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
137811
137910
|
const inline_1 = __webpack_require__(/*! ../inline */ "./node_modules/@abaplint/transpiler/build/src/inline.js");
|
|
137812
137911
|
class FormTranspiler {
|
|
137813
137912
|
transpile(node, traversal) {
|
|
137814
137913
|
const formName = node.findFirstStatement(abaplint.Statements.Form)
|
|
137815
|
-
?.findDirectExpression(abaplint.Expressions.FormName)?.concatTokens()
|
|
137914
|
+
?.findDirectExpression(abaplint.Expressions.FormName)?.concatTokens().toUpperCase();
|
|
137816
137915
|
const ret = new chunk_1.Chunk();
|
|
137817
137916
|
for (const c of node.getChildren()) {
|
|
137818
137917
|
ret.appendChunk(traversal.traverse(c));
|
|
@@ -137822,7 +137921,7 @@ class FormTranspiler {
|
|
|
137822
137921
|
}
|
|
137823
137922
|
}
|
|
137824
137923
|
if (formName && traversal.getCurrentObject().getType() === "PROG") {
|
|
137825
|
-
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)};`);
|
|
137826
137925
|
}
|
|
137827
137926
|
return ret;
|
|
137828
137927
|
}
|
|
@@ -139364,6 +139463,12 @@ class Traversal {
|
|
|
139364
139463
|
}
|
|
139365
139464
|
return name + "";
|
|
139366
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
|
+
}
|
|
139367
139472
|
static isBracketComponent(name) {
|
|
139368
139473
|
return name.match(/^\d/) !== null || name.includes("/") || name.startsWith("%");
|
|
139369
139474
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.21",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"author": "abaplint",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@abaplint/core": "^2.120.
|
|
31
|
-
"@abaplint/transpiler": "^2.14.
|
|
30
|
+
"@abaplint/core": "^2.120.96",
|
|
31
|
+
"@abaplint/transpiler": "^2.14.21",
|
|
32
32
|
"@types/glob": "^9.0.0",
|
|
33
33
|
"@types/node": "^26.6.6",
|
|
34
34
|
"@types/progress": "^2.0.7",
|