@abaplint/transpiler 2.7.164 → 2.8.0

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.
Files changed (72) hide show
  1. package/build/src/db/index.js +2 -3
  2. package/build/src/db/schema_generation/pg_database_schema.js +1 -1
  3. package/build/src/db/schema_generation/snowflake_database_schema.js +1 -1
  4. package/build/src/db/schema_generation/sqlite_database_schema.js +1 -1
  5. package/build/src/expressions/call_transformation_parameters.js +1 -2
  6. package/build/src/expressions/compare.js +2 -3
  7. package/build/src/expressions/component_compare.js +2 -2
  8. package/build/src/expressions/constant.js +6 -1
  9. package/build/src/expressions/method_call.js +3 -4
  10. package/build/src/expressions/method_call_param.js +2 -3
  11. package/build/src/expressions/method_source.js +1 -1
  12. package/build/src/expressions/parameter_s.js +2 -3
  13. package/build/src/expressions/parameter_t.js +2 -3
  14. package/build/src/expressions/sql_cond.js +2 -3
  15. package/build/src/expressions/sql_source.js +1 -1
  16. package/build/src/handlers/handle_abap.js +6 -9
  17. package/build/src/handlers/handle_data_element.js +1 -2
  18. package/build/src/handlers/handle_enqu.js +1 -2
  19. package/build/src/handlers/handle_msag.js +1 -2
  20. package/build/src/handlers/handle_oa2p.js +1 -2
  21. package/build/src/handlers/handle_smim.js +4 -5
  22. package/build/src/handlers/handle_table.js +1 -2
  23. package/build/src/handlers/handle_table_type.js +1 -2
  24. package/build/src/handlers/handle_type_pool.js +3 -4
  25. package/build/src/handlers/handle_view.js +1 -2
  26. package/build/src/handlers/handle_w3mi.js +4 -5
  27. package/build/src/index.js +7 -8
  28. package/build/src/requires.js +6 -7
  29. package/build/src/statements/assign.js +10 -11
  30. package/build/src/statements/call.js +5 -7
  31. package/build/src/statements/call_function.js +2 -3
  32. package/build/src/statements/call_transformation.js +1 -2
  33. package/build/src/statements/class_implementation.js +3 -4
  34. package/build/src/statements/concatenate.js +1 -2
  35. package/build/src/statements/convert.js +8 -8
  36. package/build/src/statements/create_data.js +3 -4
  37. package/build/src/statements/create_object.js +5 -7
  38. package/build/src/statements/data.js +1 -2
  39. package/build/src/statements/end_method.js +6 -7
  40. package/build/src/statements/field_symbol.js +1 -1
  41. package/build/src/statements/find.js +3 -4
  42. package/build/src/statements/form.js +4 -4
  43. package/build/src/statements/loop.js +7 -8
  44. package/build/src/statements/method_implementation.js +9 -11
  45. package/build/src/statements/move.js +1 -2
  46. package/build/src/statements/open_cursor.js +4 -4
  47. package/build/src/statements/perform.js +7 -8
  48. package/build/src/statements/raise.js +4 -5
  49. package/build/src/statements/read_table.js +3 -3
  50. package/build/src/statements/receive.js +1 -2
  51. package/build/src/statements/replace.js +1 -1
  52. package/build/src/statements/return.js +3 -3
  53. package/build/src/statements/select.js +1 -2
  54. package/build/src/statements/tables.js +1 -2
  55. package/build/src/statements/write.js +1 -2
  56. package/build/src/structures/at.js +7 -5
  57. package/build/src/structures/case.js +1 -2
  58. package/build/src/structures/case_type.js +2 -3
  59. package/build/src/structures/class_definition.js +2 -3
  60. package/build/src/structures/class_implementation.js +3 -5
  61. package/build/src/structures/constants.js +2 -3
  62. package/build/src/structures/data.js +2 -3
  63. package/build/src/structures/function_module.js +3 -5
  64. package/build/src/structures/interface.js +5 -6
  65. package/build/src/structures/loop.js +1 -2
  66. package/build/src/structures/select.js +2 -3
  67. package/build/src/structures/try.js +1 -1
  68. package/build/src/transpile_types.js +11 -12
  69. package/build/src/traversal.js +33 -38
  70. package/build/src/unit_test.js +2 -3
  71. package/build/src/validation.js +3 -4
  72. package/package.json +1 -1
@@ -55,7 +55,7 @@ class DatabaseSetup {
55
55
  }
