@abaplint/core 2.85.23 → 2.85.24
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/abap/2_statements/expressions/sql_as_name.js +3 -1
- package/build/src/abap/2_statements/expressions/sql_field_list.js +1 -1
- package/build/src/abap/5_syntax/expressions/source.js +5 -2
- package/build/src/abap/5_syntax/expressions/switch_body.js +9 -0
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +53 -3
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SQLAsName = void 0;
|
|
4
|
+
const tokens_1 = require("../../1_lexer/tokens");
|
|
4
5
|
const combi_1 = require("../combi");
|
|
5
6
|
class SQLAsName extends combi_1.Expression {
|
|
6
7
|
getRunnable() {
|
|
7
8
|
// todo, below allows too much?
|
|
8
|
-
|
|
9
|
+
const field = (0, combi_1.regex)(/^[&_!]?\*?\w*(\/\w+\/)?\d*[a-zA-Z_%\$][\w\*%\$\?]*(~\w+)?$/);
|
|
10
|
+
return (0, combi_1.seq)(field, (0, combi_1.starPrio)((0, combi_1.seq)((0, combi_1.tok)(tokens_1.Dash), field)));
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
exports.SQLAsName = SQLAsName;
|
|
@@ -12,7 +12,7 @@ class SQLFieldList extends combi_1.Expression {
|
|
|
12
12
|
getRunnable() {
|
|
13
13
|
const comma = (0, combi_1.optPrio)((0, combi_1.ver)(version_1.Version.v740sp05, ","));
|
|
14
14
|
const abap = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WAt), simple_field_chain_1.SimpleFieldChain));
|
|
15
|
-
const as = (0, combi_1.seq)("AS", _1.
|
|
15
|
+
const as = (0, combi_1.seq)("AS", _1.SQLAsName);
|
|
16
16
|
const field = (0, combi_1.altPrio)(_1.SQLAggregation, _1.SQLCase, sql_function_1.SQLFunction, sql_path_1.SQLPath, _1.SQLFieldName, abap, _1.Constant);
|
|
17
17
|
const sub = (0, combi_1.plusPrio)((0, combi_1.seq)((0, combi_1.altPrio)("+", "-", "*", "/", "&&"), (0, combi_1.optPrio)((0, combi_1.tok)(tokens_1.WParenLeftW)), field, (0, combi_1.optPrio)((0, combi_1.tok)(tokens_1.WParenRightW))));
|
|
18
18
|
const arith = (0, combi_1.ver)(version_1.Version.v740sp05, sub);
|
|
@@ -72,8 +72,11 @@ class Source {
|
|
|
72
72
|
case "SWITCH":
|
|
73
73
|
{
|
|
74
74
|
const foundType = this.determineType(node, scope, filename, targetType);
|
|
75
|
-
new switch_body_1.SwitchBody().runSyntax(node.findDirectExpression(Expressions.SwitchBody), scope, filename);
|
|
76
|
-
|
|
75
|
+
const bodyType = new switch_body_1.SwitchBody().runSyntax(node.findDirectExpression(Expressions.SwitchBody), scope, filename);
|
|
76
|
+
if (foundType === undefined) {
|
|
77
|
+
this.addIfInferred(node, scope, filename, bodyType);
|
|
78
|
+
}
|
|
79
|
+
return foundType ? foundType : bodyType;
|
|
77
80
|
}
|
|
78
81
|
case "COND":
|
|
79
82
|
{
|
|
@@ -8,9 +8,18 @@ class SwitchBody {
|
|
|
8
8
|
if (node === undefined) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
+
const thenSource = node.findExpressionAfterToken("THEN");
|
|
12
|
+
if (!((thenSource === null || thenSource === void 0 ? void 0 : thenSource.get()) instanceof Expressions.Source)) {
|
|
13
|
+
throw new Error("SwitchBody, unexpected");
|
|
14
|
+
}
|
|
15
|
+
const type = new source_1.Source().runSyntax(thenSource, scope, filename);
|
|
11
16
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
17
|
+
if (s === thenSource) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
12
20
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
13
21
|
}
|
|
22
|
+
return type;
|
|
14
23
|
}
|
|
15
24
|
}
|
|
16
25
|
exports.SwitchBody = SwitchBody;
|
package/build/src/registry.js
CHANGED
|
@@ -56,7 +56,7 @@ Current rules:
|
|
|
56
56
|
* PARTIALLY IMPLEMENTED removed, it can be quick fixed via rule implement_methods
|
|
57
57
|
* RAISE EXCEPTION ... MESSAGE
|
|
58
58
|
* APPEND expression is outlined
|
|
59
|
-
* Moving with +=, -=, /=, *=, &&=
|
|
59
|
+
* Moving with +=, -=, /=, *=, &&= is expanded
|
|
60
60
|
|
|
61
61
|
Only one transformation is applied to a statement at a time, so multiple steps might be required to do the full downport.`,
|
|
62
62
|
tags: [_irule_1.RuleTag.Experimental, _irule_1.RuleTag.Downport, _irule_1.RuleTag.Quickfix],
|
|
@@ -224,7 +224,11 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
224
224
|
if (found) {
|
|
225
225
|
return found;
|
|
226
226
|
}
|
|
227
|
-
|
|
227
|
+
found = this.replaceLineExists(high, lowFile, highSyntax);
|
|
228
|
+
if (found) {
|
|
229
|
+
return found;
|
|
230
|
+
}
|
|
231
|
+
// note: line_exists() must be replaced before this call
|
|
228
232
|
found = this.replaceTableExpression(high, lowFile, highSyntax);
|
|
229
233
|
if (found) {
|
|
230
234
|
return found;
|
|
@@ -233,7 +237,6 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
233
237
|
if (found) {
|
|
234
238
|
return found;
|
|
235
239
|
}
|
|
236
|
-
// todo, add more rules here
|
|
237
240
|
return undefined;
|
|
238
241
|
}
|
|
239
242
|
//////////////////////////////////////////
|
|
@@ -1089,6 +1092,53 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1089
1092
|
}
|
|
1090
1093
|
return undefined;
|
|
1091
1094
|
}
|
|
1095
|
+
findMethodCallExpression(node, token) {
|
|
1096
|
+
var _a;
|
|
1097
|
+
for (const m of node.findAllExpressions(Expressions.MethodCall)) {
|
|
1098
|
+
if ((_a = m.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStart().equals(token.getStart())) {
|
|
1099
|
+
return m;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
return undefined;
|
|
1103
|
+
}
|
|
1104
|
+
replaceLineExists(node, lowFile, highSyntax) {
|
|
1105
|
+
var _a, _b;
|
|
1106
|
+
const spag = highSyntax.spaghetti.lookupPosition(node.getFirstToken().getStart(), lowFile.getFilename());
|
|
1107
|
+
for (const r of (spag === null || spag === void 0 ? void 0 : spag.getData().references) || []) {
|
|
1108
|
+
if (r.referenceType === _reference_1.ReferenceType.BuiltinMethodReference
|
|
1109
|
+
&& r.position.getName().toUpperCase() === "LINE_EXISTS") {
|
|
1110
|
+
const token = r.position.getToken();
|
|
1111
|
+
const expression = this.findMethodCallExpression(node, token);
|
|
1112
|
+
if (expression === undefined) {
|
|
1113
|
+
continue;
|
|
1114
|
+
}
|
|
1115
|
+
let condition = "";
|
|
1116
|
+
for (const c of ((_a = expression === null || expression === void 0 ? void 0 : expression.findFirstExpression(Expressions.TableExpression)) === null || _a === void 0 ? void 0 : _a.getChildren()) || []) {
|
|
1117
|
+
if (c.getFirstToken().getStr() === "[" || c.getFirstToken().getStr() === "]") {
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
else if (c.get() instanceof Expressions.ComponentChainSimple && condition === "") {
|
|
1121
|
+
condition = "WITH KEY ";
|
|
1122
|
+
}
|
|
1123
|
+
condition += c.concatTokens() + " ";
|
|
1124
|
+
}
|
|
1125
|
+
const tableName = (_b = expression === null || expression === void 0 ? void 0 : expression.findFirstExpression(Expressions.SourceField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
1126
|
+
const uniqueName = this.uniqueName(node.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
1127
|
+
const indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
|
|
1128
|
+
const code = `DATA ${uniqueName} LIKE sy-subrc.\n` +
|
|
1129
|
+
indentation + `READ TABLE ${tableName} ${condition}TRANSPORTING NO FIELDS.\n` +
|
|
1130
|
+
indentation + uniqueName + " = sy-subrc.\n" +
|
|
1131
|
+
indentation;
|
|
1132
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
|
|
1133
|
+
const start = expression.getFirstToken().getStart();
|
|
1134
|
+
const end = expression.getLastToken().getEnd();
|
|
1135
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, uniqueName + " = 0");
|
|
1136
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
1137
|
+
return issue_1.Issue.atToken(lowFile, token, "Use BOOLC", this.getMetadata().key, this.conf.severity, fix);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
return undefined;
|
|
1141
|
+
}
|
|
1092
1142
|
newToCreateObject(node, lowFile, highSyntax) {
|
|
1093
1143
|
const source = node.findDirectExpression(Expressions.Source);
|
|
1094
1144
|
let fix = undefined;
|