@abaplint/transpiler 1.7.35 → 1.7.39
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/build/src/database_setup.js +8 -0
- package/build/src/expressions/database_table.d.ts +1 -1
- package/build/src/expressions/database_table.js +10 -2
- package/build/src/expressions/sql_source.js +5 -1
- package/build/src/handle_data_element.js +2 -2
- package/build/src/handle_table.js +3 -3
- package/build/src/handle_table_type.js +2 -2
- package/build/src/statements/create_data.js +5 -0
- package/build/src/statements/do.js +4 -4
- package/build/src/statements/modify_database.d.ts +1 -1
- package/build/src/statements/modify_database.js +10 -2
- package/build/src/unit_test.js +39 -39
- package/package.json +41 -41
|
@@ -66,9 +66,17 @@ class DatabaseSetup {
|
|
|
66
66
|
if (type instanceof abaplint.BasicTypes.CharacterType) {
|
|
67
67
|
return `NCHAR(${type.getLength()})`;
|
|
68
68
|
}
|
|
69
|
+
else if (type instanceof abaplint.BasicTypes.NumericType) {
|
|
70
|
+
// it will be fine, the runtime representation of numc is also text
|
|
71
|
+
return `NCHAR(${type.getLength()})`;
|
|
72
|
+
}
|
|
69
73
|
else if (type instanceof abaplint.BasicTypes.StringType) {
|
|
70
74
|
return `TEXT`;
|
|
71
75
|
}
|
|
76
|
+
else if (type instanceof abaplint.BasicTypes.XStringType) {
|
|
77
|
+
// it will be fine, the runtime representation of xstring is also text
|
|
78
|
+
return `TEXT`;
|
|
79
|
+
}
|
|
72
80
|
else if (type instanceof abaplint.BasicTypes.IntegerType) {
|
|
73
81
|
return `INT`;
|
|
74
82
|
}
|
|
@@ -3,5 +3,5 @@ import { IExpressionTranspiler } from "./_expression_transpiler";
|
|
|
3
3
|
import { Traversal } from "../traversal";
|
|
4
4
|
import { Chunk } from "../chunk";
|
|
5
5
|
export declare class DatabaseTableTranspiler implements IExpressionTranspiler {
|
|
6
|
-
transpile(node: Nodes.ExpressionNode,
|
|
6
|
+
transpile(node: Nodes.ExpressionNode, traversal: Traversal): Chunk;
|
|
7
7
|
}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DatabaseTableTranspiler = void 0;
|
|
4
|
+
const core_1 = require("@abaplint/core");
|
|
4
5
|
const chunk_1 = require("../chunk");
|
|
5
6
|
class DatabaseTableTranspiler {
|
|
6
|
-
transpile(node,
|
|
7
|
+
transpile(node, traversal) {
|
|
7
8
|
const ret = new chunk_1.Chunk();
|
|
8
|
-
|
|
9
|
+
const dyn = node.findDirectExpression(core_1.Expressions.Dynamic);
|
|
10
|
+
if (dyn) {
|
|
11
|
+
const sub = dyn.getChildren()[1];
|
|
12
|
+
return traversal.traverse(sub);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
ret.appendString('"' + node.concatTokens() + '"');
|
|
16
|
+
}
|
|
9
17
|
return ret;
|
|
10
18
|
}
|
|
11
19
|
}
|
|
@@ -4,7 +4,11 @@ exports.SQLSourceTranspiler = void 0;
|
|
|
4
4
|
const abaplint = require("@abaplint/core");
|
|
5
5
|
class SQLSourceTranspiler {
|
|
6
6
|
transpile(node, traversal) {
|
|
7
|
-
|
|
7
|
+
let s = node.findDirectExpression(abaplint.Expressions.Source);
|
|
8
|
+
if (s === undefined) {
|
|
9
|
+
s = node.findDirectExpression(abaplint.Expressions.SimpleSource3);
|
|
10
|
+
}
|
|
11
|
+
return traversal.traverse(s);
|
|
8
12
|
}
|
|
9
13
|
}
|
|
10
14
|
exports.SQLSourceTranspiler = SQLSourceTranspiler;
|
|
@@ -11,8 +11,8 @@ class HandleDataElement {
|
|
|
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
|
-
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
14
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
15
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
16
16
|
};`);
|
|
17
17
|
const output = {
|
|
18
18
|
object: {
|
|
@@ -12,9 +12,9 @@ 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
|
-
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
17
|
-
"keyFields": ${JSON.stringify(obj.listKeys())},
|
|
15
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
16
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
17
|
+
"keyFields": ${JSON.stringify(obj.listKeys())},
|
|
18
18
|
};`);
|
|
19
19
|
const output = {
|
|
20
20
|
object: {
|
|
@@ -11,8 +11,8 @@ 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
|
-
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
14
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
15
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
16
16
|
};`);
|
|
17
17
|
const output = {
|
|
18
18
|
object: {
|
|
@@ -10,6 +10,7 @@ class CreateDataTranspiler {
|
|
|
10
10
|
var _a, _b, _c;
|
|
11
11
|
const targetNode = node.findDirectExpression(abaplint.Expressions.Target);
|
|
12
12
|
const target = traversal.traverse(targetNode);
|
|
13
|
+
const concat = node.concatTokens();
|
|
13
14
|
const options = [];
|
|
14
15
|
let dynamic = (_a = node.findDirectExpression(abaplint.Expressions.Dynamic)) === null || _a === void 0 ? void 0 : _a.findFirstExpression(abaplint.Expressions.ConstantString);
|
|
15
16
|
if (dynamic) {
|
|
@@ -31,6 +32,10 @@ class CreateDataTranspiler {
|
|
|
31
32
|
if (node.findDirectTokenByText("TABLE")) {
|
|
32
33
|
options.push(`"table": true`);
|
|
33
34
|
}
|
|
35
|
+
if (concat.includes(" LIKE LINE OF ")) {
|
|
36
|
+
const so = traversal.traverse(node.findDirectExpression(abaplint.Expressions.Source));
|
|
37
|
+
options.push(`"likeLineOf": ` + so.getCode());
|
|
38
|
+
}
|
|
34
39
|
let add = "";
|
|
35
40
|
if (options.length > 0) {
|
|
36
41
|
add = ",{" + options.join(",") + "}";
|
|
@@ -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
|
}
|
|
@@ -3,5 +3,5 @@ import { IStatementTranspiler } from "./_statement_transpiler";
|
|
|
3
3
|
import { Traversal } from "../traversal";
|
|
4
4
|
import { Chunk } from "../chunk";
|
|
5
5
|
export declare class ModifyDatabaseTranspiler implements IStatementTranspiler {
|
|
6
|
-
transpile(
|
|
6
|
+
transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal): Chunk;
|
|
7
7
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ModifyDatabaseTranspiler = void 0;
|
|
4
|
+
const abaplint = require("@abaplint/core");
|
|
4
5
|
const chunk_1 = require("../chunk");
|
|
5
6
|
class ModifyDatabaseTranspiler {
|
|
6
|
-
transpile(
|
|
7
|
-
|
|
7
|
+
transpile(node, traversal) {
|
|
8
|
+
const table = traversal.traverse(node.findFirstExpression(abaplint.Expressions.DatabaseTable));
|
|
9
|
+
const options = [];
|
|
10
|
+
const tab = node.findExpressionAfterToken("TABLE");
|
|
11
|
+
if (tab) {
|
|
12
|
+
const ttab = traversal.traverse(tab);
|
|
13
|
+
options.push(`"table": ` + ttab.getCode());
|
|
14
|
+
}
|
|
15
|
+
return new chunk_1.Chunk(`abap.statements.modifyDatabase(${table.getCode()}, {${options.join(", ")}});`);
|
|
8
16
|
}
|
|
9
17
|
}
|
|
10
18
|
exports.ModifyDatabaseTranspiler = ModifyDatabaseTranspiler;
|
package/build/src/unit_test.js
CHANGED
|
@@ -5,9 +5,9 @@ const abaplint = require("@abaplint/core");
|
|
|
5
5
|
class UnitTest {
|
|
6
6
|
// todo, move this somewhere else, its much more than just unit test relevant
|
|
7
7
|
initializationScript(reg, dbSetup) {
|
|
8
|
-
let ret = `import runtime from "@abaplint/runtime";
|
|
9
|
-
global.abap = new runtime.ABAP();
|
|
10
|
-
${this.buildImports(reg)}
|
|
8
|
+
let ret = `import runtime from "@abaplint/runtime";
|
|
9
|
+
global.abap = new runtime.ABAP();
|
|
10
|
+
${this.buildImports(reg)}
|
|
11
11
|
export async function initializeABAP(settings) {\n`;
|
|
12
12
|
if (dbSetup === "") {
|
|
13
13
|
ret += `// no database artifacts, skip DB initialization\n`;
|
|
@@ -19,21 +19,21 @@ export async function initializeABAP(settings) {\n`;
|
|
|
19
19
|
return ret;
|
|
20
20
|
}
|
|
21
21
|
unitTestScript(reg, skip, _only) {
|
|
22
|
-
let ret = `/* eslint-disable curly */
|
|
23
|
-
import fs from "fs";
|
|
24
|
-
import path from "path";
|
|
25
|
-
import {fileURLToPath} from "url";
|
|
26
|
-
import {initializeABAP} from "./init.mjs";
|
|
27
|
-
import runtime from "@abaplint/runtime";
|
|
28
|
-
|
|
29
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
30
|
-
|
|
31
|
-
async function run() {
|
|
32
|
-
await initializeABAP();
|
|
33
|
-
const unit = new runtime.UnitTestResult();
|
|
34
|
-
let clas;
|
|
35
|
-
let locl;
|
|
36
|
-
let meth;
|
|
22
|
+
let ret = `/* eslint-disable curly */
|
|
23
|
+
import fs from "fs";
|
|
24
|
+
import path from "path";
|
|
25
|
+
import {fileURLToPath} from "url";
|
|
26
|
+
import {initializeABAP} from "./init.mjs";
|
|
27
|
+
import runtime from "@abaplint/runtime";
|
|
28
|
+
|
|
29
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
30
|
+
|
|
31
|
+
async function run() {
|
|
32
|
+
await initializeABAP();
|
|
33
|
+
const unit = new runtime.UnitTestResult();
|
|
34
|
+
let clas;
|
|
35
|
+
let locl;
|
|
36
|
+
let meth;
|
|
37
37
|
try {\n`;
|
|
38
38
|
for (const obj of reg.getObjects()) {
|
|
39
39
|
if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
|
|
@@ -48,9 +48,9 @@ async function run() {
|
|
|
48
48
|
|| def.methods.length === 0) {
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
51
|
-
ret += ` {
|
|
52
|
-
const {${def.name}} = await import("./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs");
|
|
53
|
-
locl = clas.addTestClass("${def.name}");
|
|
51
|
+
ret += ` {
|
|
52
|
+
const {${def.name}} = await import("./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs");
|
|
53
|
+
locl = clas.addTestClass("${def.name}");
|
|
54
54
|
if (${def.name}.class_setup) await ${def.name}.class_setup();\n`;
|
|
55
55
|
for (const m of def.methods) {
|
|
56
56
|
if (m.isForTesting === false) {
|
|
@@ -77,24 +77,24 @@ async function run() {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
ret += `// -------------------END-------------------
|
|
81
|
-
console.log(abap.console.get());
|
|
82
|
-
fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
|
|
83
|
-
} catch (e) {
|
|
84
|
-
if (meth) {
|
|
85
|
-
meth.fail();
|
|
86
|
-
}
|
|
87
|
-
console.log(abap.console.get());
|
|
88
|
-
fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
|
|
89
|
-
throw e;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
run().then(() => {
|
|
94
|
-
process.exit(0);
|
|
95
|
-
}).catch((err) => {
|
|
96
|
-
console.log(err);
|
|
97
|
-
process.exit(1);
|
|
80
|
+
ret += `// -------------------END-------------------
|
|
81
|
+
console.log(abap.console.get());
|
|
82
|
+
fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
|
|
83
|
+
} catch (e) {
|
|
84
|
+
if (meth) {
|
|
85
|
+
meth.fail();
|
|
86
|
+
}
|
|
87
|
+
console.log(abap.console.get());
|
|
88
|
+
fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
|
|
89
|
+
throw e;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
run().then(() => {
|
|
94
|
+
process.exit(0);
|
|
95
|
+
}).catch((err) => {
|
|
96
|
+
console.log(err);
|
|
97
|
+
process.exit(1);
|
|
98
98
|
});`;
|
|
99
99
|
return ret;
|
|
100
100
|
}
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "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:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
-
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
-
"test": "npm run compile && mocha"
|
|
16
|
-
},
|
|
17
|
-
"mocha": {
|
|
18
|
-
"recursive": true,
|
|
19
|
-
"reporter": "progress",
|
|
20
|
-
"spec": "build/test/**/*.js",
|
|
21
|
-
"require": "source-map-support/register"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"ABAP",
|
|
25
|
-
"abaplint"
|
|
26
|
-
],
|
|
27
|
-
"author": "abaplint",
|
|
28
|
-
"license": "MIT",
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@abaplint/core": "^2.
|
|
31
|
-
"source-map": "^0.7.3"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/chai": "^4.3.0",
|
|
35
|
-
"@types/mocha": "^9.1.0",
|
|
36
|
-
"chai": "^4.3.6",
|
|
37
|
-
"mocha": "^9.2.0",
|
|
38
|
-
"source-map-support": "^0.5.21",
|
|
39
|
-
"typescript": "^4.5.5"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@abaplint/transpiler",
|
|
3
|
+
"version": "1.7.39",
|
|
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:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
+
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
+
"test": "npm run compile && mocha"
|
|
16
|
+
},
|
|
17
|
+
"mocha": {
|
|
18
|
+
"recursive": true,
|
|
19
|
+
"reporter": "progress",
|
|
20
|
+
"spec": "build/test/**/*.js",
|
|
21
|
+
"require": "source-map-support/register"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"ABAP",
|
|
25
|
+
"abaplint"
|
|
26
|
+
],
|
|
27
|
+
"author": "abaplint",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@abaplint/core": "^2.85.9",
|
|
31
|
+
"source-map": "^0.7.3"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/chai": "^4.3.0",
|
|
35
|
+
"@types/mocha": "^9.1.0",
|
|
36
|
+
"chai": "^4.3.6",
|
|
37
|
+
"mocha": "^9.2.0",
|
|
38
|
+
"source-map-support": "^0.5.21",
|
|
39
|
+
"typescript": "^4.5.5"
|
|
40
|
+
}
|
|
41
|
+
}
|