@abaplint/core 2.93.36 → 2.93.37
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.
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +52 -0
- package/package.json +2 -2
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,53 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1538
1543
|
}
|
|
1539
1544
|
return { body, end };
|
|
1540
1545
|
}
|
|
1546
|
+
outlineFilter(low, high, lowFile, highSyntax) {
|
|
1547
|
+
var _a, _b, _c;
|
|
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
|
+
let type = this.findType(i, lowFile, highSyntax);
|
|
1561
|
+
if (type === undefined) {
|
|
1562
|
+
if (high.get() instanceof Statements.Move
|
|
1563
|
+
&& high.findDirectExpression(Expressions.Source) === i
|
|
1564
|
+
&& ((_a = high.findDirectExpression(Expressions.Target)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.TargetField)) !== undefined) {
|
|
1565
|
+
type = "LIKE " + ((_b = high.findDirectExpression(Expressions.Target)) === null || _b === void 0 ? void 0 : _b.concatTokens());
|
|
1566
|
+
}
|
|
1567
|
+
if (type === undefined) {
|
|
1568
|
+
continue;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
else {
|
|
1572
|
+
type = "TYPE " + type;
|
|
1573
|
+
}
|
|
1574
|
+
const sourceName = (_c = filterBody.findDirectExpression(Expressions.Source)) === null || _c === void 0 ? void 0 : _c.concatTokens();
|
|
1575
|
+
if (sourceName === undefined) {
|
|
1576
|
+
continue;
|
|
1577
|
+
}
|
|
1578
|
+
const uniqueName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
|
|
1579
|
+
const loopName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
|
|
1580
|
+
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
1581
|
+
let body = "";
|
|
1582
|
+
body += `${indentation}DATA ${uniqueName} ${type}.\n`;
|
|
1583
|
+
body += `${indentation}LOOP AT ${sourceName} INTO DATA(${loopName}) ${filterBody.concatTokens().substring(sourceName.length + 1)}.\n`;
|
|
1584
|
+
body += `${indentation} INSERT ${loopName} INTO TABLE ${uniqueName}.\n`;
|
|
1585
|
+
body += `${indentation}ENDLOOP.\n`;
|
|
1586
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getStart(), body);
|
|
1587
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, firstToken.getStart(), i.getLastToken().getEnd(), uniqueName);
|
|
1588
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
1589
|
+
return issue_1.Issue.atToken(lowFile, firstToken, "Downport FILTER", this.getMetadata().key, this.conf.severity, fix);
|
|
1590
|
+
}
|
|
1591
|
+
return undefined;
|
|
1592
|
+
}
|
|
1541
1593
|
outlineSwitch(low, high, lowFile, highSyntax) {
|
|
1542
1594
|
var _a, _b, _c, _d;
|
|
1543
1595
|
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.37",
|
|
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",
|