@abaplint/core 2.93.25 → 2.93.27
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.
|
@@ -15,7 +15,8 @@ class For extends combi_1.Expression {
|
|
|
15
15
|
const whil = (0, combi_1.seq)((0, combi_1.altPrio)("UNTIL", "WHILE"), _1.Cond);
|
|
16
16
|
const itera = (0, combi_1.seq)(_1.InlineFieldDefinition, (0, combi_1.opt)(then), whil);
|
|
17
17
|
const groupBy = (0, combi_1.seq)("GROUP BY", (0, combi_1.alt)(field_chain_1.FieldChain, (0, combi_1.seq)("(", (0, combi_1.plus)(_1.LoopGroupByComponent), ")")), (0, combi_1.opt)((0, combi_1.seq)((0, combi_1.alt)("ASCENDING", "DESCENDING"), (0, combi_1.opt)("AS TEXT"))), (0, combi_1.opt)("WITHOUT MEMBERS"));
|
|
18
|
-
const
|
|
18
|
+
const t = (0, combi_1.alt)(_1.TargetField, _1.TargetFieldSymbol);
|
|
19
|
+
const groups = (0, combi_1.ver)(version_1.Version.v740sp08, (0, combi_1.seq)("GROUPS", t, "OF", t, "IN", _1.Source, (0, combi_1.optPrio)(groupBy)));
|
|
19
20
|
const f = (0, combi_1.seq)("FOR", (0, combi_1.alt)(itera, inn, groups), (0, combi_1.optPrio)(_1.Let));
|
|
20
21
|
return (0, combi_1.ver)(version_1.Version.v740sp05, f);
|
|
21
22
|
}
|
|
@@ -8,12 +8,17 @@ const inline_loop_definition_1 = require("./inline_loop_definition");
|
|
|
8
8
|
const _scope_type_1 = require("../_scope_type");
|
|
9
9
|
const component_cond_1 = require("./component_cond");
|
|
10
10
|
const cond_1 = require("./cond");
|
|
11
|
+
const basic_1 = require("../../types/basic");
|
|
12
|
+
const _typed_identifier_1 = require("../../types/_typed_identifier");
|
|
13
|
+
const _reference_1 = require("../_reference");
|
|
11
14
|
class For {
|
|
12
15
|
runSyntax(node, scope, filename) {
|
|
16
|
+
var _a;
|
|
13
17
|
let scoped = false;
|
|
14
18
|
const inlineLoop = node.findDirectExpressions(Expressions.InlineLoopDefinition);
|
|
15
19
|
const inlineField = node.findAllExpressions(Expressions.InlineFieldDefinition);
|
|
16
|
-
const
|
|
20
|
+
const groupsToken = (_a = node.findExpressionAfterToken("GROUPS")) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
21
|
+
const addScope = inlineLoop.length > 0 || inlineField.length > 0 || groupsToken !== undefined;
|
|
17
22
|
if (addScope) {
|
|
18
23
|
// this scope is popped in parent expressions
|
|
19
24
|
scope.push(_scope_type_1.ScopeType.For, "FOR", node.getFirstToken().getStart(), filename);
|
|
@@ -25,6 +30,12 @@ class For {
|
|
|
25
30
|
for (const f of inlineField) {
|
|
26
31
|
new inline_field_definition_1.InlineFieldDefinition().runSyntax(f, scope, filename);
|
|
27
32
|
}
|
|
33
|
+
if (groupsToken !== undefined) {
|
|
34
|
+
const type = new basic_1.VoidType("todoGroupBy");
|
|
35
|
+
const identifier = new _typed_identifier_1.TypedIdentifier(groupsToken, filename, type, ["inline" /* IdentifierMeta.InlineDefinition */]);
|
|
36
|
+
scope.addIdentifier(identifier);
|
|
37
|
+
scope.addReference(groupsToken, identifier, _reference_1.ReferenceType.DataWriteReference, filename);
|
|
38
|
+
}
|
|
28
39
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
29
40
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
30
41
|
}
|
|
@@ -6,7 +6,6 @@ const for_1 = require("./for");
|
|
|
6
6
|
const source_1 = require("./source");
|
|
7
7
|
const inline_field_definition_1 = require("./inline_field_definition");
|
|
8
8
|
const unknown_type_1 = require("../../types/basic/unknown_type");
|
|
9
|
-
const _scope_type_1 = require("../_scope_type");
|
|
10
9
|
const reduce_next_1 = require("./reduce_next");
|
|
11
10
|
const let_1 = require("./let");
|
|
12
11
|
class ReduceBody {
|
|
@@ -26,8 +25,12 @@ class ReduceBody {
|
|
|
26
25
|
first = found;
|
|
27
26
|
}
|
|
28
27
|
}
|
|
28
|
+
let forScopes = 0;
|
|
29
29
|
for (const forNode of node.findDirectExpressions(Expressions.For) || []) {
|
|
30
|
-
new for_1.For().runSyntax(forNode, scope, filename);
|
|
30
|
+
const scoped = new for_1.For().runSyntax(forNode, scope, filename);
|
|
31
|
+
if (scoped === true) {
|
|
32
|
+
forScopes++;
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
35
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
33
36
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
@@ -38,7 +41,7 @@ class ReduceBody {
|
|
|
38
41
|
if (scoped === true) {
|
|
39
42
|
scope.pop(node.getLastToken().getEnd());
|
|
40
43
|
}
|
|
41
|
-
|
|
44
|
+
for (let i = 0; i < forScopes; i++) {
|
|
42
45
|
scope.pop(node.getLastToken().getEnd());
|
|
43
46
|
}
|
|
44
47
|
if (first) {
|
package/build/src/registry.js
CHANGED
|
@@ -218,7 +218,7 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
218
218
|
if (found) {
|
|
219
219
|
return found;
|
|
220
220
|
}
|
|
221
|
-
found = this.downportRefSimple(high, lowFile);
|
|
221
|
+
found = this.downportRefSimple(high, lowFile, highSyntax);
|
|
222
222
|
if (found) {
|
|
223
223
|
return found;
|
|
224
224
|
}
|
|
@@ -258,13 +258,31 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
258
258
|
if (found) {
|
|
259
259
|
return found;
|
|
260
260
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
let skipValue = false;
|
|
262
|
+
let skipReduce = false;
|
|
263
|
+
const valueBody = high.findFirstExpression(Expressions.ValueBody);
|
|
264
|
+
const reduceBody = high.findFirstExpression(Expressions.ReduceBody);
|
|
265
|
+
if (valueBody && reduceBody) {
|
|
266
|
+
const valueToken = valueBody.getFirstToken();
|
|
267
|
+
const reduceToken = reduceBody.getFirstToken();
|
|
268
|
+
if (valueToken.getStart().isBefore(reduceToken.getStart())) {
|
|
269
|
+
skipReduce = true;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
skipValue = true;
|
|
273
|
+
}
|
|
264
274
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
275
|
+
if (skipValue !== true) {
|
|
276
|
+
found = this.outlineValue(low, high, lowFile, highSyntax);
|
|
277
|
+
if (found) {
|
|
278
|
+
return found;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (skipReduce !== true) {
|
|
282
|
+
found = this.outlineReduce(low, high, lowFile, highSyntax);
|
|
283
|
+
if (found) {
|
|
284
|
+
return found;
|
|
285
|
+
}
|
|
268
286
|
}
|
|
269
287
|
found = this.outlineSwitch(low, high, lowFile, highSyntax);
|
|
270
288
|
if (found) {
|
|
@@ -899,7 +917,7 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
|
|
|
899
917
|
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
|
|
900
918
|
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, simple CORRESPONDING move", this.getMetadata().key, this.conf.severity, fix);
|
|
901
919
|
}
|
|
902
|
-
downportRefSimple(high, lowFile) {
|
|
920
|
+
downportRefSimple(high, lowFile, highSyntax) {
|
|
903
921
|
var _a;
|
|
904
922
|
if (!(high.get() instanceof Statements.Move)
|
|
905
923
|
|| high.getChildren().length !== 4
|
|
@@ -911,10 +929,19 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
|
|
|
911
929
|
return undefined;
|
|
912
930
|
}
|
|
913
931
|
const sourceRef = (_a = high.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Source);
|
|
914
|
-
if (sourceRef === undefined
|
|
915
|
-
|
|
932
|
+
if (sourceRef === undefined
|
|
933
|
+
|| sourceRef.getChildren().length !== 1) {
|
|
934
|
+
return undefined;
|
|
935
|
+
}
|
|
936
|
+
let code = "";
|
|
937
|
+
if (sourceRef.findFirstExpression(Expressions.TableExpression)) {
|
|
938
|
+
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
939
|
+
code = `ASSIGN ${sourceRef.concatTokens()} TO FIELD-SYMBOL(<${uniqueName}>).
|
|
940
|
+
GET REFERENCE OF <${uniqueName}> INTO ${target.concatTokens()}`;
|
|
941
|
+
}
|
|
942
|
+
else {
|
|
943
|
+
code = `GET REFERENCE OF ${sourceRef.concatTokens()} INTO ${target.concatTokens()}`;
|
|
916
944
|
}
|
|
917
|
-
const code = `GET REFERENCE OF ${sourceRef.concatTokens()} INTO ${target.concatTokens()}`;
|
|
918
945
|
const start = high.getFirstToken().getStart();
|
|
919
946
|
const end = high.getLastToken().getStart();
|
|
920
947
|
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
|
|
@@ -1388,24 +1415,28 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1388
1415
|
return undefined;
|
|
1389
1416
|
}
|
|
1390
1417
|
outlineFor(forLoop, indentation, lowFile, highSyntax) {
|
|
1391
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1418
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1392
1419
|
let body = "";
|
|
1393
1420
|
let end = "";
|
|
1394
1421
|
const loopSource = (_a = forLoop.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
1395
1422
|
let loopTargetField = (_b = forLoop.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
1396
|
-
|
|
1423
|
+
const of = (_c = forLoop.findExpressionAfterToken("OF")) === null || _c === void 0 ? void 0 : _c.concatTokens();
|
|
1424
|
+
if (of !== undefined) {
|
|
1425
|
+
loopTargetField = of;
|
|
1426
|
+
}
|
|
1427
|
+
if (((_e = (_d = forLoop.findDirectExpression(Expressions.InlineLoopDefinition)) === null || _d === void 0 ? void 0 : _d.getFirstChild()) === null || _e === void 0 ? void 0 : _e.get()) instanceof Expressions.TargetFieldSymbol) {
|
|
1397
1428
|
loopTargetField = undefined;
|
|
1398
1429
|
}
|
|
1399
|
-
let cond = ((
|
|
1430
|
+
let cond = ((_f = forLoop.findDirectExpression(Expressions.ComponentCond)) === null || _f === void 0 ? void 0 : _f.concatTokens()) || "";
|
|
1400
1431
|
if (cond !== "") {
|
|
1401
1432
|
cond = " WHERE " + cond;
|
|
1402
1433
|
}
|
|
1403
1434
|
const loop = forLoop.findDirectExpression(Expressions.InlineLoopDefinition);
|
|
1404
|
-
const indexInto = (
|
|
1435
|
+
const indexInto = (_g = loop === null || loop === void 0 ? void 0 : loop.findExpressionAfterToken("INTO")) === null || _g === void 0 ? void 0 : _g.concatTokens();
|
|
1405
1436
|
if (forLoop.findDirectTokenByText("UNTIL")
|
|
1406
1437
|
|| forLoop.findDirectTokenByText("WHILE")) {
|
|
1407
1438
|
const fieldDef = forLoop.findDirectExpression(Expressions.InlineFieldDefinition);
|
|
1408
|
-
const field = (
|
|
1439
|
+
const field = (_h = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.findFirstExpression(Expressions.Field)) === null || _h === void 0 ? void 0 : _h.concatTokens();
|
|
1409
1440
|
const indexBackup = this.uniqueName(forLoop.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
1410
1441
|
body += indentation + "DATA " + field + " TYPE i.\n";
|
|
1411
1442
|
const second = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.getChildren()[2];
|
|
@@ -1428,9 +1459,9 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1428
1459
|
end += indentation + "ENDWHILE";
|
|
1429
1460
|
}
|
|
1430
1461
|
else if (loopTargetField !== undefined) {
|
|
1431
|
-
let from = (
|
|
1462
|
+
let from = (_j = forLoop.findExpressionAfterToken("FROM")) === null || _j === void 0 ? void 0 : _j.concatTokens();
|
|
1432
1463
|
from = from ? " FROM " + from : "";
|
|
1433
|
-
let to = (
|
|
1464
|
+
let to = (_k = forLoop.findExpressionAfterToken("TO")) === null || _k === void 0 ? void 0 : _k.concatTokens();
|
|
1434
1465
|
to = to ? " TO " + to : "";
|
|
1435
1466
|
let gby = "";
|
|
1436
1467
|
for (const lg of forLoop.findDirectExpressions(Expressions.LoopGroupByComponent)) {
|
|
@@ -1459,7 +1490,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1459
1490
|
}
|
|
1460
1491
|
else if (loopTargetField === undefined) {
|
|
1461
1492
|
// todo, also backup sy-index / sy-tabix here?
|
|
1462
|
-
const loopTargetFieldSymbol = (
|
|
1493
|
+
const loopTargetFieldSymbol = (_l = forLoop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _l === void 0 ? void 0 : _l.concatTokens();
|
|
1463
1494
|
body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol})${cond}.\n`;
|
|
1464
1495
|
if (indexInto) {
|
|
1465
1496
|
body += indentation + " DATA(" + indexInto + ") = sy-tabix.\n";
|