@abaplint/transpiler 2.1.44 → 2.1.45

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.
@@ -8,7 +8,7 @@ class CallFunctionTranspiler {
8
8
  var _a, _b;
9
9
  const fmname = (_a = node.findDirectExpression(abaplint.Expressions.FunctionName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
10
10
  if (fmname === undefined) {
11
- throw "CallFunctionTranspilerNameNotFound";
11
+ throw new Error("CallFunctionTranspilerNameNotFound");
12
12
  }
13
13
  let param = "";
14
14
  const fmp = node.findDirectExpression(abaplint.Expressions.FunctionParameters);
@@ -71,7 +71,7 @@ class MethodImplementationTranspiler {
71
71
  }
72
72
  }
73
73
  else {
74
- throw "MethodImplementationTranspiler, unknown default param type";
74
+ throw new Error("MethodImplementationTranspiler, unknown default param type");
75
75
  }
76
76
  after += "if (" + unique + " === undefined || " + unique + "." + varName + " === undefined) {" + varName + " = " + val + ";}\n";
77
77
  }
@@ -6,5 +6,7 @@ export declare class SelectTranspiler implements IStatementTranspiler {
6
6
  transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal, targetOverride?: string): Chunk;
7
7
  private findKeys;
8
8
  private concatCond;
9
+ private sqlIn;
10
+ private basicCondition;
9
11
  private isWhereExpression;
10
12
  }
@@ -98,10 +98,17 @@ class SelectTranspiler {
98
98
  concatCond(cond, traversal) {
99
99
  let ret = "";
100
100
  for (const c of cond.getChildren()) {
101
- if (c.get() instanceof abaplint.Expressions.SimpleSource3
102
- && c instanceof abaplint.Nodes.ExpressionNode
103
- && c.findDirectExpression(abaplint.Expressions.Constant) === undefined) {
104
- ret += " '\" + " + new expressions_1.SimpleSource3Transpiler(true).transpile(c, traversal).getCode() + " + \"'";
101
+ if (c instanceof abaplint.Nodes.ExpressionNode
102
+ && c.get() instanceof abaplint.Expressions.SQLCompare) {
103
+ if (ret !== "") {
104
+ ret += " ";
105
+ }
106
+ if (c.findDirectExpression(abaplint.Expressions.SQLIn)) {
107
+ ret += this.sqlIn(c, traversal);
108
+ }
109
+ else {
110
+ ret += this.basicCondition(c, traversal);
111
+ }
105
112
  }
106
113
  else if (c instanceof abaplint.Nodes.ExpressionNode) {
107
114
  ret += " " + this.concatCond(c, traversal);
@@ -112,6 +119,37 @@ class SelectTranspiler {
112
119
  }
113
120
  return ret.trim();
114
121
  }
122
+ sqlIn(c, _traversal) {
123
+ const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName);
124
+ const slqin = c.findDirectExpression(abaplint.Expressions.SQLIn);
125
+ const source = c.findFirstExpression(abaplint.Expressions.SimpleSource3);
126
+ if (fieldName === undefined || slqin === undefined || source === undefined) {
127
+ throw new Error("SQL Condition, transpiler todo, " + c.concatTokens());
128
+ }
129
+ const ret = `" + abap.expandIN("${fieldName.concatTokens()}", ${source.concatTokens()}) + "`;
130
+ return ret;
131
+ }
132
+ basicCondition(c, traversal) {
133
+ let ret = "";
134
+ if (c.getChildren().length !== 3) {
135
+ throw new Error("SQL Condition, transpiler todo, " + c.concatTokens() + ", " + c.getChildren().length);
136
+ }
137
+ const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName);
138
+ const operator = c.findDirectExpression(abaplint.Expressions.SQLCompareOperator);
139
+ const source = c.findDirectExpression(abaplint.Expressions.SQLSource);
140
+ if (fieldName === undefined || operator === undefined || source === undefined) {
141
+ throw new Error("SQL Condition, transpiler todo, " + c.concatTokens());
142
+ }
143
+ ret += fieldName.concatTokens() + " " + operator.concatTokens() + " ";
144
+ const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);
145
+ if (simple && simple.findDirectExpression(abaplint.Expressions.Constant) === undefined) {
146
+ ret += "'\" + " + new expressions_1.SimpleSource3Transpiler(true).transpile(simple, traversal).getCode() + " + \"'";
147
+ }
148
+ else {
149
+ ret += source.concatTokens();
150
+ }
151
+ return ret;
152
+ }
115
153
  isWhereExpression(node, expression) {
116
154
  // check if previous token before sqlCond is "WHERE". It could also be "ON" in case of join condition
117
155
  let prevToken;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.1.44",
3
+ "version": "2.1.45",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "author": "abaplint",
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@abaplint/core": "^2.93.6",
31
+ "@abaplint/core": "^2.93.7",
32
32
  "source-map": "^0.7.4"
33
33
  },
34
34
  "devDependencies": {