@abaplint/transpiler 2.11.86 → 2.11.88
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.
|
@@ -7,6 +7,12 @@ const expressions_1 = require("../expressions");
|
|
|
7
7
|
const unique_identifier_1 = require("../unique_identifier");
|
|
8
8
|
class RaiseTranspiler {
|
|
9
9
|
transpile(node, traversal) {
|
|
10
|
+
if (node.findDirectTokenByText("RESUMABLE")) {
|
|
11
|
+
throw new Error("RaiseTranspiler, RESUMABLE not implemented");
|
|
12
|
+
}
|
|
13
|
+
else if (node.findDirectTokenByText("SHORTDUMP")) {
|
|
14
|
+
throw new Error("RaiseTranspiler, SHORTDUMP not implemented");
|
|
15
|
+
}
|
|
10
16
|
const classNameToken = node.findFirstExpression(abaplint.Expressions.ClassName)?.getFirstToken();
|
|
11
17
|
const className = classNameToken?.getStr();
|
|
12
18
|
if (className === undefined) {
|
|
@@ -29,8 +35,61 @@ class RaiseTranspiler {
|
|
|
29
35
|
const extra = `{"INTERNAL_FILENAME": "${traversal.getFilename()}","INTERNAL_LINE": ${node.getStart().getRow()}}`;
|
|
30
36
|
const lookup = traversal.lookupClassOrInterface(classNameToken?.getStr(), classNameToken);
|
|
31
37
|
const id = unique_identifier_1.UniqueIdentifier.get();
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
const messageSource = node.findDirectExpression(abaplint.Expressions.MessageSource);
|
|
39
|
+
let pre = "";
|
|
40
|
+
let post = "";
|
|
41
|
+
if (messageSource) {
|
|
42
|
+
let msgid = messageSource.findDirectExpression(abaplint.Expressions.MessageClass)?.concatTokens().toUpperCase();
|
|
43
|
+
if (msgid === undefined) {
|
|
44
|
+
msgid = traversal.traverse(messageSource.findExpressionAfterToken("ID")).getCode();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
msgid = `'${msgid}'`;
|
|
48
|
+
}
|
|
49
|
+
let msgno = messageSource.findDirectExpression(abaplint.Expressions.MessageTypeAndNumber)?.concatTokens().substring(1);
|
|
50
|
+
if (msgno === undefined) {
|
|
51
|
+
msgno = traversal.traverse(messageSource.findExpressionAfterToken("NUMBER")).getCode();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
msgno = `'${msgno}'`;
|
|
55
|
+
}
|
|
56
|
+
let msgty = messageSource.findDirectExpression(abaplint.Expressions.MessageTypeAndNumber)?.concatTokens().substring(0, 1).toUpperCase();
|
|
57
|
+
if (msgty === undefined) {
|
|
58
|
+
msgty = traversal.traverse(messageSource.findExpressionAfterToken("TYPE")).getCode();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
msgty = `'${msgty}'`;
|
|
62
|
+
}
|
|
63
|
+
const textid = unique_identifier_1.UniqueIdentifier.get();
|
|
64
|
+
pre = `const ${textid} = new abap.types.Structure({
|
|
65
|
+
"msgid": new abap.types.Character(20, {}),
|
|
66
|
+
"msgno": new abap.types.Numc({length: 3}),
|
|
67
|
+
"attr1": new abap.types.Character(255, {}),
|
|
68
|
+
"attr2": new abap.types.Character(255, {}),
|
|
69
|
+
"attr3": new abap.types.Character(255, {}),
|
|
70
|
+
"attr4": new abap.types.Character(255, {})}, "SCX_T100KEY", "SCX_T100KEY", {}, {});
|
|
71
|
+
${textid}.get().msgid.set(${msgid});
|
|
72
|
+
${textid}.get().msgno.set(${msgno});
|
|
73
|
+
${textid}.get().attr1.set('IF_T100_DYN_MSG~MSGV1');
|
|
74
|
+
${textid}.get().attr2.set('IF_T100_DYN_MSG~MSGV2');
|
|
75
|
+
${textid}.get().attr3.set('IF_T100_DYN_MSG~MSGV3');
|
|
76
|
+
${textid}.get().attr4.set('IF_T100_DYN_MSG~MSGV4');
|
|
77
|
+
`;
|
|
78
|
+
if (p === "") {
|
|
79
|
+
p = `{"textid": ${textid}}`;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
p = `{...${p}, "textid": ${textid}}`;
|
|
83
|
+
}
|
|
84
|
+
post = `\n${id}.if_t100_dyn_msg$msgty?.set(${msgty});`;
|
|
85
|
+
let count = 1;
|
|
86
|
+
for (const w of node.findDirectExpression(abaplint.Expressions.RaiseWith)?.findDirectExpressions(abaplint.Expressions.Source) || []) {
|
|
87
|
+
post += `\n${id}.if_t100_dyn_msg$msgv${count}?.set(${traversal.traverse(w).getCode()});`;
|
|
88
|
+
count++;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return new chunk_1.Chunk().append(pre + `const ${id} = await (new ${lookup}()).constructor_(${p});
|
|
92
|
+
${id}.EXTRA_CX = ${extra};${post}
|
|
34
93
|
throw ${id};`, node, traversal);
|
|
35
94
|
}
|
|
36
95
|
}
|
package/build/src/validation.js
CHANGED