@abaplint/core 2.91.25 → 2.91.28
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 +16 -1
- package/build/src/abap/2_statements/expressions/index.js +4 -1
- package/build/src/abap/2_statements/expressions/loop_group_by.js +4 -9
- package/build/src/abap/2_statements/expressions/loop_group_by_component.js +15 -0
- package/build/src/abap/2_statements/expressions/loop_group_by_target.js +15 -0
- package/build/src/abap/2_statements/expressions/loop_target.js +15 -0
- package/build/src/abap/2_statements/statements/loop.js +1 -4
- package/build/src/abap/5_syntax/basic_types.js +20 -4
- package/build/src/abap/5_syntax/expressions/loop_group_by.js +6 -6
- package/build/src/abap/5_syntax/expressions/type_table.js +11 -4
- package/build/src/abap/5_syntax/expressions/type_table_key.js +25 -0
- package/build/src/abap/5_syntax/statements/loop.js +3 -2
- package/build/src/abap/5_syntax/statements/type.js +3 -3
- package/build/src/abap/5_syntax/structures/types.js +1 -1
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +91 -5
- package/package.json +1 -1
package/build/abaplint.d.ts
CHANGED
|
@@ -1866,7 +1866,10 @@ declare namespace Expressions {
|
|
|
1866
1866
|
Language,
|
|
1867
1867
|
Length,
|
|
1868
1868
|
Let,
|
|
1869
|
+
LoopGroupByComponent,
|
|
1870
|
+
LoopGroupByTarget,
|
|
1869
1871
|
LoopGroupBy,
|
|
1872
|
+
LoopTarget,
|
|
1870
1873
|
MacroName,
|
|
1871
1874
|
MessageClass_2 as MessageClass,
|
|
1872
1875
|
MessageNumber,
|
|
@@ -1933,10 +1936,10 @@ declare namespace Expressions {
|
|
|
1933
1936
|
SQLCompareOperator,
|
|
1934
1937
|
SQLCompare,
|
|
1935
1938
|
SQLCond,
|
|
1936
|
-
SQLField,
|
|
1937
1939
|
SQLFieldListLoop,
|
|
1938
1940
|
SQLFieldList,
|
|
1939
1941
|
SQLFieldName,
|
|
1942
|
+
SQLField,
|
|
1940
1943
|
SQLForAllEntries,
|
|
1941
1944
|
SQLFromSource,
|
|
1942
1945
|
SQLFrom,
|
|
@@ -3549,6 +3552,18 @@ declare class LoopGroupBy extends Expression {
|
|
|
3549
3552
|
getRunnable(): IStatementRunnable;
|
|
3550
3553
|
}
|
|
3551
3554
|
|
|
3555
|
+
declare class LoopGroupByComponent extends Expression {
|
|
3556
|
+
getRunnable(): IStatementRunnable;
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
declare class LoopGroupByTarget extends Expression {
|
|
3560
|
+
getRunnable(): IStatementRunnable;
|
|
3561
|
+
}
|
|
3562
|
+
|
|
3563
|
+
declare class LoopTarget extends Expression {
|
|
3564
|
+
getRunnable(): IStatementRunnable;
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3552
3567
|
declare class MacroName extends Expression {
|
|
3553
3568
|
getRunnable(): IStatementRunnable;
|
|
3554
3569
|
}
|
|
@@ -96,7 +96,10 @@ __exportStar(require("./interface_name"), exports);
|
|
|
96
96
|
__exportStar(require("./language"), exports);
|
|
97
97
|
__exportStar(require("./length"), exports);
|
|
98
98
|
__exportStar(require("./let"), exports);
|
|
99
|
+
__exportStar(require("./loop_group_by_component"), exports);
|
|
100
|
+
__exportStar(require("./loop_group_by_target"), exports);
|
|
99
101
|
__exportStar(require("./loop_group_by"), exports);
|
|
102
|
+
__exportStar(require("./loop_target"), exports);
|
|
100
103
|
__exportStar(require("./macro_name"), exports);
|
|
101
104
|
__exportStar(require("./message_class"), exports);
|
|
102
105
|
__exportStar(require("./message_number"), exports);
|
|
@@ -163,10 +166,10 @@ __exportStar(require("./sql_client"), exports);
|
|
|
163
166
|
__exportStar(require("./sql_compare_operator"), exports);
|
|
164
167
|
__exportStar(require("./sql_compare"), exports);
|
|
165
168
|
__exportStar(require("./sql_cond"), exports);
|
|
166
|
-
__exportStar(require("./sql_field"), exports);
|
|
167
169
|
__exportStar(require("./sql_field_list_loop"), exports);
|
|
168
170
|
__exportStar(require("./sql_field_list"), exports);
|
|
169
171
|
__exportStar(require("./sql_field_name"), exports);
|
|
172
|
+
__exportStar(require("./sql_field"), exports);
|
|
170
173
|
__exportStar(require("./sql_for_all_entries"), exports);
|
|
171
174
|
__exportStar(require("./sql_from_source"), exports);
|
|
172
175
|
__exportStar(require("./sql_from"), exports);
|
|
@@ -3,18 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LoopGroupBy = void 0;
|
|
4
4
|
const combi_1 = require("../combi");
|
|
5
5
|
const tokens_1 = require("../../1_lexer/tokens");
|
|
6
|
-
const component_name_1 = require("./component_name");
|
|
7
|
-
const component_compare_1 = require("./component_compare");
|
|
8
|
-
const target_1 = require("./target");
|
|
9
|
-
const fstarget_1 = require("./fstarget");
|
|
10
6
|
const source_1 = require("./source");
|
|
7
|
+
const loop_group_by_target_1 = require("./loop_group_by_target");
|
|
8
|
+
const loop_group_by_component_1 = require("./loop_group_by_component");
|
|
11
9
|
class LoopGroupBy extends combi_1.Expression {
|
|
12
10
|
getRunnable() {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const groupSize = (0, combi_1.seq)(component_name_1.ComponentName, "=", "GROUP SIZE");
|
|
16
|
-
const components = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), (0, combi_1.plus)((0, combi_1.alt)(component_compare_1.ComponentCompare, groupSize)), (0, combi_1.tok)(tokens_1.WParenRightW));
|
|
17
|
-
const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)("ASCENDING"), (0, combi_1.optPrio)("WITHOUT MEMBERS"), (0, combi_1.optPrio)((0, combi_1.alt)(into, assigning)));
|
|
11
|
+
const components = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), (0, combi_1.plus)(loop_group_by_component_1.LoopGroupByComponent), (0, combi_1.tok)(tokens_1.WParenRightW));
|
|
12
|
+
const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)("ASCENDING"), (0, combi_1.optPrio)("WITHOUT MEMBERS"), loop_group_by_target_1.LoopGroupByTarget);
|
|
18
13
|
return ret;
|
|
19
14
|
}
|
|
20
15
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoopGroupByComponent = void 0;
|
|
4
|
+
const combi_1 = require("../combi");
|
|
5
|
+
const component_name_1 = require("./component_name");
|
|
6
|
+
const component_compare_simple_1 = require("./component_compare_simple");
|
|
7
|
+
class LoopGroupByComponent extends combi_1.Expression {
|
|
8
|
+
getRunnable() {
|
|
9
|
+
const groupSize = (0, combi_1.seq)(component_name_1.ComponentName, "=", "GROUP SIZE");
|
|
10
|
+
const components = (0, combi_1.alt)(component_compare_simple_1.ComponentCompareSimple, groupSize);
|
|
11
|
+
return components;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.LoopGroupByComponent = LoopGroupByComponent;
|
|
15
|
+
//# sourceMappingURL=loop_group_by_component.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoopGroupByTarget = void 0;
|
|
4
|
+
const combi_1 = require("../combi");
|
|
5
|
+
const target_1 = require("./target");
|
|
6
|
+
const fstarget_1 = require("./fstarget");
|
|
7
|
+
class LoopGroupByTarget extends combi_1.Expression {
|
|
8
|
+
getRunnable() {
|
|
9
|
+
const into = (0, combi_1.seq)((0, combi_1.opt)("REFERENCE"), "INTO", target_1.Target);
|
|
10
|
+
const assigning = (0, combi_1.seq)("ASSIGNING", fstarget_1.FSTarget);
|
|
11
|
+
return (0, combi_1.optPrio)((0, combi_1.alt)(into, assigning));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.LoopGroupByTarget = LoopGroupByTarget;
|
|
15
|
+
//# sourceMappingURL=loop_group_by_target.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoopTarget = void 0;
|
|
4
|
+
const combi_1 = require("../combi");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
class LoopTarget extends combi_1.Expression {
|
|
7
|
+
getRunnable() {
|
|
8
|
+
const into = (0, combi_1.seq)((0, combi_1.opt)("REFERENCE"), "INTO", _1.Target);
|
|
9
|
+
const assigning = (0, combi_1.seq)("ASSIGNING", _1.FSTarget);
|
|
10
|
+
const target = (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.alt)(into, assigning), (0, combi_1.optPrio)("CASTING")), "TRANSPORTING NO FIELDS");
|
|
11
|
+
return target;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.LoopTarget = LoopTarget;
|
|
15
|
+
//# sourceMappingURL=loop_target.js.map
|
|
@@ -9,14 +9,11 @@ const loop_group_by_1 = require("../expressions/loop_group_by");
|
|
|
9
9
|
class Loop {
|
|
10
10
|
getMatcher() {
|
|
11
11
|
const where = (0, combi_1.seq)("WHERE", (0, combi_1.alt)(expressions_1.ComponentCond, expressions_1.Dynamic));
|
|
12
|
-
const into = (0, combi_1.seq)((0, combi_1.opt)("REFERENCE"), "INTO", expressions_1.Target);
|
|
13
|
-
const assigning = (0, combi_1.seq)("ASSIGNING", expressions_1.FSTarget);
|
|
14
12
|
const group = (0, combi_1.ver)(version_1.Version.v740sp08, (0, combi_1.seq)("GROUP BY", loop_group_by_1.LoopGroupBy));
|
|
15
|
-
const target = (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.alt)(into, assigning), (0, combi_1.optPrio)("CASTING")), "TRANSPORTING NO FIELDS");
|
|
16
13
|
const from = (0, combi_1.seq)("FROM", expressions_1.Source);
|
|
17
14
|
const to = (0, combi_1.seq)("TO", expressions_1.Source);
|
|
18
15
|
const usingKey = (0, combi_1.seq)("USING KEY", (0, combi_1.altPrio)(expressions_1.SimpleName, expressions_1.Dynamic));
|
|
19
|
-
const options = (0, combi_1.per)(
|
|
16
|
+
const options = (0, combi_1.per)(expressions_1.LoopTarget, from, to, where, usingKey, group);
|
|
20
17
|
const at = (0, combi_1.seq)("AT", (0, combi_1.opt)((0, combi_1.seq)("SCREEN", (0, combi_1.fail)())), (0, combi_1.opt)((0, combi_1.ver)(version_1.Version.v740sp08, "GROUP")), (0, combi_1.alt)(simple_source2_1.SimpleSource2, (0, combi_1.ver)(version_1.Version.v740sp02, expressions_1.Source)), (0, combi_1.opt)(options));
|
|
21
18
|
return (0, combi_1.seq)("LOOP", (0, combi_1.opt)(at));
|
|
22
19
|
}
|
|
@@ -24,6 +24,7 @@ class BasicTypes {
|
|
|
24
24
|
}
|
|
25
25
|
lookupQualifiedName(name) {
|
|
26
26
|
var _a;
|
|
27
|
+
// argh, todo, rewrite this entire method
|
|
27
28
|
if (name === undefined) {
|
|
28
29
|
return undefined;
|
|
29
30
|
}
|
|
@@ -43,6 +44,21 @@ class BasicTypes {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
}
|
|
47
|
+
else if (name.includes("-")) {
|
|
48
|
+
const split = name.split("-");
|
|
49
|
+
const typeName = split[0];
|
|
50
|
+
const fieldName = split[1];
|
|
51
|
+
const type = this.scope.findType(typeName);
|
|
52
|
+
if (type) {
|
|
53
|
+
const stru = type.getType();
|
|
54
|
+
if (stru instanceof basic_1.StructureType) {
|
|
55
|
+
const f = stru.getComponentByName(fieldName);
|
|
56
|
+
if (f) {
|
|
57
|
+
return new _typed_identifier_1.TypedIdentifier(type.getToken(), type.getFilename(), f);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
46
62
|
const lookup = this.scope.getDDIC().lookupNoVoid(name);
|
|
47
63
|
const id = (_a = lookup === null || lookup === void 0 ? void 0 : lookup.object) === null || _a === void 0 ? void 0 : _a.getIdentifier();
|
|
48
64
|
if (id && (lookup === null || lookup === void 0 ? void 0 : lookup.type)) {
|
|
@@ -193,7 +209,7 @@ class BasicTypes {
|
|
|
193
209
|
}
|
|
194
210
|
return undefined;
|
|
195
211
|
}
|
|
196
|
-
simpleType(node,
|
|
212
|
+
simpleType(node, qualifiedNamePrefix) {
|
|
197
213
|
let nameExpr = node.findFirstExpression(Expressions.NamespaceSimpleName);
|
|
198
214
|
if (nameExpr === undefined) {
|
|
199
215
|
nameExpr = node.findFirstExpression(Expressions.DefinitionName);
|
|
@@ -211,15 +227,15 @@ class BasicTypes {
|
|
|
211
227
|
qualifiedName = name.getStr();
|
|
212
228
|
}
|
|
213
229
|
else {
|
|
214
|
-
qualifiedName = name.getStr();
|
|
230
|
+
qualifiedName = (qualifiedNamePrefix || "") + name.getStr();
|
|
215
231
|
if (this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition
|
|
216
232
|
|| this.scope.getType() === _scope_type_1.ScopeType.Interface) {
|
|
217
233
|
qualifiedName = this.scope.getName() + "=>" + qualifiedName;
|
|
218
234
|
}
|
|
219
235
|
}
|
|
220
236
|
}
|
|
221
|
-
if (
|
|
222
|
-
qualifiedName =
|
|
237
|
+
else if (qualifiedNamePrefix) {
|
|
238
|
+
qualifiedName = qualifiedNamePrefix + qualifiedName;
|
|
223
239
|
}
|
|
224
240
|
const found = this.parseType(node, qualifiedName);
|
|
225
241
|
if (found) {
|
|
@@ -10,10 +10,8 @@ const target_1 = require("./target");
|
|
|
10
10
|
class LoopGroupBy {
|
|
11
11
|
runSyntax(node, scope, filename) {
|
|
12
12
|
const components = [];
|
|
13
|
-
for (const c of node.findDirectExpressions(Expressions.
|
|
14
|
-
|
|
15
|
-
components.push({ name: f.getFirstToken().getStr(), type: new basic_1.VoidType("todoGroupBy") });
|
|
16
|
-
}
|
|
13
|
+
for (const c of node.findDirectExpressions(Expressions.LoopGroupByComponent)) {
|
|
14
|
+
components.push({ name: c.getFirstToken().getStr(), type: new basic_1.VoidType("todoGroupBy") });
|
|
17
15
|
}
|
|
18
16
|
if (components.length === 0) {
|
|
19
17
|
return;
|
|
@@ -32,8 +30,10 @@ class LoopGroupBy {
|
|
|
32
30
|
if (inlinefs) {
|
|
33
31
|
new inline_fs_1.InlineFS().runSyntax(inlinefs, scope, filename, sourceType);
|
|
34
32
|
}
|
|
35
|
-
for (const
|
|
36
|
-
|
|
33
|
+
for (const c of node.findDirectExpressions(Expressions.LoopGroupByComponent)) {
|
|
34
|
+
for (const t of c.findDirectExpressions(Expressions.ComponentCompareSimple)) {
|
|
35
|
+
new component_compare_1.ComponentCompare().runSyntax(t, scope, filename);
|
|
36
|
+
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -6,8 +6,9 @@ const basic_types_1 = require("../basic_types");
|
|
|
6
6
|
const Expressions = require("../../2_statements/expressions");
|
|
7
7
|
const basic_1 = require("../../types/basic");
|
|
8
8
|
const _scope_type_1 = require("../_scope_type");
|
|
9
|
+
const type_table_key_1 = require("./type_table_key");
|
|
9
10
|
class TypeTable {
|
|
10
|
-
runSyntax(node, scope, filename) {
|
|
11
|
+
runSyntax(node, scope, filename, qualifiedNamePrefix) {
|
|
11
12
|
// todo, input is currently the statement, but should be the expression?
|
|
12
13
|
let nameExpr = node.findFirstExpression(Expressions.DefinitionName);
|
|
13
14
|
if (nameExpr === undefined) {
|
|
@@ -17,18 +18,24 @@ class TypeTable {
|
|
|
17
18
|
return undefined;
|
|
18
19
|
}
|
|
19
20
|
const name = nameExpr.getFirstToken();
|
|
20
|
-
let qualifiedName = "";
|
|
21
|
+
let qualifiedName = qualifiedNamePrefix || "";
|
|
21
22
|
if (node.getFirstToken().getStr().toUpperCase() === "TYPES") {
|
|
22
|
-
qualifiedName = name.getStr();
|
|
23
|
+
qualifiedName = qualifiedName + name.getStr();
|
|
23
24
|
if (scope.getType() === _scope_type_1.ScopeType.ClassDefinition
|
|
24
25
|
|| scope.getType() === _scope_type_1.ScopeType.Interface) {
|
|
25
26
|
qualifiedName = scope.getName() + "=>" + qualifiedName;
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
let type = new basic_types_1.BasicTypes(filename, scope).parseTable(node, qualifiedName);
|
|
29
30
|
if (type === undefined) {
|
|
30
31
|
return new _typed_identifier_1.TypedIdentifier(name, filename, new basic_1.UnknownType("TableType, fallback"));
|
|
31
32
|
}
|
|
33
|
+
for (const tt of node.findAllExpressions(Expressions.TypeTableKey)) {
|
|
34
|
+
const error = new type_table_key_1.TypeTableKey().runSyntax(tt, type);
|
|
35
|
+
if (error) {
|
|
36
|
+
type = error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
32
39
|
return new _typed_identifier_1.TypedIdentifier(name, filename, type);
|
|
33
40
|
}
|
|
34
41
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeTableKey = void 0;
|
|
4
|
+
const Expressions = require("../../2_statements/expressions");
|
|
5
|
+
const basic_1 = require("../../types/basic");
|
|
6
|
+
class TypeTableKey {
|
|
7
|
+
runSyntax(node, type) {
|
|
8
|
+
if (type instanceof basic_1.TableType) {
|
|
9
|
+
const rowType = type.getRowType();
|
|
10
|
+
if (rowType instanceof basic_1.StructureType) {
|
|
11
|
+
for (const c of node.findAllExpressions(Expressions.FieldSub)) {
|
|
12
|
+
const concat = c.concatTokens();
|
|
13
|
+
if (concat.includes("-") === false // todo, properly check sub fields
|
|
14
|
+
&& rowType.getComponentByName(concat) === undefined
|
|
15
|
+
&& concat.toUpperCase() !== "TABLE_LINE") {
|
|
16
|
+
return new basic_1.UnknownType(`Field ${concat} not part of structure`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.TypeTableKey = TypeTableKey;
|
|
25
|
+
//# sourceMappingURL=type_table_key.js.map
|
|
@@ -14,7 +14,8 @@ const dynamic_1 = require("../expressions/dynamic");
|
|
|
14
14
|
const loop_group_by_1 = require("../expressions/loop_group_by");
|
|
15
15
|
class Loop {
|
|
16
16
|
runSyntax(node, scope, filename) {
|
|
17
|
-
|
|
17
|
+
const loopTarget = node.findDirectExpression(Expressions.LoopTarget);
|
|
18
|
+
let target = loopTarget === null || loopTarget === void 0 ? void 0 : loopTarget.findDirectExpression(Expressions.Target);
|
|
18
19
|
const targetType = target ? new target_1.Target().runSyntax(target, scope, filename) : undefined;
|
|
19
20
|
if (target === undefined) {
|
|
20
21
|
target = node.findDirectExpression(Expressions.FSTarget);
|
|
@@ -58,7 +59,7 @@ class Loop {
|
|
|
58
59
|
new inline_fs_1.InlineFS().runSyntax(inlinefs, scope, filename, sourceType);
|
|
59
60
|
}
|
|
60
61
|
else {
|
|
61
|
-
const fstarget =
|
|
62
|
+
const fstarget = loopTarget === null || loopTarget === void 0 ? void 0 : loopTarget.findDirectExpression(Expressions.FSTarget);
|
|
62
63
|
if (fstarget) {
|
|
63
64
|
new fstarget_1.FSTarget().runSyntax(fstarget, scope, filename, sourceType);
|
|
64
65
|
}
|
|
@@ -7,12 +7,12 @@ const basic_1 = require("../../types/basic");
|
|
|
7
7
|
const Expressions = require("../../2_statements/expressions");
|
|
8
8
|
const type_table_1 = require("../expressions/type_table");
|
|
9
9
|
class Type {
|
|
10
|
-
runSyntax(node, scope, filename,
|
|
10
|
+
runSyntax(node, scope, filename, qualifiedNamePrefix) {
|
|
11
11
|
const tt = node.findFirstExpression(Expressions.TypeTable);
|
|
12
12
|
if (tt) {
|
|
13
|
-
return new type_table_1.TypeTable().runSyntax(node, scope, filename);
|
|
13
|
+
return new type_table_1.TypeTable().runSyntax(node, scope, filename, qualifiedNamePrefix);
|
|
14
14
|
}
|
|
15
|
-
const found = new basic_types_1.BasicTypes(filename, scope).simpleType(node,
|
|
15
|
+
const found = new basic_types_1.BasicTypes(filename, scope).simpleType(node, qualifiedNamePrefix);
|
|
16
16
|
if (found) {
|
|
17
17
|
return found;
|
|
18
18
|
}
|
|
@@ -20,7 +20,7 @@ class Types {
|
|
|
20
20
|
const ctyp = c.get();
|
|
21
21
|
if (c instanceof nodes_1.StatementNode) {
|
|
22
22
|
if (ctyp instanceof Statements.Type) {
|
|
23
|
-
const found = new type_1.Type().runSyntax(c, scope, filename,
|
|
23
|
+
const found = new type_1.Type().runSyntax(c, scope, filename, name.getStr() + "-");
|
|
24
24
|
if (found) {
|
|
25
25
|
components.push({ name: found.getName(), type: found.getType() });
|
|
26
26
|
}
|
package/build/src/registry.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Downport = exports.DownportConf = void 0;
|
|
4
|
+
/* eslint-disable max-len */
|
|
4
5
|
const Statements = require("../abap/2_statements/statements");
|
|
5
6
|
const Expressions = require("../abap/2_statements/expressions");
|
|
6
7
|
const Structures = require("../abap/3_structures/structures");
|
|
@@ -208,6 +209,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
208
209
|
if (found) {
|
|
209
210
|
return found;
|
|
210
211
|
}
|
|
212
|
+
found = this.downportLoopGroup(high, lowFile, highSyntax, highFile);
|
|
213
|
+
if (found) {
|
|
214
|
+
return found;
|
|
215
|
+
}
|
|
211
216
|
found = this.callFunctionParameterSimple(high, lowFile, highSyntax);
|
|
212
217
|
if (found) {
|
|
213
218
|
return found;
|
|
@@ -860,6 +865,87 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
|
|
|
860
865
|
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
|
|
861
866
|
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, simple REF move", this.getMetadata().key, this.conf.severity, fix);
|
|
862
867
|
}
|
|
868
|
+
downportLoopGroup(high, lowFile, highSyntax, highFile) {
|
|
869
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
870
|
+
if (!(high.get() instanceof Statements.Loop)) {
|
|
871
|
+
return undefined;
|
|
872
|
+
}
|
|
873
|
+
const group = high.findDirectExpression(Expressions.LoopGroupBy);
|
|
874
|
+
if (group === undefined) {
|
|
875
|
+
return undefined;
|
|
876
|
+
}
|
|
877
|
+
const groupTargetName = ((_a = group.findFirstExpression(Expressions.TargetField)) === null || _a === void 0 ? void 0 : _a.concatTokens()) || "nameNotFound";
|
|
878
|
+
const loopSourceName = ((_b = high.findFirstExpression(Expressions.SimpleSource2)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "nameNotFound";
|
|
879
|
+
const loopTargetName = ((_c = high.findFirstExpression(Expressions.TargetField)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "nameNotFound";
|
|
880
|
+
const groupTarget = ((_d = group.findDirectExpression(Expressions.LoopGroupByTarget)) === null || _d === void 0 ? void 0 : _d.concatTokens()) || "";
|
|
881
|
+
let loopSourceRowType = "typeNotFound";
|
|
882
|
+
const spag = highSyntax.spaghetti.lookupPosition(high.getFirstToken().getStart(), lowFile.getFilename());
|
|
883
|
+
if (spag !== undefined) {
|
|
884
|
+
const found = spag.findVariable(loopSourceName);
|
|
885
|
+
const tt = found === null || found === void 0 ? void 0 : found.getType();
|
|
886
|
+
if (tt instanceof basic_1.TableType) {
|
|
887
|
+
loopSourceRowType = tt.getRowType().getQualifiedName() || "typeNotFound";
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
let code = `TYPES: BEGIN OF ${groupTargetName}type,\n`;
|
|
891
|
+
let condition = "";
|
|
892
|
+
let groupCountName = undefined;
|
|
893
|
+
for (const c of group.findAllExpressions(Expressions.LoopGroupByComponent)) {
|
|
894
|
+
const name = c.findFirstExpression(Expressions.ComponentName);
|
|
895
|
+
let type = ((_e = c.findFirstExpression(Expressions.Source)) === null || _e === void 0 ? void 0 : _e.concatTokens()) || "todo";
|
|
896
|
+
if ((_f = c.concatTokens()) === null || _f === void 0 ? void 0 : _f.toUpperCase().endsWith(" = GROUP SIZE")) {
|
|
897
|
+
type = "i";
|
|
898
|
+
groupCountName = name === null || name === void 0 ? void 0 : name.concatTokens();
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
condition += c.concatTokens();
|
|
902
|
+
type = type.replace(loopTargetName, loopSourceRowType);
|
|
903
|
+
type = type.replace("->", "-");
|
|
904
|
+
}
|
|
905
|
+
code += ` ${name === null || name === void 0 ? void 0 : name.concatTokens()} TYPE ${type},\n`;
|
|
906
|
+
}
|
|
907
|
+
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
908
|
+
const uniqueFS = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
909
|
+
code += ` items LIKE ${loopSourceName},
|
|
910
|
+
END OF ${groupTargetName}type.
|
|
911
|
+
DATA ${groupTargetName}tab TYPE STANDARD TABLE OF ${groupTargetName}type WITH DEFAULT KEY.
|
|
912
|
+
DATA ${uniqueName} LIKE LINE OF ${groupTargetName}tab.
|
|
913
|
+
LOOP AT ${loopSourceName} ${(_g = high.findFirstExpression(Expressions.LoopTarget)) === null || _g === void 0 ? void 0 : _g.concatTokens()}.
|
|
914
|
+
READ TABLE ${groupTargetName}tab ASSIGNING FIELD-SYMBOL(<${uniqueFS}>) WITH KEY ${condition}.
|
|
915
|
+
IF sy-subrc = 0.
|
|
916
|
+
<${uniqueFS}>-${groupCountName} = <${uniqueFS}>-${groupCountName} + 1.
|
|
917
|
+
INSERT ${loopTargetName}->* INTO TABLE <${uniqueFS}>-items.
|
|
918
|
+
ELSE.\n`;
|
|
919
|
+
code += ` CLEAR ${uniqueName}.\n`;
|
|
920
|
+
for (const c of group.findAllExpressions(Expressions.LoopGroupByComponent)) {
|
|
921
|
+
code += ` ${uniqueName}-${c.concatTokens().replace("GROUP SIZE", "1")}.\n`;
|
|
922
|
+
}
|
|
923
|
+
code += ` INSERT ${loopTargetName}->* INTO TABLE ${uniqueName}-items.\n`;
|
|
924
|
+
code += ` INSERT ${uniqueName} INTO TABLE ${groupTargetName}tab.\n`;
|
|
925
|
+
code += `ENDIF.
|
|
926
|
+
ENDLOOP.
|
|
927
|
+
LOOP AT ${groupTargetName}tab ${groupTarget}.`;
|
|
928
|
+
let fix = edit_helper_1.EditHelper.replaceRange(lowFile, high.getFirstToken().getStart(), high.getLastToken().getEnd(), code);
|
|
929
|
+
for (const l of ((_h = highFile.getStructure()) === null || _h === void 0 ? void 0 : _h.findAllStructures(Structures.Loop)) || []) {
|
|
930
|
+
// make sure to find the correct/current loop statement
|
|
931
|
+
if (l.findDirectStatement(Statements.Loop) !== high) {
|
|
932
|
+
continue;
|
|
933
|
+
}
|
|
934
|
+
for (const loop of l.findAllStatements(Statements.Loop)) {
|
|
935
|
+
if ((_j = loop.concatTokens()) === null || _j === void 0 ? void 0 : _j.toUpperCase().startsWith("LOOP AT GROUP ")) {
|
|
936
|
+
const subLoopSource = loop.findFirstExpression(Expressions.SimpleSource2);
|
|
937
|
+
if (subLoopSource === undefined) {
|
|
938
|
+
continue;
|
|
939
|
+
}
|
|
940
|
+
const subLoopSourceName = (subLoopSource === null || subLoopSource === void 0 ? void 0 : subLoopSource.concatTokens()) || "nameNotFound";
|
|
941
|
+
const subCode = `LOOP AT ${subLoopSourceName}->items`;
|
|
942
|
+
const subFix = edit_helper_1.EditHelper.replaceRange(lowFile, loop.getFirstToken().getStart(), subLoopSource.getLastToken().getEnd(), subCode);
|
|
943
|
+
fix = edit_helper_1.EditHelper.merge(subFix, fix);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, LOOP GROUP", this.getMetadata().key, this.conf.severity, fix);
|
|
948
|
+
}
|
|
863
949
|
downportRef(high, lowFile, highSyntax) {
|
|
864
950
|
let found = undefined;
|
|
865
951
|
for (const s of high.findAllExpressionsRecursive(Expressions.Source)) {
|
|
@@ -1111,7 +1197,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1111
1197
|
return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Outline LOOP input", this.getMetadata().key, this.conf.severity, fix);
|
|
1112
1198
|
}
|
|
1113
1199
|
outlineLoopTarget(node, lowFile, _highSyntax) {
|
|
1114
|
-
var _a, _b, _c, _d, _e;
|
|
1200
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1115
1201
|
// also allows outlining of voided types
|
|
1116
1202
|
if (!(node.get() instanceof Statements.Loop)) {
|
|
1117
1203
|
return undefined;
|
|
@@ -1125,18 +1211,18 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1125
1211
|
return undefined;
|
|
1126
1212
|
}
|
|
1127
1213
|
const indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
|
|
1128
|
-
const dataTarget = (_b = node.findDirectExpression(Expressions.
|
|
1214
|
+
const dataTarget = (_c = (_b = node.findDirectExpression(Expressions.LoopTarget)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.Target)) === null || _c === void 0 ? void 0 : _c.findDirectExpression(Expressions.InlineData);
|
|
1129
1215
|
if (dataTarget) {
|
|
1130
|
-
const targetName = ((
|
|
1216
|
+
const targetName = ((_d = dataTarget.findDirectExpression(Expressions.TargetField)) === null || _d === void 0 ? void 0 : _d.concatTokens()) || "DOWNPORT_ERROR";
|
|
1131
1217
|
const code = `DATA ${targetName} LIKE LINE OF ${sourceName}.\n${indentation}`;
|
|
1132
1218
|
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
|
|
1133
1219
|
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, dataTarget.getFirstToken().getStart(), dataTarget.getLastToken().getEnd(), targetName);
|
|
1134
1220
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
1135
1221
|
return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Outline LOOP data target", this.getMetadata().key, this.conf.severity, fix);
|
|
1136
1222
|
}
|
|
1137
|
-
const fsTarget = (
|
|
1223
|
+
const fsTarget = (_f = (_e = node.findDirectExpression(Expressions.LoopTarget)) === null || _e === void 0 ? void 0 : _e.findDirectExpression(Expressions.FSTarget)) === null || _f === void 0 ? void 0 : _f.findDirectExpression(Expressions.InlineFS);
|
|
1138
1224
|
if (fsTarget) {
|
|
1139
|
-
const targetName = ((
|
|
1225
|
+
const targetName = ((_g = fsTarget.findDirectExpression(Expressions.TargetFieldSymbol)) === null || _g === void 0 ? void 0 : _g.concatTokens()) || "DOWNPORT_ERROR";
|
|
1140
1226
|
const code = `FIELD-SYMBOLS ${targetName} LIKE LINE OF ${sourceName}.\n${indentation}`;
|
|
1141
1227
|
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
|
|
1142
1228
|
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, fsTarget.getFirstToken().getStart(), fsTarget.getLastToken().getEnd(), targetName);
|