@abaplint/core 2.85.31 → 2.85.34
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/abaplint.d.ts +5 -0
- package/build/src/abap/1_lexer/tokens/index.js +5 -1
- package/build/src/abap/2_statements/expressions/index.js +6 -1
- package/build/src/abap/2_statements/expressions/select_loop.js +2 -12
- package/build/src/abap/2_statements/expressions/sql_field_list_loop.js +21 -0
- package/build/src/abap/2_statements/statements/index.js +5 -1
- package/build/src/abap/3_structures/structures/index.js +5 -1
- package/build/src/abap/5_syntax/expressions/constant.js +5 -1
- package/build/src/abap/nodes/index.js +5 -1
- package/build/src/abap/types/basic/index.js +5 -1
- package/build/src/abap/types/index.js +5 -1
- package/build/src/cds/expressions/index.js +5 -1
- package/build/src/ddl/expressions/index.js +5 -1
- package/build/src/objects/index.js +5 -1
- package/build/src/registry.js +1 -1
- package/build/src/rules/avoid_use.js +1 -0
- package/build/src/rules/downport.js +89 -10
- package/build/src/rules/empty_structure.js +14 -1
- package/build/src/rules/index.js +5 -1
- package/package.json +2 -2
package/build/abaplint.d.ts
CHANGED
|
@@ -1912,6 +1912,7 @@ declare namespace Expressions {
|
|
|
1912
1912
|
SQLCompareOperator,
|
|
1913
1913
|
SQLCompare,
|
|
1914
1914
|
SQLCond,
|
|
1915
|
+
SQLFieldListLoop,
|
|
1915
1916
|
SQLFieldList,
|
|
1916
1917
|
SQLFieldName,
|
|
1917
1918
|
SQLForAllEntries,
|
|
@@ -4894,6 +4895,10 @@ declare class SQLFieldList extends Expression {
|
|
|
4894
4895
|
getRunnable(): IStatementRunnable;
|
|
4895
4896
|
}
|
|
4896
4897
|
|
|
4898
|
+
declare class SQLFieldListLoop extends Expression {
|
|
4899
|
+
getRunnable(): IStatementRunnable;
|
|
4900
|
+
}
|
|
4901
|
+
|
|
4897
4902
|
declare class SQLFieldName extends Expression {
|
|
4898
4903
|
getRunnable(): IStatementRunnable;
|
|
4899
4904
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -158,6 +162,7 @@ __exportStar(require("./sql_client"), exports);
|
|
|
158
162
|
__exportStar(require("./sql_compare_operator"), exports);
|
|
159
163
|
__exportStar(require("./sql_compare"), exports);
|
|
160
164
|
__exportStar(require("./sql_cond"), exports);
|
|
165
|
+
__exportStar(require("./sql_field_list_loop"), exports);
|
|
161
166
|
__exportStar(require("./sql_field_list"), exports);
|
|
162
167
|
__exportStar(require("./sql_field_name"), exports);
|
|
163
168
|
__exportStar(require("./sql_for_all_entries"), exports);
|
|
@@ -3,25 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SelectLoop = void 0;
|
|
4
4
|
const combi_1 = require("../combi");
|
|
5
5
|
const _1 = require(".");
|
|
6
|
-
const version_1 = require("../../../version");
|
|
7
6
|
const sql_order_by_1 = require("./sql_order_by");
|
|
8
7
|
const sql_having_1 = require("./sql_having");
|
|
9
|
-
const sql_path_1 = require("./sql_path");
|
|
10
|
-
const sql_as_name_1 = require("./sql_as_name");
|
|
11
|
-
const sql_case_1 = require("./sql_case");
|
|
12
8
|
const sql_into_structure_1 = require("./sql_into_structure");
|
|
13
9
|
const sql_field_list_1 = require("./sql_field_list");
|
|
14
10
|
const sql_hints_1 = require("./sql_hints");
|
|
15
|
-
const
|
|
11
|
+
const sql_field_list_loop_1 = require("./sql_field_list_loop");
|
|
16
12
|
class SelectLoop extends combi_1.Expression {
|
|
17
13
|
getRunnable() {
|
|
18
14
|
const where = (0, combi_1.seq)("WHERE", _1.SQLCond);
|
|
19
|
-
const comma = (0, combi_1.opt)((0, combi_1.ver)(version_1.Version.v740sp05, ","));
|
|
20
|
-
const as = (0, combi_1.seq)("AS", sql_as_name_1.SQLAsName);
|
|
21
|
-
const someField = (0, combi_1.seq)((0, combi_1.alt)(_1.SQLFieldName, sql_path_1.SQLPath, _1.SQLAggregation, sql_function_1.SQLFunction, sql_case_1.SQLCase), (0, combi_1.optPrio)(as), comma);
|
|
22
|
-
const fieldList = (0, combi_1.seq)((0, combi_1.star)(someField), (0, combi_1.alt)(_1.SQLFieldName, sql_path_1.SQLPath), (0, combi_1.optPrio)(as), comma, (0, combi_1.star)(someField));
|
|
23
|
-
// todo, use SQLFieldList instead?
|
|
24
|
-
const fields = (0, combi_1.alt)("*", _1.Dynamic, fieldList);
|
|
25
15
|
const client = "CLIENT SPECIFIED";
|
|
26
16
|
const bypass = "BYPASSING BUFFER";
|
|
27
17
|
const up = (0, combi_1.seq)("UP TO", _1.SQLSource, "ROWS");
|
|
@@ -29,7 +19,7 @@ class SelectLoop extends combi_1.Expression {
|
|
|
29
19
|
const tab = (0, combi_1.seq)(_1.SQLIntoTable, (0, combi_1.alt)(pack, (0, combi_1.seq)(_1.SQLFrom, pack), (0, combi_1.seq)(pack, _1.SQLFrom)));
|
|
30
20
|
const perm = (0, combi_1.per)(_1.SQLFrom, where, up, sql_order_by_1.SQLOrderBy, sql_having_1.SQLHaving, client, bypass, _1.SQLGroupBy, _1.SQLForAllEntries, (0, combi_1.alt)(tab, sql_into_structure_1.SQLIntoStructure));
|
|
31
21
|
const strict = (0, combi_1.seq)(_1.SQLFrom, "FIELDS", sql_field_list_1.SQLFieldList, where, sql_into_structure_1.SQLIntoStructure, up);
|
|
32
|
-
const ret = (0, combi_1.seq)("SELECT", (0, combi_1.altPrio)((0, combi_1.seq)((0, combi_1.optPrio)("DISTINCT"),
|
|
22
|
+
const ret = (0, combi_1.seq)("SELECT", (0, combi_1.altPrio)((0, combi_1.seq)((0, combi_1.optPrio)("DISTINCT"), sql_field_list_loop_1.SQLFieldListLoop, perm), strict), (0, combi_1.optPrio)(sql_hints_1.SQLHints));
|
|
33
23
|
return ret;
|
|
34
24
|
}
|
|
35
25
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SQLFieldListLoop = void 0;
|
|
4
|
+
const combi_1 = require("../combi");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const version_1 = require("../../../version");
|
|
7
|
+
const sql_function_1 = require("./sql_function");
|
|
8
|
+
const sql_path_1 = require("./sql_path");
|
|
9
|
+
// loop must include one field from the database table
|
|
10
|
+
class SQLFieldListLoop extends combi_1.Expression {
|
|
11
|
+
getRunnable() {
|
|
12
|
+
const comma = (0, combi_1.opt)((0, combi_1.ver)(version_1.Version.v740sp05, ","));
|
|
13
|
+
const as = (0, combi_1.seq)("AS", _1.SQLAsName);
|
|
14
|
+
const someField = (0, combi_1.seq)((0, combi_1.alt)(_1.SQLFieldName, sql_path_1.SQLPath, _1.SQLAggregation, sql_function_1.SQLFunction, _1.SQLCase), (0, combi_1.optPrio)(as), comma);
|
|
15
|
+
const fieldList = (0, combi_1.seq)((0, combi_1.star)(someField), (0, combi_1.alt)(_1.SQLFieldName, sql_path_1.SQLPath), (0, combi_1.optPrio)(as), comma, (0, combi_1.star)(someField));
|
|
16
|
+
const fields = (0, combi_1.alt)("*", _1.Dynamic, fieldList);
|
|
17
|
+
return fields;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.SQLFieldListLoop = SQLFieldListLoop;
|
|
21
|
+
//# sourceMappingURL=sql_field_list_loop.js.map
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -9,7 +9,11 @@ class Constant {
|
|
|
9
9
|
return new basic_1.IntegerType("I");
|
|
10
10
|
}
|
|
11
11
|
else if (node.getFirstToken().getStr().startsWith("'")) {
|
|
12
|
-
|
|
12
|
+
let len = node.getFirstToken().getStr().length - 2;
|
|
13
|
+
if (len <= 0) {
|
|
14
|
+
len = 1;
|
|
15
|
+
}
|
|
16
|
+
return new basic_1.CharacterType(len);
|
|
13
17
|
}
|
|
14
18
|
else {
|
|
15
19
|
return new basic_1.StringType("STRING");
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/build/src/registry.js
CHANGED
|
@@ -84,6 +84,7 @@ DESCRIBE TABLE LINES: use lines() instead (quickfix exists)`,
|
|
|
84
84
|
}
|
|
85
85
|
else if (this.conf.break && statement instanceof Statements.Break) {
|
|
86
86
|
message = "BREAK/BREAK-POINT";
|
|
87
|
+
fix = edit_helper_1.EditHelper.deleteStatement(file, statementNode);
|
|
87
88
|
}
|
|
88
89
|
if (message) {
|
|
89
90
|
issues.push(issue_1.Issue.atStatement(file, statementNode, this.getDescription(message), this.getMetadata().key, this.conf.severity, fix));
|
|
@@ -170,6 +170,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
170
170
|
if (found) {
|
|
171
171
|
return found;
|
|
172
172
|
}
|
|
173
|
+
found = this.moveWithSimpleValue(high, lowFile);
|
|
174
|
+
if (found) {
|
|
175
|
+
return found;
|
|
176
|
+
}
|
|
173
177
|
found = this.downportSelectInline(low, high, lowFile, highSyntax);
|
|
174
178
|
if (found) {
|
|
175
179
|
return found;
|
|
@@ -210,6 +214,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
210
214
|
if (found) {
|
|
211
215
|
return found;
|
|
212
216
|
}
|
|
217
|
+
found = this.outlineCatchSimple(high, lowFile);
|
|
218
|
+
if (found) {
|
|
219
|
+
return found;
|
|
220
|
+
}
|
|
213
221
|
found = this.outlineDataSimple(high, lowFile);
|
|
214
222
|
if (found) {
|
|
215
223
|
return found;
|
|
@@ -250,8 +258,8 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
250
258
|
if (!(low.get() instanceof _statement_1.Unknown)) {
|
|
251
259
|
return undefined;
|
|
252
260
|
}
|
|
253
|
-
// todo: select loop
|
|
254
261
|
if (!(high.get() instanceof Statements.Select)
|
|
262
|
+
&& !(high.get() instanceof Statements.SelectLoop)
|
|
255
263
|
&& !(high.get() instanceof Statements.UpdateDatabase)
|
|
256
264
|
&& !(high.get() instanceof Statements.ModifyDatabase)
|
|
257
265
|
&& !(high.get() instanceof Statements.DeleteDatabase)
|
|
@@ -291,8 +299,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
291
299
|
}
|
|
292
300
|
}
|
|
293
301
|
downportSelectInline(low, high, lowFile, highSyntax) {
|
|
294
|
-
if (!(low.get() instanceof _statement_1.Unknown)
|
|
295
|
-
|
|
302
|
+
if (!(low.get() instanceof _statement_1.Unknown)) {
|
|
303
|
+
return undefined;
|
|
304
|
+
}
|
|
305
|
+
else if (!(high.get() instanceof Statements.Select) && !(high.get() instanceof Statements.SelectLoop)) {
|
|
296
306
|
return undefined;
|
|
297
307
|
}
|
|
298
308
|
// as first step outline the @DATA, note that void types are okay, as long the field names are specified
|
|
@@ -325,7 +335,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
325
335
|
return undefined;
|
|
326
336
|
}
|
|
327
337
|
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
328
|
-
|
|
338
|
+
let fieldList = high.findFirstExpression(Expressions.SQLFieldList);
|
|
339
|
+
if (fieldList === undefined) {
|
|
340
|
+
fieldList = high.findFirstExpression(Expressions.SQLFieldListLoop);
|
|
341
|
+
}
|
|
329
342
|
if (fieldList === undefined) {
|
|
330
343
|
return undefined;
|
|
331
344
|
}
|
|
@@ -368,26 +381,31 @@ ${indentation}`);
|
|
|
368
381
|
if (targets.length !== 1) {
|
|
369
382
|
return undefined;
|
|
370
383
|
}
|
|
384
|
+
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
371
385
|
const inlineData = targets[0].findFirstExpression(Expressions.InlineData);
|
|
372
386
|
if (inlineData === undefined) {
|
|
373
387
|
return undefined;
|
|
374
388
|
}
|
|
375
389
|
const sqlFrom = high.findAllExpressions(Expressions.SQLFromSource);
|
|
376
|
-
if (sqlFrom.length
|
|
377
|
-
return
|
|
390
|
+
if (sqlFrom.length === 0) {
|
|
391
|
+
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Error outlining, sqlFrom not found", this.getMetadata().key, this.conf.severity);
|
|
378
392
|
}
|
|
379
|
-
|
|
393
|
+
let tableName = (_b = sqlFrom[0].findDirectExpression(Expressions.DatabaseTable)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
380
394
|
if (tableName === undefined) {
|
|
381
395
|
return undefined;
|
|
382
396
|
}
|
|
383
|
-
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
384
397
|
const fieldList = high.findFirstExpression(Expressions.SQLFieldList);
|
|
385
398
|
if (fieldList === undefined) {
|
|
386
399
|
return undefined;
|
|
387
400
|
}
|
|
388
401
|
let fieldDefinitions = "";
|
|
389
402
|
for (const f of fieldList.findDirectExpressions(Expressions.SQLFieldName)) {
|
|
390
|
-
|
|
403
|
+
let fieldName = f.concatTokens();
|
|
404
|
+
if (fieldName.includes("~")) {
|
|
405
|
+
const split = fieldName.split("~");
|
|
406
|
+
tableName = split[0];
|
|
407
|
+
fieldName = split[1];
|
|
408
|
+
}
|
|
391
409
|
fieldDefinitions += indentation + " " + fieldName + " TYPE " + tableName + "-" + fieldName + ",\n";
|
|
392
410
|
}
|
|
393
411
|
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
@@ -474,6 +492,28 @@ ${indentation}`);
|
|
|
474
492
|
}
|
|
475
493
|
return undefined;
|
|
476
494
|
}
|
|
495
|
+
outlineCatchSimple(node, lowFile) {
|
|
496
|
+
// outlines "CATCH cx_bcs INTO DATA(lx_bcs_excep).", note that this does not need to look at types
|
|
497
|
+
var _a, _b;
|
|
498
|
+
if (!(node.get() instanceof Statements.Catch)) {
|
|
499
|
+
return undefined;
|
|
500
|
+
}
|
|
501
|
+
const target = node.findFirstExpression(Expressions.Target);
|
|
502
|
+
if (!(((_a = target === null || target === void 0 ? void 0 : target.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.InlineData)) {
|
|
503
|
+
return undefined;
|
|
504
|
+
}
|
|
505
|
+
const classNames = node.findDirectExpressions(Expressions.ClassName);
|
|
506
|
+
if (classNames.length !== 1) {
|
|
507
|
+
return undefined;
|
|
508
|
+
}
|
|
509
|
+
const className = classNames[0].concatTokens();
|
|
510
|
+
const targetName = (_b = target.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
511
|
+
const indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
|
|
512
|
+
const code = ` DATA ${targetName} TYPE REF TO ${className}.
|
|
513
|
+
${indentation}CATCH ${className} INTO ${targetName}.`;
|
|
514
|
+
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, node.getStart(), node.getEnd(), code);
|
|
515
|
+
return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Outline DATA", this.getMetadata().key, this.conf.severity, fix);
|
|
516
|
+
}
|
|
477
517
|
outlineDataSimple(node, lowFile) {
|
|
478
518
|
// outlines "DATA(ls_msg) = temp1.", note that this does not need to look at types
|
|
479
519
|
var _a, _b, _c;
|
|
@@ -611,6 +651,38 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
|
|
|
611
651
|
}
|
|
612
652
|
return undefined;
|
|
613
653
|
}
|
|
654
|
+
moveWithSimpleValue(high, lowFile) {
|
|
655
|
+
if (!(high.get() instanceof Statements.Move)
|
|
656
|
+
|| high.getChildren().length !== 4) {
|
|
657
|
+
return undefined;
|
|
658
|
+
}
|
|
659
|
+
const target = high.findDirectExpression(Expressions.Target);
|
|
660
|
+
if (target === undefined) {
|
|
661
|
+
return undefined;
|
|
662
|
+
}
|
|
663
|
+
const source = high.findDirectExpression(Expressions.Source);
|
|
664
|
+
if (source === undefined) {
|
|
665
|
+
return undefined;
|
|
666
|
+
}
|
|
667
|
+
const field = target.findDirectExpression(Expressions.TargetField);
|
|
668
|
+
if (field === undefined) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
const valueBody = source.findDirectExpression(Expressions.ValueBody);
|
|
672
|
+
if (valueBody === undefined || valueBody.getChildren().length !== 1) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
const fieldAssignment = valueBody.findDirectExpression(Expressions.FieldAssignment);
|
|
676
|
+
if (fieldAssignment === undefined) {
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
680
|
+
const code = `CLEAR ${target.concatTokens()}.\n` + indentation + target.concatTokens() + "-" + fieldAssignment.concatTokens();
|
|
681
|
+
const start = high.getFirstToken().getStart();
|
|
682
|
+
const end = high.getLastToken().getStart();
|
|
683
|
+
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
|
|
684
|
+
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, Reduce statement", this.getMetadata().key, this.conf.severity, fix);
|
|
685
|
+
}
|
|
614
686
|
moveWithOperator(high, lowFile) {
|
|
615
687
|
var _a, _b, _c;
|
|
616
688
|
if (!(high.get() instanceof Statements.Move)) {
|
|
@@ -1103,11 +1175,18 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1103
1175
|
}
|
|
1104
1176
|
buildCondBody(body, uniqueName, indent, lowFile, highSyntax) {
|
|
1105
1177
|
let code = "";
|
|
1178
|
+
let first = true;
|
|
1106
1179
|
for (const c of body.getChildren()) {
|
|
1107
1180
|
if (c instanceof nodes_1.TokenNode) {
|
|
1108
1181
|
switch (c.getFirstToken().getStr().toUpperCase()) {
|
|
1109
1182
|
case "WHEN":
|
|
1110
|
-
|
|
1183
|
+
if (first === true) {
|
|
1184
|
+
code += indent + "IF ";
|
|
1185
|
+
first = false;
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
code += indent + "ELSEIF ";
|
|
1189
|
+
}
|
|
1111
1190
|
break;
|
|
1112
1191
|
case "THEN":
|
|
1113
1192
|
code += ".\n";
|
|
@@ -25,7 +25,9 @@ class EmptyStructureConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
|
25
25
|
this.at = true;
|
|
26
26
|
/** Checks for empty TRY blocks */
|
|
27
27
|
this.try = true;
|
|
28
|
-
|
|
28
|
+
/** Checks for empty WHEN blocks */
|
|
29
|
+
this.when = true;
|
|
30
|
+
// todo, other category containing ELSE
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
exports.EmptyStructureConf = EmptyStructureConf;
|
|
@@ -108,6 +110,17 @@ class EmptyStructure extends _abap_rule_1.ABAPRule {
|
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
}
|
|
113
|
+
if (this.getConfig().when === true) {
|
|
114
|
+
const tries = stru.findAllStructures(Structures.When);
|
|
115
|
+
for (const t of tries) {
|
|
116
|
+
if (t.getChildren().length === 1) {
|
|
117
|
+
const token = t.getFirstToken();
|
|
118
|
+
const message = this.getDescription(t.get().constructor.name);
|
|
119
|
+
const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity);
|
|
120
|
+
issues.push(issue);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
111
124
|
return issues;
|
|
112
125
|
}
|
|
113
126
|
}
|
package/build/src/rules/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.85.
|
|
3
|
+
"version": "2.85.34",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"c8": "^7.11.0",
|
|
56
56
|
"source-map-support": "^0.5.21",
|
|
57
57
|
"ts-json-schema-generator": "^0.98.0",
|
|
58
|
-
"typescript": "^4.
|
|
58
|
+
"typescript": "^4.6.2"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"fast-xml-parser": "^4.0.3",
|