@abaplint/transpiler 2.10.71 → 2.10.73
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.
|
@@ -37,17 +37,23 @@ class FieldChainTranspiler {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
else if (c.get() instanceof core_1.Expressions.AttributeName) {
|
|
40
|
-
|
|
40
|
+
const interfaceName = traversal.isInterfaceAttribute(c.getFirstToken());
|
|
41
|
+
let name = c.getFirstToken().getStr().toLowerCase();
|
|
41
42
|
if (context instanceof abaplint.BasicTypes.ObjectReferenceType) {
|
|
42
43
|
const cdef = traversal.findClassDefinition(context.getIdentifierName(), scope);
|
|
43
44
|
const attr = cdef?.getAttributes().findByName(c.getFirstToken().getStr());
|
|
44
45
|
if (feature_flags_1.FEATURE_FLAGS.PRIVATE_ATTRIBUTES === true
|
|
45
46
|
&& attr?.getVisibility() === abaplint.Visibility.Private) {
|
|
46
|
-
|
|
47
|
+
const id = scope?.getParent()?.getParent()?.getIdentifier();
|
|
48
|
+
if (id?.stype === abaplint.ScopeType.ClassImplementation
|
|
49
|
+
&& cdef?.getName().toUpperCase() === id.sname.toUpperCase()) {
|
|
50
|
+
name = "#" + name;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
name = `FRIENDS_ACCESS_INSTANCE["${name}"]`;
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
|
-
const interfaceName = traversal.isInterfaceAttribute(c.getFirstToken());
|
|
50
|
-
let name = pprefix + c.getFirstToken().getStr().toLowerCase();
|
|
51
57
|
if (prefix && interfaceName && name.startsWith(interfaceName) === false && interfaceNameAdded === false) {
|
|
52
58
|
name = traversal_1.Traversal.escapeNamespace(name).replace("~", "$");
|
|
53
59
|
name = traversal_1.Traversal.escapeNamespace(interfaceName) + "$" + name;
|
package/build/src/traversal.js
CHANGED
|
@@ -413,6 +413,9 @@ class Traversal {
|
|
|
413
413
|
const name = "this." + escaped;
|
|
414
414
|
ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
|
|
415
415
|
ret += this.setValues(a, name);
|
|
416
|
+
if (escaped?.startsWith("#")) {
|
|
417
|
+
ret += `this.FRIENDS_ACCESS_INSTANCE["${escaped.replace("#", "")}"] = ${name};\n`;
|
|
418
|
+
}
|
|
416
419
|
}
|
|
417
420
|
}
|
|
418
421
|
return ret;
|
|
@@ -422,18 +425,35 @@ class Traversal {
|
|
|
422
425
|
if (hasSuperClass === true) {
|
|
423
426
|
ret += `"SUPER": sup.FRIENDS_ACCESS_INSTANCE,\n`;
|
|
424
427
|
}
|
|
425
|
-
for (const
|
|
426
|
-
const name =
|
|
427
|
-
if (name === "constructor" ||
|
|
428
|
+
for (const method of def.getMethodDefinitions()?.getAll() || []) {
|
|
429
|
+
const name = method.getName().toLowerCase();
|
|
430
|
+
if (name === "constructor" || method.isStatic() === true) {
|
|
428
431
|
continue;
|
|
429
432
|
}
|
|
430
433
|
let privateHash = "";
|
|
431
|
-
if (
|
|
434
|
+
if (method.getVisibility() === abaplint.Visibility.Private) {
|
|
432
435
|
privateHash = "#";
|
|
433
436
|
}
|
|
434
437
|
const methodName = privateHash + Traversal.escapeNamespace(name.replace("~", "$"));
|
|
438
|
+
// NOTE: currently all are needed in the unit test setup
|
|
435
439
|
ret += `"${name.replace("~", "$")}": this.${methodName}.bind(this),\n`;
|
|
436
440
|
}
|
|
441
|
+
/*
|
|
442
|
+
for (const attribute of def.getAttributes()?.getAll() || []) {
|
|
443
|
+
if (attribute.getMeta().includes(abaplint.IdentifierMeta.Static) === true) {
|
|
444
|
+
// hmm, is this correct?
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
let privateHash = "";
|
|
448
|
+
if (attribute.getVisibility() === abaplint.Visibility.Private) {
|
|
449
|
+
privateHash = "#";
|
|
450
|
+
} else {
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
const attributeName = privateHash + Traversal.escapeNamespace(attribute.getName().toLowerCase());
|
|
454
|
+
ret += `"${attribute.getName().toLowerCase()}": this.${attributeName},\n`;
|
|
455
|
+
}
|
|
456
|
+
*/
|
|
437
457
|
ret += "};\n";
|
|
438
458
|
return ret;
|
|
439
459
|
}
|