@abaplint/core 2.91.27 → 2.91.30

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.
@@ -209,6 +209,10 @@ declare class AssignmentServiceToAuthorizationGroup extends AbstractObject {
209
209
  getDescription(): string | undefined;
210
210
  }
211
211
 
212
+ declare class AssignSource extends Expression {
213
+ getRunnable(): IStatementRunnable;
214
+ }
215
+
212
216
  declare class AssociationName extends Expression {
213
217
  getRunnable(): IStatementRunnable;
214
218
  }
@@ -1799,6 +1803,7 @@ declare namespace Expressions {
1799
1803
  Cast,
1800
1804
  ClassFinal,
1801
1805
  ClassFriends,
1806
+ AssignSource,
1802
1807
  ClassGlobal_2 as ClassGlobal,
1803
1808
  ClassName,
1804
1809
  Color,
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AssignSource = void 0;
4
+ const combi_1 = require("../combi");
5
+ const tokens_1 = require("../../1_lexer/tokens");
6
+ const source_1 = require("./source");
7
+ const dynamic_1 = require("./dynamic");
8
+ const field_1 = require("./field");
9
+ class AssignSource extends combi_1.Expression {
10
+ getRunnable() {
11
+ const component = (0, combi_1.seq)("COMPONENT", source_1.Source, "OF STRUCTURE", source_1.Source);
12
+ const tableField = (0, combi_1.seq)("TABLE FIELD", (0, combi_1.alt)(source_1.Source, dynamic_1.Dynamic));
13
+ const arrow = (0, combi_1.alt)((0, combi_1.tok)(tokens_1.InstanceArrow), (0, combi_1.tok)(tokens_1.StaticArrow));
14
+ const source = (0, combi_1.alt)((0, combi_1.seq)(source_1.Source, (0, combi_1.opt)((0, combi_1.seq)(arrow, dynamic_1.Dynamic))), component, tableField, (0, combi_1.seq)(dynamic_1.Dynamic, (0, combi_1.opt)((0, combi_1.seq)(arrow, (0, combi_1.alt)(field_1.Field, dynamic_1.Dynamic)))));
15
+ return source;
16
+ }
17
+ }
18
+ exports.AssignSource = AssignSource;
19
+ //# sourceMappingURL=assign_source.js.map
@@ -29,6 +29,7 @@ __exportStar(require("./call_transformation_parameters"), exports);
29
29
  __exportStar(require("./cast"), exports);
30
30
  __exportStar(require("./class_final"), exports);
31
31
  __exportStar(require("./class_friends"), exports);
32
+ __exportStar(require("./assign_source"), exports);
32
33
  __exportStar(require("./class_global"), exports);
33
34
  __exportStar(require("./class_name"), exports);
34
35
  __exportStar(require("./color"), exports);
@@ -2,14 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Assign = void 0;
4
4
  const combi_1 = require("../combi");
5
- const tokens_1 = require("../../1_lexer/tokens");
6
5
  const expressions_1 = require("../expressions");
7
6
  class Assign {
8
7
  getMatcher() {
9
- const component = (0, combi_1.seq)("COMPONENT", expressions_1.Source, "OF STRUCTURE", expressions_1.Source);
10
- const tableField = (0, combi_1.seq)("TABLE FIELD", (0, combi_1.alt)(expressions_1.Source, expressions_1.Dynamic));
11
- const arrow = (0, combi_1.alt)((0, combi_1.tok)(tokens_1.InstanceArrow), (0, combi_1.tok)(tokens_1.StaticArrow));
12
- const source = (0, combi_1.alt)((0, combi_1.seq)(expressions_1.Source, (0, combi_1.opt)((0, combi_1.seq)(arrow, expressions_1.Dynamic))), component, tableField, (0, combi_1.seq)(expressions_1.Dynamic, (0, combi_1.opt)((0, combi_1.seq)(arrow, (0, combi_1.alt)(expressions_1.Field, expressions_1.Dynamic)))));
13
8
  const type = (0, combi_1.seq)("TYPE", (0, combi_1.alt)(expressions_1.Dynamic, expressions_1.TypeName));
14
9
  const like = (0, combi_1.seq)("LIKE", (0, combi_1.alt)(expressions_1.Dynamic, expressions_1.Source));
15
10
  const handle = (0, combi_1.seq)("TYPE HANDLE", expressions_1.Source);
@@ -17,7 +12,7 @@ class Assign {
17
12
  const decimals = (0, combi_1.seq)("DECIMALS", expressions_1.Source);
18
13
  const casting = (0, combi_1.seq)("CASTING", (0, combi_1.opt)((0, combi_1.alt)(like, handle, (0, combi_1.per)(type, decimals))));
19
14
  const obsoleteType = (0, combi_1.seq)("TYPE", expressions_1.Source, (0, combi_1.optPrio)(decimals));
20
- const ret = (0, combi_1.seq)("ASSIGN", (0, combi_1.opt)((0, combi_1.seq)(expressions_1.Target, "INCREMENT")), source, "TO", expressions_1.FSTarget, (0, combi_1.opt)((0, combi_1.altPrio)(casting, obsoleteType)), (0, combi_1.opt)(range));
15
+ const ret = (0, combi_1.seq)("ASSIGN", (0, combi_1.opt)((0, combi_1.seq)(expressions_1.Target, "INCREMENT")), expressions_1.AssignSource, "TO", expressions_1.FSTarget, (0, combi_1.opt)((0, combi_1.altPrio)(casting, obsoleteType)), (0, combi_1.opt)(range));
21
16
  return ret;
22
17
  }
23
18
  }
@@ -6,6 +6,7 @@ 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
11
  runSyntax(node, scope, filename, qualifiedNamePrefix) {
11
12
  // todo, input is currently the statement, but should be the expression?
@@ -25,10 +26,16 @@ class TypeTable {
25
26
  qualifiedName = scope.getName() + "=>" + qualifiedName;
26
27
  }
27
28
  }
28
- const type = new basic_types_1.BasicTypes(filename, scope).parseTable(node, qualifiedName);
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
@@ -8,13 +8,14 @@ const dynamic_1 = require("../expressions/dynamic");
8
8
  const basic_1 = require("../../types/basic");
9
9
  class Assign {
10
10
  runSyntax(node, scope, filename) {
11
- const sources = node.findDirectExpressions(Expressions.Source);
11
+ var _a, _b;
12
+ const sources = node.findAllExpressions(Expressions.Source);
12
13
  const firstSource = sources[0];
13
14
  let sourceType = new source_1.Source().runSyntax(firstSource, scope, filename);
14
- if (sourceType === undefined || node.findDirectExpression(Expressions.Dynamic)) {
15
+ if (sourceType === undefined || ((_a = node.findDirectExpression(Expressions.AssignSource)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Dynamic))) {
15
16
  sourceType = new basic_1.VoidType("DynamicAssign");
16
17
  }
17
- for (const d of node.findAllExpressions(Expressions.Dynamic)) {
18
+ for (const d of ((_b = node.findDirectExpression(Expressions.AssignSource)) === null || _b === void 0 ? void 0 : _b.findAllExpressions(Expressions.Dynamic)) || []) {
18
19
  new dynamic_1.Dynamic().runSyntax(d, scope, filename);
19
20
  }
20
21
  const target = node.findDirectExpression(Expressions.FSTarget);
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.91.27";
71
+ return "2.91.30";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -201,6 +201,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
201
201
  if (found) {
202
202
  return found;
203
203
  }
204
+ found = this.assignWithTable(high, lowFile);
205
+ if (found) {
206
+ return found;
207
+ }
204
208
  found = this.downportRefSimple(high, lowFile);
205
209
  if (found) {
206
210
  return found;
@@ -916,6 +920,7 @@ IF sy-subrc = 0.
916
920
  <${uniqueFS}>-${groupCountName} = <${uniqueFS}>-${groupCountName} + 1.
917
921
  INSERT ${loopTargetName}->* INTO TABLE <${uniqueFS}>-items.
918
922
  ELSE.\n`;
923
+ code += ` CLEAR ${uniqueName}.\n`;
919
924
  for (const c of group.findAllExpressions(Expressions.LoopGroupByComponent)) {
920
925
  code += ` ${uniqueName}-${c.concatTokens().replace("GROUP SIZE", "1")}.\n`;
921
926
  }
@@ -963,6 +968,30 @@ LOOP AT ${groupTargetName}tab ${groupTarget}.`;
963
968
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
964
969
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, REF", this.getMetadata().key, this.conf.severity, fix);
965
970
  }
971
+ assignWithTable(high, lowFile) {
972
+ var _a, _b;
973
+ if (!(high.get() instanceof Statements.Assign)
974
+ || high.getChildren().length !== 5) {
975
+ return undefined;
976
+ }
977
+ const fieldChain = (_b = (_a = high.findDirectExpression(Expressions.AssignSource)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Source)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.FieldChain);
978
+ if ((fieldChain === null || fieldChain === void 0 ? void 0 : fieldChain.getChildren().length) !== 2) {
979
+ return undefined;
980
+ }
981
+ const tableExpression = fieldChain === null || fieldChain === void 0 ? void 0 : fieldChain.getChildren()[1];
982
+ if (!(tableExpression.get() instanceof Expressions.TableExpression)
983
+ || !(tableExpression instanceof nodes_1.ExpressionNode)) {
984
+ return undefined;
985
+ }
986
+ const index = tableExpression.findDirectExpression(Expressions.Source);
987
+ if (index === undefined) {
988
+ return undefined;
989
+ }
990
+ const fsTarget = high.findDirectExpression(Expressions.FSTarget);
991
+ const code = `READ TABLE ${fieldChain === null || fieldChain === void 0 ? void 0 : fieldChain.getChildren()[0].concatTokens()} INDEX ${index.concatTokens()} ASSIGNING ${fsTarget === null || fsTarget === void 0 ? void 0 : fsTarget.concatTokens()}.`;
992
+ const fix = edit_helper_1.EditHelper.replaceRange(lowFile, high.getFirstToken().getStart(), high.getLastToken().getEnd(), code);
993
+ return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, ASSIGN table expr", this.getMetadata().key, this.conf.severity, fix);
994
+ }
966
995
  moveWithSimpleValue(high, lowFile) {
967
996
  if (!(high.get() instanceof Statements.Move)
968
997
  || high.getChildren().length !== 4) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.91.27",
3
+ "version": "2.91.30",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -45,10 +45,10 @@
45
45
  },
46
46
  "homepage": "https://abaplint.org",
47
47
  "devDependencies": {
48
- "@microsoft/api-extractor": "^7.29.0",
49
- "@types/chai": "^4.3.1",
48
+ "@microsoft/api-extractor": "^7.29.2",
49
+ "@types/chai": "^4.3.3",
50
50
  "@types/mocha": "^9.1.1",
51
- "@types/node": "^18.6.4",
51
+ "@types/node": "^18.7.2",
52
52
  "chai": "^4.3.6",
53
53
  "eslint": "^8.21.0",
54
54
  "mocha": "^10.0.0",