@abaplint/transpiler 2.3.73 → 2.3.75
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/index.js +6 -6
- package/build/src/keywords.d.ts +3 -0
- package/build/src/keywords.js +32 -23
- package/build/src/types.d.ts +2 -0
- package/build/src/validation.js +25 -24
- package/package.json +1 -1
package/build/src/index.js
CHANGED
|
@@ -30,17 +30,17 @@ class Transpiler {
|
|
|
30
30
|
return new Transpiler().run(reg);
|
|
31
31
|
}
|
|
32
32
|
async run(reg, progress) {
|
|
33
|
-
var _a, _b, _c, _d, _e, _f;
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
34
34
|
reg.parse();
|
|
35
|
-
new keywords_1.Keywords().handle(reg);
|
|
35
|
+
new keywords_1.Keywords((_a = this.options) === null || _a === void 0 ? void 0 : _a.keywords).handle(reg);
|
|
36
36
|
this.validate(reg);
|
|
37
37
|
const dbSetup = new db_1.DatabaseSetup(reg).run();
|
|
38
38
|
const output = {
|
|
39
39
|
objects: [],
|
|
40
|
-
unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, (
|
|
41
|
-
unitTestScriptOpen: new unit_test_1.UnitTest().unitTestScriptOpen(reg, (
|
|
42
|
-
initializationScript: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, (
|
|
43
|
-
initializationScript2: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, (
|
|
40
|
+
unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, (_b = this.options) === null || _b === void 0 ? void 0 : _b.skip, (_c = this.options) === null || _c === void 0 ? void 0 : _c.only),
|
|
41
|
+
unitTestScriptOpen: new unit_test_1.UnitTest().unitTestScriptOpen(reg, (_d = this.options) === null || _d === void 0 ? void 0 : _d.skip, (_e = this.options) === null || _e === void 0 ? void 0 : _e.only),
|
|
42
|
+
initializationScript: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, (_f = this.options) === null || _f === void 0 ? void 0 : _f.extraSetup),
|
|
43
|
+
initializationScript2: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, (_g = this.options) === null || _g === void 0 ? void 0 : _g.extraSetup, true),
|
|
44
44
|
databaseSetup: dbSetup,
|
|
45
45
|
reg: reg,
|
|
46
46
|
};
|
package/build/src/keywords.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as abaplint from "@abaplint/core";
|
|
2
|
+
export declare const defaultKeywords: string[];
|
|
2
3
|
/** Replaces javascript keywords in ABAP source code, in-memory only */
|
|
3
4
|
export declare class Keywords {
|
|
5
|
+
private readonly keywords;
|
|
6
|
+
constructor(keywords?: string[]);
|
|
4
7
|
handle(reg: abaplint.IRegistry): void;
|
|
5
8
|
private traverse;
|
|
6
9
|
}
|
package/build/src/keywords.js
CHANGED
|
@@ -1,9 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Keywords = void 0;
|
|
3
|
+
exports.Keywords = exports.defaultKeywords = void 0;
|
|
4
4
|
const abaplint = require("@abaplint/core");
|
|
5
|
+
// https://www.w3schools.com/js/js_reserved.asp
|
|
6
|
+
exports.defaultKeywords = [
|
|
7
|
+
"abstract", "arguments", "await",
|
|
8
|
+
"break", "byte", "catch",
|
|
9
|
+
"char", "class", "const", "continue",
|
|
10
|
+
"debugger", "default", "do",
|
|
11
|
+
"double", "else", "enum", "eval",
|
|
12
|
+
"export", "extends", "false", "final",
|
|
13
|
+
"finally", "for", "function",
|
|
14
|
+
"goto", "if", "implements", "import",
|
|
15
|
+
"in", "instanceof", "interface",
|
|
16
|
+
"let", "long", "native", "new",
|
|
17
|
+
"null", "package", "private",
|
|
18
|
+
"public", "return", "short", "static",
|
|
19
|
+
"switch", "synchronized", "this",
|
|
20
|
+
"throw", "throws", "transient", "true",
|
|
21
|
+
"try", "typeof", "var", "void",
|
|
22
|
+
"volatile", "while", "yield"
|
|
23
|
+
];
|
|
24
|
+
// "with"
|
|
25
|
+
// "delete"
|
|
5
26
|
/** Replaces javascript keywords in ABAP source code, in-memory only */
|
|
6
27
|
class Keywords {
|
|
28
|
+
constructor(keywords) {
|
|
29
|
+
this.keywords = [];
|
|
30
|
+
if (keywords !== undefined) {
|
|
31
|
+
this.keywords = keywords;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.keywords = exports.defaultKeywords;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
7
37
|
handle(reg) {
|
|
8
38
|
reg.parse();
|
|
9
39
|
for (const o of reg.getObjects()) {
|
|
@@ -30,27 +60,6 @@ class Keywords {
|
|
|
30
60
|
reg.parse();
|
|
31
61
|
}
|
|
32
62
|
traverse(node, file) {
|
|
33
|
-
// https://www.w3schools.com/js/js_reserved.asp
|
|
34
|
-
const keywords = [
|
|
35
|
-
"abstract", "arguments", "await",
|
|
36
|
-
"break", "byte", "catch",
|
|
37
|
-
"char", "class", "const", "continue",
|
|
38
|
-
"debugger", "default", "do",
|
|
39
|
-
"double", "else", "enum", "eval",
|
|
40
|
-
"export", "extends", "false", "final",
|
|
41
|
-
"finally", "for", "function",
|
|
42
|
-
"goto", "if", "implements", "import",
|
|
43
|
-
"in", "instanceof", "interface",
|
|
44
|
-
"let", "long", "native", "new",
|
|
45
|
-
"null", "package", "private",
|
|
46
|
-
"public", "return", "short", "static",
|
|
47
|
-
"switch", "synchronized", "this",
|
|
48
|
-
"throw", "throws", "transient", "true",
|
|
49
|
-
"try", "typeof", "var", "void",
|
|
50
|
-
"volatile", "while", "yield"
|
|
51
|
-
];
|
|
52
|
-
// "with"
|
|
53
|
-
// "delete"
|
|
54
63
|
const ret = [];
|
|
55
64
|
for (const c of node.getChildren()) {
|
|
56
65
|
if (c instanceof abaplint.Nodes.TokenNodeRegex) {
|
|
@@ -59,7 +68,7 @@ class Keywords {
|
|
|
59
68
|
if (start instanceof abaplint.VirtualPosition) {
|
|
60
69
|
continue;
|
|
61
70
|
}
|
|
62
|
-
for (const k of keywords) {
|
|
71
|
+
for (const k of this.keywords) {
|
|
63
72
|
const lower = token.getStr().toLowerCase();
|
|
64
73
|
if (k === lower
|
|
65
74
|
|| "!" + k === lower
|
package/build/src/types.d.ts
CHANGED
package/build/src/validation.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Validation = exports.config = void 0;
|
|
4
4
|
const core_1 = require("@abaplint/core");
|
|
5
|
+
const keywords_1 = require("./keywords");
|
|
5
6
|
exports.config = {
|
|
6
7
|
"global": {
|
|
7
8
|
"files": "/**/*.*",
|
|
@@ -28,6 +29,7 @@ exports.config = {
|
|
|
28
29
|
"parser_error": true,
|
|
29
30
|
"allowed_object_types": {
|
|
30
31
|
"allowed": [
|
|
32
|
+
"AUTH",
|
|
31
33
|
"CLAS",
|
|
32
34
|
"DEVC",
|
|
33
35
|
"DOMA",
|
|
@@ -43,7 +45,11 @@ exports.config = {
|
|
|
43
45
|
"SHMA",
|
|
44
46
|
"SICF",
|
|
45
47
|
"SMIM",
|
|
48
|
+
"SRFC",
|
|
49
|
+
"SUSO",
|
|
46
50
|
"TABL",
|
|
51
|
+
"TOBJ",
|
|
52
|
+
"TRAN",
|
|
47
53
|
"TTYP",
|
|
48
54
|
"TYPE",
|
|
49
55
|
"VIEW",
|
|
@@ -62,45 +68,40 @@ exports.config = {
|
|
|
62
68
|
"setExtended": true,
|
|
63
69
|
},
|
|
64
70
|
"forbidden_identifier": {
|
|
65
|
-
"check": [
|
|
66
|
-
"^abstract$", "^arguments$", "^await$",
|
|
67
|
-
"^break$", "^byte$", "^catch$",
|
|
68
|
-
"^char$", "^class$", "^const$", "^continue$",
|
|
69
|
-
"^debugger$", "^default$", "^do$",
|
|
70
|
-
"^double$", "^else$", "^enum$", "^eval$",
|
|
71
|
-
"^export$", "^extends$", "^false$", "^final$",
|
|
72
|
-
"^finally$", "^for$", "^function$",
|
|
73
|
-
"^goto$", "^if$", "^implements$", "^import$",
|
|
74
|
-
"^in$", "^instanceof$", "^interface$",
|
|
75
|
-
"^let$", "^long$", "^native$", "^new$",
|
|
76
|
-
"^null$", "^package$", "^private$",
|
|
77
|
-
// "^protected$",
|
|
78
|
-
"^public$", "^return$", "^short$", "^static$",
|
|
79
|
-
"^switch$", "^synchronized$", "^this$",
|
|
80
|
-
"^throw$", "^throws$", "^transient$", "^true$",
|
|
81
|
-
"^try$", "^typeof$", "^var$", "^void$",
|
|
82
|
-
"^volatile$", "^while$", "^yield$",
|
|
83
|
-
"^unique\\d+$"
|
|
84
|
-
],
|
|
71
|
+
"check": [],
|
|
85
72
|
},
|
|
86
73
|
},
|
|
87
74
|
};
|
|
88
75
|
// todo, make sure nothing is overloaded, eg "lines()", there is a rule for this in abaplint now
|
|
76
|
+
// hmm this ^ is okay? since lines will be prefixed with "abap.builtin"?
|
|
89
77
|
class Validation {
|
|
90
78
|
constructor(options) {
|
|
91
79
|
this.options = options;
|
|
92
80
|
}
|
|
93
81
|
run(reg) {
|
|
94
|
-
var _a, _b;
|
|
82
|
+
var _a, _b, _c;
|
|
95
83
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.ignoreSyntaxCheck) === true) {
|
|
96
84
|
exports.config.rules["check_syntax"] = false;
|
|
97
85
|
}
|
|
98
86
|
else {
|
|
99
87
|
exports.config.rules["check_syntax"] = true;
|
|
100
88
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
exports.config.rules["forbidden_identifier"]["check"] = ["^unique\\d+$"];
|
|
90
|
+
if (((_b = this.options) === null || _b === void 0 ? void 0 : _b.keywords) === undefined) {
|
|
91
|
+
for (const d of keywords_1.defaultKeywords) {
|
|
92
|
+
const add = "^" + d + "$";
|
|
93
|
+
exports.config.rules["forbidden_identifier"]["check"].push(add);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
for (const d of this.options.keywords) {
|
|
98
|
+
const add = "^" + d + "$";
|
|
99
|
+
exports.config.rules["forbidden_identifier"]["check"].push(add);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (((_c = this.options) === null || _c === void 0 ? void 0 : _c.unknownTypes) === "runtimeError") {
|
|
103
|
+
// this is not a constant, just a regex that happens to not match anything
|
|
104
|
+
exports.config.syntax.errorNamespace = "VOID_EVERYTHING";
|
|
104
105
|
}
|
|
105
106
|
const conf = new core_1.Config(JSON.stringify(exports.config));
|
|
106
107
|
reg.setConfig(conf);
|