@abaplint/transpiler 2.13.82 → 2.13.84

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,10 +1,54 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.CommitTranspiler = void 0;
37
+ const abaplint = __importStar(require("@abaplint/core"));
4
38
  const chunk_1 = require("../chunk");
39
+ const insert_database_1 = require("./insert_database");
5
40
  class CommitTranspiler {
6
41
  transpile(node, traversal) {
7
- return new chunk_1.Chunk().append("abap.statements.commit();", node, traversal);
42
+ const options = [];
43
+ const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
44
+ if (connection) {
45
+ options.push(`"connection": ${(0, insert_database_1.findConnection)(connection, traversal)}`);
46
+ }
47
+ else if (node.findTokenSequencePosition("AND", "WAIT")) {
48
+ options.push(`"wait": true`);
49
+ }
50
+ const opt = options.length === 0 ? "" : `{${options.join(", ")}}`;
51
+ return new chunk_1.Chunk().append(`await abap.statements.commit(${opt});`, node, traversal);
8
52
  }
9
53
  }
10
54
  exports.CommitTranspiler = CommitTranspiler;
@@ -5,4 +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;
8
+ export declare function findConnection(connection: abaplint.Nodes.ExpressionNode, traversal: Traversal): string;
@@ -63,19 +63,31 @@ class InsertDatabaseTranspiler {
63
63
  }
64
64
  const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
65
65
  if (connection) {
66
- const con = findConnection(connection);
67
- options.push(`"connection": "${con}"`);
66
+ const con = findConnection(connection, traversal);
67
+ options.push(`"connection": ${con}`);
68
68
  }
69
69
  return new chunk_1.Chunk(`await abap.statements.insertDatabase(${table.getCode()}, {${options.join(", ")}});`);
70
70
  }
71
71
  }
72
72
  exports.InsertDatabaseTranspiler = InsertDatabaseTranspiler;
73
- function findConnection(connection) {
73
+ function findConnection(connection, traversal) {
74
+ const dynamic = connection.findDirectExpression(abaplint.Expressions.Dynamic);
75
+ if (dynamic) {
76
+ const field = dynamic.findFirstExpression(abaplint.Expressions.FieldChain);
77
+ if (field === undefined) {
78
+ throw new Error("findConnection: dynamic connection name not found");
79
+ }
80
+ const value = traversal.traverse(field).getCode();
81
+ return `${value}.get().trimEnd().toUpperCase()`;
82
+ }
74
83
  let con = connection.getLastToken().getStr().toUpperCase();
84
+ if (con.startsWith("'") && con.endsWith("'")) {
85
+ con = con.substring(1, con.length - 1).replace(/''/g, "'");
86
+ }
75
87
  if (con === "DEFAULT_") {
76
88
  // todo, workaround for replacing of keywords,
77
89
  con = "DEFAULT";
78
90
  }
79
- return con;
91
+ return JSON.stringify(con);
80
92
  }
81
93
  //# sourceMappingURL=insert_database.js.map
@@ -66,8 +66,8 @@ class OpenCursorTranspiler {
66
66
  const options = [];
67
67
  const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
68
68
  if (connection) {
69
- const con = (0, insert_database_1.findConnection)(connection);
70
- options.push(`"connection": "${con}"`);
69
+ const con = (0, insert_database_1.findConnection)(connection, traversal);
70
+ options.push(`"connection": ${con}`);
71
71
  }
72
72
  return new chunk_1.Chunk().append(`await abap.statements.openCursor(${target}, "${select}", {${options.join(", ")}});`, node, traversal);
73
73
  }
@@ -1,10 +1,51 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.RollbackTranspiler = void 0;
37
+ const abaplint = __importStar(require("@abaplint/core"));
4
38
  const chunk_1 = require("../chunk");
39
+ const insert_database_1 = require("./insert_database");
5
40
  class RollbackTranspiler {
6
41
  transpile(node, traversal) {
7
- return new chunk_1.Chunk().append("abap.statements.rollback();", node, traversal);
42
+ const options = [];
43
+ const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
44
+ if (connection) {
45
+ options.push(`"connection": ${(0, insert_database_1.findConnection)(connection, traversal)}`);
46
+ }
47
+ const opt = options.length === 0 ? "" : `{${options.join(", ")}}`;
48
+ return new chunk_1.Chunk().append(`await abap.statements.rollback(${opt});`, node, traversal);
8
49
  }
9
50
  }
10
51
  exports.RollbackTranspiler = RollbackTranspiler;
@@ -144,11 +144,13 @@ class ClassImplementationTranspiler {
144
144
  ret += traversal.setValues(attr.identifier, name);
145
145
  }
146
146
  for (const alias of cdef.getAliases()) {
147
- const isStatic = staticAttributes.some(s => s.prefix.replace("$", "~") + s.identifier.getName() === alias.getComponent());
147
+ // note: the component is the raw source casing, so compare case insensitive
148
+ const component = alias.getComponent().toLowerCase();
149
+ const isStatic = staticAttributes.some(s => (s.prefix.replace("$", "~") + s.identifier.getName()).toLowerCase() === component);
148
150
  if (isStatic === false) {
149
151
  continue;
150
152
  }
151
- ret += traversal_1.Traversal.escapeNamespace(clasName) + "." + alias.getName().toLowerCase() + " = " + traversal_1.Traversal.escapeNamespace(clasName) + "." + traversal_1.Traversal.escapeNamespace(alias.getComponent().replace("~", "$")) + ";\n";
153
+ ret += traversal_1.Traversal.escapeNamespace(clasName) + "." + alias.getName().toLowerCase() + " = " + traversal_1.Traversal.escapeNamespace(clasName) + "." + traversal_1.Traversal.escapeNamespace(component.replace("~", "$")) + ";\n";
152
154
  }
153
155
  for (const e of cdef.getEvents()) {
154
156
  if (e.isStatic() === false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.13.82",
3
+ "version": "2.13.84",
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.120.45",
32
+ "@abaplint/core": "^2.120.48",
33
33
  "source-map": "^0.8.0"
34
34
  },
35
35
  "devDependencies": {