@abaplint/transpiler 2.12.29 → 2.12.30
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/rearranger.d.ts +3 -0
- package/build/src/rearranger.js +56 -1
- package/build/src/statements/end_of_selection.d.ts +6 -0
- package/build/src/statements/end_of_selection.js +11 -0
- package/build/src/statements/index.d.ts +1 -0
- package/build/src/statements/index.js +1 -0
- package/build/src/traversal.js +0 -4
- package/package.json +2 -2
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Nodes } from "@abaplint/core";
|
|
2
2
|
export declare class Rearranger {
|
|
3
3
|
run(type: string, node: Nodes.StructureNode | undefined): Nodes.StructureNode | undefined;
|
|
4
|
+
/** Rearranges list event blocks so START-OF-SELECTION runs before END-OF-SELECTION,
|
|
5
|
+
* matching ABAP runtime behavior regardless of source order */
|
|
6
|
+
private rearrangeListEvents;
|
|
4
7
|
private rebuild;
|
|
5
8
|
private precedence;
|
|
6
9
|
private flatten;
|
package/build/src/rearranger.js
CHANGED
|
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Rearranger = void 0;
|
|
4
4
|
const core_1 = require("@abaplint/core");
|
|
5
5
|
// this rearranges the AST to take precedence into account
|
|
6
|
+
var EventKind;
|
|
7
|
+
(function (EventKind) {
|
|
8
|
+
EventKind[EventKind["None"] = 0] = "None";
|
|
9
|
+
EventKind[EventKind["Start"] = 1] = "Start";
|
|
10
|
+
EventKind[EventKind["End"] = 2] = "End";
|
|
11
|
+
})(EventKind || (EventKind = {}));
|
|
6
12
|
class Rearranger {
|
|
7
13
|
run(type, node) {
|
|
8
14
|
if (!node) {
|
|
@@ -14,7 +20,56 @@ class Rearranger {
|
|
|
14
20
|
}
|
|
15
21
|
const flattened = this.flatten(node);
|
|
16
22
|
const rebuilt = this.rebuild(flattened);
|
|
17
|
-
|
|
23
|
+
const rearranged = this.rearrangeListEvents(rebuilt);
|
|
24
|
+
return rearranged;
|
|
25
|
+
}
|
|
26
|
+
/** Rearranges list event blocks so START-OF-SELECTION runs before END-OF-SELECTION,
|
|
27
|
+
* matching ABAP runtime behavior regardless of source order */
|
|
28
|
+
rearrangeListEvents(node) {
|
|
29
|
+
if (!(node.get() instanceof core_1.Structures.Any)) {
|
|
30
|
+
return node;
|
|
31
|
+
}
|
|
32
|
+
const children = node.getChildren();
|
|
33
|
+
// Check if there are any list event statements
|
|
34
|
+
const hasStartOfSelection = children.some(c => c instanceof core_1.Nodes.StatementNode && c.get() instanceof core_1.Statements.StartOfSelection);
|
|
35
|
+
const hasEndOfSelection = children.some(c => c instanceof core_1.Nodes.StatementNode && c.get() instanceof core_1.Statements.EndOfSelection);
|
|
36
|
+
if (!hasStartOfSelection && !hasEndOfSelection) {
|
|
37
|
+
return node;
|
|
38
|
+
}
|
|
39
|
+
// Split children into: preamble (before first event), event blocks (keyed by event type)
|
|
40
|
+
const preamble = [];
|
|
41
|
+
const startBlocks = [];
|
|
42
|
+
const endBlocks = [];
|
|
43
|
+
let currentEvent = EventKind.None;
|
|
44
|
+
for (const child of children) {
|
|
45
|
+
if (child instanceof core_1.Nodes.StatementNode && child.get() instanceof core_1.Statements.StartOfSelection) {
|
|
46
|
+
currentEvent = EventKind.Start;
|
|
47
|
+
startBlocks.push(child);
|
|
48
|
+
}
|
|
49
|
+
else if (child instanceof core_1.Nodes.StatementNode && child.get() instanceof core_1.Statements.EndOfSelection) {
|
|
50
|
+
currentEvent = EventKind.End;
|
|
51
|
+
endBlocks.push(child);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
switch (currentEvent) {
|
|
55
|
+
case EventKind.None:
|
|
56
|
+
preamble.push(child);
|
|
57
|
+
break;
|
|
58
|
+
case EventKind.Start:
|
|
59
|
+
startBlocks.push(child);
|
|
60
|
+
break;
|
|
61
|
+
case EventKind.End:
|
|
62
|
+
endBlocks.push(child);
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Reassemble: preamble, then START-OF-SELECTION blocks, then END-OF-SELECTION blocks
|
|
70
|
+
const newChildren = [...preamble, ...startBlocks, ...endBlocks];
|
|
71
|
+
node.setChildren(newChildren);
|
|
72
|
+
return node;
|
|
18
73
|
}
|
|
19
74
|
/////////////////
|
|
20
75
|
rebuild(node) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { Chunk } from "../chunk";
|
|
3
|
+
import { IStatementTranspiler } from "./_statement_transpiler";
|
|
4
|
+
export declare class EndOfSelectionTranspiler implements IStatementTranspiler {
|
|
5
|
+
transpile(_node: abaplint.Nodes.StatementNode): Chunk;
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EndOfSelectionTranspiler = void 0;
|
|
4
|
+
const chunk_1 = require("../chunk");
|
|
5
|
+
class EndOfSelectionTranspiler {
|
|
6
|
+
transpile(_node) {
|
|
7
|
+
return new chunk_1.Chunk("");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.EndOfSelectionTranspiler = EndOfSelectionTranspiler;
|
|
11
|
+
//# sourceMappingURL=end_of_selection.js.map
|
|
@@ -43,6 +43,7 @@ __exportStar(require("./collect"), exports);
|
|
|
43
43
|
__exportStar(require("./commit"), exports);
|
|
44
44
|
__exportStar(require("./compute"), exports);
|
|
45
45
|
__exportStar(require("./concatenate"), exports);
|
|
46
|
+
__exportStar(require("./end_of_selection"), exports);
|
|
46
47
|
__exportStar(require("./condense"), exports);
|
|
47
48
|
__exportStar(require("./constant"), exports);
|
|
48
49
|
__exportStar(require("./continue"), exports);
|
package/build/src/traversal.js
CHANGED
|
@@ -667,10 +667,6 @@ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
|
|
|
667
667
|
lookupInferred(node, scope) {
|
|
668
668
|
if (scope === undefined) {
|
|
669
669
|
return undefined;
|
|
670
|
-
/*
|
|
671
|
-
} else if (node.concatTokens() !== "#") {
|
|
672
|
-
throw new Error("lookupInferred, unexpected, " + node.get());
|
|
673
|
-
*/
|
|
674
670
|
}
|
|
675
671
|
return this.findInferredTypeReference(node.getFirstToken());
|
|
676
672
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.30",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"author": "abaplint",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@abaplint/core": "^2.115.
|
|
32
|
+
"@abaplint/core": "^2.115.26",
|
|
33
33
|
"source-map": "^0.7.6"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|