@abaplint/transpiler 1.7.2 → 1.7.3
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.
|
@@ -5,28 +5,13 @@ const abaplint = require("@abaplint/core");
|
|
|
5
5
|
const chunk_1 = require("../chunk");
|
|
6
6
|
class EndMethodTranspiler {
|
|
7
7
|
transpile(node, traversal) {
|
|
8
|
-
var _a, _b;
|
|
9
8
|
const token = node.getFirstToken();
|
|
10
9
|
const scope = traversal.findCurrentScopeByToken(token);
|
|
11
10
|
if (scope === undefined) {
|
|
12
11
|
throw new Error("EndMethodTranspiler, scope not found");
|
|
13
12
|
}
|
|
14
13
|
let returning = "";
|
|
15
|
-
|
|
16
|
-
if ((scope === null || scope === void 0 ? void 0 : scope.getIdentifier().stype) === abaplint.ScopeType.Method) {
|
|
17
|
-
methodName = scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname;
|
|
18
|
-
}
|
|
19
|
-
let className = undefined;
|
|
20
|
-
if (((_a = scope === null || scope === void 0 ? void 0 : scope.getParent()) === null || _a === void 0 ? void 0 : _a.getIdentifier().stype) === abaplint.ScopeType.ClassImplementation) {
|
|
21
|
-
className = (_b = scope === null || scope === void 0 ? void 0 : scope.getParent()) === null || _b === void 0 ? void 0 : _b.getIdentifier().sname;
|
|
22
|
-
}
|
|
23
|
-
if (methodName && className) {
|
|
24
|
-
const classDef = scope.findClassDefinition(className);
|
|
25
|
-
const methodDef = classDef === null || classDef === void 0 ? void 0 : classDef.getMethodDefinitions().getByName(methodName);
|
|
26
|
-
if (methodDef && methodDef.getExceptions().length > 0) {
|
|
27
|
-
returning += "abap.builtin.sy.get().subrc.set(0);\n";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
14
|
+
returning += this.setSubrc(scope, traversal);
|
|
30
15
|
const vars = scope.getData().vars;
|
|
31
16
|
for (const n in vars) {
|
|
32
17
|
const identifier = vars[n];
|
|
@@ -40,6 +25,34 @@ class EndMethodTranspiler {
|
|
|
40
25
|
}
|
|
41
26
|
return new chunk_1.Chunk().append(returning + "}", node, traversal);
|
|
42
27
|
}
|
|
28
|
+
setSubrc(scope, traversal) {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
let methodName = undefined;
|
|
31
|
+
if ((scope === null || scope === void 0 ? void 0 : scope.getIdentifier().stype) === abaplint.ScopeType.Method) {
|
|
32
|
+
methodName = scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname;
|
|
33
|
+
}
|
|
34
|
+
let className = undefined;
|
|
35
|
+
if (((_a = scope === null || scope === void 0 ? void 0 : scope.getParent()) === null || _a === void 0 ? void 0 : _a.getIdentifier().stype) === abaplint.ScopeType.ClassImplementation) {
|
|
36
|
+
className = (_b = scope === null || scope === void 0 ? void 0 : scope.getParent()) === null || _b === void 0 ? void 0 : _b.getIdentifier().sname;
|
|
37
|
+
}
|
|
38
|
+
if (methodName === undefined || className === undefined) {
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
let methodDef = undefined;
|
|
42
|
+
if (methodName.includes("~")) {
|
|
43
|
+
const split = methodName.split("~");
|
|
44
|
+
const classDef = traversal.findInterfaceDefinition(split[0], scope);
|
|
45
|
+
methodDef = classDef === null || classDef === void 0 ? void 0 : classDef.getMethodDefinitions().getByName(split[1]);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const classDef = traversal.findClassDefinition(className, scope);
|
|
49
|
+
methodDef = classDef === null || classDef === void 0 ? void 0 : classDef.getMethodDefinitions().getByName(methodName);
|
|
50
|
+
}
|
|
51
|
+
if (methodDef && methodDef.getExceptions().length > 0) {
|
|
52
|
+
return "abap.builtin.sy.get().subrc.set(0);\n";
|
|
53
|
+
}
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
43
56
|
}
|
|
44
57
|
exports.EndMethodTranspiler = EndMethodTranspiler;
|
|
45
58
|
//# sourceMappingURL=end_method.js.map
|
package/build/src/traversal.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export declare class Traversal {
|
|
|
31
31
|
isInterfaceAttribute(token: abaplint.Token): string | undefined;
|
|
32
32
|
private findReadOrWriteReference;
|
|
33
33
|
buildConstructorContents(scope: abaplint.ISpaghettiScopeNode | undefined, def: abaplint.IClassDefinition, inputName: string): string;
|
|
34
|
+
findInterfaceDefinition(name: string, scope: abaplint.ISpaghettiScopeNode | undefined): abaplint.IInterfaceDefinition | undefined;
|
|
35
|
+
findClassDefinition(name: string, scope: abaplint.ISpaghettiScopeNode | undefined): abaplint.IClassDefinition | undefined;
|
|
34
36
|
private dataFromInterfaces;
|
|
35
37
|
determineType(node: abaplint.Nodes.ExpressionNode | abaplint.Nodes.StatementNode, scope: abaplint.ISpaghettiScopeNode | undefined): abaplint.AbstractType | undefined;
|
|
36
38
|
registerClassOrInterface(def: abaplint.IClassDefinition | abaplint.IInterfaceDefinition | undefined): string;
|
package/build/src/traversal.js
CHANGED
|
@@ -281,13 +281,25 @@ class Traversal {
|
|
|
281
281
|
}
|
|
282
282
|
return ret;
|
|
283
283
|
}
|
|
284
|
-
|
|
285
|
-
let ret = "";
|
|
284
|
+
findInterfaceDefinition(name, scope) {
|
|
286
285
|
let intf = scope === null || scope === void 0 ? void 0 : scope.findInterfaceDefinition(name);
|
|
287
286
|
if (intf === undefined) {
|
|
288
287
|
const iglobal = this.reg.getObject("INTF", name);
|
|
289
288
|
intf = iglobal === null || iglobal === void 0 ? void 0 : iglobal.getDefinition();
|
|
290
289
|
}
|
|
290
|
+
return intf;
|
|
291
|
+
}
|
|
292
|
+
findClassDefinition(name, scope) {
|
|
293
|
+
let clas = scope === null || scope === void 0 ? void 0 : scope.findClassDefinition(name);
|
|
294
|
+
if (clas === undefined) {
|
|
295
|
+
const iglobal = this.reg.getObject("CLAS", name);
|
|
296
|
+
clas = iglobal === null || iglobal === void 0 ? void 0 : iglobal.getDefinition();
|
|
297
|
+
}
|
|
298
|
+
return clas;
|
|
299
|
+
}
|
|
300
|
+
dataFromInterfaces(name, scope) {
|
|
301
|
+
let ret = "";
|
|
302
|
+
const intf = this.findInterfaceDefinition(name, scope);
|
|
291
303
|
for (const a of (intf === null || intf === void 0 ? void 0 : intf.getAttributes().getAll()) || []) {
|
|
292
304
|
if (a.getMeta().includes("static" /* Static */) === true) {
|
|
293
305
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"author": "abaplint",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abaplint/core": "^2.83.
|
|
30
|
+
"@abaplint/core": "^2.83.17",
|
|
31
31
|
"source-map": "^0.7.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|