@abaplint/transpiler 2.5.66 → 2.5.68
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.
|
@@ -22,7 +22,7 @@ class ClassImplementationTranspiler {
|
|
|
22
22
|
return new chunk_1.Chunk().append(ret + ` {
|
|
23
23
|
static INTERNAL_TYPE = 'CLAS';
|
|
24
24
|
static IMPLEMENTED_INTERFACES = [${this.findImplementedClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
|
|
25
|
-
static ATTRIBUTES = {};`, node, traversal);
|
|
25
|
+
static ATTRIBUTES = {${traversal.buildAttributes(def)}};`, node, traversal);
|
|
26
26
|
}
|
|
27
27
|
findImplementedInterface(traversal, def, scope) {
|
|
28
28
|
if (def === undefined || scope === undefined) {
|
|
@@ -4,7 +4,6 @@ import { Traversal } from "../traversal";
|
|
|
4
4
|
import { Chunk } from "../chunk";
|
|
5
5
|
export declare class InterfaceTranspiler implements IStructureTranspiler {
|
|
6
6
|
transpile(node: abaplint.Nodes.StructureNode, traversal: Traversal): Chunk;
|
|
7
|
-
private buildAttributes;
|
|
8
7
|
private buildTypes;
|
|
9
8
|
private buildConstants;
|
|
10
9
|
}
|
|
@@ -18,7 +18,7 @@ class InterfaceTranspiler {
|
|
|
18
18
|
name = traversal_1.Traversal.escapeNamespace(name);
|
|
19
19
|
ret += `class ${name} {\n`;
|
|
20
20
|
ret += `static INTERNAL_TYPE = 'INTF';\n`;
|
|
21
|
-
ret += `static ATTRIBUTES = {${
|
|
21
|
+
ret += `static ATTRIBUTES = {${traversal.buildAttributes(def)}};\n`;
|
|
22
22
|
}
|
|
23
23
|
else if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.EndInterface) {
|
|
24
24
|
ret += "}\n";
|
|
@@ -29,18 +29,6 @@ class InterfaceTranspiler {
|
|
|
29
29
|
ret += this.buildTypes(def);
|
|
30
30
|
return new chunk_1.Chunk(ret);
|
|
31
31
|
}
|
|
32
|
-
buildAttributes(idef) {
|
|
33
|
-
const attr = [];
|
|
34
|
-
for (const a of (idef === null || idef === void 0 ? void 0 : idef.getAttributes().getAll()) || []) {
|
|
35
|
-
const type = new transpile_types_1.TranspileTypes().toType(a.getType());
|
|
36
|
-
attr.push(`"${a.getName().toUpperCase()}": {"type": ${type}, "visibility": "U", "is_constant": " "}`);
|
|
37
|
-
}
|
|
38
|
-
for (const a of (idef === null || idef === void 0 ? void 0 : idef.getAttributes().getConstants()) || []) {
|
|
39
|
-
const type = new transpile_types_1.TranspileTypes().toType(a.getType());
|
|
40
|
-
attr.push(`"${a.getName().toUpperCase()}": {"type": ${type}, "visibility": "U", "is_constant": "X"}`);
|
|
41
|
-
}
|
|
42
|
-
return attr.join(",\n");
|
|
43
|
-
}
|
|
44
32
|
buildTypes(idef) {
|
|
45
33
|
if (idef === undefined) {
|
|
46
34
|
return "";
|
package/build/src/traversal.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare class Traversal {
|
|
|
24
24
|
private isClassAttribute;
|
|
25
25
|
prefixAndName(t: abaplint.Token, filename?: string): string;
|
|
26
26
|
private isStaticClassAttribute;
|
|
27
|
+
buildAttributes(def: abaplint.IClassDefinition | abaplint.IInterfaceDefinition | undefined): string;
|
|
27
28
|
isBuiltinMethod(token: abaplint.Token): boolean;
|
|
28
29
|
findMethodReference(token: abaplint.Token, scope: ISpaghettiScopeNode | undefined): undefined | {
|
|
29
30
|
def: abaplint.Types.MethodDefinition;
|
package/build/src/traversal.js
CHANGED
|
@@ -169,6 +169,19 @@ class Traversal {
|
|
|
169
169
|
}
|
|
170
170
|
return undefined;
|
|
171
171
|
}
|
|
172
|
+
buildAttributes(def) {
|
|
173
|
+
const attr = [];
|
|
174
|
+
// TODO: visibility is wrong for classes
|
|
175
|
+
for (const a of (def === null || def === void 0 ? void 0 : def.getAttributes().getAll()) || []) {
|
|
176
|
+
const type = new transpile_types_1.TranspileTypes().toType(a.getType());
|
|
177
|
+
attr.push(`"${a.getName().toUpperCase()}": {"type": () => {return ${type};}, "visibility": "U", "is_constant": " "}`);
|
|
178
|
+
}
|
|
179
|
+
for (const a of (def === null || def === void 0 ? void 0 : def.getAttributes().getConstants()) || []) {
|
|
180
|
+
const type = new transpile_types_1.TranspileTypes().toType(a.getType());
|
|
181
|
+
attr.push(`"${a.getName().toUpperCase()}": {"type": () => {return ${type};}, "visibility": "U", "is_constant": "X"}`);
|
|
182
|
+
}
|
|
183
|
+
return attr.join(",\n");
|
|
184
|
+
}
|
|
172
185
|
isBuiltinMethod(token) {
|
|
173
186
|
const scope = this.findCurrentScopeByToken(token);
|
|
174
187
|
if (scope === undefined) {
|