56
56
  else if (obj instanceof abaplint.Objects.Class
57
57
  || obj instanceof abaplint.Objects.Interface) {
58
- if ((options === null || options === void 0 ? void 0 : options.skipReposrc) !== true) {
58
+ if (options?.skipReposrc !== true) {
59
59
  insert.push(this.insertREPOSRC(obj));
60
60
  }
61
61
  }
@@ -64,12 +64,11 @@ class DatabaseSetup {
64
64
  return insert;
65
65
  }
66
66
  insertREPOSRC(obj) {
67
- var _a;
68
67
  if (this.reg.getObject("TABL", "REPOSRC") === undefined) {
69
68
  return "";
70
69
  }
71
70
  const name = obj.getName().toUpperCase();
72
- const raw = (_a = obj.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getRaw();
71
+ const raw = obj.getMainABAPFile()?.getRaw();
73
72
  if (raw === undefined) {
74
73
  return "";
75
74
  }
@@ -9,7 +9,7 @@ class PGDatabaseSchema {
9
9
  buildVIEW(view) {
10
10
  const fields = view.getFields();
11
11
  let firstTabname = "";
12
- const columns = fields === null || fields === void 0 ? void 0 : fields.map((f) => {
12
+ const columns = fields?.map((f) => {
13
13
  firstTabname = "'" + f.TABNAME.toLowerCase() + "'";
14
14
  return firstTabname + "." + f.FIELDNAME.toLowerCase() + " AS " + f.VIEWFIELD.toLowerCase();
15
15
  }).join(", ");
@@ -9,7 +9,7 @@ class SnowflakeDatabaseSchema {
9
9
  buildVIEW(view) {
10
10
  const fields = view.getFields();
11
11
  let firstTabname = "";
12
- const columns = fields === null || fields === void 0 ? void 0 : fields.map((f) => {
12
+ const columns = fields?.map((f) => {
13
13
  firstTabname = "'" + f.TABNAME.toLowerCase() + "'";
14
14
  return firstTabname + "." + f.FIELDNAME.toLowerCase() + " AS " + f.VIEWFIELD.toLowerCase();
15
15
  }).join(", ");
@@ -10,7 +10,7 @@ class SQLiteDatabaseSchema {
10
10
  buildVIEW(view) {
11
11
  const fields = view.getFields();
12
12
  let firstTabname = "";
13
- const columns = fields === null || fields === void 0 ? void 0 : fields.map((f) => {
13
+ const columns = fields?.map((f) => {
14
14
  firstTabname = "'" + f.TABNAME.toLowerCase() + "'";
15
15
  return firstTabname + "." + f.FIELDNAME.toLowerCase() + " AS " + f.VIEWFIELD.toLowerCase();
16
16
  }).join(", ");
@@ -5,8 +5,7 @@ const abaplint = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
6
  class CallTransformationParametersTranspiler {
7
7
  transpile(node, traversal) {
8
- var _a;
9
- if (((_a = node.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof abaplint.Expressions.Dynamic) {
8
+ if (node.getFirstChild()?.get() instanceof abaplint.Expressions.Dynamic) {
10
9
  return new chunk_1.Chunk().append(node.concatTokens(), node, traversal);
11
10
  }
12
11
  else {
@@ -6,7 +6,6 @@ const chunk_1 = require("../chunk");
6
6
  class CompareTranspiler {
7
7
  transpile(node, traversal) {
8
8
  // todo, this is not correct
9
- var _a, _b;
10
9
  const concat = node.concatTokens().toUpperCase();
11
10
  let pre = concat.startsWith("NOT ") ? "!" : "";
12
11
  const sources = node.findDirectExpressions(core_1.Expressions.Source).concat(node.findDirectExpressions(core_1.Expressions.SourceFieldSymbol));
@@ -52,11 +51,11 @@ class CompareTranspiler {
52
51
  return new chunk_1.Chunk().appendString(pre + "INPUT && INPUT." + field + " === undefined && INPUT.importing?." + field + " === undefined");
53
52
  }
54
53
  if (concat.startsWith("NOT ") || concat.includes(" IS NOT INSTANCE OF ")) {
55
- const cname = (_a = node.findDirectExpression(core_1.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
54
+ const cname = node.findDirectExpression(core_1.Expressions.ClassName)?.concatTokens();
56
55
  return new chunk_1.Chunk().appendString("abap.compare.instance_of(").appendChunk(s0).appendString(`, ${cname}) === false`);
57
56
  }
58
57
  else if (concat.includes(" IS INSTANCE OF ")) {
59
- const cname = (_b = node.findDirectExpression(core_1.Expressions.ClassName)) === null || _b === void 0 ? void 0 : _b.concatTokens();
58
+ const cname = node.findDirectExpression(core_1.Expressions.ClassName)?.concatTokens();
60
59
  return new chunk_1.Chunk().appendString("abap.compare.instance_of(").appendChunk(s0).appendString(`, ${cname})`);
61
60
  }
62
61
  }
@@ -25,11 +25,11 @@ class ComponentCompareTranspiler {
25
25
  else if (concat.endsWith("IS INITIAL")) {
26
26
  return new chunk_1.Chunk(`(I) => {return abap.compare.initial(${component});}`);
27
27
  }
28
- if (concat.startsWith((componentExpression === null || componentExpression === void 0 ? void 0 : componentExpression.concatTokens().toUpperCase()) + " IN ")) {
28
+ if (concat.startsWith(componentExpression?.concatTokens().toUpperCase() + " IN ")) {
29
29
  const source = traversal.traverse(node.findDirectExpression(core_1.Expressions.Source)).getCode();
30
30
  return new chunk_1.Chunk(`(I) => {return ${pre}abap.compare.in(${component}, ${source});}`);
31
31
  }
32
- else if (concat.startsWith((componentExpression === null || componentExpression === void 0 ? void 0 : componentExpression.concatTokens().toUpperCase()) + " NOT IN ")) {
32
+ else if (concat.startsWith(componentExpression?.concatTokens().toUpperCase() + " NOT IN ")) {
33
33
  const source = traversal.traverse(node.findDirectExpression(core_1.Expressions.Source)).getCode();
34
34
  return new chunk_1.Chunk(`(I) => {return !abap.compare.in(${component}, ${source});}`);
35
35
  }
@@ -13,7 +13,12 @@ class ConstantTranspiler {
13
13
  const concat = int.concatTokens().trim();
14
14
  const parsed = Number.parseInt(concat, 10);
15
15
  let code = "";
16
- if (parsed > 2147483647 || parsed < -2147483648) {
16
+ if (concat.length > 18) {
17
+ // its potentially larger than Number.MAX_SAFE_INTEGER
18
+ // https://stackoverflow.com/questions/1379934/large-numbers-erroneously-rounded-in-javascript
19
+ code = `new abap.types.Integer8().set("${concat}")`;
20
+ }
21
+ else if (parsed > 2147483647 || parsed < -2147483648) {
17
22
  code = `new abap.types.Integer8().set(${concat})`;
18
23
  }
19
24
  else if (parsed >= -10 && parsed <= 200) {
@@ -7,8 +7,7 @@ const method_call_param_1 = require("./method_call_param");
7
7
  const chunk_1 = require("../chunk");
8
8
  class MethodCallTranspiler {
9
9
  transpile(node, traversal) {
10
- var _a;
11
- const nameToken = (_a = node.findDirectExpression(core_1.Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
10
+ const nameToken = node.findDirectExpression(core_1.Expressions.MethodName)?.getFirstToken();
12
11
  if (nameToken === undefined) {
13
12
  throw new Error("MethodCallTranspiler, name not found");
14
13
  }
@@ -20,7 +19,7 @@ class MethodCallTranspiler {
20
19
  name = name + "(";
21
20
  }
22
21
  const m = traversal.findMethodReference(nameToken, traversal.findCurrentScopeByToken(nameToken));
23
- if ((m === null || m === void 0 ? void 0 : m.name) && traversal.isBuiltinMethod(nameToken) === false) {
22
+ if (m?.name && traversal.isBuiltinMethod(nameToken) === false) {
24
23
  name = m.name.toLowerCase() + "(";
25
24
  }
26
25
  const step = node.findDirectExpression(core_1.Expressions.MethodCallParam);
@@ -29,7 +28,7 @@ class MethodCallTranspiler {
29
28
  }
30
29
  const ret = new chunk_1.Chunk();
31
30
  ret.append(traversal_1.Traversal.escapeNamespace(name.replace("~", "$")), nameToken, traversal);
32
- ret.appendChunk(new method_call_param_1.MethodCallParamTranspiler(m === null || m === void 0 ? void 0 : m.def).transpile(step, traversal));
31
+ ret.appendChunk(new method_call_param_1.MethodCallParamTranspiler(m?.def).transpile(step, traversal));
33
32
  ret.appendString(")");
34
33
  return ret;
35
34
  }
@@ -8,14 +8,13 @@ class MethodCallParamTranspiler {
8
8
  this.m = m;
9
9
  }
10
10
  transpile(node, traversal) {
11
- var _a, _b;
12
11
  let name = "";
13
12
  if (!(node.get() instanceof core_1.Expressions.MethodCallParam)) {
14
- throw new Error("MethodCallParam, unexpected node, " + (node === null || node === void 0 ? void 0 : node.get().constructor.name));
13
+ throw new Error("MethodCallParam, unexpected node, " + node?.get().constructor.name);
15
14
  }
16
15
  const source = node.findDirectExpression(core_1.Expressions.Source);
17
16
  if (source) {
18
- const def = (_b = (_a = this.m) === null || _a === void 0 ? void 0 : _a.getParameters().getDefaultImporting()) === null || _b === void 0 ? void 0 : _b.toLowerCase();
17
+ const def = this.m?.getParameters().getDefaultImporting()?.toLowerCase();
19
18
  if (this.m === undefined || def === undefined) {
20
19
  return traversal.traverse(source);
21
20
  }
@@ -20,7 +20,7 @@ class MethodSourceTranspiler {
20
20
  if (child.get() instanceof core_1.Expressions.ClassName) {
21
21
  call += traversal.lookupClassOrInterface(child.concatTokens(), child.getFirstToken());
22
22
  }
23
- else if (child.get() instanceof core_1.Expressions.Dynamic && (nextChild === null || nextChild === void 0 ? void 0 : nextChild.concatTokens()) === "=>") {
23
+ else if (child.get() instanceof core_1.Expressions.Dynamic && nextChild?.concatTokens() === "=>") {
24
24
  const second = child.getChildren()[1];
25
25
  const illegalClass = traversal.lookupClassOrInterface("'CX_SY_DYN_CALL_ILLEGAL_CLASS'", child.getFirstToken(), true);
26
26
  const illegalMethod = traversal.lookupClassOrInterface("'CX_SY_DYN_CALL_ILLEGAL_METHOD'", child.getFirstToken(), true);
@@ -5,9 +5,8 @@ const core_1 = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
6
  class ParameterSTranspiler {
7
7
  transpile(node, traversal) {
8
- var _a;
9
- const nameToken = (_a = node.findDirectExpression(core_1.Expressions.ParameterName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
10
- const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.getStr().toLowerCase();
8
+ const nameToken = node.findDirectExpression(core_1.Expressions.ParameterName)?.getFirstToken();
9
+ const name = nameToken?.getStr().toLowerCase();
11
10
  const source = traversal.traverse(node.findDirectExpression(core_1.Expressions.Source));
12
11
  return new chunk_1.Chunk().append(name + ": ", nameToken || node, traversal).appendChunk(source);
13
12
  }
@@ -5,9 +5,8 @@ const core_1 = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
6
  class ParameterTTranspiler {
7
7
  transpile(node, traversal) {
8
- var _a;
9
- const nameToken = (_a = node.findDirectExpression(core_1.Expressions.ParameterName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
10
- const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.getStr();
8
+ const nameToken = node.findDirectExpression(core_1.Expressions.ParameterName)?.getFirstToken();
9
+ const name = nameToken?.getStr();
11
10
  const source = traversal.traverse(node.findDirectExpression(core_1.Expressions.Target));
12
11
  return new chunk_1.Chunk().append(name + ": ", nameToken || node, traversal).appendChunk(source);
13
12
  }
@@ -11,7 +11,6 @@ const transpile_types_1 = require("../transpile_types");
11
11
  const source_1 = require("./source");
12
12
  class SQLCondTranspiler {
13
13
  transpile(node, traversal, table) {
14
- var _a;
15
14
  let ret = "";
16
15
  for (const c of node.getChildren()) {
17
16
  if (c instanceof abaplint.Nodes.ExpressionNode
@@ -20,7 +19,7 @@ class SQLCondTranspiler {
20
19
  ret += " ";
21
20
  }
22
21
  if (c.findDirectExpression(abaplint.Expressions.Dynamic)) {
23
- const chain = (_a = c.findDirectExpression(abaplint.Expressions.Dynamic)) === null || _a === void 0 ? void 0 : _a.findFirstExpression(abaplint.Expressions.FieldChain);
22
+ const chain = c.findDirectExpression(abaplint.Expressions.Dynamic)?.findFirstExpression(abaplint.Expressions.FieldChain);
24
23
  if (chain) {
25
24
  const code = new field_chain_1.FieldChainTranspiler(true).transpile(chain, traversal).getCode();
26
25
  ret += `" + abap.expandDynamic(${code}, (name) => {try { return eval(name);} catch {}}) + "`;
@@ -131,7 +130,7 @@ class SQLCondTranspiler {
131
130
  const concat = source.concatTokens();
132
131
  const conversionField = traversal.isSQLConversion(source.getFirstToken());
133
132
  if (conversionField) {
134
- const field = (table === null || table === void 0 ? void 0 : table.parseType(traversal.reg)).getComponentByName(conversionField);
133
+ const field = (table?.parseType(traversal.reg)).getComponentByName(conversionField);
135
134
  ret += "'\" + " + new transpile_types_1.TranspileTypes().toType(field) + ".set(" + concat + ").get() + \"'";
136
135
  }
137
136
  else if (concat.startsWith("`")) {
@@ -6,7 +6,7 @@ const chunk_1 = require("../chunk");
6
6
  class SQLSourceTranspiler {
7
7
  transpile(node, traversal) {
8
8
  let s = node.findDirectExpression(abaplint.Expressions.Source);
9
- if ((s === null || s === void 0 ? void 0 : s.getChildren().length) === 1 && s.getChildren()[0].get() instanceof abaplint.Expressions.SQLAliasField) {
9
+ if (s?.getChildren().length === 1 && s.getChildren()[0].get() instanceof abaplint.Expressions.SQLAliasField) {
10
10
  const chunk = new chunk_1.Chunk();
11
11
  let concat = s.concatTokens();
12
12
  if (concat.includes("~") && concat.split("~")[0].includes("/")) {
@@ -11,7 +11,6 @@ class HandleABAP {
11
11
  this.options = options;
12
12
  }
13
13
  runObject(obj, reg) {
14
- var _a, _b, _c;
15
14
  let ret = [];
16
15
  if (obj instanceof abaplint.Objects.Program && obj.isInclude() === true) {
17
16
  // includes are only compiled along with the programs where its used?
@@ -20,14 +19,14 @@ class HandleABAP {
20
19
  const spaghetti = new abaplint.SyntaxLogic(reg, obj).run().spaghetti;
21
20
  for (const file of obj.getSequencedFiles()) {
22
21
  const chunk = new chunk_1.Chunk();
23
- if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.addFilenames) === true) {
22
+ if (this.options?.addFilenames === true) {
24
23
  chunk.appendString("// " + file.getFilename() + "\n");
25
24
  }
26
25
  const rearranged = new rearranger_1.Rearranger().run(obj.getType(), file.getStructure());
27
26
  const contents = new traversal_1.Traversal(spaghetti, file, obj, reg, this.options).traverse(rearranged);
28
27
  chunk.appendChunk(contents);
29
28
  chunk.stripLastNewline();
30
- chunk.runIndentationLogic((_b = this.options) === null || _b === void 0 ? void 0 : _b.ignoreSourceMap);
29
+ chunk.runIndentationLogic(this.options?.ignoreSourceMap);
31
30
  const exports = this.findExports(file.getStructure());
32
31
  const filename = file.getFilename().replace(".abap", ".mjs").toLowerCase();
33
32
  const output = {
@@ -43,7 +42,7 @@ class HandleABAP {
43
42
  ret.push(output);
44
43
  }
45
44
  ret = this.rearrangeClassLocals(obj, ret);
46
- if (((_c = this.options) === null || _c === void 0 ? void 0 : _c.addCommonJS) === true) {
45
+ if (this.options?.addCommonJS === true) {
47
46
  ret.map(output => output.chunk = this.addImportsAndExports(output));
48
47
  }
49
48
  return ret;
@@ -99,10 +98,9 @@ class HandleABAP {
99
98
  return ret;
100
99
  }
101
100
  addImportsAndExports(output) {
102
- var _a;
103
101
  const contents = new chunk_1.Chunk();
104
102
  for (const r of output.requires) {
105
- const name = (_a = r.name) === null || _a === void 0 ? void 0 : _a.toLowerCase();
103
+ const name = r.name?.toLowerCase();
106
104
  const filename = r.filename.replace(".abap", ".mjs");
107
105
  if (filename === output.filename) {
108
106
  continue;
@@ -121,19 +119,18 @@ class HandleABAP {
121
119
  return contents;
122
120
  }
123
121
  findExports(node) {
124
- var _a, _b;
125
122
  if (node === undefined) {
126
123
  return [];
127
124
  }
128
125
  const res = [];
129
126
  for (const c of node.findAllStatements(abaplint.Statements.ClassDefinition)) {
130
- const e = (_a = c.findFirstExpression(abaplint.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
127
+ const e = c.findFirstExpression(abaplint.Expressions.ClassName)?.getFirstToken().getStr();
131
128
  if (e) {
132
129
  res.push(e.toLowerCase());
133
130
  }
134
131
  }
135
132
  for (const c of node.findAllStatements(abaplint.Statements.Interface)) {
136
- const e = (_b = c.findFirstExpression(abaplint.Expressions.InterfaceName)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
133
+ const e = c.findFirstExpression(abaplint.Expressions.InterfaceName)?.getFirstToken().getStr();
137
134
  if (e) {
138
135
  res.push(e.toLowerCase());
139
136
  }
@@ -5,8 +5,7 @@ const chunk_1 = require("../chunk");
5
5
  const transpile_types_1 = require("../transpile_types");
6
6
  class HandleDataElement {
7
7
  runObject(obj, reg) {
8
- var _a;
9
- const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
8
+ const filename = obj.getXMLFile()?.getFilename().replace(".xml", ".mjs").toLowerCase();
10
9
  if (filename === undefined) {
11
10
  return [];
12
11
  }
@@ -5,8 +5,7 @@ const chunk_1 = require("../chunk");
5
5
  // view, much like the tables
6
6
  class HandleEnqu {
7
7
  runObject(obj, _reg) {
8
- var _a;
9
- const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
8
+ const filename = obj.getXMLFile()?.getFilename().replace(".xml", ".mjs").toLowerCase();
10
9
  if (filename === undefined) {
11
10
  return [];
12
11
  }
@@ -4,8 +4,7 @@ exports.HandleMSAG = void 0;
4
4
  const chunk_1 = require("../chunk");
5
5
  class HandleMSAG {
6
6
  runObject(obj, _reg) {
7
- var _a;
8
- const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
7
+ const filename = obj.getXMLFile()?.getFilename().replace(".xml", ".mjs").toLowerCase();
9
8
  if (filename === undefined) {
10
9
  return [];
11
10
  }
@@ -4,8 +4,7 @@ exports.HandleOA2P = void 0;
4
4
  const chunk_1 = require("../chunk");
5
5
  class HandleOA2P {
6
6
  runObject(obj, _reg) {
7
- var _a;
8
- const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
7
+ const filename = obj.getXMLFile()?.getFilename().replace(".xml", ".mjs").toLowerCase();
9
8
  if (filename === undefined) {
10
9
  return [];
11
10
  }
@@ -4,8 +4,7 @@ exports.HandleSMIM = void 0;
4
4
  const chunk_1 = require("../chunk");
5
5
  class HandleSMIM {
6
6
  runObject(obj, _reg) {
7
- var _a;
8
- const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
7
+ const filename = obj.getXMLFile()?.getFilename().replace(".xml", ".mjs").toLowerCase();
9
8
  if (filename === undefined) {
10
9
  return [];
11
10
  }
@@ -13,7 +12,7 @@ class HandleSMIM {
13
12
  const dataFile = obj.getDataFile();
14
13
  const chunk = new chunk_1.Chunk().appendString(`abap.SMIM["${obj.getName().toUpperCase()}"] = {
15
14
  "objectType": "SMIM",
16
- "filename": ${JSON.stringify(dataFile === null || dataFile === void 0 ? void 0 : dataFile.getFilename())},
15
+ "filename": ${JSON.stringify(dataFile?.getFilename())},
17
16
  "url": ${JSON.stringify(obj.getURL())},
18
17
  "class": ${JSON.stringify(obj.getClass())},
19
18
  };`);
@@ -34,8 +33,8 @@ class HandleSMIM {
34
33
  name: obj.getName(),
35
34
  type: obj.getType(),
36
35
  },
37
- filename: dataFile === null || dataFile === void 0 ? void 0 : dataFile.getFilename(),
38
- chunk: new chunk_1.Chunk().appendString(dataFile === null || dataFile === void 0 ? void 0 : dataFile.getRaw()),
36
+ filename: dataFile?.getFilename(),
37
+ chunk: new chunk_1.Chunk().appendString(dataFile?.getRaw()),
39
38
  requires: [],
40
39
  exports: [],
41
40
  };
@@ -6,8 +6,7 @@ const transpile_types_1 = require("../transpile_types");
6
6
  // tables or structures
7
7
  class HandleTable {
8
8
  runObject(obj, reg) {
9
- var _a;
10
- const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
9
+ const filename = obj.getXMLFile()?.getFilename().replace(".xml", ".mjs").toLowerCase();
11
10
  if (filename === undefined) {
12
11
  return [];
13
12
  }
@@ -5,8 +5,7 @@ const chunk_1 = require("../chunk");
5
5
  const transpile_types_1 = require("../transpile_types");
6
6
  class HandleTableType {
7
7
  runObject(obj, reg) {
8
- var _a;
9
- const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
8
+ const filename = obj.getXMLFile()?.getFilename().replace(".xml", ".mjs").toLowerCase();
10
9
  if (filename === undefined) {
11
10
  return [];
12
11
  }
@@ -7,17 +7,16 @@ const transpile_types_1 = require("../transpile_types");
7
7
  const traversal_1 = require("../traversal");
8
8
  class HandleTypePool {
9
9
  runObject(obj, reg) {
10
- var _a;
11
- const spaghetti = (_a = new abaplint.SyntaxLogic(reg, obj).run().spaghetti.getFirstChild()) === null || _a === void 0 ? void 0 : _a.getFirstChild();
10
+ const spaghetti = new abaplint.SyntaxLogic(reg, obj).run().spaghetti.getFirstChild()?.getFirstChild();
12
11
  const chunk = new chunk_1.Chunk();
13
12
  chunk.appendString(`const pool = {};\n`);
14
- for (const v in spaghetti === null || spaghetti === void 0 ? void 0 : spaghetti.getData().vars) {
13
+ for (const v in spaghetti?.getData().vars) {
15
14
  const abs = spaghetti.getData().vars[v];
16
15
  const name = `pool['${v.toLowerCase()}']`;
17
16
  chunk.appendString(`${name} = ${new transpile_types_1.TranspileTypes().toType(abs.getType())};\n`);
18
17
  chunk.appendString(traversal_1.Traversal.setValues(abs, name));
19
18
  }
20
- for (const t in spaghetti === null || spaghetti === void 0 ? void 0 : spaghetti.getData().types) {
19
+ for (const t in spaghetti?.getData().types) {
21
20
  const abs = spaghetti.getData().types[t];
22
21
  chunk.appendString(`pool['${t.toLowerCase()}'] = ${new transpile_types_1.TranspileTypes().toType(abs.getType())};\n`);
23
22
  }
@@ -6,8 +6,7 @@ const transpile_types_1 = require("../transpile_types");
6
6
  // view, much like the tables
7
7
  class HandleView {
8
8
  runObject(obj, reg) {
9
- var _a;
10
- const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
9
+ const filename = obj.getXMLFile()?.getFilename().replace(".xml", ".mjs").toLowerCase();
11
10
  if (filename === undefined) {
12
11
  return [];
13
12
  }
@@ -4,8 +4,7 @@ exports.HandleW3MI = void 0;
4
4
  const chunk_1 = require("../chunk");
5
5
  class HandleW3MI {
6
6
  runObject(obj, _reg) {
7
- var _a;
8
- const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
7
+ const filename = obj.getXMLFile()?.getFilename().replace(".xml", ".mjs").toLowerCase();
9
8
  if (filename === undefined) {
10
9
  return [];
11
10
  }
@@ -13,7 +12,7 @@ class HandleW3MI {
13
12
  const dataFile = obj.getDataFile();
14
13
  const chunk = new chunk_1.Chunk().appendString(`abap.W3MI["${obj.getName().toUpperCase()}"] = {
15
14
  "objectType": "W3MI",
16
- "filename": ${JSON.stringify(dataFile === null || dataFile === void 0 ? void 0 : dataFile.getFilename())},
15
+ "filename": ${JSON.stringify(dataFile?.getFilename())},
17
16
  };`);
18
17
  const output = {
19
18
  object: {
@@ -32,8 +31,8 @@ class HandleW3MI {
32
31
  name: obj.getName(),
33
32
  type: obj.getType(),
34
33
  },
35
- filename: dataFile === null || dataFile === void 0 ? void 0 : dataFile.getFilename(),
36
- chunk: new chunk_1.Chunk().appendString(dataFile === null || dataFile === void 0 ? void 0 : dataFile.getRaw()),
34
+ filename: dataFile?.getFilename(),
35
+ chunk: new chunk_1.Chunk().appendString(dataFile?.getRaw()),
37
36
  requires: [],
38
37
  exports: [],
39
38
  };
@@ -37,23 +37,22 @@ class Transpiler {
37
37
  return new Transpiler().run(reg);
38
38
  }
39
39
  async run(reg, progress) {
40
- var _a, _b, _c, _d, _e;
41
40
  reg.parse();
42
- new keywords_1.Keywords((_a = this.options) === null || _a === void 0 ? void 0 : _a.keywords).handle(reg);
41
+ new keywords_1.Keywords(this.options?.keywords).handle(reg);
43
42
  this.validate(reg);
44
43
  const dbSetup = new db_1.DatabaseSetup(reg).run(this.options);
45
44
  const output = {
46
45
  objects: [],
47
- unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, (_b = this.options) === null || _b === void 0 ? void 0 : _b.skip),
48
- unitTestScriptOpen: new unit_test_1.UnitTest().unitTestScriptOpen(reg, (_c = this.options) === null || _c === void 0 ? void 0 : _c.skip),
49
- initializationScript: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, (_d = this.options) === null || _d === void 0 ? void 0 : _d.extraSetup),
50
- initializationScript2: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, (_e = this.options) === null || _e === void 0 ? void 0 : _e.extraSetup, true),
46
+ unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, this.options?.skip),
47
+ unitTestScriptOpen: new unit_test_1.UnitTest().unitTestScriptOpen(reg, this.options?.skip),
48
+ initializationScript: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, this.options?.extraSetup),
49
+ initializationScript2: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, this.options?.extraSetup, true),
51
50
  databaseSetup: dbSetup,
52
51
  reg: reg,
53
52
  };
54
- progress === null || progress === void 0 ? void 0 : progress.set(reg.getObjectCount(false), "Building");
53
+ progress?.set(reg.getObjectCount(false), "Building");
55
54
  for (const obj of reg.getObjects()) {
56
- await (progress === null || progress === void 0 ? void 0 : progress.tick("Building, " + obj.getName()));
55
+ await progress?.tick("Building, " + obj.getName());
57
56
  if (obj instanceof abaplint.ABAPObject && !(obj instanceof abaplint.Objects.TypePool)) {
58
57
  output.objects.push(...new handle_abap_1.HandleABAP(this.options).runObject(obj, reg));
59
58
  }
@@ -8,7 +8,6 @@ class Requires {
8
8
  }
9
9
  // todo, refactor this method
10
10
  find(obj, _node, filename) {
11
- var _a, _b, _c, _d, _e, _f, _g, _h;
12
11
  const ret = [];
13
12
  if (obj.getType() === "INTF") {
14
13
  return [];
@@ -28,19 +27,19 @@ class Requires {
28
27
  if (obj.getType() === "CLAS") {
29
28
  // add the superclass
30
29
  const clas = obj;
31
- const sup = (_b = (_a = clas.getDefinition()) === null || _a === void 0 ? void 0 : _a.getSuperClass()) === null || _b === void 0 ? void 0 : _b.toLowerCase().replace(/\//g, "#");
30
+ const sup = clas.getDefinition()?.getSuperClass()?.toLowerCase().replace(/\//g, "#");
32
31
  if (sup) {
33
- add({ filename: sup + ".clas.abap", name: (_d = (_c = clas.getDefinition()) === null || _c === void 0 ? void 0 : _c.getSuperClass()) === null || _d === void 0 ? void 0 : _d.toLowerCase() });
32
+ add({ filename: sup + ".clas.abap", name: clas.getDefinition()?.getSuperClass()?.toLowerCase() });
34
33
  }
35
34
  for (const f of clas.getSequencedFiles()) {
36
35
  if (filename.endsWith(".testclasses.abap")) {
37
36
  // add the global class, in case its inherited by a local testclass
38
- add({ filename: ((_e = clas.getMainABAPFile()) === null || _e === void 0 ? void 0 : _e.getFilename()) || "", name: obj.getName().toLowerCase() });
37
+ add({ filename: clas.getMainABAPFile()?.getFilename() || "", name: obj.getName().toLowerCase() });
39
38
  }
40
39
  if (f.getFilename() === filename
41
40
  || f.getFilename().endsWith(".clas.testclasses.abap")
42
41
  || f.getFilename().endsWith(".clas.macros.abap")
43
- || f.getFilename() === ((_f = clas.getMainABAPFile()) === null || _f === void 0 ? void 0 : _f.getFilename())) {
42
+ || f.getFilename() === clas.getMainABAPFile()?.getFilename()) {
44
43
  continue;
45
44
  }
46
45
  let foo = f.getFilename();
@@ -61,7 +60,7 @@ class Requires {
61
60
  if (obj.getType() !== "INTF") {
62
61
  const cx = this.reg.getObject("CLAS", "CX_ROOT");
63
62
  if (cx && cx instanceof abaplint.ABAPObject) {
64
- const main = (_g = cx.getMainABAPFile()) === null || _g === void 0 ? void 0 : _g.getFilename();
63
+ const main = cx.getMainABAPFile()?.getFilename();
65
64
  if (main) {
66
65
  add({
67
66
  filename: main,
@@ -77,7 +76,7 @@ class Requires {
77
76
  }
78
77
  const found = this.reg.getObject("CLAS", c.superClassName);
79
78
  if (found && found instanceof abaplint.ABAPObject) {
80
- const main = (_h = found.getMainABAPFile()) === null || _h === void 0 ? void 0 : _h.getFilename();
79
+ const main = found.getMainABAPFile()?.getFilename();
81
80
  if (main) {
82
81
  add({
83
82
  filename: main,
@@ -7,9 +7,8 @@ const expressions_1 = require("../expressions");
7
7
  const chunk_1 = require("../chunk");
8
8
  class AssignTranspiler {
9
9
  transpile(node, traversal) {
10
- var _a, _b;
11
10
  const assignSource = node.findDirectExpression(abaplint.Expressions.AssignSource);
12
- const sources = (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpressionsMulti([abaplint.Expressions.Source, abaplint.Expressions.SimpleSource3]).map(e => new expressions_1.SourceTranspiler(false).transpile(e, traversal).getCode())) || [];
11
+ const sources = assignSource?.findDirectExpressionsMulti([abaplint.Expressions.Source, abaplint.Expressions.SimpleSource3]).map(e => new expressions_1.SourceTranspiler(false).transpile(e, traversal).getCode()) || [];
13
12
  const fs = new expressions_1.FieldSymbolTranspiler().transpile(node.findDirectExpression(abaplint.Expressions.FSTarget), traversal).getCode();
14
13
  const options = [];
15
14
  const concat = node.concatTokens().toUpperCase();
@@ -18,19 +17,19 @@ class AssignTranspiler {
18
17
  }
19
18
  options.push("target: " + fs);
20
19
  if (sources.length !== 0
21
- && (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpression(abaplint.Expressions.Dynamic)) === undefined) {
20
+ && assignSource?.findDirectExpression(abaplint.Expressions.Dynamic) === undefined) {
22
21
  options.push("source: " + sources.pop());
23
22
  }
24
23
  else {
25
24
  let dynamicName = "";
26
- for (const c of (assignSource === null || assignSource === void 0 ? void 0 : assignSource.getChildren()) || []) {
25
+ for (const c of assignSource?.getChildren() || []) {
27
26
  if (c instanceof abaplint.Nodes.ExpressionNode
28
27
  && c.get() instanceof abaplint.Expressions.Dynamic
29
28
  && c.findFirstExpression(abaplint.Expressions.ConstantString)) {
30
29
  if (dynamicName !== "") {
31
30
  dynamicName += " + ";
32
31
  }
33
- dynamicName += (_a = c.findFirstExpression(abaplint.Expressions.ConstantString)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
32
+ dynamicName += c.findFirstExpression(abaplint.Expressions.ConstantString)?.getFirstToken().getStr();
34
33
  }
35
34
  else if (c instanceof abaplint.Nodes.ExpressionNode
36
35
  && c.get() instanceof abaplint.Expressions.Dynamic
@@ -55,17 +54,17 @@ class AssignTranspiler {
55
54
  }
56
55
  options.push(`dynamicName: ` + dynamicName);
57
56
  // dynamicSource is the first part of the dynamic part
58
- const first = assignSource === null || assignSource === void 0 ? void 0 : assignSource.getFirstChild();
59
- if ((first === null || first === void 0 ? void 0 : first.get()) instanceof abaplint.Expressions.Dynamic && first instanceof abaplint.Nodes.ExpressionNode) {
57
+ const first = assignSource?.getFirstChild();
58
+ if (first?.get() instanceof abaplint.Expressions.Dynamic && first instanceof abaplint.Nodes.ExpressionNode) {
60
59
  const firstFirst = first.getChildren()[1];
61
- if ((firstFirst === null || firstFirst === void 0 ? void 0 : firstFirst.get()) instanceof abaplint.Expressions.Constant) {
62
- const s = (_b = firstFirst.getFirstToken().getStr().toLowerCase().match(/\w+/)) === null || _b === void 0 ? void 0 : _b.toString();
60
+ if (firstFirst?.get() instanceof abaplint.Expressions.Constant) {
61
+ const s = firstFirst.getFirstToken().getStr().toLowerCase().match(/\w+/)?.toString();
63
62
  options.push(`dynamicSource: (() => {
64
63
  try { return ${s}; } catch {}
65
64
  try { return this.${s}; } catch {}
66
65
  })()`);
67
66
  }
68
- else if ((firstFirst === null || firstFirst === void 0 ? void 0 : firstFirst.get()) instanceof abaplint.Expressions.FieldChain && firstFirst instanceof abaplint.Nodes.ExpressionNode) {
67
+ else if (firstFirst?.get() instanceof abaplint.Expressions.FieldChain && firstFirst instanceof abaplint.Nodes.ExpressionNode) {
69
68
  const code = new expressions_1.FieldChainTranspiler(true).transpile(firstFirst, traversal).getCode();
70
69
  options.push(`dynamicSource: (() => {
71
70
  const name = ${code}.toLowerCase().replace(/[~\\/]/g, "$").match(/[\\w\\$\\/]+/)[0];
@@ -74,7 +73,7 @@ class AssignTranspiler {
74
73
  })()`);
75
74
  }
76
75
  }
77
- else if ((first === null || first === void 0 ? void 0 : first.get()) instanceof abaplint.Expressions.Source && first instanceof abaplint.Nodes.ExpressionNode) {
76
+ else if (first?.get() instanceof abaplint.Expressions.Source && first instanceof abaplint.Nodes.ExpressionNode) {
78
77
  // const name = first.concatTokens().toLowerCase();
79
78
  const name = new expressions_1.SourceTranspiler().transpile(first, traversal).getCode();
80
79
  options.push(`dynamicSource: (() => {