@abaplint/transpiler 2.12.29 → 2.12.31

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.
@@ -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;
@@ -3,6 +3,14 @@ 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["AtLineSelection"] = 3] = "AtLineSelection";
12
+ EventKind[EventKind["AtSelectionScreen"] = 4] = "AtSelectionScreen";
13
+ })(EventKind || (EventKind = {}));
6
14
  class Rearranger {
7
15
  run(type, node) {
8
16
  if (!node) {
@@ -14,7 +22,70 @@ class Rearranger {
14
22
  }
15
23
  const flattened = this.flatten(node);
16
24
  const rebuilt = this.rebuild(flattened);
17
- return rebuilt;
25
+ const rearranged = this.rearrangeListEvents(rebuilt);
26
+ return rearranged;
27
+ }
28
+ /** Rearranges list event blocks so START-OF-SELECTION runs before END-OF-SELECTION,
29
+ * matching ABAP runtime behavior regardless of source order */
30
+ rearrangeListEvents(node) {
31
+ if (!(node.get() instanceof core_1.Structures.Any)) {
32
+ return node;
33
+ }
34
+ const children = node.getChildren();
35
+ // Check if there are any list event statements
36
+ const hasStartOfSelection = children.some(c => c instanceof core_1.Nodes.StatementNode && c.get() instanceof core_1.Statements.StartOfSelection);
37
+ const hasEndOfSelection = children.some(c => c instanceof core_1.Nodes.StatementNode && c.get() instanceof core_1.Statements.EndOfSelection);
38
+ const hasAtLineSelection = children.some(c => c instanceof core_1.Nodes.StatementNode && c.get() instanceof core_1.Statements.AtLineSelection);
39
+ const hasAtSelectionScreen = children.some(c => c instanceof core_1.Nodes.StatementNode && c.get() instanceof core_1.Statements.AtSelectionScreen);
40
+ if (!hasStartOfSelection && !hasEndOfSelection && !hasAtLineSelection && !hasAtSelectionScreen) {
41
+ return node;
42
+ }
43
+ // Split children into: preamble (before first event), event blocks (keyed by event type)
44
+ const preamble = [];
45
+ const startBlocks = [];
46
+ const endBlocks = [];
47
+ // AT LINE-SELECTION and AT SELECTION-SCREEN are interactive events, their blocks are discarded
48
+ let currentEvent = EventKind.None;
49
+ for (const child of children) {
50
+ if (child instanceof core_1.Nodes.StatementNode && child.get() instanceof core_1.Statements.StartOfSelection) {
51
+ currentEvent = EventKind.Start;
52
+ startBlocks.push(child);
53
+ }
54
+ else if (child instanceof core_1.Nodes.StatementNode && child.get() instanceof core_1.Statements.EndOfSelection) {
55
+ currentEvent = EventKind.End;
56
+ endBlocks.push(child);
57
+ }
58
+ else if (child instanceof core_1.Nodes.StatementNode && child.get() instanceof core_1.Statements.AtLineSelection) {
59
+ currentEvent = EventKind.AtLineSelection;
60
+ }
61
+ else if (child instanceof core_1.Nodes.StatementNode && child.get() instanceof core_1.Statements.AtSelectionScreen) {
62
+ currentEvent = EventKind.AtSelectionScreen;
63
+ }
64
+ else {
65
+ switch (currentEvent) {
66
+ case EventKind.None:
67
+ preamble.push(child);
68
+ break;
69
+ case EventKind.Start:
70
+ startBlocks.push(child);
71
+ break;
72
+ case EventKind.End:
73
+ endBlocks.push(child);
74
+ break;
75
+ case EventKind.AtLineSelection:
76
+ case EventKind.AtSelectionScreen:
77
+ // discard: these are interactive events not executed in batch
78
+ break;
79
+ default:
80
+ break;
81
+ }
82
+ }
83
+ }
84
+ // Reassemble: preamble, then START-OF-SELECTION blocks, then END-OF-SELECTION blocks
85
+ // AT LINE-SELECTION and AT SELECTION-SCREEN blocks are omitted
86
+ const newChildren = [...preamble, ...startBlocks, ...endBlocks];
87
+ node.setChildren(newChildren);
88
+ return node;
18
89
  }
19
90
  /////////////////
20
91
  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 AtLineSelectionTranspiler 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.AtLineSelectionTranspiler = void 0;
4
+ const chunk_1 = require("../chunk");
5
+ class AtLineSelectionTranspiler {
6
+ transpile(_node) {
7
+ return new chunk_1.Chunk("");
8
+ }
9
+ }
10
+ exports.AtLineSelectionTranspiler = AtLineSelectionTranspiler;
11
+ //# sourceMappingURL=at_line_selection.js.map
@@ -4,7 +4,7 @@ exports.AtSelectionScreenTranspiler = void 0;
4
4
  const chunk_1 = require("../chunk");
5
5
  class AtSelectionScreenTranspiler {
6
6
  transpile(_node, _traversal) {
7
- return new chunk_1.Chunk(`throw new Error("AtSelectionScreen, not supported, transpiler");`);
7
+ return new chunk_1.Chunk(``);
8
8
  }
9
9
  }
10
10
  exports.AtSelectionScreenTranspiler = AtSelectionScreenTranspiler;
@@ -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
@@ -27,6 +27,7 @@ export * from "./collect";
27
27
  export * from "./commit";
28
28
  export * from "./compute";
29
29
  export * from "./concatenate";
30
+ export * from "./end_of_selection";
30
31
  export * from "./condense";
31
32
  export * from "./constant";
32
33
  export * from "./continue";
@@ -136,6 +137,7 @@ export * from "./split";
136
137
  export * from "./start_of_selection";
137
138
  export * from "./submit";
138
139
  export * from "./subtract";
140
+ export * from "./at_line_selection";
139
141
  export * from "./syntax_check";
140
142
  export * from "./system_call";
141
143
  export * from "./tables";
@@ -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);
@@ -152,6 +153,7 @@ __exportStar(require("./split"), exports);
152
153
  __exportStar(require("./start_of_selection"), exports);
153
154
  __exportStar(require("./submit"), exports);
154
155
  __exportStar(require("./subtract"), exports);
156
+ __exportStar(require("./at_line_selection"), exports);
155
157
  __exportStar(require("./syntax_check"), exports);
156
158
  __exportStar(require("./system_call"), exports);
157
159
  __exportStar(require("./tables"), exports);
@@ -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.29",
3
+ "version": "2.12.31",
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.25",
32
+ "@abaplint/core": "^2.115.26",
33
33
  "source-map": "^0.7.6"
34
34
  },
35
35
  "devDependencies": {