@abaplint/core 2.86.4 → 2.86.7
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
CHANGED
|
@@ -56,6 +56,7 @@ class DoubleSpace extends _abap_rule_1.ABAPRule {
|
|
|
56
56
|
&& !(s.get() instanceof _statement_1.Unknown)
|
|
57
57
|
&& !(s.get() instanceof statements_1.MethodDef)
|
|
58
58
|
&& !(s.get() instanceof _statement_1.MacroCall)
|
|
59
|
+
&& !(s.get() instanceof statements_1.Events)
|
|
59
60
|
&& !(s.get() instanceof _statement_1.MacroContent)) {
|
|
60
61
|
issues = issues.concat(this.checkKeywords(s, file));
|
|
61
62
|
}
|
|
@@ -267,6 +267,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
267
267
|
if (found) {
|
|
268
268
|
return found;
|
|
269
269
|
}
|
|
270
|
+
found = this.replaceMethodConditional(high, lowFile, highSyntax);
|
|
271
|
+
if (found) {
|
|
272
|
+
return found;
|
|
273
|
+
}
|
|
270
274
|
found = this.replaceTableExpression(high, lowFile, highSyntax);
|
|
271
275
|
if (found) {
|
|
272
276
|
return found;
|
|
@@ -894,15 +898,19 @@ ${indentation} output = ${topTarget}.`;
|
|
|
894
898
|
return undefined;
|
|
895
899
|
}
|
|
896
900
|
outlineFor(forLoop, indentation, lowFile, highSyntax) {
|
|
897
|
-
var _a, _b, _c, _d;
|
|
901
|
+
var _a, _b, _c, _d, _e;
|
|
898
902
|
let body = "";
|
|
899
903
|
let end = "";
|
|
900
904
|
const loopSource = (_a = forLoop.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
901
905
|
const loopTargetField = (_b = forLoop.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
906
|
+
let cond = ((_c = forLoop.findDirectExpression(Expressions.ComponentCond)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "";
|
|
907
|
+
if (cond !== "") {
|
|
908
|
+
cond = " WHERE " + cond;
|
|
909
|
+
}
|
|
902
910
|
if (forLoop.findDirectTokenByText("UNTIL")
|
|
903
911
|
|| forLoop.findDirectTokenByText("WHILE")) {
|
|
904
912
|
const fieldDef = forLoop.findDirectExpression(Expressions.InlineFieldDefinition);
|
|
905
|
-
const field = (
|
|
913
|
+
const field = (_d = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.findFirstExpression(Expressions.Field)) === null || _d === void 0 ? void 0 : _d.concatTokens();
|
|
906
914
|
body += indentation + "DATA " + field + " TYPE i.\n";
|
|
907
915
|
const second = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.getChildren()[2];
|
|
908
916
|
if ((second === null || second === void 0 ? void 0 : second.get()) instanceof Expressions.Source) {
|
|
@@ -915,12 +923,12 @@ ${indentation} output = ${topTarget}.`;
|
|
|
915
923
|
end += indentation + "ENDWHILE";
|
|
916
924
|
}
|
|
917
925
|
else if (loopTargetField) {
|
|
918
|
-
body += indentation + `LOOP AT ${loopSource} INTO DATA(${loopTargetField}).\n`;
|
|
926
|
+
body += indentation + `LOOP AT ${loopSource} INTO DATA(${loopTargetField})${cond}.\n`;
|
|
919
927
|
end = "ENDLOOP";
|
|
920
928
|
}
|
|
921
929
|
else if (loopTargetField === undefined) {
|
|
922
|
-
const loopTargetFieldSymbol = (
|
|
923
|
-
body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol}).\n`;
|
|
930
|
+
const loopTargetFieldSymbol = (_e = forLoop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _e === void 0 ? void 0 : _e.concatTokens();
|
|
931
|
+
body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol})${cond}.\n`;
|
|
924
932
|
end = "ENDLOOP";
|
|
925
933
|
}
|
|
926
934
|
const l = forLoop.findDirectExpression(Expressions.Let);
|
|
@@ -1023,12 +1031,12 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1023
1031
|
name = init.getFirstToken().getStr();
|
|
1024
1032
|
body += indentation + `DATA(${name}) = ${(_a = reduceBody.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens()}.\n`;
|
|
1025
1033
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1034
|
+
let end = "";
|
|
1035
|
+
for (const forLoop of (reduceBody === null || reduceBody === void 0 ? void 0 : reduceBody.findDirectExpressions(Expressions.For)) || []) {
|
|
1036
|
+
const outlineFor = this.outlineFor(forLoop, indentation, lowFile, highSyntax);
|
|
1037
|
+
body += outlineFor.body;
|
|
1038
|
+
end = outlineFor.end + `.\n` + end;
|
|
1029
1039
|
}
|
|
1030
|
-
const outlineFor = this.outlineFor(forLoop, indentation, lowFile, highSyntax);
|
|
1031
|
-
body += outlineFor.body;
|
|
1032
1040
|
const next = reduceBody.findDirectExpression(Expressions.ReduceNext);
|
|
1033
1041
|
if (next === undefined) {
|
|
1034
1042
|
continue;
|
|
@@ -1048,7 +1056,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1048
1056
|
body += concat;
|
|
1049
1057
|
}
|
|
1050
1058
|
}
|
|
1051
|
-
body += indentation +
|
|
1059
|
+
body += indentation + end;
|
|
1052
1060
|
body += indentation + `${uniqueName} = ${name}.\n`;
|
|
1053
1061
|
const abap = `DATA ${uniqueName} TYPE ${type}.\n` +
|
|
1054
1062
|
body +
|
|
@@ -1135,6 +1143,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1135
1143
|
body += indentation + end;
|
|
1136
1144
|
}
|
|
1137
1145
|
const abap = `DATA ${uniqueName} ${type}.\n` +
|
|
1146
|
+
indentation + `CLEAR ${uniqueName}.\n` + // might be called inside a loop
|
|
1138
1147
|
body +
|
|
1139
1148
|
indentation;
|
|
1140
1149
|
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), abap);
|
|
@@ -1303,6 +1312,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1303
1312
|
buildCondBody(body, uniqueName, indent, lowFile, highSyntax) {
|
|
1304
1313
|
let code = "";
|
|
1305
1314
|
let first = true;
|
|
1315
|
+
let addElse = true;
|
|
1306
1316
|
for (const c of body.getChildren()) {
|
|
1307
1317
|
if (c instanceof nodes_1.TokenNode) {
|
|
1308
1318
|
switch (c.getFirstToken().getStr().toUpperCase()) {
|
|
@@ -1320,6 +1330,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1320
1330
|
break;
|
|
1321
1331
|
case "ELSE":
|
|
1322
1332
|
code += indent + "ELSE.\n";
|
|
1333
|
+
addElse = false;
|
|
1323
1334
|
break;
|
|
1324
1335
|
default:
|
|
1325
1336
|
throw "buildCondBody, unexpected token";
|
|
@@ -1338,6 +1349,11 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1338
1349
|
throw "buildCondBody, unexpected expression, " + c.get().constructor.name;
|
|
1339
1350
|
}
|
|
1340
1351
|
}
|
|
1352
|
+
if (addElse) {
|
|
1353
|
+
// COND might be called inside a loop
|
|
1354
|
+
code += indent + "ELSE.\n";
|
|
1355
|
+
code += indent + ` CLEAR ${uniqueName}.\n`;
|
|
1356
|
+
}
|
|
1341
1357
|
code += indent + "ENDIF.\n";
|
|
1342
1358
|
code += indent;
|
|
1343
1359
|
return code;
|
|
@@ -1348,6 +1364,10 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1348
1364
|
if (i.getFirstToken().getStr().toUpperCase() !== "CONV") {
|
|
1349
1365
|
continue;
|
|
1350
1366
|
}
|
|
1367
|
+
const end = i.findDirectTokenByText(")");
|
|
1368
|
+
if (end === undefined) {
|
|
1369
|
+
continue;
|
|
1370
|
+
}
|
|
1351
1371
|
const body = (_a = i.findDirectExpression(Expressions.ConvBody)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
1352
1372
|
if (body === undefined) {
|
|
1353
1373
|
continue;
|
|
@@ -1359,7 +1379,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1359
1379
|
indent + `${uniqueName} = ${body}.\n` +
|
|
1360
1380
|
indent;
|
|
1361
1381
|
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), abap);
|
|
1362
|
-
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, i.getFirstToken().getStart(),
|
|
1382
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, i.getFirstToken().getStart(), end.getEnd(), uniqueName);
|
|
1363
1383
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
1364
1384
|
return issue_1.Issue.atToken(lowFile, i.getFirstToken(), "Downport CONV", this.getMetadata().key, this.conf.severity, fix);
|
|
1365
1385
|
}
|
|
@@ -1420,6 +1440,18 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1420
1440
|
}
|
|
1421
1441
|
return undefined;
|
|
1422
1442
|
}
|
|
1443
|
+
replaceMethodConditional(node, lowFile, _highSyntax) {
|
|
1444
|
+
for (const c of node.findAllExpressionsRecursive(Expressions.Compare)) {
|
|
1445
|
+
const chain = c.findDirectExpression(Expressions.MethodCallChain);
|
|
1446
|
+
if (chain === undefined) {
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
const end = chain.getLastToken().getEnd();
|
|
1450
|
+
const fix = edit_helper_1.EditHelper.insertAt(lowFile, end, " IS NOT INITIAL");
|
|
1451
|
+
return issue_1.Issue.atToken(lowFile, chain.getFirstToken(), "Downport method conditional", this.getMetadata().key, this.conf.severity, fix);
|
|
1452
|
+
}
|
|
1453
|
+
return undefined;
|
|
1454
|
+
}
|
|
1423
1455
|
replaceContains(node, lowFile, highSyntax) {
|
|
1424
1456
|
const spag = highSyntax.spaghetti.lookupPosition(node.getFirstToken().getStart(), lowFile.getFilename());
|
|
1425
1457
|
// only downport if its an single method call condition
|
|
@@ -141,12 +141,16 @@ class KeywordCase extends _abap_rule_1.ABAPRule {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
const skip = new Skip(this.getConfig());
|
|
144
|
+
let prev = undefined;
|
|
144
145
|
for (const statement of file.getStatements()) {
|
|
145
146
|
if (skip.skipStatement(statement) === true) {
|
|
146
147
|
continue;
|
|
147
148
|
}
|
|
148
149
|
let result = this.traverse(statement, statement.get());
|
|
149
150
|
if (result.length > 0) {
|
|
151
|
+
if (prev && result[0].token.getStart().equals(prev.getStart())) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
150
154
|
if (statement.getColon() !== undefined) {
|
|
151
155
|
// if its a chained statement, go token by token
|
|
152
156
|
result = [result[0]];
|
|
@@ -156,6 +160,7 @@ class KeywordCase extends _abap_rule_1.ABAPRule {
|
|
|
156
160
|
if (issues.length > MAX_ISSUES) {
|
|
157
161
|
break;
|
|
158
162
|
}
|
|
163
|
+
prev = result[0].token;
|
|
159
164
|
}
|
|
160
165
|
}
|
|
161
166
|
return issues;
|