@abaplint/transpiler 2.3.58 → 2.3.60

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.
@@ -19,6 +19,8 @@ export * from "./field_length";
19
19
  export * from "./field_offset";
20
20
  export * from "./field_symbol";
21
21
  export * from "./function_exporting";
22
+ export * from "./sql_from";
23
+ export * from "./sql_join";
22
24
  export * from "./function_parameters";
23
25
  export * from "./message_number";
24
26
  export * from "./method_call_body";
@@ -35,6 +35,8 @@ __exportStar(require("./field_length"), exports);
35
35
  __exportStar(require("./field_offset"), exports);
36
36
  __exportStar(require("./field_symbol"), exports);
37
37
  __exportStar(require("./function_exporting"), exports);
38
+ __exportStar(require("./sql_from"), exports);
39
+ __exportStar(require("./sql_join"), exports);
38
40
  __exportStar(require("./function_parameters"), exports);
39
41
  __exportStar(require("./message_number"), exports);
40
42
  __exportStar(require("./method_call_body"), exports);
@@ -0,0 +1,7 @@
1
+ import { Nodes } from "@abaplint/core";
2
+ import { IExpressionTranspiler } from "./_expression_transpiler";
3
+ import { Traversal } from "../traversal";
4
+ import { Chunk } from "../chunk";
5
+ export declare class SQLFromTranspiler implements IExpressionTranspiler {
6
+ transpile(node: Nodes.ExpressionNode, traversal: Traversal): Chunk;
7
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SQLFromTranspiler = void 0;
4
+ const abaplint = require("@abaplint/core");
5
+ const chunk_1 = require("../chunk");
6
+ const sql_join_1 = require("./sql_join");
7
+ class SQLFromTranspiler {
8
+ transpile(node, traversal) {
9
+ const chunk = new chunk_1.Chunk();
10
+ for (const c of node.getChildren()) {
11
+ if (c instanceof abaplint.Nodes.TokenNode) {
12
+ chunk.appendString(c.concatTokens() + " ");
13
+ }
14
+ else if (c.get() instanceof abaplint.Expressions.SQLJoin) {
15
+ chunk.appendChunk(new sql_join_1.SQLJoinTranspiler().transpile(c, traversal));
16
+ chunk.appendString(" ");
17
+ }
18
+ else {
19
+ chunk.appendString(c.concatTokens() + " ");
20
+ }
21
+ }
22
+ return chunk;
23
+ }
24
+ }
25
+ exports.SQLFromTranspiler = SQLFromTranspiler;
26
+ //# sourceMappingURL=sql_from.js.map
@@ -0,0 +1,7 @@
1
+ import { Nodes } from "@abaplint/core";
2
+ import { IExpressionTranspiler } from "./_expression_transpiler";
3
+ import { Traversal } from "../traversal";
4
+ import { Chunk } from "../chunk";
5
+ export declare class SQLJoinTranspiler implements IExpressionTranspiler {
6
+ transpile(node: Nodes.ExpressionNode, traversal: Traversal): Chunk;
7
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SQLJoinTranspiler = void 0;
4
+ const abaplint = require("@abaplint/core");
5
+ const chunk_1 = require("../chunk");
6
+ const sql_cond_1 = require("./sql_cond");
7
+ class SQLJoinTranspiler {
8
+ transpile(node, traversal) {
9
+ const chunk = new chunk_1.Chunk();
10
+ for (const c of node.getChildren()) {
11
+ if (c instanceof abaplint.Nodes.TokenNode) {
12
+ chunk.appendString(c.concatTokens() + " ");
13
+ }
14
+ else if (c.get() instanceof abaplint.Expressions.SQLCond) {
15
+ chunk.appendChunk(new sql_cond_1.SQLCondTranspiler().transpile(c, traversal));
16
+ }
17
+ else {
18
+ chunk.appendString(c.concatTokens() + " ");
19
+ }
20
+ }
21
+ return chunk;
22
+ }
23
+ }
24
+ exports.SQLJoinTranspiler = SQLJoinTranspiler;
25
+ //# sourceMappingURL=sql_join.js.map
@@ -32,15 +32,15 @@ class ReplaceTranspiler {
32
32
  if (type === "REGEX") {
33
33
  extra.push("regex: " + new expressions_1.SourceTranspiler().transpile(sources[0], traversal).getCode());
34
34
  }
35
- if (o === undefined && o === undefined) {
35
+ if (o === undefined && o === undefined && type !== "REGEX") {
36
36
  extra.push("of: " + new expressions_1.SourceTranspiler().transpile(sources[0], traversal).getCode());
37
37
  }
38
38
  if (concat.includes(" IGNORING CASE")) {
39
39
  extra.push("ignoringCase: true");
40
40
  }
41
41
  return new chunk_1.Chunk()
42
- .append("abap.statements.replace({target:", node, traversal)
43
- .appendString(target + ", all:" + all + ", " + extra.join(","))
42
+ .append("abap.statements.replace({target: ", node, traversal)
43
+ .appendString(target + ", all: " + all + ", " + extra.join(", "))
44
44
  .append("});", node.getLastToken(), traversal);
45
45
  }
46
46
  }
@@ -5,9 +5,10 @@ const abaplint = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
6
  const expressions_1 = require("../expressions");
7
7
  const unique_identifier_1 = require("../unique_identifier");
8
+ const sql_from_1 = require("../expressions/sql_from");
8
9
  class SelectTranspiler {
9
10
  transpile(node, traversal, targetOverride) {
10
- var _a, _b, _c, _d;
11
+ var _a, _b, _c;
11
12
  let target = "undefined";
12
13
  if (targetOverride) {
13
14
  target = targetOverride;
@@ -26,7 +27,10 @@ class SelectTranspiler {
26
27
  select += fieldList === null || fieldList === void 0 ? void 0 : fieldList.findAllExpressions(abaplint.Expressions.SQLField).map(e => e.concatTokens()).join(", ");
27
28
  }
28
29
  select += " ";
29
- select += ((_a = node.findFirstExpression(abaplint.Expressions.SQLFrom)) === null || _a === void 0 ? void 0 : _a.concatTokens()) + " ";
30
+ const from = node.findFirstExpression(abaplint.Expressions.SQLFrom);
31
+ if (from) {
32
+ select += new sql_from_1.SQLFromTranspiler().transpile(from, traversal).getCode();
33
+ }
30
34
  let where = undefined;
31
35
  for (const sqlCond of node.findAllExpressions(abaplint.Expressions.SQLCond)) {
32
36
  if (this.isWhereExpression(node, sqlCond)) {
@@ -72,7 +76,7 @@ class SelectTranspiler {
72
76
  }
73
77
  if (node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) {
74
78
  const unique = unique_identifier_1.UniqueIdentifier.get();
75
- const faeName = (_d = (_c = (_b = node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(abaplint.Expressions.SQLSource)) === null || _c === void 0 ? void 0 : _c.concatTokens()) === null || _d === void 0 ? void 0 : _d.toLowerCase();
79
+ const faeName = (_c = (_b = (_a = node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(abaplint.Expressions.SQLSource)) === null || _b === void 0 ? void 0 : _b.concatTokens()) === null || _c === void 0 ? void 0 : _c.toLowerCase();
76
80
  select = select.replace(new RegExp(" " + faeName, "g"), " " + unique);
77
81
  select = select.replace(unique + ".get().table_line.get()", unique + ".get()"); // there can be only one?
78
82
  const code = `if (${faeName}.array().length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.3.58",
3
+ "version": "2.3.60",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",