@abaplint/transpiler 2.10.13 → 2.10.15
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
CHANGED
|
@@ -5,7 +5,6 @@ const abaplint = require("@abaplint/core");
|
|
|
5
5
|
const validation_1 = require("./validation");
|
|
6
6
|
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return validation_1.config; } });
|
|
7
7
|
const unit_test_1 = require("./unit_test");
|
|
8
|
-
const keywords_1 = require("./keywords");
|
|
9
8
|
const types_1 = require("./types");
|
|
10
9
|
Object.defineProperty(exports, "UnknownTypesEnum", { enumerable: true, get: function () { return types_1.UnknownTypesEnum; } });
|
|
11
10
|
const db_1 = require("./db");
|
|
@@ -39,7 +38,6 @@ class Transpiler {
|
|
|
39
38
|
}
|
|
40
39
|
async run(reg, progress) {
|
|
41
40
|
reg.parse();
|
|
42
|
-
new keywords_1.Keywords(this.options?.keywords).handle(reg);
|
|
43
41
|
this.validate(reg);
|
|
44
42
|
const dbSetup = new db_1.DatabaseSetup(reg).run(this.options);
|
|
45
43
|
const output = {
|
package/build/src/keywords.d.ts
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
import * as abaplint from "@abaplint/core";
|
|
2
1
|
export declare const DEFAULT_KEYWORDS: string[];
|
|
3
|
-
/** Replaces javascript keywords in ABAP source code, in-memory only */
|
|
4
|
-
export declare class Keywords {
|
|
5
|
-
private readonly keywords;
|
|
6
|
-
constructor(keywords?: string[]);
|
|
7
|
-
handle(reg: abaplint.IRegistry): void;
|
|
8
|
-
private handleMacro;
|
|
9
|
-
private traverse;
|
|
10
|
-
}
|
package/build/src/keywords.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const abaplint = require("@abaplint/core");
|
|
3
|
+
exports.DEFAULT_KEYWORDS = void 0;
|
|
5
4
|
// https://www.w3schools.com/js/js_reserved.asp
|
|
6
5
|
exports.DEFAULT_KEYWORDS = [
|
|
7
6
|
"abstract", "arguments", "await",
|
|
@@ -20,96 +19,8 @@ exports.DEFAULT_KEYWORDS = [
|
|
|
20
19
|
"switch", "synchronized", "this",
|
|
21
20
|
"throw", "throws", "transient", "true",
|
|
22
21
|
"try", "typeof", "var", "void",
|
|
22
|
+
"delete",
|
|
23
23
|
"volatile", "while", "yield"
|
|
24
24
|
];
|
|
25
25
|
// "with"
|
|
26
|
-
// "delete"
|
|
27
|
-
/** Replaces javascript keywords in ABAP source code, in-memory only */
|
|
28
|
-
class Keywords {
|
|
29
|
-
constructor(keywords) {
|
|
30
|
-
this.keywords = [];
|
|
31
|
-
if (keywords !== undefined) {
|
|
32
|
-
this.keywords = keywords;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this.keywords = exports.DEFAULT_KEYWORDS;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
handle(reg) {
|
|
39
|
-
if (this.keywords.length === 0) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
reg.parse();
|
|
43
|
-
for (const o of reg.getObjects()) {
|
|
44
|
-
if (!(o instanceof abaplint.ABAPObject)) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
for (const f of o.getABAPFiles()) {
|
|
48
|
-
const tokens = [];
|
|
49
|
-
for (const s of f.getStatements()) {
|
|
50
|
-
if (s.get() instanceof abaplint.MacroCall) {
|
|
51
|
-
tokens.push(...this.handleMacro(s));
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
tokens.push(...this.traverse(s, f));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (tokens.length === 0) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const rows = f.getRawRows();
|
|
61
|
-
for (const t of tokens.reverse()) {
|
|
62
|
-
const original = rows[t.getRow() - 1];
|
|
63
|
-
const index = t.getEnd().getCol() - 1;
|
|
64
|
-
rows[t.getRow() - 1] = original.substring(0, index) + "_" + original.substring(index);
|
|
65
|
-
}
|
|
66
|
-
reg.updateFile(new abaplint.MemoryFile(f.getFilename(), rows.join("\n")));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
reg.parse();
|
|
70
|
-
}
|
|
71
|
-
handleMacro(node) {
|
|
72
|
-
const tokens = [];
|
|
73
|
-
for (const token of node.getTokens()) {
|
|
74
|
-
for (const k of this.keywords) {
|
|
75
|
-
const lower = token.getStr().toLowerCase();
|
|
76
|
-
if (k === lower
|
|
77
|
-
|| "!" + k === lower
|
|
78
|
-
|| lower.endsWith("~" + k)) {
|
|
79
|
-
tokens.push(token);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return tokens;
|
|
84
|
-
}
|
|
85
|
-
traverse(node, file) {
|
|
86
|
-
const ret = [];
|
|
87
|
-
for (const c of node.getChildren()) {
|
|
88
|
-
if (c instanceof abaplint.Nodes.TokenNodeRegex) {
|
|
89
|
-
const token = c.getFirstToken();
|
|
90
|
-
const start = token.getStart();
|
|
91
|
-
if (start instanceof abaplint.VirtualPosition) {
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
for (const k of this.keywords) {
|
|
95
|
-
const lower = token.getStr().toLowerCase();
|
|
96
|
-
if (k === lower
|
|
97
|
-
|| "!" + k === lower
|
|
98
|
-
|| lower.endsWith("~" + k)) {
|
|
99
|
-
ret.push(token);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else if (c instanceof abaplint.Nodes.TokenNode) {
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
ret.push(...this.traverse(c, file));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return ret;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
exports.Keywords = Keywords;
|
|
115
26
|
//# sourceMappingURL=keywords.js.map
|
|
@@ -26,7 +26,7 @@ class DataTranspiler {
|
|
|
26
26
|
value = "\n" + traversal.setValues(found, found.getName());
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
value = DataTranspiler.buildValue(node, found.getName().toLowerCase(), traversal);
|
|
29
|
+
value = DataTranspiler.buildValue(node, traversal_1.Traversal.prefixVariable(found.getName().toLowerCase()), traversal);
|
|
30
30
|
}
|
|
31
31
|
const ret = new chunk_1.Chunk()
|
|
32
32
|
.appendString("let ")
|
package/build/src/traversal.js
CHANGED
package/build/src/validation.js
CHANGED
|
@@ -2,14 +2,10 @@
|
|
|
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");
|
|
6
5
|
const types_1 = require("./types");
|
|
7
6
|
exports.config = {
|
|
8
7
|
"global": {
|
|
9
8
|
"files": "/**/*.*",
|
|
10
|
-
"skipGeneratedGatewayClasses": true,
|
|
11
|
-
"skipGeneratedPersistentClasses": true,
|
|
12
|
-
"skipGeneratedFunctionGroups": true,
|
|
13
9
|
},
|
|
14
10
|
"syntax": {
|
|
15
11
|
"version": core_1.Version.OpenABAP,
|
|
@@ -119,18 +115,6 @@ class Validation {
|
|
|
119
115
|
exports.config.rules["check_syntax"] = true;
|
|
120
116
|
}
|
|
121
117
|
exports.config.rules["forbidden_identifier"]["check"] = ["^unique\\d+$"];
|
|
122
|
-
if (this.options?.keywords === undefined) {
|
|
123
|
-
for (const d of keywords_1.DEFAULT_KEYWORDS) {
|
|
124
|
-
const add = "^" + d + "$";
|
|
125
|
-
exports.config.rules["forbidden_identifier"]["check"].push(add);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
for (const d of this.options.keywords) {
|
|
130
|
-
const add = "^" + d + "$";
|
|
131
|
-
exports.config.rules["forbidden_identifier"]["check"].push(add);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
118
|
if (this.options?.unknownTypes === types_1.UnknownTypesEnum.runtimeError) {
|
|
135
119
|
// this is not a constant, just a regex that happens to not match anything
|
|
136
120
|
exports.config.syntax.errorNamespace = "VOID_EVERYTHING";
|