@abaplint/core 2.91.25 → 2.91.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.
@@ -1866,6 +1866,8 @@ declare namespace Expressions {
1866
1866
  Language,
1867
1867
  Length,
1868
1868
  Let,
1869
+ LoopGroupByComponent,
1870
+ LoopGroupByTarget,
1869
1871
  LoopGroupBy,
1870
1872
  MacroName,
1871
1873
  MessageClass_2 as MessageClass,
@@ -1933,10 +1935,10 @@ declare namespace Expressions {
1933
1935
  SQLCompareOperator,
1934
1936
  SQLCompare,
1935
1937
  SQLCond,
1936
- SQLField,
1937
1938
  SQLFieldListLoop,
1938
1939
  SQLFieldList,
1939
1940
  SQLFieldName,
1941
+ SQLField,
1940
1942
  SQLForAllEntries,
1941
1943
  SQLFromSource,
1942
1944
  SQLFrom,
@@ -3549,6 +3551,14 @@ declare class LoopGroupBy extends Expression {
3549
3551
  getRunnable(): IStatementRunnable;
3550
3552
  }
3551
3553
 
3554
+ declare class LoopGroupByComponent extends Expression {
3555
+ getRunnable(): IStatementRunnable;
3556
+ }
3557
+
3558
+ declare class LoopGroupByTarget extends Expression {
3559
+ getRunnable(): IStatementRunnable;
3560
+ }
3561
+
3552
3562
  declare class MacroName extends Expression {
3553
3563
  getRunnable(): IStatementRunnable;
3554
3564
  }
@@ -96,6 +96,8 @@ __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);
100
102
  __exportStar(require("./macro_name"), exports);
101
103
  __exportStar(require("./message_class"), exports);
@@ -163,10 +165,10 @@ __exportStar(require("./sql_client"), exports);
163
165
  __exportStar(require("./sql_compare_operator"), exports);
164
166
  __exportStar(require("./sql_compare"), exports);
165
167
  __exportStar(require("./sql_cond"), exports);
166
- __exportStar(require("./sql_field"), exports);
167
168
  __exportStar(require("./sql_field_list_loop"), exports);
168
169
  __exportStar(require("./sql_field_list"), exports);
169
170
  __exportStar(require("./sql_field_name"), exports);
171
+ __exportStar(require("./sql_field"), exports);
170
172
  __exportStar(require("./sql_for_all_entries"), exports);
171
173
  __exportStar(require("./sql_from_source"), exports);
172
174
  __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 into = (0, combi_1.seq)((0, combi_1.opt)("REFERENCE"), "INTO", target_1.Target);
14
- const assigning = (0, combi_1.seq)("ASSIGNING", fstarget_1.FSTarget);
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
@@ -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, noQualifiedName) {
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 (noQualifiedName === true) {
222
- qualifiedName = undefined;
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.ComponentCompare)) {
14
- for (const f of c.findDirectExpressions(Expressions.ComponentChainSimple)) {
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 t of node.findDirectExpressions(Expressions.ComponentCompare)) {
36
- new component_compare_1.ComponentCompare().runSyntax(t, scope, filename);
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
  }
@@ -7,7 +7,7 @@ const Expressions = require("../../2_statements/expressions");
7
7
  const basic_1 = require("../../types/basic");
8
8
  const _scope_type_1 = require("../_scope_type");
9
9
  class TypeTable {
10
- runSyntax(node, scope, filename) {
10
+ runSyntax(node, scope, filename, qualifiedNamePrefix) {
11
11
  // todo, input is currently the statement, but should be the expression?
12
12
  let nameExpr = node.findFirstExpression(Expressions.DefinitionName);
13
13
  if (nameExpr === undefined) {
@@ -17,9 +17,9 @@ class TypeTable {
17
17
  return undefined;
18
18
  }
19
19
  const name = nameExpr.getFirstToken();
20
- let qualifiedName = "";
20
+ let qualifiedName = qualifiedNamePrefix || "";
21
21
  if (node.getFirstToken().getStr().toUpperCase() === "TYPES") {
22
- qualifiedName = name.getStr();
22
+ qualifiedName = qualifiedName + name.getStr();
23
23
  if (scope.getType() === _scope_type_1.ScopeType.ClassDefinition
24
24
  || scope.getType() === _scope_type_1.ScopeType.Interface) {
25
25
  qualifiedName = scope.getName() + "=>" + qualifiedName;
@@ -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, noQualifiedName) {
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, noQualifiedName);
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, true);
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
  }
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.91.25";
71
+ return "2.91.26";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -208,6 +208,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
208
208
  if (found) {
209
209
  return found;
210
210
  }
211
+ found = this.downportLoopGroup(high, lowFile, highSyntax, highFile);
212
+ if (found) {
213
+ return found;
214
+ }
211
215
  found = this.callFunctionParameterSimple(high, lowFile, highSyntax);
212
216
  if (found) {
213
217
  return found;
@@ -860,6 +864,67 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
860
864
  const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
861
865
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, simple REF move", this.getMetadata().key, this.conf.severity, fix);
862
866
  }
867
+ downportLoopGroup(high, lowFile, highSyntax, highFile) {
868
+ var _a, _b, _c, _d, _e, _f, _g, _h;
869
+ if (!(high.get() instanceof Statements.Loop)) {
870
+ return undefined;
871
+ }
872
+ const group = high.findDirectExpression(Expressions.LoopGroupBy);
873
+ if (group === undefined) {
874
+ return undefined;
875
+ }
876
+ const groupTargetName = ((_a = group.findFirstExpression(Expressions.TargetField)) === null || _a === void 0 ? void 0 : _a.concatTokens()) || "nameNotFound";
877
+ const loopSourceName = ((_b = high.findFirstExpression(Expressions.SimpleSource2)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "nameNotFound";
878
+ const loopTargetName = ((_c = high.findFirstExpression(Expressions.TargetField)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "nameNotFound";
879
+ const groupTarget = ((_d = group.findDirectExpression(Expressions.LoopGroupByTarget)) === null || _d === void 0 ? void 0 : _d.concatTokens()) || "";
880
+ let loopSourceRowType = "typeNotFound";
881
+ const spag = highSyntax.spaghetti.lookupPosition(high.getFirstToken().getStart(), lowFile.getFilename());
882
+ if (spag !== undefined) {
883
+ const found = spag.findVariable(loopSourceName);
884
+ const tt = found === null || found === void 0 ? void 0 : found.getType();
885
+ if (tt instanceof basic_1.TableType) {
886
+ loopSourceRowType = tt.getRowType().getQualifiedName() || "typeNotFound";
887
+ }
888
+ }
889
+ let code = `TYPES: BEGIN OF ${groupTargetName}#type,\n`;
890
+ for (const c of group.findAllExpressions(Expressions.LoopGroupByComponent)) {
891
+ const name = c.findFirstExpression(Expressions.ComponentName);
892
+ let type = ((_e = c.findFirstExpression(Expressions.Source)) === null || _e === void 0 ? void 0 : _e.concatTokens()) || "todo";
893
+ if ((_f = c.concatTokens()) === null || _f === void 0 ? void 0 : _f.toUpperCase().endsWith(" = GROUP SIZE")) {
894
+ type = "i";
895
+ }
896
+ else {
897
+ type = type.replace(loopTargetName, loopSourceRowType);
898
+ type = type.replace("->", "-");
899
+ }
900
+ code += ` ${name === null || name === void 0 ? void 0 : name.concatTokens()} TYPE ${type},\n`;
901
+ }
902
+ code += ` items LIKE ${loopSourceName},
903
+ END OF ${groupTargetName}#type.
904
+ DATA ${groupTargetName}#tab TYPE STANDARD TABLE OF ${groupTargetName}#type WITH DEFAULT KEY.
905
+ * todo, aggregation code here
906
+ LOOP AT ${groupTargetName}#tab ${groupTarget}.`;
907
+ let fix = edit_helper_1.EditHelper.replaceRange(lowFile, high.getFirstToken().getStart(), high.getLastToken().getEnd(), code);
908
+ for (const l of ((_g = highFile.getStructure()) === null || _g === void 0 ? void 0 : _g.findAllStructures(Structures.Loop)) || []) {
909
+ // make sure to find the correct/current loop statement
910
+ if (l.findDirectStatement(Statements.Loop) !== high) {
911
+ continue;
912
+ }
913
+ for (const loop of l.findAllStatements(Statements.Loop)) {
914
+ if ((_h = loop.concatTokens()) === null || _h === void 0 ? void 0 : _h.toUpperCase().startsWith("LOOP AT GROUP ")) {
915
+ const subLoopSource = loop.findFirstExpression(Expressions.SimpleSource2);
916
+ if (subLoopSource === undefined) {
917
+ continue;
918
+ }
919
+ const subLoopSourceName = (subLoopSource === null || subLoopSource === void 0 ? void 0 : subLoopSource.concatTokens()) || "nameNotFound";
920
+ const subCode = `LOOP AT ${subLoopSourceName}->items`;
921
+ const subFix = edit_helper_1.EditHelper.replaceRange(lowFile, loop.getFirstToken().getStart(), subLoopSource.getLastToken().getEnd(), subCode);
922
+ fix = edit_helper_1.EditHelper.merge(subFix, fix);
923
+ }
924
+ }
925
+ }
926
+ return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, LOOP GROUP", this.getMetadata().key, this.conf.severity, fix);
927
+ }
863
928
  downportRef(high, lowFile, highSyntax) {
864
929
  let found = undefined;
865
930
  for (const s of high.findAllExpressionsRecursive(Expressions.Source)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.91.25",
3
+ "version": "2.91.26",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",