@abaplint/core 2.93.25 → 2.93.26
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
|
}
|
|
@@ -899,7 +899,7 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
|
|
|
899
899
|
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
|
|
900
900
|
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, simple CORRESPONDING move", this.getMetadata().key, this.conf.severity, fix);
|
|
901
901
|
}
|
|
902
|
-
downportRefSimple(high, lowFile) {
|
|
902
|
+
downportRefSimple(high, lowFile, highSyntax) {
|
|
903
903
|
var _a;
|
|
904
904
|
if (!(high.get() instanceof Statements.Move)
|
|
905
905
|
|| high.getChildren().length !== 4
|
|
@@ -911,10 +911,19 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
|
|
|
911
911
|
return undefined;
|
|
912
912
|
}
|
|
913
913
|
const sourceRef = (_a = high.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Source);
|
|
914
|
-
if (sourceRef === undefined
|
|
915
|
-
|
|
914
|
+
if (sourceRef === undefined
|
|
915
|
+
|| sourceRef.getChildren().length !== 1) {
|
|
916
|
+
return undefined;
|
|
917
|
+
}
|
|
918
|
+
let code = "";
|
|
919
|
+
if (sourceRef.findFirstExpression(Expressions.TableExpression)) {
|
|
920
|
+
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
921
|
+
code = `DATA(${uniqueName}) = ${sourceRef.concatTokens()}.
|
|
922
|
+
GET REFERENCE OF ${uniqueName} INTO ${target.concatTokens()}`;
|
|
923
|
+
}
|
|
924
|
+
else {
|
|
925
|
+
code = `GET REFERENCE OF ${sourceRef.concatTokens()} INTO ${target.concatTokens()}`;
|
|
916
926
|
}
|
|
917
|
-
const code = `GET REFERENCE OF ${sourceRef.concatTokens()} INTO ${target.concatTokens()}`;
|
|
918
927
|
const start = high.getFirstToken().getStart();
|
|
919
928
|
const end = high.getLastToken().getStart();
|
|
920
929
|
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
|
|
@@ -1388,24 +1397,28 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1388
1397
|
return undefined;
|
|
1389
1398
|
}
|
|
1390
1399
|
outlineFor(forLoop, indentation, lowFile, highSyntax) {
|
|
1391
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1400
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1392
1401
|
let body = "";
|
|
1393
1402
|
let end = "";
|
|
1394
1403
|
const loopSource = (_a = forLoop.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
1395
1404
|
let loopTargetField = (_b = forLoop.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
1396
|
-
|
|
1405
|
+
const of = (_c = forLoop.findExpressionAfterToken("OF")) === null || _c === void 0 ? void 0 : _c.concatTokens();
|
|
1406
|
+
if (of !== undefined) {
|
|
1407
|
+
loopTargetField = of;
|
|
1408
|
+
}
|
|
1409
|
+
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
1410
|
loopTargetField = undefined;
|
|
1398
1411
|
}
|
|
1399
|
-
let cond = ((
|
|
1412
|
+
let cond = ((_f = forLoop.findDirectExpression(Expressions.ComponentCond)) === null || _f === void 0 ? void 0 : _f.concatTokens()) || "";
|
|
1400
1413
|
if (cond !== "") {
|
|
1401
1414
|
cond = " WHERE " + cond;
|
|
1402
1415
|
}
|
|
1403
1416
|
const loop = forLoop.findDirectExpression(Expressions.InlineLoopDefinition);
|
|
1404
|
-
const indexInto = (
|
|
1417
|
+
const indexInto = (_g = loop === null || loop === void 0 ? void 0 : loop.findExpressionAfterToken("INTO")) === null || _g === void 0 ? void 0 : _g.concatTokens();
|
|
1405
1418
|
if (forLoop.findDirectTokenByText("UNTIL")
|
|
1406
1419
|
|| forLoop.findDirectTokenByText("WHILE")) {
|
|
1407
1420
|
const fieldDef = forLoop.findDirectExpression(Expressions.InlineFieldDefinition);
|
|
1408
|
-
const field = (
|
|
1421
|
+
const field = (_h = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.findFirstExpression(Expressions.Field)) === null || _h === void 0 ? void 0 : _h.concatTokens();
|
|
1409
1422
|
const indexBackup = this.uniqueName(forLoop.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
1410
1423
|
body += indentation + "DATA " + field + " TYPE i.\n";
|
|
1411
1424
|
const second = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.getChildren()[2];
|
|
@@ -1428,9 +1441,9 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1428
1441
|
end += indentation + "ENDWHILE";
|
|
1429
1442
|
}
|
|
1430
1443
|
else if (loopTargetField !== undefined) {
|
|
1431
|
-
let from = (
|
|
1444
|
+
let from = (_j = forLoop.findExpressionAfterToken("FROM")) === null || _j === void 0 ? void 0 : _j.concatTokens();
|
|
1432
1445
|
from = from ? " FROM " + from : "";
|
|
1433
|
-
let to = (
|
|
1446
|
+
let to = (_k = forLoop.findExpressionAfterToken("TO")) === null || _k === void 0 ? void 0 : _k.concatTokens();
|
|
1434
1447
|
to = to ? " TO " + to : "";
|
|
1435
1448
|
let gby = "";
|
|
1436
1449
|
for (const lg of forLoop.findDirectExpressions(Expressions.LoopGroupByComponent)) {
|
|
@@ -1459,7 +1472,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1459
1472
|
}
|
|
1460
1473
|
else if (loopTargetField === undefined) {
|
|
1461
1474
|
// todo, also backup sy-index / sy-tabix here?
|
|
1462
|
-
const loopTargetFieldSymbol = (
|
|
1475
|
+
const loopTargetFieldSymbol = (_l = forLoop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _l === void 0 ? void 0 : _l.concatTokens();
|
|
1463
1476
|
body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol})${cond}.\n`;
|
|
1464
1477
|
if (indexInto) {
|
|
1465
1478
|
body += indentation + " DATA(" + indexInto + ") = sy-tabix.\n";
|