@abaplint/core 2.85.33 → 2.85.36
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 +53 -12
- package/package.json +1 -1
package/build/src/registry.js
CHANGED
|
@@ -214,6 +214,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
214
214
|
if (found) {
|
|
215
215
|
return found;
|
|
216
216
|
}
|
|
217
|
+
found = this.outlineCatchSimple(high, lowFile);
|
|
218
|
+
if (found) {
|
|
219
|
+
return found;
|
|
220
|
+
}
|
|
217
221
|
found = this.outlineDataSimple(high, lowFile);
|
|
218
222
|
if (found) {
|
|
219
223
|
return found;
|
|
@@ -238,7 +242,6 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
238
242
|
if (found) {
|
|
239
243
|
return found;
|
|
240
244
|
}
|
|
241
|
-
// note: line_exists() must be replaced before this call
|
|
242
245
|
found = this.replaceTableExpression(high, lowFile, highSyntax);
|
|
243
246
|
if (found) {
|
|
244
247
|
return found;
|
|
@@ -254,8 +257,8 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
254
257
|
if (!(low.get() instanceof _statement_1.Unknown)) {
|
|
255
258
|
return undefined;
|
|
256
259
|
}
|
|
257
|
-
// todo: select loop
|
|
258
260
|
if (!(high.get() instanceof Statements.Select)
|
|
261
|
+
&& !(high.get() instanceof Statements.SelectLoop)
|
|
259
262
|
&& !(high.get() instanceof Statements.UpdateDatabase)
|
|
260
263
|
&& !(high.get() instanceof Statements.ModifyDatabase)
|
|
261
264
|
&& !(high.get() instanceof Statements.DeleteDatabase)
|
|
@@ -280,7 +283,7 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
280
283
|
addFix(c.getFirstToken());
|
|
281
284
|
}
|
|
282
285
|
}
|
|
283
|
-
for (const fieldList of high.
|
|
286
|
+
for (const fieldList of high.findAllExpressionsMulti([Expressions.SQLFieldList, Expressions.SQLFieldListLoop], true)) {
|
|
284
287
|
for (const token of fieldList.getDirectTokens()) {
|
|
285
288
|
if (token.getStr() === ",") {
|
|
286
289
|
addFix(token);
|
|
@@ -446,6 +449,11 @@ ${indentation}${uniqueName} = ${source.concatTokens()}.\n${indentation}`);
|
|
|
446
449
|
if (tableExpression === undefined) {
|
|
447
450
|
continue;
|
|
448
451
|
}
|
|
452
|
+
const concat = node.concatTokens().toUpperCase();
|
|
453
|
+
if (concat.includes(" LINE_EXISTS( ") || concat.includes(" LINE_INDEX( ")) {
|
|
454
|
+
// note: line_exists() must be replaced before handling table expressions
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
449
457
|
let pre = "";
|
|
450
458
|
let startToken = undefined;
|
|
451
459
|
for (const child of fieldChain.getChildren()) {
|
|
@@ -488,6 +496,28 @@ ${indentation}`);
|
|
|
488
496
|
}
|
|
489
497
|
return undefined;
|
|
490
498
|
}
|
|
499
|
+
outlineCatchSimple(node, lowFile) {
|
|
500
|
+
// outlines "CATCH cx_bcs INTO DATA(lx_bcs_excep).", note that this does not need to look at types
|
|
501
|
+
var _a, _b;
|
|
502
|
+
if (!(node.get() instanceof Statements.Catch)) {
|
|
503
|
+
return undefined;
|
|
504
|
+
}
|
|
505
|
+
const target = node.findFirstExpression(Expressions.Target);
|
|
506
|
+
if (!(((_a = target === null || target === void 0 ? void 0 : target.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.InlineData)) {
|
|
507
|
+
return undefined;
|
|
508
|
+
}
|
|
509
|
+
const classNames = node.findDirectExpressions(Expressions.ClassName);
|
|
510
|
+
if (classNames.length !== 1) {
|
|
511
|
+
return undefined;
|
|
512
|
+
}
|
|
513
|
+
const className = classNames[0].concatTokens();
|
|
514
|
+
const targetName = (_b = target.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
515
|
+
const indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
|
|
516
|
+
const code = ` DATA ${targetName} TYPE REF TO ${className}.
|
|
517
|
+
${indentation}CATCH ${className} INTO ${targetName}.`;
|
|
518
|
+
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, node.getStart(), node.getEnd(), code);
|
|
519
|
+
return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Outline DATA", this.getMetadata().key, this.conf.severity, fix);
|
|
520
|
+
}
|
|
491
521
|
outlineDataSimple(node, lowFile) {
|
|
492
522
|
// outlines "DATA(ls_msg) = temp1.", note that this does not need to look at types
|
|
493
523
|
var _a, _b, _c;
|
|
@@ -945,17 +975,26 @@ ${indentation} output = ${topTarget}.`;
|
|
|
945
975
|
return undefined;
|
|
946
976
|
}
|
|
947
977
|
outlineValue(node, lowFile, highSyntax) {
|
|
978
|
+
var _a;
|
|
948
979
|
const allSources = node.findAllExpressionsRecursive(Expressions.Source);
|
|
949
|
-
for (const
|
|
950
|
-
const firstToken =
|
|
980
|
+
for (const s of allSources) {
|
|
981
|
+
const firstToken = s.getFirstToken();
|
|
951
982
|
if (firstToken.getStr().toUpperCase() !== "VALUE") {
|
|
952
983
|
continue;
|
|
953
984
|
}
|
|
954
|
-
|
|
985
|
+
let type = this.findType(s, lowFile, highSyntax);
|
|
955
986
|
if (type === undefined) {
|
|
956
|
-
|
|
987
|
+
if (node.get() instanceof Statements.Move && node.findDirectExpression(Expressions.Source) === s) {
|
|
988
|
+
type = "LIKE " + ((_a = node.findDirectExpression(Expressions.Target)) === null || _a === void 0 ? void 0 : _a.concatTokens());
|
|
989
|
+
}
|
|
990
|
+
if (type === undefined) {
|
|
991
|
+
continue;
|
|
992
|
+
}
|
|
957
993
|
}
|
|
958
|
-
|
|
994
|
+
else {
|
|
995
|
+
type = "TYPE " + type;
|
|
996
|
+
}
|
|
997
|
+
const valueBody = s.findDirectExpression(Expressions.ValueBody);
|
|
959
998
|
const uniqueName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
|
|
960
999
|
let indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
|
|
961
1000
|
let body = "";
|
|
@@ -995,11 +1034,11 @@ ${indentation} output = ${topTarget}.`;
|
|
|
995
1034
|
indentation = indentation.substring(2);
|
|
996
1035
|
body += indentation + outlineFor.end + `.\n`;
|
|
997
1036
|
}
|
|
998
|
-
const abap = `DATA ${uniqueName}
|
|
1037
|
+
const abap = `DATA ${uniqueName} ${type}.\n` +
|
|
999
1038
|
body +
|
|
1000
1039
|
indentation;
|
|
1001
1040
|
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), abap);
|
|
1002
|
-
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, firstToken.getStart(),
|
|
1041
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, firstToken.getStart(), s.getLastToken().getEnd(), uniqueName);
|
|
1003
1042
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
1004
1043
|
return issue_1.Issue.atToken(lowFile, firstToken, "Downport VALUE", this.getMetadata().key, this.conf.severity, fix);
|
|
1005
1044
|
}
|
|
@@ -1271,9 +1310,11 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1271
1310
|
var _a, _b;
|
|
1272
1311
|
const spag = highSyntax.spaghetti.lookupPosition(node.getFirstToken().getStart(), lowFile.getFilename());
|
|
1273
1312
|
for (const r of (spag === null || spag === void 0 ? void 0 : spag.getData().references) || []) {
|
|
1313
|
+
if (r.referenceType !== _reference_1.ReferenceType.BuiltinMethodReference) {
|
|
1314
|
+
continue;
|
|
1315
|
+
}
|
|
1274
1316
|
const func = r.position.getName().toUpperCase();
|
|
1275
|
-
if (
|
|
1276
|
-
&& (func === "LINE_EXISTS" || func === "LINE_INDEX")) {
|
|
1317
|
+
if (func === "LINE_EXISTS" || func === "LINE_INDEX") {
|
|
1277
1318
|
const token = r.position.getToken();
|
|
1278
1319
|
const expression = this.findMethodCallExpression(node, token);
|
|
1279
1320
|
if (expression === undefined) {
|