@abaplint/transpiler-cli 2.10.66 → 2.10.69
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 +83 -8
- package/package.json +2 -2
package/build/bundle.js
CHANGED
|
@@ -80732,13 +80732,17 @@ exports.StringTemplateSourceTranspiler = StringTemplateSourceTranspiler;
|
|
|
80732
80732
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
80733
80733
|
exports.TargetTranspiler = void 0;
|
|
80734
80734
|
const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
|
|
80735
|
+
const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
|
|
80735
80736
|
const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
|
|
80736
80737
|
const _1 = __webpack_require__(/*! . */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
|
|
80737
80738
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
80739
|
+
const feature_flags_1 = __webpack_require__(/*! ../feature_flags */ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js");
|
|
80738
80740
|
class TargetTranspiler {
|
|
80739
80741
|
transpile(node, traversal) {
|
|
80740
80742
|
const offset = [];
|
|
80741
80743
|
let ret = new chunk_1.Chunk();
|
|
80744
|
+
let context = undefined;
|
|
80745
|
+
const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
|
|
80742
80746
|
const children = node.getChildren();
|
|
80743
80747
|
for (let i = 0; i < children.length; i++) {
|
|
80744
80748
|
const c = children[i];
|
|
@@ -80746,6 +80750,7 @@ class TargetTranspiler {
|
|
|
80746
80750
|
if (c.get() instanceof core_1.Expressions.TargetField) {
|
|
80747
80751
|
const prefix = traversal.prefixAndName(c.getFirstToken()).replace("~", "$");
|
|
80748
80752
|
ret.append(traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(prefix)), c, traversal);
|
|
80753
|
+
context = scope?.findVariable(c.getFirstToken().getStr())?.getType();
|
|
80749
80754
|
}
|
|
80750
80755
|
else if (c.get() instanceof core_1.Expressions.ClassName) {
|
|
80751
80756
|
const name = traversal.lookupClassOrInterface(c.getFirstToken().getStr(), c.getFirstToken());
|
|
@@ -80761,8 +80766,17 @@ class TargetTranspiler {
|
|
|
80761
80766
|
}
|
|
80762
80767
|
}
|
|
80763
80768
|
else if (c.get() instanceof core_1.Expressions.AttributeName) {
|
|
80769
|
+
let prefix = "";
|
|
80770
|
+
if (context instanceof abaplint.BasicTypes.ObjectReferenceType) {
|
|
80771
|
+
const cdef = traversal.findClassDefinition(context.getIdentifierName(), scope);
|
|
80772
|
+
const attr = cdef?.getAttributes().findByName(c.getFirstToken().getStr());
|
|
80773
|
+
if (feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === true
|
|
80774
|
+
&& attr?.getVisibility() === abaplint.Visibility.Private) {
|
|
80775
|
+
prefix = "#";
|
|
80776
|
+
}
|
|
80777
|
+
}
|
|
80764
80778
|
const intf = traversal_1.Traversal.escapeNamespace(traversal.isInterfaceAttribute(c.getFirstToken()));
|
|
80765
|
-
let name = traversal_1.Traversal.escapeNamespace(c.getFirstToken().getStr()).replace("~", "$").toLowerCase();
|
|
80779
|
+
let name = prefix + traversal_1.Traversal.escapeNamespace(c.getFirstToken().getStr()).replace("~", "$").toLowerCase();
|
|
80766
80780
|
if (intf && name.startsWith(intf) === false) {
|
|
80767
80781
|
name = intf + "$" + name;
|
|
80768
80782
|
}
|
|
@@ -80811,6 +80825,23 @@ exports.TargetTranspiler = TargetTranspiler;
|
|
|
80811
80825
|
|
|
80812
80826
|
/***/ }),
|
|
80813
80827
|
|
|
80828
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js":
|
|
80829
|
+
/*!**********************************************************************!*\
|
|
80830
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/feature_flags.js ***!
|
|
80831
|
+
\**********************************************************************/
|
|
80832
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
80833
|
+
|
|
80834
|
+
"use strict";
|
|
80835
|
+
|
|
80836
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
80837
|
+
exports.FEATURE_FLAGS = void 0;
|
|
80838
|
+
exports.FEATURE_FLAGS = {
|
|
80839
|
+
PRIVATE_ATTRIBUTES: true,
|
|
80840
|
+
};
|
|
80841
|
+
//# sourceMappingURL=feature_flags.js.map
|
|
80842
|
+
|
|
80843
|
+
/***/ }),
|
|
80844
|
+
|
|
80814
80845
|
/***/ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js":
|
|
80815
80846
|
/*!*****************************************************************************!*\
|
|
80816
80847
|
!*** ./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js ***!
|
|
@@ -88168,6 +88199,7 @@ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abap
|
|
|
88168
88199
|
const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
|
|
88169
88200
|
const transpile_types_1 = __webpack_require__(/*! ../transpile_types */ "./node_modules/@abaplint/transpiler/build/src/transpile_types.js");
|
|
88170
88201
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
88202
|
+
const feature_flags_1 = __webpack_require__(/*! ../feature_flags */ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js");
|
|
88171
88203
|
class ClassImplementationTranspiler {
|
|
88172
88204
|
transpile(node, traversal) {
|
|
88173
88205
|
const ret = new chunk_1.Chunk();
|
|
@@ -88236,6 +88268,22 @@ class ClassImplementationTranspiler {
|
|
|
88236
88268
|
}
|
|
88237
88269
|
return ret;
|
|
88238
88270
|
}
|
|
88271
|
+
buildPrivate(node, traversal) {
|
|
88272
|
+
if (node === undefined || feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === false) {
|
|
88273
|
+
return "";
|
|
88274
|
+
}
|
|
88275
|
+
const cdef = traversal.getClassDefinition(node.getFirstToken());
|
|
88276
|
+
if (cdef === undefined) {
|
|
88277
|
+
return "ERROR_CDEF_NOT_FOUND";
|
|
88278
|
+
}
|
|
88279
|
+
let ret = "";
|
|
88280
|
+
for (const attr of cdef.getAttributes().getAll()) {
|
|
88281
|
+
if (attr.getVisibility() === abaplint.Visibility.Private) {
|
|
88282
|
+
ret += "#" + traversal_1.Traversal.escapeNamespace(attr.getName().toLowerCase()) + ";\n";
|
|
88283
|
+
}
|
|
88284
|
+
}
|
|
88285
|
+
return ret;
|
|
88286
|
+
}
|
|
88239
88287
|
/** this builds the part after the class, containing the static variables/constants */
|
|
88240
88288
|
buildStatic(node, traversal) {
|
|
88241
88289
|
if (node === undefined) {
|
|
@@ -88307,8 +88355,9 @@ class ClassImplementationTranspiler {
|
|
|
88307
88355
|
if (ret === "") {
|
|
88308
88356
|
return ret;
|
|
88309
88357
|
}
|
|
88358
|
+
const privates = this.buildPrivate(node.findFirstExpression(abaplint.Expressions.ClassName), traversal);
|
|
88310
88359
|
// note: for CALL TRANSFORMATION, its nice that the values are initialized by the JS constructor,
|
|
88311
|
-
return "constructor() {\n" + ret + "}\n";
|
|
88360
|
+
return privates + "constructor() {\n" + ret + "}\n";
|
|
88312
88361
|
}
|
|
88313
88362
|
}
|
|
88314
88363
|
exports.ClassImplementationTranspiler = ClassImplementationTranspiler;
|
|
@@ -89301,6 +89350,7 @@ const transpile_types_1 = __webpack_require__(/*! ./transpile_types */ "./node_m
|
|
|
89301
89350
|
const chunk_1 = __webpack_require__(/*! ./chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
89302
89351
|
const expressions_1 = __webpack_require__(/*! ./expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
|
|
89303
89352
|
const keywords_1 = __webpack_require__(/*! ./keywords */ "./node_modules/@abaplint/transpiler/build/src/keywords.js");
|
|
89353
|
+
const feature_flags_1 = __webpack_require__(/*! ./feature_flags */ "./node_modules/@abaplint/transpiler/build/src/feature_flags.js");
|
|
89304
89354
|
class Traversal {
|
|
89305
89355
|
constructor(spaghetti, file, obj, reg, options) {
|
|
89306
89356
|
this.scopeCache = undefined;
|
|
@@ -89416,6 +89466,22 @@ class Traversal {
|
|
|
89416
89466
|
}
|
|
89417
89467
|
return undefined;
|
|
89418
89468
|
}
|
|
89469
|
+
isPrivateAttribute(token) {
|
|
89470
|
+
const scope = this.findCurrentScopeByToken(token);
|
|
89471
|
+
if (scope === undefined) {
|
|
89472
|
+
throw new Error("isPrivateAttribute, unable to lookup position");
|
|
89473
|
+
}
|
|
89474
|
+
const name = token.getStr();
|
|
89475
|
+
if (name.toLowerCase() === "me") {
|
|
89476
|
+
return false;
|
|
89477
|
+
}
|
|
89478
|
+
const found = scope.findVariable(name);
|
|
89479
|
+
if (found instanceof abaplint.Types.ClassAttribute
|
|
89480
|
+
&& found.getVisibility() === abaplint.Visibility.Private) {
|
|
89481
|
+
return true;
|
|
89482
|
+
}
|
|
89483
|
+
return false;
|
|
89484
|
+
}
|
|
89419
89485
|
isClassAttribute(token) {
|
|
89420
89486
|
const scope = this.findCurrentScopeByToken(token);
|
|
89421
89487
|
if (scope === undefined) {
|
|
@@ -89457,7 +89523,11 @@ class Traversal {
|
|
|
89457
89523
|
return name;
|
|
89458
89524
|
}
|
|
89459
89525
|
else if (this.isClassAttribute(t)) {
|
|
89460
|
-
|
|
89526
|
+
let escaped = Traversal.escapeNamespace(name);
|
|
89527
|
+
if (feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === true && this.isPrivateAttribute(t)) {
|
|
89528
|
+
escaped = "#" + escaped;
|
|
89529
|
+
}
|
|
89530
|
+
name = "this." + escaped;
|
|
89461
89531
|
}
|
|
89462
89532
|
else if (this.isBuiltinVariable(t)) {
|
|
89463
89533
|
name = "abap.builtin." + name.toLowerCase().replace("%", "$");
|
|
@@ -89672,14 +89742,19 @@ class Traversal {
|
|
|
89672
89742
|
buildThisAttributes(def, cName) {
|
|
89673
89743
|
let ret = "";
|
|
89674
89744
|
for (const a of def.getAttributes()?.getAll() || []) {
|
|
89675
|
-
|
|
89745
|
+
let escaped = Traversal.escapeNamespace(a.getName().toLowerCase());
|
|
89676
89746
|
if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
|
|
89677
89747
|
ret += "this." + escaped + " = " + cName + "." + escaped + ";\n";
|
|
89678
|
-
continue;
|
|
89679
89748
|
}
|
|
89680
|
-
|
|
89681
|
-
|
|
89682
|
-
|
|
89749
|
+
else {
|
|
89750
|
+
if (feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === true
|
|
89751
|
+
&& a.getVisibility() === abaplint.Visibility.Private) {
|
|
89752
|
+
escaped = "#" + escaped;
|
|
89753
|
+
}
|
|
89754
|
+
const name = "this." + escaped;
|
|
89755
|
+
ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
|
|
89756
|
+
ret += this.setValues(a, name);
|
|
89757
|
+
}
|
|
89683
89758
|
}
|
|
89684
89759
|
return ret;
|
|
89685
89760
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.69",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@abaplint/core": "^2.113.149",
|
|
31
|
-
"@abaplint/transpiler": "^2.10.
|
|
31
|
+
"@abaplint/transpiler": "^2.10.69",
|
|
32
32
|
"@types/glob": "^8.1.0",
|
|
33
33
|
"@types/node": "^22.16.5",
|
|
34
34
|
"@types/progress": "^2.0.7",
|