@abaplint/transpiler 2.7.97 → 2.7.99

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.
@@ -46,6 +46,9 @@ class CreateDataTranspiler {
46
46
  if (concat.includes(" TYPE LINE OF ")) {
47
47
  options.push(`"typeLineOf": true`);
48
48
  }
49
+ if (concat.includes(" REF TO ")) {
50
+ options.push(`"refTo": true`);
51
+ }
49
52
  const handle = node.findExpressionAfterToken("HANDLE");
50
53
  if (handle) {
51
54
  const so = traversal.traverse(node.findDirectExpression(abaplint.Expressions.Source));
@@ -5,7 +5,7 @@ const abaplint = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
6
  class FindTranspiler {
7
7
  transpile(node, traversal) {
8
- var _a;
8
+ var _a, _b;
9
9
  const options = [];
10
10
  let index = 1;
11
11
  const sources = node.findDirectExpressions(abaplint.Expressions.Source);
@@ -13,6 +13,9 @@ class FindTranspiler {
13
13
  if ((_a = node.findFirstExpression(abaplint.Expressions.FindType)) === null || _a === void 0 ? void 0 : _a.findDirectTokenByText("REGEX")) {
14
14
  options.push("regex: " + source0);
15
15
  }
16
+ else if ((_b = node.findFirstExpression(abaplint.Expressions.FindType)) === null || _b === void 0 ? void 0 : _b.findDirectTokenByText("PCRE")) {
17
+ options.push("pcre: " + source0);
18
+ }
16
19
  else {
17
20
  options.push("find: " + source0);
18
21
  }
@@ -5,3 +5,4 @@ import { Chunk } from "../chunk";
5
5
  export declare class InsertDatabaseTranspiler implements IStatementTranspiler {
6
6
  transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal): Chunk;
7
7
  }
8
+ export declare function findConnection(connection: abaplint.Nodes.ExpressionNode): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InsertDatabaseTranspiler = void 0;
3
+ exports.findConnection = exports.InsertDatabaseTranspiler = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
6
  const expressions_1 = require("../expressions");
@@ -29,15 +29,20 @@ class InsertDatabaseTranspiler {
29
29
  }
30
30
  const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
31
31
  if (connection) {
32
- let con = connection.getLastToken().getStr().toUpperCase();
33
- if (con === "DEFAULT_") {
34
- // todo, workaround for replacing of keywords,
35
- con = "DEFAULT";
36
- }
32
+ const con = findConnection(connection);
37
33
  options.push(`"connection": "${con}"`);
38
34
  }
39
35
  return new chunk_1.Chunk(`await abap.statements.insertDatabase(${table.getCode()}, {${options.join(", ")}});`);
40
36
  }
41
37
  }
42
38
  exports.InsertDatabaseTranspiler = InsertDatabaseTranspiler;
39
+ function findConnection(connection) {
40
+ let con = connection.getLastToken().getStr().toUpperCase();
41
+ if (con === "DEFAULT_") {
42
+ // todo, workaround for replacing of keywords,
43
+ con = "DEFAULT";
44
+ }
45
+ return con;
46
+ }
47
+ exports.findConnection = findConnection;
43
48
  //# sourceMappingURL=insert_database.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpenCursorTranspiler = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
+ const insert_database_1 = require("./insert_database");
6
7
  class OpenCursorTranspiler {
7
8
  transpile(node, traversal) {
8
9
  const target = traversal.traverse(node.findDirectExpression(abaplint.Expressions.SQLTarget)).getCode();
@@ -18,7 +19,13 @@ class OpenCursorTranspiler {
18
19
  if (orderBy) {
19
20
  select += "ORDER BY " + traversal.traverse(node).getCode();
20
21
  }
21
- return new chunk_1.Chunk().append(`await abap.statements.openCursor(${target}, "${select}");`, node, traversal);
22
+ const options = [];
23
+ const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
24
+ if (connection) {
25
+ const con = (0, insert_database_1.findConnection)(connection);
26
+ options.push(`"connection": "${con}"`);
27
+ }
28
+ return new chunk_1.Chunk().append(`await abap.statements.openCursor(${target}, "${select}", {${options.join(", ")}});`, node, traversal);
22
29
  }
23
30
  }
24
31
  exports.OpenCursorTranspiler = OpenCursorTranspiler;
@@ -32,7 +32,10 @@ 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 && type !== "REGEX") {
35
+ else if (type === "PCRE") {
36
+ extra.push("pcre: " + new expressions_1.SourceTranspiler().transpile(sources[0], traversal).getCode());
37
+ }
38
+ if (o === undefined && o === undefined && type !== "REGEX" && type !== "PCRE") {
36
39
  extra.push("of: " + new expressions_1.SourceTranspiler().transpile(sources[0], traversal).getCode());
37
40
  }
38
41
  if (concat.includes(" IGNORING CASE")) {
@@ -42,6 +42,7 @@ export declare class Traversal {
42
42
  findTable(name: string): abaplint.Objects.Table | undefined;
43
43
  findClassDefinition(name: string | undefined, scope: abaplint.ISpaghettiScopeNode | undefined): abaplint.IClassDefinition | undefined;
44
44
  private dataFromInterfaces;
45
+ private aliasesFromInterfaces;
45
46
  determineType(node: abaplint.Nodes.ExpressionNode | abaplint.Nodes.StatementNode, scope: abaplint.ISpaghettiScopeNode | undefined): abaplint.AbstractType | undefined;
46
47
  isInsideLoop(node: abaplint.Nodes.StatementNode): boolean;
47
48
  isInsideDoOrWhile(node: abaplint.Nodes.StatementNode): boolean;
@@ -355,12 +355,6 @@ class Traversal {
355
355
  if (def.getSuperClass() !== undefined || def.getName().toUpperCase() === "CX_ROOT") {
356
356
  ret += "super();\n";
357
357
  }
358
- /*
359
- if (def.getSuperClass() !== undefined
360
- && def.getMethodDefinitions().getByName("CONSTRUCTOR") === undefined) {
361
- ret += `await super.constructor_(INPUT);\n`;
362
- }
363
- */
364
358
  const cName = Traversal.escapeNamespace(def.getName().toLowerCase());
365
359
  ret += "this.me = new abap.types.ABAPObject();\n";
366
360
  ret += "this.me.set(this);\n";
@@ -377,6 +371,7 @@ class Traversal {
377
371
  // attributes from directly implemented interfaces(not interfaces implemented in super classes)
378
372
  for (const i of def.getImplementing()) {
379
373
  ret += this.dataFromInterfaces(i.name, scope, cName);
374
+ ret += this.aliasesFromInterfaces(i.name, scope, cName);
380
375
  }
381
376
  // handle aliases after initialization of carrier variables
382
377
  for (const a of ((_b = def.getAliases()) === null || _b === void 0 ? void 0 : _b.getAll()) || []) {
@@ -439,6 +434,20 @@ class Traversal {
439
434
  }
440
435
  return ret;
441
436
  }
437
+ aliasesFromInterfaces(name, scope, cname) {
438
+ let ret = "";
439
+ const intf = this.findInterfaceDefinition(name, scope);
440
+ for (const a of (intf === null || intf === void 0 ? void 0 : intf.getAliases().getAll()) || []) {
441
+ const iname = Traversal.escapeNamespace(intf === null || intf === void 0 ? void 0 : intf.getName().toLowerCase());
442
+ const aname = Traversal.escapeNamespace(a.getName().toLowerCase());
443
+ const cname = Traversal.escapeNamespace(a.getComponent().toLowerCase().replace("~", "$"));
444
+ ret += "this." + iname + "$" + aname + " = this." + cname + ";\n";
445
+ }
446
+ for (const i of (intf === null || intf === void 0 ? void 0 : intf.getImplementing()) || []) {
447
+ ret += this.aliasesFromInterfaces(i.name, scope, cname);
448
+ }
449
+ return ret;
450
+ }
442
451
  determineType(node, scope) {
443
452
  var _a, _b, _c;
444
453
  if (scope === undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.7.97",
3
+ "version": "2.7.99",
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.102.41",
32
+ "@abaplint/core": "^2.102.44",
33
33
  "source-map": "^0.7.4"
34
34
  },
35
35
  "devDependencies": {