@abaplint/transpiler 2.1.7 → 2.1.8

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.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # @abaplint/transpiler
2
-
1
+ # @abaplint/transpiler
2
+
3
3
  Transpiler
@@ -18,11 +18,11 @@ class HandleDataElement {
18
18
  fixedValues = doma.getFixedValues();
19
19
  }
20
20
  }
21
- const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
22
- "objectType": "DTEL",
23
- "type": ${new transpile_types_1.TranspileTypes().toType(type)},
24
- "domain": ${JSON.stringify(obj.getDomainName())},
25
- "fixedValues": ${JSON.stringify(fixedValues)},
21
+ const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
22
+ "objectType": "DTEL",
23
+ "type": ${new transpile_types_1.TranspileTypes().toType(type)},
24
+ "domain": ${JSON.stringify(obj.getDomainName())},
25
+ "fixedValues": ${JSON.stringify(fixedValues)},
26
26
  };`);
27
27
  const output = {
28
28
  object: {
@@ -12,10 +12,10 @@ class HandleTable {
12
12
  return [];
13
13
  }
14
14
  const type = obj.parseType(reg);
15
- const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
16
- "objectType": "TABL",
17
- "type": ${new transpile_types_1.TranspileTypes().toType(type)},
18
- "keyFields": ${JSON.stringify(obj.listKeys())},
15
+ const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
16
+ "objectType": "TABL",
17
+ "type": ${new transpile_types_1.TranspileTypes().toType(type)},
18
+ "keyFields": ${JSON.stringify(obj.listKeys())},
19
19
  };`);
20
20
  const output = {
21
21
  object: {
@@ -11,9 +11,9 @@ class HandleTableType {
11
11
  return [];
12
12
  }
13
13
  const type = obj.parseType(reg);
14
- const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
15
- "objectType": "TTYP",
16
- "type": ${new transpile_types_1.TranspileTypes().toType(type)},
14
+ const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
15
+ "objectType": "TTYP",
16
+ "type": ${new transpile_types_1.TranspileTypes().toType(type)},
17
17
  };`);
18
18
  const output = {
19
19
  object: {
@@ -12,14 +12,14 @@ class DoTranspiler {
12
12
  const source = new expressions_1.SourceTranspiler(true).transpile(found, traversal).getCode();
13
13
  const idSource = unique_identifier_1.UniqueIdentifier.get();
14
14
  const id = unique_identifier_1.UniqueIdentifier.get();
15
- return new chunk_1.Chunk(`const ${idSource} = ${source};
16
- for (let ${id} = 0; ${id} < ${idSource}; ${id}++) {
15
+ return new chunk_1.Chunk(`const ${idSource} = ${source};
16
+ for (let ${id} = 0; ${id} < ${idSource}; ${id}++) {
17
17
  abap.builtin.sy.get().index.set(${id} + 1);`);
18
18
  }
19
19
  else {
20
20
  const unique = unique_identifier_1.UniqueIdentifier.get();
21
- return new chunk_1.Chunk(`let ${unique} = 1;
22
- while (true) {
21
+ return new chunk_1.Chunk(`let ${unique} = 1;
22
+ while (true) {
23
23
  abap.builtin.sy.get().index.set(${unique}++);`);
24
24
  }
25
25
  }
@@ -20,13 +20,13 @@ class ClassDefinitionTranspiler {
20
20
  }
21
21
  else {
22
22
  // its an abstract class with only abstract methods
23
- return new chunk_1.Chunk(`
24
- class ${className === null || className === void 0 ? void 0 : className.toLowerCase()} {
25
- async constructor_() {
26
- this.me = new abap.types.ABAPObject();
27
- this.me.set(this);
28
- return this;
29
- }
23
+ return new chunk_1.Chunk(`
24
+ class ${className === null || className === void 0 ? void 0 : className.toLowerCase()} {
25
+ async constructor_() {
26
+ this.me = new abap.types.ABAPObject();
27
+ this.me.set(this);
28
+ return this;
29
+ }
30
30
  }`);
31
31
  }
32
32
  }
@@ -84,7 +84,12 @@ class TranspileTypes {
84
84
  }
85
85
  else if (type instanceof abaplint.BasicTypes.PackedType) {
86
86
  resolved = "Packed";
87
- extra = "{length: " + type.getLength() + ", decimals: " + type.getDecimals() + "}";
87
+ if (type.getQualifiedName()) {
88
+ extra = "{length: " + type.getLength() + ", decimals: " + type.getDecimals() + ", qualifiedName: \"" + type.getQualifiedName() + "\"}";
89
+ }
90
+ else {
91
+ extra = "{length: " + type.getLength() + ", decimals: " + type.getDecimals() + "}";
92
+ }
88
93
  }
89
94
  else if (type instanceof abaplint.BasicTypes.NumericGenericType) {
90
95
  resolved = "Packed";
@@ -8,16 +8,16 @@ class UnitTest {
8
8
  initializationScript(reg, dbSetup, extraSetup, useImport) {
9
9
  let ret = "";
10
10
  if (useImport === true) {
11
- ret = `/* eslint-disable import/newline-after-import */
11
+ ret = `/* eslint-disable import/newline-after-import */
12
12
  import "./_top.mjs";\n`;
13
13
  }
14
14
  else {
15
- ret = `/* eslint-disable import/newline-after-import */
16
- import runtime from "@abaplint/runtime";
15
+ ret = `/* eslint-disable import/newline-after-import */
16
+ import runtime from "@abaplint/runtime";
17
17
  globalThis.abap = new runtime.ABAP();\n`;
18
18
  }
19
- ret += `${this.buildImports(reg, useImport)}
20
-
19
+ ret += `${this.buildImports(reg, useImport)}
20
+
21
21
  export async function initializeABAP() {\n`;
22
22
  ret += ` const sqlite = \`${dbSetup.schemas.sqlite}\`;\n`;
23
23
  ret += ` const hdb = \`${dbSetup.schemas.hdb}\`;\n`;
@@ -39,19 +39,19 @@ export async function initializeABAP() {\n`;
39
39
  return filename.replace(/\//g, "%23");
40
40
  }
41
41
  unitTestScriptOpen(reg, _skip, _only) {
42
- let ret = `/* eslint-disable curly */
43
- import fs from "fs";
44
- import path from "path";
45
- import {fileURLToPath} from "url";
46
- import {initializeABAP} from "./init.mjs";
47
-
48
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
49
-
50
- async function run() {
51
- await initializeABAP();
52
- let lt_input = new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]});
53
- let ls_input = new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})});
54
- let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30}), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String()}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]}), json: new abap.types.String()});
42
+ let ret = `/* eslint-disable curly */
43
+ import fs from "fs";
44
+ import path from "path";
45
+ import {fileURLToPath} from "url";
46
+ import {initializeABAP} from "./init.mjs";
47
+
48
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
49
+
50
+ async function run() {
51
+ await initializeABAP();
52
+ let lt_input = new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]});
53
+ let ls_input = new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})});
54
+ let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30}), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String()}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]}), json: new abap.types.String()});
55
55
  `;
