@abaplint/core 2.93.36 → 2.93.38
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.
|
@@ -108,7 +108,14 @@ class Source {
|
|
|
108
108
|
case "FILTER":
|
|
109
109
|
{
|
|
110
110
|
const foundType = this.determineType(node, scope, filename, targetType);
|
|
111
|
-
|
|
111
|
+
const bodyType = new filter_body_1.FilterBody().runSyntax(node.findDirectExpression(Expressions.FilterBody), scope, filename, foundType);
|
|
112
|
+
if (foundType === undefined || foundType.isGeneric()) {
|
|
113
|
+
this.addIfInferred(node, scope, filename, bodyType);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.addIfInferred(node, scope, filename, foundType);
|
|
117
|
+
}
|
|
118
|
+
return foundType ? foundType : bodyType;
|
|
112
119
|
}
|
|
113
120
|
case "CORRESPONDING":
|
|
114
121
|
{
|
package/build/src/registry.js
CHANGED
|
@@ -50,6 +50,7 @@ Current rules:
|
|
|
50
50
|
* COND is outlined
|
|
51
51
|
* REDUCE is outlined
|
|
52
52
|
* SWITCH is outlined
|
|
53
|
+
* FILTER is outlined
|
|
53
54
|
* APPEND expression is outlined
|
|
54
55
|
* INSERT expression is outlined
|
|
55
56
|
* EMPTY KEY is changed to DEFAULT KEY, opposite of DEFAULT KEY in https://rules.abaplint.org/avoid_use/
|
|
@@ -288,6 +289,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
288
289
|
if (found) {
|
|
289
290
|
return found;
|
|
290
291
|
}
|
|
292
|
+
found = this.outlineFilter(low, high, lowFile, highSyntax);
|
|
293
|
+
if (found) {
|
|
294
|
+
return found;
|
|
295
|
+
}
|
|
291
296
|
found = this.outlineCast(low, high, lowFile, highSyntax);
|
|
292
297
|
if (found) {
|
|
293
298
|
return found;
|
|
@@ -1538,6 +1543,46 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1538
1543
|
}
|
|
1539
1544
|
return { body, end };
|
|
1540
1545
|
}
|
|
1546
|
+
outlineFilter(low, high, lowFile, highSyntax) {
|
|
1547
|
+
var _a;
|
|
1548
|
+
if (!(low.get() instanceof _statement_1.Unknown)) {
|
|
1549
|
+
return undefined;
|
|
1550
|
+
}
|
|
1551
|
+
for (const i of high.findAllExpressionsRecursive(Expressions.Source)) {
|
|
1552
|
+
const firstToken = i.getFirstToken();
|
|
1553
|
+
if (firstToken.getStr().toUpperCase() !== "FILTER") {
|
|
1554
|
+
continue;
|
|
1555
|
+
}
|
|
1556
|
+
const filterBody = i.findDirectExpression(Expressions.FilterBody);
|
|
1557
|
+
if (filterBody === undefined) {
|
|
1558
|
+
continue;
|
|
1559
|
+
}
|
|
1560
|
+
const sourceName = (_a = filterBody.findDirectExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
1561
|
+
if (sourceName === undefined) {
|
|
1562
|
+
continue;
|
|
1563
|
+
}
|
|
1564
|
+
let type = this.findType(i, lowFile, highSyntax);
|
|
1565
|
+
if (type === undefined) {
|
|
1566
|
+
type = "LIKE " + sourceName;
|
|
1567
|
+
}
|
|
1568
|
+
else {
|
|
1569
|
+
type = "TYPE " + type;
|
|
1570
|
+
}
|
|
1571
|
+
const uniqueName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
|
|
1572
|
+
const loopName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
|
|
1573
|
+
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
1574
|
+
let body = "";
|
|
1575
|
+
body += `DATA ${uniqueName} ${type}.\n`;
|
|
1576
|
+
body += `${indentation}LOOP AT ${sourceName} INTO DATA(${loopName}) ${filterBody.concatTokens().substring(sourceName.length + 1)}.\n`;
|
|
1577
|
+
body += `${indentation} INSERT ${loopName} INTO TABLE ${uniqueName}.\n`;
|
|
1578
|
+
body += `${indentation}ENDLOOP.\n${indentation}`;
|
|
1579
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getStart(), body);
|
|
1580
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, firstToken.getStart(), i.getLastToken().getEnd(), uniqueName);
|
|
1581
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
1582
|
+
return issue_1.Issue.atToken(lowFile, firstToken, "Downport FILTER", this.getMetadata().key, this.conf.severity, fix);
|
|
1583
|
+
}
|
|
1584
|
+
return undefined;
|
|
1585
|
+
}
|
|
1541
1586
|
outlineSwitch(low, high, lowFile, highSyntax) {
|
|
1542
1587
|
var _a, _b, _c, _d;
|
|
1543
1588
|
if (!(low.get() instanceof _statement_1.Unknown)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.93.
|
|
3
|
+
"version": "2.93.38",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@microsoft/api-extractor": "^7.32.0",
|
|
50
50
|
"@types/chai": "^4.3.3",
|
|
51
51
|
"@types/mocha": "^10.0.0",
|
|
52
|
-
"@types/node": "^18.8.
|
|
52
|
+
"@types/node": "^18.8.3",
|
|
53
53
|
"chai": "^4.3.6",
|
|
54
54
|
"eslint": "^8.24.0",
|
|
55
55
|
"mocha": "^10.0.0",
|