@abaplint/transpiler 2.0.28 → 2.0.29

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.
@@ -6,4 +6,5 @@ export declare class SelectTranspiler implements IStatementTranspiler {
6
6
  transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal): Chunk;
7
7
  private findKeys;
8
8
  private concatCond;
9
+ private isWhereExpression;
9
10
  }
@@ -11,18 +11,23 @@ class SelectTranspiler {
11
11
  let select = "SELECT ";
12
12
  select += ((_a = node.findFirstExpression(abaplint.Expressions.SQLFieldList)) === null || _a === void 0 ? void 0 : _a.concatTokens()) + " ";
13
13
  select += ((_b = node.findFirstExpression(abaplint.Expressions.SQLFrom)) === null || _b === void 0 ? void 0 : _b.concatTokens()) + " ";
14
- const where = node.findFirstExpression(abaplint.Expressions.SQLCond);
14
+ let where;
15
+ for (const sqlCond of node.findAllExpressions(abaplint.Expressions.SQLCond)) {
16
+ if (this.isWhereExpression(node, sqlCond)) {
17
+ where = sqlCond;
18
+ }
19
+ }
15
20
  if (where) {
16
21
  select += "WHERE " + this.concatCond(where, traversal) + " ";
17
22
  }
18
- const orderBy = node.findFirstExpression(abaplint.Expressions.SQLOrderBy);
19
- if (orderBy) {
20
- select += orderBy.concatTokens() + " ";
21
- }
22
23
  const upTo = node.findFirstExpression(abaplint.Expressions.SQLUpTo);
23
24
  if (upTo) {
24
25
  select += upTo.concatTokens() + " ";
25
26
  }
27
+ const orderBy = node.findFirstExpression(abaplint.Expressions.SQLOrderBy);
28
+ if (orderBy) {
29
+ select += orderBy.concatTokens() + " ";
30
+ }
26
31
  for (const d of node.findAllExpressionsRecursive(abaplint.Expressions.Dynamic)) {
27
32
  const chain = d.findFirstExpression(abaplint.Expressions.FieldChain);
28
33
  if (chain) {
@@ -69,6 +74,23 @@ class SelectTranspiler {
69
74
  }
70
75
  return ret.trim();
71
76
  }
77
+ isWhereExpression(node, expression) {
78
+ // check if previous token before sqlCond is "WHERE". It could also be "ON" in case of join condition
79
+ let prevToken;
80
+ const sqlCondToken = expression.getFirstToken();
81
+ for (const token of node.getTokens()) {
82
+ if (token.getStart() === sqlCondToken.getStart()) {
83
+ break;
84
+ }
85
+ prevToken = token;
86
+ }
87
+ if (prevToken && prevToken.getStr() === "WHERE") {
88
+ return true;
89
+ }
90
+ else {
91
+ return false;
92
+ }
93
+ }
72
94
  }
73
95
  exports.SelectTranspiler = SelectTranspiler;
74
96
  //# sourceMappingURL=select.js.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClassImplementationTranspiler = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
+ const traversal_1 = require("../traversal");
5
6
  const transpile_types_1 = require("../transpile_types");
6
7
  const expressions_1 = require("../expressions");
7
8
  const chunk_1 = require("../chunk");
@@ -69,7 +70,7 @@ class ClassImplementationTranspiler {
69
70
  const clasName = node.getFirstToken().getStr().toLowerCase();
70
71
  const staticAttributes = this.findStaticAttributes(cdef, scope);
71
72
  for (const attr of staticAttributes) {
72
- const name = clasName + "." + attr.prefix + attr.identifier.getName().toLowerCase();
73
+ const name = traversal_1.Traversal.escapeClassName(clasName) + "." + attr.prefix + attr.identifier.getName().toLowerCase();
73
74
  ret += name + " = " + new transpile_types_1.TranspileTypes().toType(attr.identifier.getType()) + ";\n";
74
75
  const val = attr.identifier.getValue();
75
76
  if (typeof val === "string") {
@@ -124,17 +124,17 @@ class Traversal {
124
124
  const found = this.reg.findObjectForFile(file);
125
125
  if (found) {
126
126
  if (found instanceof abaplint.Objects.Interface) {
127
- return this.lookupClassOrInterface(found.getName(), t) + "." + found.getName().toLowerCase() + "$" + name;
127
+ return Traversal.escapeClassName(this.lookupClassOrInterface(found.getName(), t)) + "." + found.getName().toLowerCase() + "$" + name;
128
128
  }
129
129
  else {
130
- return this.lookupClassOrInterface(found.getName(), t) + "." + name;
130
+ return Traversal.escapeClassName(this.lookupClassOrInterface(found.getName(), t)) + "." + name;
131
131
  }
132
132
  }
133
133
  }
134
134
  }
135
135
  const className = this.isStaticClassAttribute(t);
136
136
  if (className) {
137
- name = className + "." + name;
137
+ name = Traversal.escapeClassName(className) + "." + name;
138
138
  }
139
139
  else if (name === "super") {
140
140
  return name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.0.28",
3
+ "version": "2.0.29",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",