@abaplint/transpiler 1.7.43 → 1.8.2

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.
@@ -28,6 +28,10 @@ class ConstantTranspiler {
28
28
  const code = "new abap.types.Character({length: " + (res.length - 2) + "}).set(" + this.escape(res) + ")";
29
29
  return new chunk_1.Chunk().append(code, node, traversal);
30
30
  }
31
+ else if (res.startsWith("`") && this.addGet === false) {
32
+ const code = "new abap.types.String().set(" + this.escape(res) + ")";
33
+ return new chunk_1.Chunk().append(code, node, traversal);
34
+ }
31
35
  else {
32
36
  if (res.startsWith("'")) {
33
37
  res = "'" + res.substring(1, res.length - 1).trimEnd() + "'";
@@ -66,11 +66,10 @@ class SourceTranspiler {
66
66
  }
67
67
  }
68
68
  else if (c instanceof core_1.Nodes.TokenNode && (c.getFirstToken().getStr() === "&&" || c.getFirstToken().getStr() === "&")) {
69
- if (this.addGet === false) {
70
- return new SourceTranspiler(true).transpile(node, traversal);
71
- }
72
- else {
73
- ret.append(" + ", c, traversal);
69
+ ret = new chunk_1.Chunk().appendString("abap.operators.concat(").appendChunk(ret).appendString(",");
70
+ post.appendString(")");
71
+ if (this.addGet) {
72
+ post.append(".get()", c, traversal);
74
73
  }
75
74
  }
76
75
  else if (c instanceof core_1.Nodes.TokenNodeRegex && c.getFirstToken().getStr().toUpperCase() === "BOOLC") {
@@ -33,7 +33,7 @@ class StringTemplateTranspiler {
33
33
  ret += new _1.StringTemplateSourceTranspiler().transpile(c, traversal).getCode();
34
34
  }
35
35
  }
36
- return new chunk_1.Chunk(ret);
36
+ return new chunk_1.Chunk("new abap.types.String().set(" + ret + ")");
37
37
  }
38
38
  }
39
39
  exports.StringTemplateTranspiler = StringTemplateTranspiler;
@@ -36,7 +36,7 @@ class Transpiler {
36
36
  const output = {
37
37
  objects: [],
38
38
  unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, (_a = this.options) === null || _a === void 0 ? void 0 : _a.skip, (_b = this.options) === null || _b === void 0 ? void 0 : _b.only),
39
- unitTestScriptKernel: new unit_test_1.UnitTest().unitTestScriptKernel(reg, (_c = this.options) === null || _c === void 0 ? void 0 : _c.skip, (_d = this.options) === null || _d === void 0 ? void 0 : _d.only),
39
+ unitTestScriptOpen: new unit_test_1.UnitTest().unitTestScriptOpen(reg, (_c = this.options) === null || _c === void 0 ? void 0 : _c.skip, (_d = this.options) === null || _d === void 0 ? void 0 : _d.only),
40
40
  initializationScript: new unit_test_1.UnitTest().initializationScript(reg, dbSetup),
41
41
  databaseSetup: dbSetup,
42
42
  reg: reg,
@@ -102,7 +102,7 @@ class MethodImplementationTranspiler {
102
102
  const intfName = split[0];
103
103
  name = split[1];
104
104
  const scope = traversal.findCurrentScopeByToken(cdef.getToken());
105
- const intf = scope === null || scope === void 0 ? void 0 : scope.findInterfaceDefinition(intfName);
105
+ const intf = traversal.findInterfaceDefinition(intfName, scope);
106
106
  return (_a = intf === null || intf === void 0 ? void 0 : intf.getMethodDefinitions()) === null || _a === void 0 ? void 0 : _a.getByName(name);
107
107
  }
108
108
  else {
@@ -14,7 +14,7 @@ export interface IOutput {
14
14
  objects: IOutputFile[];
15
15
  reg: abaplint.IRegistry;
16
16
  unitTestScript: string;
17
- unitTestScriptKernel: string;
17
+ unitTestScriptOpen: string;
18
18
  initializationScript: string;
19
19
  databaseSetup: string;
20
20
  }
@@ -6,7 +6,7 @@ export declare type TestMethodList = {
6
6
  }[];
7
7
  export declare class UnitTest {
8
8
  initializationScript(reg: abaplint.IRegistry, dbSetup: string): string;
9
- unitTestScriptKernel(reg: abaplint.IRegistry, _skip?: TestMethodList, _only?: TestMethodList): string;
9
+ unitTestScriptOpen(reg: abaplint.IRegistry, _skip?: TestMethodList, _only?: TestMethodList): string;
10
10
  unitTestScript(reg: abaplint.IRegistry, skip?: TestMethodList, _only?: TestMethodList): string;
11
11
  private buildImports;
12
12
  }
@@ -19,7 +19,7 @@ export async function initializeABAP(settings) {\n`;
19
19
  ret += `}`;
20
20
  return ret;
21
21
  }
22
- unitTestScriptKernel(reg, _skip, _only) {
22
+ unitTestScriptOpen(reg, _skip, _only) {
23
23
  let ret = `/* eslint-disable curly */
24
24
  import fs from "fs";
25
25
  import path from "path";
@@ -38,6 +38,10 @@ async function run() {
38
38
  if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
39
39
  continue;
40
40
  }
41
+ const hasTestFile = obj.getFiles().some(f => { return f.getFilename().includes(".testclasses."); });
42
+ if (hasTestFile === true) {
43
+ ret += ` await import("./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs");\n`;
44
+ }
41
45
  for (const file of obj.getABAPFiles()) {
42
46
  for (const def of file.getInfo().listClassDefinitions()) {
43
47
  if (def.isForTesting === false || def.isGlobal === true || def.methods.length === 0) {
@@ -48,8 +52,7 @@ async function run() {
48
52
  if (m.isForTesting === false) {
49
53
  continue;
50
54
  }
51
- ret += `
52
- ls_input.get().class_name.set("${obj.getName()}");
55
+ ret += ` ls_input.get().class_name.set("${obj.getName()}");
53
56
  ls_input.get().testclass_name.set("${def.name.toUpperCase()}");
54
57
  ls_input.get().method_name.set("${m.name.toUpperCase()}");
55
58
  abap.statements.append({source: ls_input, target: lt_input});`;
@@ -60,7 +63,6 @@ async function run() {
60
63
  ret += `
61
64
 
62
65
  ls_result.set(await abap.Classes["KERNEL_UNIT_RUNNER"].run({it_input: lt_input}));
63
- console.dir(ls_result);
64
66
  fs.writeFileSync(__dirname + path.sep + "output.json", ls_result.get().json.get());
65
67
  }
66
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "1.7.43",
3
+ "version": "1.8.2",
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.85.10",
30
+ "@abaplint/core": "^2.85.13",
31
31
  "source-map": "^0.7.3"
32
32
  },
33
33
  "devDependencies": {