56
56
  for (const obj of reg.getObjects()) {
57
57
  if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
@@ -71,44 +71,44 @@ async function run() {
71
71
  if (m.isForTesting === false) {
72
72
  continue;
73
73
  }
74
- ret += ` ls_input.get().class_name.set("${obj.getName()}");
75
- ls_input.get().testclass_name.set("${def.name.toUpperCase()}");
76
- ls_input.get().method_name.set("${m.name.toUpperCase()}");
74
+ ret += ` ls_input.get().class_name.set("${obj.getName()}");
75
+ ls_input.get().testclass_name.set("${def.name.toUpperCase()}");
76
+ ls_input.get().method_name.set("${m.name.toUpperCase()}");
77
77
  abap.statements.append({source: ls_input, target: lt_input});\n`;
78
78
  }
79
79
  }
80
80
  }
81
81
  }
82
- ret += `
83
-
84
- ls_result.set(await abap.Classes["KERNEL_UNIT_RUNNER"].run({it_input: lt_input}));
85
- fs.writeFileSync(__dirname + path.sep + "output.json", ls_result.get().json.get());
86
- }
87
-
88
- run().then(() => {
89
- process.exit(0);
90
- }).catch((err) => {
91
- console.log(err);
92
- process.exit(1);
82
+ ret += `
83
+
84
+ ls_result.set(await abap.Classes["KERNEL_UNIT_RUNNER"].run({it_input: lt_input}));
85
+ fs.writeFileSync(__dirname + path.sep + "output.json", ls_result.get().json.get());
86
+ }
87
+
88
+ run().then(() => {
89
+ process.exit(0);
90
+ }).catch((err) => {
91
+ console.log(err);
92
+ process.exit(1);
93
93
  });`;
94
94
  return ret;
95
95
  }
96
96
  unitTestScript(reg, skip, _only) {
97
- let ret = `/* eslint-disable curly */
98
- import fs from "fs";
99
- import path from "path";
100
- import {fileURLToPath} from "url";
101
- import {initializeABAP} from "./init.mjs";
102
- import runtime from "@abaplint/runtime";
103
-
104
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
105
-
106
- async function run() {
107
- await initializeABAP();
108
- const unit = new runtime.UnitTestResult();
109
- let clas;
110
- let locl;
111
- let meth;
97
+ let ret = `/* eslint-disable curly */
98
+ import fs from "fs";
99
+ import path from "path";
100
+ import {fileURLToPath} from "url";
101
+ import {initializeABAP} from "./init.mjs";
102
+ import runtime from "@abaplint/runtime";
103
+
104
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
105
+
106
+ async function run() {
107
+ await initializeABAP();
108
+ const unit = new runtime.UnitTestResult();
109
+ let clas;
110
+ let locl;
111
+ let meth;
112
112
  try {\n`;
113
113
  for (const obj of reg.getObjects()) {
114
114
  if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
@@ -122,9 +122,9 @@ async function run() {
122
122
  // todo, fix, there might be global test methods
123
123
  continue;
124
124
  }
125
- ret += ` {
126
- const {${def.name}} = await import("./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs");
127
- locl = clas.addTestClass("${def.name}");
125
+ ret += ` {
126
+ const {${def.name}} = await import("./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs");
127
+ locl = clas.addTestClass("${def.name}");
128
128
  if (${def.name}.class_setup) await ${def.name}.class_setup();\n`;
129
129
  for (const m of def.methods) {
130
130
  if (m.isForTesting === false) {
@@ -151,24 +151,24 @@ async function run() {
151
151
  }
152
152
  }
153
153
  }
154
- ret += `// -------------------END-------------------
155
- console.log(abap.console.get());
156
- fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
157
- } catch (e) {
158
- if (meth) {
159
- meth.fail();
160
- }
161
- console.log(abap.console.get());
162
- fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
163
- throw e;
164
- }
165
- }
166
-
167
- run().then(() => {
168
- process.exit(0);
169
- }).catch((err) => {
170
- console.log(err);
171
- process.exit(1);
154
+ ret += `// -------------------END-------------------
155
+ console.log(abap.console.get());
156
+ fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
157
+ } catch (e) {
158
+ if (meth) {
159
+ meth.fail();
160
+ }
161
+ console.log(abap.console.get());
162
+ fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
163
+ throw e;
164
+ }
165
+ }
166
+
167
+ run().then(() => {
168
+ process.exit(0);
169
+ }).catch((err) => {
170
+ console.log(err);
171
+ process.exit(1);
172
172
  });`;
173
173
  return ret;
174
174
  }
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
- {
2
- "name": "@abaplint/transpiler",
3
- "version": "2.1.7",
4
- "description": "Transpiler",
5
- "main": "build/src/index.js",
6
- "typings": "build/src/index.d.ts",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/abaplint/transpiler.git"
10
- },
11
- "scripts": {
12
- "compile": "tsc",
13
- "publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
14
- "publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
15
- "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
16
- "test": "npm run compile && mocha"
17
- },
18
- "mocha": {
19
- "recursive": true,
20
- "reporter": "progress",
21
- "spec": "build/test/**/*.js",
22
- "require": "source-map-support/register"
23
- },
24
- "keywords": [
25
- "ABAP",
26
- "abaplint"
27
- ],
28
- "author": "abaplint",
29
- "license": "MIT",
30
- "dependencies": {
31
- "@abaplint/core": "^2.91.18",
32
- "source-map": "^0.7.4"
33
- },
34
- "devDependencies": {
35
- "@types/chai": "^4.3.1",
36
- "@types/mocha": "^9.1.1",
37
- "chai": "^4.3.6",
38
- "mocha": "^10.0.0",
39
- "source-map-support": "^0.5.21",
40
- "typescript": "^4.7.4"
41
- }
42
- }
1
+ {
2
+ "name": "@abaplint/transpiler",
3
+ "version": "2.1.8",
4
+ "description": "Transpiler",
5
+ "main": "build/src/index.js",
6
+ "typings": "build/src/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/abaplint/transpiler.git"
10
+ },
11
+ "scripts": {
12
+ "compile": "tsc",
13
+ "publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
14
+ "publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
15
+ "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
16
+ "test": "npm run compile && mocha"
17
+ },
18
+ "mocha": {
19
+ "recursive": true,
20
+ "reporter": "progress",
21
+ "spec": "build/test/**/*.js",
22
+ "require": "source-map-support/register"
23
+ },
24
+ "keywords": [
25
+ "ABAP",
26
+ "abaplint"
27
+ ],
28
+ "author": "abaplint",
29
+ "license": "MIT",
30
+ "dependencies": {
31
+ "@abaplint/core": "^2.91.18",
32
+ "source-map": "^0.7.4"
33
+ },
34
+ "devDependencies": {
35
+ "@types/chai": "^4.3.1",
36
+ "@types/mocha": "^9.1.1",
37
+ "chai": "^4.3.6",
38
+ "mocha": "^10.0.0",
39
+ "source-map-support": "^0.5.21",
40
+ "typescript": "^4.7.4"
41
+ }
42
+ }