@abaplint/transpiler 2.1.87 → 2.1.89
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.
|
@@ -40,6 +40,12 @@ class CompareOperatorTranspiler {
|
|
|
40
40
|
return new chunk_1.Chunk().append("na", node, traversal);
|
|
41
41
|
case "NP":
|
|
42
42
|
return new chunk_1.Chunk().append("np", node, traversal);
|
|
43
|
+
case "O":
|
|
44
|
+
return new chunk_1.Chunk().append("o", node, traversal);
|
|
45
|
+
case "Z":
|
|
46
|
+
return new chunk_1.Chunk().append("z", node, traversal);
|
|
47
|
+
case "M":
|
|
48
|
+
return new chunk_1.Chunk().append("m", node, traversal);
|
|
43
49
|
default:
|
|
44
50
|
return new chunk_1.Chunk().append("compareoperatortodo" + op, node, traversal);
|
|
45
51
|
}
|
|
@@ -18,9 +18,9 @@ class ConstantTranspiler {
|
|
|
18
18
|
}
|
|
19
19
|
return new chunk_1.Chunk().append(ret, node, traversal);
|
|
20
20
|
}
|
|
21
|
-
let str = node.
|
|
21
|
+
let str = node.findDirectExpression(core_1.Expressions.ConstantString);
|
|
22
22
|
if (str === undefined) {
|
|
23
|
-
str = node.
|
|
23
|
+
str = node.findDirectExpression(core_1.Expressions.TextElementString);
|
|
24
24
|
}
|
|
25
25
|
if (str) {
|
|
26
26
|
let res = str.getFirstToken().getStr();
|
|
@@ -40,6 +40,30 @@ class ConstantTranspiler {
|
|
|
40
40
|
return new chunk_1.Chunk().append(code, node, traversal);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
const concat = node.findDirectExpression(core_1.Expressions.ConcatenatedConstant);
|
|
44
|
+
if (concat) {
|
|
45
|
+
const chunk = new chunk_1.Chunk().appendString("abap.operators.concat([");
|
|
46
|
+
let first = true;
|
|
47
|
+
for (const child of concat.getChildren()) {
|
|
48
|
+
const res = child.getFirstToken().getStr();
|
|
49
|
+
if (first === true) {
|
|
50
|
+
first = false;
|
|
51
|
+
}
|
|
52
|
+
else if (res !== "&") {
|
|
53
|
+
chunk.appendString(",");
|
|
54
|
+
}
|
|
55
|
+
if (res.startsWith("'") && this.addGet === false) {
|
|
56
|
+
const code = "new abap.types.Character({length: " + (res.length - 2) + "}).set(" + this.escape(res) + ")";
|
|
57
|
+
chunk.append(code, node, traversal);
|
|
58
|
+
}
|
|
59
|
+
else if (res.startsWith("`") && this.addGet === false) {
|
|
60
|
+
const code = "new abap.types.String().set(" + this.escape(res) + ")";
|
|
61
|
+
chunk.append(code, node, traversal);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
chunk.appendString("])");
|
|
65
|
+
return chunk;
|
|
66
|
+
}
|
|
43
67
|
return new chunk_1.Chunk(`todo, Constant`);
|
|
44
68
|
}
|
|
45
69
|
escape(str) {
|
|
@@ -55,15 +55,29 @@ class SQLCondTranspiler {
|
|
|
55
55
|
basicCondition(c, traversal) {
|
|
56
56
|
let ret = "";
|
|
57
57
|
if (c.getChildren().length !== 3) {
|
|
58
|
-
|
|
58
|
+
return this.basicConditionNew(c, traversal);
|
|
59
|
+
// throw new Error("SQL Condition, transpiler todo1, " + c.concatTokens() + ", " + c.getChildren().length);
|
|
59
60
|
}
|
|
60
61
|
const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName);
|
|
61
62
|
const operator = c.findDirectExpression(abaplint.Expressions.SQLCompareOperator);
|
|
62
63
|
const source = c.findDirectExpression(abaplint.Expressions.SQLSource);
|
|
63
64
|
if (fieldName === undefined || operator === undefined || source === undefined) {
|
|
64
|
-
throw new Error("SQL Condition, transpiler
|
|
65
|
+
throw new Error("SQL Condition, transpiler todo2, " + c.concatTokens());
|
|
65
66
|
}
|
|
66
67
|
ret += fieldName.concatTokens() + " " + operator.concatTokens() + " ";
|
|
68
|
+
ret += this.sqlSource(source, traversal);
|
|
69
|
+
/*
|
|
70
|
+
const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);
|
|
71
|
+
if (simple && simple.findDirectExpression(abaplint.Expressions.Constant) === undefined) {
|
|
72
|
+
ret += "'\" + " + new SimpleSource3Transpiler(true).transpile(simple, traversal).getCode() + " + \"'";
|
|
73
|
+
} else {
|
|
74
|
+
ret += source.concatTokens();
|
|
75
|
+
}
|
|
76
|
+
*/
|
|
77
|
+
return ret;
|
|
78
|
+
}
|
|
79
|
+
sqlSource(source, traversal) {
|
|
80
|
+
let ret = "";
|
|
67
81
|
const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);
|
|
68
82
|
if (simple && simple.findDirectExpression(abaplint.Expressions.Constant) === undefined) {
|
|
69
83
|
ret += "'\" + " + new simple_source3_1.SimpleSource3Transpiler(true).transpile(simple, traversal).getCode() + " + \"'";
|
|
@@ -73,6 +87,25 @@ class SQLCondTranspiler {
|
|
|
73
87
|
}
|
|
74
88
|
return ret;
|
|
75
89
|
}
|
|
90
|
+
basicConditionNew(node, traversal) {
|
|
91
|
+
let ret = "";
|
|
92
|
+
for (const child of node.getChildren()) {
|
|
93
|
+
if (ret !== "") {
|
|
94
|
+
ret += " ";
|
|
95
|
+
}
|
|
96
|
+
if (child.get() instanceof abaplint.Expressions.SQLFieldName) {
|
|
97
|
+
ret += child.concatTokens();
|
|
98
|
+
}
|
|
99
|
+
else if (child.get() instanceof abaplint.Expressions.SQLSource
|
|
100
|
+
&& child instanceof abaplint.Nodes.ExpressionNode) {
|
|
101
|
+
ret += this.sqlSource(child, traversal);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
ret += child.concatTokens();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
76
109
|
}
|
|
77
110
|
exports.SQLCondTranspiler = SQLCondTranspiler;
|
|
78
111
|
//# sourceMappingURL=sql_cond.js.map
|