@abaplint/cli 2.120.110 → 2.120.112

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.
Files changed (2) hide show
  1. package/build/cli.js +1355 -91
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -6091,7 +6091,7 @@ const loop_group_by_component_1 = __webpack_require__(/*! ./loop_group_by_compon
6091
6091
  class LoopGroupBy extends combi_1.Expression {
6092
6092
  getRunnable() {
6093
6093
  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));
6094
- 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);
6094
+ const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)((0, combi_1.seq)((0, combi_1.alt)("ASCENDING", "DESCENDING"), (0, combi_1.optPrio)("AS TEXT"))), (0, combi_1.optPrio)("WITHOUT MEMBERS"), loop_group_by_target_1.LoopGroupByTarget);
6095
6095
  return ret;
6096
6096
  }
6097
6097
  }
@@ -12209,7 +12209,7 @@ class AuthorityCheck {
12209
12209
  getMatcher() {
12210
12210
  const field = (0, combi_1.seq)("FIELD", expressions_1.Source);
12211
12211
  const id = (0, combi_1.seq)("ID", expressions_1.Source, (0, combi_1.alt)(field, "DUMMY"));
12212
- const ret = (0, combi_1.seq)("AUTHORITY-CHECK OBJECT", expressions_1.Source, (0, combi_1.opt)((0, combi_1.seq)("FOR USER", expressions_1.Source)), (0, combi_1.plus)(id));
12212
+ const ret = (0, combi_1.seq)("AUTHORITY-CHECK OBJECT", expressions_1.Source, (0, combi_1.opt)((0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.seq)("FOR USER", expressions_1.Source))), (0, combi_1.plus)(id));
12213
12213
  return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, ret);
12214
12214
  }
12215
12215
  }
@@ -13102,7 +13102,7 @@ const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src
13102
13102
  class Commit {
13103
13103
  getMatcher() {
13104
13104
  const work = (0, combi_1.seq)("WORK", (0, combi_1.opt)("AND WAIT"));
13105
- return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("COMMIT", (0, combi_1.alt)(work, expressions_1.DatabaseConnection)));
13105
+ return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("COMMIT", (0, combi_1.alt)(work, (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, expressions_1.DatabaseConnection))));
13106
13106
  }
13107
13107
  }
13108
13108
  exports.Commit = Commit;
@@ -13411,9 +13411,9 @@ class Convert {
13411
13411
  const tim = (0, combi_1.seq)("TIME", expressions_1.Source);
13412
13412
  const stamp = (0, combi_1.seq)("INTO TIME STAMP", expressions_1.Target);
13413
13413
  const intoutc = (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("INTO UTCLONG", expressions_1.Target), { also: combi_1.AlsoIn.OpenABAP });
13414
- const invert = (0, combi_1.seq)("INTO INVERTED-DATE", expressions_1.Target);
13414
+ const invert = (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.seq)("INTO INVERTED-DATE", expressions_1.Target));
13415
13415
  const date = (0, combi_1.seq)((0, combi_1.per)(dat, tim), (0, combi_1.per)(daylightSource, stamp, zone, invert, intoutc));
13416
- const inv = (0, combi_1.seq)("INVERTED-DATE", expressions_1.Source, "INTO DATE", expressions_1.Target);
13416
+ const inv = (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.seq)("INVERTED-DATE", expressions_1.Source, "INTO DATE", expressions_1.Target));
13417
13417
  const utclong = (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("UTCLONG", expressions_1.Source, (0, combi_1.per)(zone, into, daylightTarget)), { also: combi_1.AlsoIn.OpenABAP });
13418
13418
  return (0, combi_1.seq)("CONVERT", (0, combi_1.alt)(time, date, inv, utclong));
13419
13419
  }
@@ -13981,13 +13981,14 @@ exports.Divide = Divide;
13981
13981
  Object.defineProperty(exports, "__esModule", ({ value: true }));
13982
13982
  exports.Do = void 0;
13983
13983
  const combi_1 = __webpack_require__(/*! ../combi */ "../core/build/src/abap/2_statements/combi.js");
13984
+ const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
13984
13985
  const expressions_1 = __webpack_require__(/*! ../expressions */ "../core/build/src/abap/2_statements/expressions/index.js");
13985
13986
  class Do {
13986
13987
  getMatcher() {
13987
13988
  const range = (0, combi_1.seq)("RANGE", expressions_1.Source);
13988
13989
  const vary = (0, combi_1.seq)("VARYING", expressions_1.Target, "FROM", expressions_1.Source, "NEXT", expressions_1.Source, (0, combi_1.optPrio)(range));
13989
13990
  const times = (0, combi_1.seq)(expressions_1.Source, "TIMES");
13990
- return (0, combi_1.seq)("DO", (0, combi_1.optPrio)((0, combi_1.per)((0, combi_1.plus)(vary), times)));
13991
+ return (0, combi_1.seq)("DO", (0, combi_1.optPrio)((0, combi_1.per)((0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.plus)(vary)), times)));
13991
13992
  }
13992
13993
  }
13993
13994
  exports.Do = Do;
@@ -14810,9 +14811,10 @@ exports.ExecSQL = ExecSQL;
14810
14811
  Object.defineProperty(exports, "__esModule", ({ value: true }));
14811
14812
  exports.Exit = void 0;
14812
14813
  const combi_1 = __webpack_require__(/*! ../combi */ "../core/build/src/abap/2_statements/combi.js");
14814
+ const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
14813
14815
  class Exit {
14814
14816
  getMatcher() {
14815
- return (0, combi_1.seq)("EXIT", (0, combi_1.opt)((0, combi_1.alt)("FROM SQL", "FROM STEP-LOOP")));
14817
+ return (0, combi_1.seq)("EXIT", (0, combi_1.opt)((0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.alt)("FROM SQL", "FROM STEP-LOOP"))));
14816
14818
  }
14817
14819
  }
14818
14820
  exports.Exit = Exit;
@@ -15685,8 +15687,9 @@ const expressions_1 = __webpack_require__(/*! ../expressions */ "../core/build/s
15685
15687
  const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
15686
15688
  class GetTime {
15687
15689
  getMatcher() {
15688
- const options = (0, combi_1.seq)((0, combi_1.alt)("STAMP FIELD", "FIELD"), expressions_1.Target);
15689
- return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("GET TIME", (0, combi_1.opt)(options)));
15690
+ const stamp = (0, combi_1.seq)("GET TIME STAMP FIELD", expressions_1.Target);
15691
+ const time = (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.seq)("GET TIME", (0, combi_1.opt)((0, combi_1.seq)("FIELD", expressions_1.Target))));
15692
+ return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.alt)(stamp, time));
15690
15693
  }
15691
15694
  }
15692
15695
  exports.GetTime = GetTime;
@@ -17525,7 +17528,7 @@ const expressions_1 = __webpack_require__(/*! ../expressions */ "../core/build/s
17525
17528
  class Perform {
17526
17529
  getMatcher() {
17527
17530
  const level = (0, combi_1.seq)("LEVEL", Expressions.Source);
17528
- const commit = (0, combi_1.alt)((0, combi_1.seq)("ON COMMIT", (0, combi_1.opt)(level)), "ON ROLLBACK");
17531
+ const commit = (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.alt)((0, combi_1.seq)("ON COMMIT", (0, combi_1.opt)(level)), "ON ROLLBACK"));
17529
17532
  const short = (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.seq)(Expressions.FormName, (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.IncludeName, (0, combi_1.tok)(tokens_1.ParenRightW)));
17530
17533
  const program = (0, combi_1.seq)("IN PROGRAM", (0, combi_1.opt)((0, combi_1.alt)(Expressions.Dynamic, Expressions.IncludeName)));
17531
17534
  const found = (0, combi_1.str)("IF FOUND");
@@ -18382,7 +18385,7 @@ const expressions_1 = __webpack_require__(/*! ../expressions */ "../core/build/s
18382
18385
  const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
18383
18386
  class Rollback {
18384
18387
  getMatcher() {
18385
- return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("ROLLBACK", (0, combi_1.altPrio)("WORK", expressions_1.DatabaseConnection)));
18388
+ return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("ROLLBACK", (0, combi_1.altPrio)("WORK", (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, expressions_1.DatabaseConnection))));
18386
18389
  }
18387
18390
  }
18388
18391
  exports.Rollback = Rollback;
@@ -20338,7 +20341,7 @@ class Wait {
20338
20341
  const type = (0, combi_1.seq)("FOR", (0, combi_1.per)(channels, push, tasks));
20339
20342
  const until = (0, combi_1.seq)((0, combi_1.opt)(type), "UNTIL", expressions_1.Cond, (0, combi_1.opt)(up));
20340
20343
  const ret = (0, combi_1.seq)("WAIT", (0, combi_1.alt)(until, up));
20341
- return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, ret);
20344
+ return (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, ret);
20342
20345
  }
20343
20346
  }
20344
20347
  exports.Wait = Wait;
@@ -26191,6 +26194,114 @@ BuiltIn.argumentTypedReturn = new Set(["ABS", "CEIL", "FLOOR", "FRAC", "SIGN", "
26191
26194
 
26192
26195
  /***/ },
26193
26196
 
26197
+ /***/ "../core/build/src/abap/5_syntax/_builtin_call.js"
26198
+ /*!********************************************************!*\
26199
+ !*** ../core/build/src/abap/5_syntax/_builtin_call.js ***!
26200
+ \********************************************************/
26201
+ (__unused_webpack_module, exports, __webpack_require__) {
26202
+
26203
+ "use strict";
26204
+
26205
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26206
+ if (k2 === undefined) k2 = k;
26207
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26208
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26209
+ desc = { enumerable: true, get: function() { return m[k]; } };
26210
+ }
26211
+ Object.defineProperty(o, k2, desc);
26212
+ }) : (function(o, m, k, k2) {
26213
+ if (k2 === undefined) k2 = k;
26214
+ o[k2] = m[k];
26215
+ }));
26216
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26217
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26218
+ }) : function(o, v) {
26219
+ o["default"] = v;
26220
+ });
26221
+ var __importStar = (this && this.__importStar) || (function () {
26222
+ var ownKeys = function(o) {
26223
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26224
+ var ar = [];
26225
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26226
+ return ar;
26227
+ };
26228
+ return ownKeys(o);
26229
+ };
26230
+ return function (mod) {
26231
+ if (mod && mod.__esModule) return mod;
26232
+ var result = {};
26233
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
26234
+ __setModuleDefault(result, mod);
26235
+ return result;
26236
+ };
26237
+ })();
26238
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
26239
+ exports.BuiltInCall = void 0;
26240
+ const Expressions = __importStar(__webpack_require__(/*! ../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
26241
+ const nodes_1 = __webpack_require__(/*! ../nodes */ "../core/build/src/abap/nodes/index.js");
26242
+ const _builtin_1 = __webpack_require__(/*! ./_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
26243
+ const _object_oriented_1 = __webpack_require__(/*! ./_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
26244
+ const basic_1 = __webpack_require__(/*! ../types/basic */ "../core/build/src/abap/types/basic/index.js");
26245
+ class BuiltInCall {
26246
+ // the call of a built-in function that starts a method call chain, not hidden by a method of the same name
26247
+ static fromChain(chain, input) {
26248
+ if (chain === undefined || !(chain.get() instanceof Expressions.MethodCallChain)) {
26249
+ return undefined;
26250
+ }
26251
+ const call = chain.getChildren()[0];
26252
+ if (!(call instanceof nodes_1.ExpressionNode) || !(call.get() instanceof Expressions.MethodCall)) {
26253
+ return undefined;
26254
+ }
26255
+ const name = this.callName(call);
26256
+ // upper case, the definition is cached with the name it is first searched with
26257
+ if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name.toUpperCase()) === undefined) {
26258
+ return undefined;
26259
+ }
26260
+ const enclosing = input.scope.findClassDefinition(input.scope.getEnclosingClassName());
26261
+ if (enclosing !== undefined && new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(enclosing, name).method !== undefined) {
26262
+ return undefined;
26263
+ }
26264
+ return call;
26265
+ }
26266
+ // the call of a built-in function when the source is exactly that one call
26267
+ static fromSource(source, input) {
26268
+ const chain = source === null || source === void 0 ? void 0 : source.getChildren();
26269
+ if ((chain === null || chain === void 0 ? void 0 : chain.length) !== 1 || !(chain[0] instanceof nodes_1.ExpressionNode) || chain[0].getChildren().length !== 1) {
26270
+ return undefined;
26271
+ }
26272
+ return this.fromChain(chain[0], input);
26273
+ }
26274
+ static callName(call) {
26275
+ var _a;
26276
+ return (_a = call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
26277
+ }
26278
+ static isNumeric(call) {
26279
+ var _a, _b, _c;
26280
+ const returning = (_c = (_b = _builtin_1.BuiltIn.searchBuiltin((_a = this.callName(call)) === null || _a === void 0 ? void 0 : _a.toUpperCase())) === null || _b === void 0 ? void 0 : _b.getParameters().getReturning()) === null || _c === void 0 ? void 0 : _c.getType();
26281
+ return returning instanceof basic_1.IntegerType || returning instanceof basic_1.FloatType || returning instanceof basic_1.DecFloat34Type;
26282
+ }
26283
+ // the call has a single argument, without a parameter name, that is a data object and not an expression
26284
+ static hasDataObjectArgument(call) {
26285
+ var _a;
26286
+ const argument = (_a = call.findDirectExpression(Expressions.MethodCallParam)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Source);
26287
+ const children = (argument === null || argument === void 0 ? void 0 : argument.getChildren()) || [];
26288
+ // a literal or a text symbol, text-001
26289
+ if (children.length === 1
26290
+ && (children[0].get() instanceof Expressions.Constant || children[0].get() instanceof Expressions.TextElement)) {
26291
+ return true;
26292
+ }
26293
+ // a field, a component, an offset/length or a dereference, r->*
26294
+ return children.length > 0
26295
+ && children[0].get() instanceof Expressions.FieldChain
26296
+ && children.every(c => c.get() instanceof Expressions.FieldChain || c.get() instanceof Expressions.Dereference)
26297
+ && (argument === null || argument === void 0 ? void 0 : argument.findFirstExpression(Expressions.TableExpression)) === undefined;
26298
+ }
26299
+ }
26300
+ exports.BuiltInCall = BuiltInCall;
26301
+ //# sourceMappingURL=_builtin_call.js.map
26302
+
26303
+ /***/ },
26304
+
26194
26305
  /***/ "../core/build/src/abap/5_syntax/_current_scope.js"
26195
26306
  /*!*********************************************************!*\
26196
26307
  !*** ../core/build/src/abap/5_syntax/_current_scope.js ***!
@@ -26235,6 +26346,9 @@ class CurrentScope {
26235
26346
  this.localFriends = new Map();
26236
26347
  /** types of the FOR and LET names used in a procedure, key is the scope node of the procedure */
26237
26348
  this.localNameTypes = new WeakMap();
26349
+ /** row type of the members of a group, key is the identifier of the group variable,
26350
+ * a LOOP AT ... GROUP BY binds the group until its ENDLOOP */
26351
+ this.groupMemberTypes = new Map();
26238
26352
  this.current = undefined;
26239
26353
  this.parentObj = obj;
26240
26354
  this.reg = reg;
@@ -26767,6 +26881,18 @@ class CurrentScope {
26767
26881
  && type.isGeneric() === false
26768
26882
  && type.toText(0).includes("Unknown type") === false;
26769
26883
  }
26884
+ setGroupMemberType(group, rowType) {
26885
+ this.groupMemberTypes.set(CurrentScope.groupKey(group), rowType);
26886
+ }
26887
+ findGroupMemberType(group) {
26888
+ return this.groupMemberTypes.get(CurrentScope.groupKey(group));
26889
+ }
26890
+ removeGroupMemberType(group) {
26891
+ this.groupMemberTypes.delete(CurrentScope.groupKey(group));
26892
+ }
26893
+ static groupKey(group) {
26894
+ return group.getFilename() + ":" + group.getStart().getRow() + ":" + group.getStart().getCol();
26895
+ }
26770
26896
  getEnclosingMethodName() {
26771
26897
  let curr = this.current;
26772
26898
  while (curr !== undefined) {
@@ -27360,6 +27486,17 @@ class ObjectOriented {
27360
27486
  }
27361
27487
  return undefined;
27362
27488
  }
27489
+ // RAISE EXCEPTION and THROW are not allowed in a method whose interface declares classic EXCEPTIONS,
27490
+ // not even for a CX_NO_CHECK class
27491
+ checkClassBasedException() {
27492
+ var _a;
27493
+ const methodName = this.scope.getEnclosingMethodName();
27494
+ const classDef = this.scope.findClassDefinition(this.scope.getEnclosingClassName());
27495
+ if (methodName && classDef && ((_a = this.searchMethodName(classDef, methodName).method) === null || _a === void 0 ? void 0 : _a.getExceptions().length)) {
27496
+ return "Old exceptions and class-based exceptions cannot be used at the same time";
27497
+ }
27498
+ return undefined;
27499
+ }
27363
27500
  // SUPER-> can only call the previous implementation of the method it is used in, returns the message otherwise
27364
27501
  // both names are resolved in the super class, so an alias and the method it stands for are the same
27365
27502
  checkSuperCall(superDef, methodName) {
@@ -30129,6 +30266,11 @@ class BasicTypes {
30129
30266
  if (text === undefined) {
30130
30267
  text = "TYPE";
30131
30268
  }
30269
+ const additionIssue = this.checkLengthDecimals(node, text);
30270
+ if (additionIssue !== undefined) {
30271
+ this.input.issues.push(additionIssue);
30272
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
30273
+ }
30132
30274
  let found = undefined;
30133
30275
  if (this.isRAPTypeStructure(text)) {
30134
30276
  return Types.VoidType.get((_f = node.findFirstExpression(Expressions.TypeStructure)) === null || _f === void 0 ? void 0 : _f.concatTokens());
@@ -30672,6 +30814,31 @@ class BasicTypes {
30672
30814
  }
30673
30815
  throw new Error("findValue, unexpected");
30674
30816
  }
30817
+ // the LENGTH and DECIMALS additions of DATA, TYPES, CONSTANTS and STATICS, as a system checks them:
30818
+ // LENGTH only with TYPE c, n, x or p, DECIMALS only with TYPE p, also not without a TYPE addition,
30819
+ // a named type cannot be given a length either. With LIKE, a system ignores LENGTH and rejects DECIMALS
30820
+ checkLengthDecimals(node, text) {
30821
+ const length = node.findDirectExpression(Expressions.Length);
30822
+ const decimals = node.findDirectExpression(Expressions.Decimals);
30823
+ if (length === undefined && decimals === undefined) {
30824
+ return undefined;
30825
+ }
30826
+ else if (text.startsWith("LIKE")) {
30827
+ if (decimals === undefined) {
30828
+ return undefined;
30829
+ }
30830
+ const message = "When referencing another field (with LIKE), type and length cannot be changed";
30831
+ return (0, _syntax_input_1.syntaxIssue)(this.input, decimals.getFirstToken(), message);
30832
+ }
30833
+ const builtin = text.startsWith("TYPE") ? text.substring(4).trim() : "";
30834
+ if (length !== undefined && ["C", "N", "X", "P"].includes(builtin) === false) {
30835
+ return (0, _syntax_input_1.syntaxIssue)(this.input, length.getFirstToken(), "\"LENGTH\" can only be specified for types C, N, X, or P");
30836
+ }
30837
+ else if (decimals !== undefined && builtin !== "P") {
30838
+ return (0, _syntax_input_1.syntaxIssue)(this.input, decimals.getFirstToken(), "\"DECIMALS\" can be specified only for type P");
30839
+ }
30840
+ return undefined;
30841
+ }
30675
30842
  findDecimals(node) {
30676
30843
  var _a, _b, _c;
30677
30844
  const dec = (_b = (_a = node.findDirectExpression(Expressions.Decimals)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Integer)) === null || _b === void 0 ? void 0 : _b.concatTokens();
@@ -31146,7 +31313,7 @@ function substringType(context, offset, length, node, input) {
31146
31313
  return context;
31147
31314
  }
31148
31315
  else if (numericName !== undefined) {
31149
- const message = `Offset or length specification not possible on a field of numeric type "${numericName}"`;
31316
+ const message = `Field type "${numericName}" does not permit substrings to be accessed`;
31150
31317
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
31151
31318
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
31152
31319
  }
@@ -31175,12 +31342,13 @@ function substringType(context, offset, length, node, input) {
31175
31342
  }
31176
31343
  return context;
31177
31344
  }
31345
+ // the internal type code the ABAP syntax check names: I, 8, P, F, a (decfloat16), e (decfloat34)
31178
31346
  function numericTypeName(context) {
31179
31347
  if (context instanceof basic_1.IntegerType) {
31180
31348
  return "I";
31181
31349
  }
31182
31350
  else if (context instanceof basic_1.Integer8Type) {
31183
- return "INT8";
31351
+ return "8";
31184
31352
  }
31185
31353
  else if (context instanceof basic_1.PackedType) {
31186
31354
  return "P";
@@ -31189,10 +31357,10 @@ function numericTypeName(context) {
31189
31357
  return "F";
31190
31358
  }
31191
31359
  else if (context instanceof basic_1.DecFloat16Type) {
31192
- return "DECFLOAT16";
31360
+ return "a";
31193
31361
  }
31194
31362
  else if (context instanceof basic_1.DecFloat34Type) {
31195
- return "DECFLOAT34";
31363
+ return "e";
31196
31364
  }
31197
31365
  else if (context instanceof basic_1.DecFloatType) {
31198
31366
  return "DECFLOAT";
@@ -31648,12 +31816,20 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/bui
31648
31816
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
31649
31817
  const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "../core/build/src/abap/5_syntax/_type_utils.js");
31650
31818
  const _builtin_1 = __webpack_require__(/*! ../_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
31651
- const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
31819
+ const _builtin_call_1 = __webpack_require__(/*! ../_builtin_call */ "../core/build/src/abap/5_syntax/_builtin_call.js");
31652
31820
  class Compare {
31653
31821
  static runSyntax(node, input) {
31654
31822
  var _a;
31655
- const sourceTypes = [];
31656
31823
  const sources = node.findDirectExpressions(Expressions.Source);
31824
+ // reported before the operands are checked, which then skip the more general predicate function message
31825
+ const initialMessage = this.checkInitialOperand(node, input);
31826
+ const predicateMessage = this.checkPredicateOperand(sources, input);
31827
+ const operandMessage = initialMessage !== null && initialMessage !== void 0 ? initialMessage : predicateMessage;
31828
+ if (operandMessage !== undefined) {
31829
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), operandMessage));
31830
+ }
31831
+ // the operands are always checked, for their own errors and references
31832
+ const sourceTypes = [];
31657
31833
  for (const t of sources) {
31658
31834
  sourceTypes.push(source_1.Source.runSyntax(t, input));
31659
31835
  }
@@ -31663,14 +31839,7 @@ class Compare {
31663
31839
  for (const t of node.findDirectExpressions(Expressions.MethodCallChain)) {
31664
31840
  method_call_chain_1.MethodCallChain.runSyntax(t, input);
31665
31841
  }
31666
- const initialMessage = this.checkInitialOperand(node, input);
31667
- if (initialMessage !== undefined) {
31668
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), initialMessage));
31669
- return;
31670
- }
31671
- const predicateMessage = this.checkPredicateOperand(sources, input);
31672
- if (predicateMessage !== undefined) {
31673
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), predicateMessage));
31842
+ if (operandMessage !== undefined) {
31674
31843
  return;
31675
31844
  }
31676
31845
  const typeUtils = new _type_utils_1.TypeUtils(input.scope);
@@ -31726,35 +31895,20 @@ class Compare {
31726
31895
  if (input.scope.getOpenABAP()) {
31727
31896
  return undefined;
31728
31897
  }
31898
+ let message = undefined;
31729
31899
  for (const source of sources) {
31730
31900
  const name = this.builtinCallName(source, input);
31731
31901
  if (_builtin_1.BuiltIn.isPredicate(name) === true) {
31732
- return `Predicate function "${name}" cannot be the operand of a comparison`;
31902
+ source_1.Source.predicateReported(source);
31903
+ message = message !== null && message !== void 0 ? message : `Predicate function "${name}" cannot be the operand of a comparison`;
31733
31904
  }
31734
31905
  }
31735
- return undefined;
31906
+ return message;
31736
31907
  }
31737
31908
  // the name of the built-in function when the source is exactly one call of it, not hidden by a method of the same name
31738
31909
  static builtinCallName(source, input) {
31739
- var _a;
31740
- const chain = source === null || source === void 0 ? void 0 : source.getChildren();
31741
- if ((chain === null || chain === void 0 ? void 0 : chain.length) !== 1 || !(chain[0] instanceof nodes_1.ExpressionNode) || !(chain[0].get() instanceof Expressions.MethodCallChain)) {
31742
- return undefined;
31743
- }
31744
- const calls = chain[0].getChildren();
31745
- if (calls.length !== 1 || !(calls[0] instanceof nodes_1.ExpressionNode) || !(calls[0].get() instanceof Expressions.MethodCall)) {
31746
- return undefined;
31747
- }
31748
- const name = (_a = calls[0].findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
31749
- if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name) === undefined) {
31750
- return undefined;
31751
- }
31752
- // a method of the same name hides the built-in function
31753
- const enclosing = input.scope.findClassDefinition(input.scope.getEnclosingClassName());
31754
- if (enclosing !== undefined && new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(enclosing, name).method !== undefined) {
31755
- return undefined;
31756
- }
31757
- return name;
31910
+ const call = _builtin_call_1.BuiltInCall.fromSource(source, input);
31911
+ return call === undefined ? undefined : _builtin_call_1.BuiltInCall.callName(call);
31758
31912
  }
31759
31913
  }
31760
31914
  exports.Compare = Compare;
@@ -32335,15 +32489,22 @@ var __importStar = (this && this.__importStar) || (function () {
32335
32489
  Object.defineProperty(exports, "__esModule", ({ value: true }));
32336
32490
  exports.CondBody = void 0;
32337
32491
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
32492
+ const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
32338
32493
  const source_1 = __webpack_require__(/*! ./source */ "../core/build/src/abap/5_syntax/expressions/source.js");
32339
32494
  const let_1 = __webpack_require__(/*! ./let */ "../core/build/src/abap/5_syntax/expressions/let.js");
32340
32495
  const cond_1 = __webpack_require__(/*! ./cond */ "../core/build/src/abap/5_syntax/expressions/cond.js");
32341
32496
  const _raise_message_1 = __webpack_require__(/*! ../_raise_message */ "../core/build/src/abap/5_syntax/_raise_message.js");
32497
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
32342
32498
  class CondBody {
32343
32499
  static runSyntax(node, input, targetType) {
32344
32500
  if (node === undefined) {
32345
32501
  return undefined;
32346
32502
  }
32503
+ const throwNode = node.findDirectExpression(Expressions.Throw);
32504
+ const throwMessage = throwNode ? new _object_oriented_1.ObjectOriented(input.scope).checkClassBasedException() : undefined;
32505
+ if (throwNode && throwMessage) {
32506
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, throwNode.getFirstToken(), throwMessage));
32507
+ }
32347
32508
  let scoped = false;
32348
32509
  const l = node.findDirectExpression(Expressions.Let);
32349
32510
  if (l) {
@@ -33415,6 +33576,7 @@ const _scope_type_1 = __webpack_require__(/*! ../_scope_type */ "../core/build/s
33415
33576
  const component_cond_1 = __webpack_require__(/*! ./component_cond */ "../core/build/src/abap/5_syntax/expressions/component_cond.js");
33416
33577
  const cond_1 = __webpack_require__(/*! ./cond */ "../core/build/src/abap/5_syntax/expressions/cond.js");
33417
33578
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
33579
+ const loop_group_by_1 = __webpack_require__(/*! ./loop_group_by */ "../core/build/src/abap/5_syntax/expressions/loop_group_by.js");
33418
33580
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
33419
33581
  const _reference_1 = __webpack_require__(/*! ../_reference */ "../core/build/src/abap/5_syntax/_reference.js");
33420
33582
  const let_1 = __webpack_require__(/*! ./let */ "../core/build/src/abap/5_syntax/expressions/let.js");
@@ -33442,18 +33604,19 @@ class For {
33442
33604
  for (const f of inlineField) {
33443
33605
  inline_field_definition_1.InlineFieldDefinition.runSyntax(f, input);
33444
33606
  }
33607
+ let groupsSource = undefined;
33445
33608
  if (groupsToken !== undefined) {
33446
33609
  const message = input.scope.checkLocalName(groupsToken.getStr(), undefined);
33447
33610
  if (message !== undefined) {
33448
33611
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, groupsToken, message));
33449
33612
  return scoped;
33450
33613
  }
33451
- const type = basic_1.VoidType.get("todoGroupBy");
33452
- const identifier = new _typed_identifier_1.TypedIdentifier(groupsToken, input.filename, type, ["inline" /* IdentifierMeta.InlineDefinition */]);
33453
- input.scope.addIdentifier(identifier);
33454
- input.scope.addReference(groupsToken, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename);
33614
+ groupsSource = this.runGroups(node, groupsToken, input);
33455
33615
  }
33456
33616
  for (const s of node.findDirectExpressions(Expressions.Source)) {
33617
+ if (s === groupsSource) {
33618
+ continue;
33619
+ }
33457
33620
  source_1.Source.runSyntax(s, input);
33458
33621
  }
33459
33622
  for (const s of node.findDirectExpressions(Expressions.ComponentCond)) {
@@ -33467,6 +33630,32 @@ class For {
33467
33630
  }
33468
33631
  return scoped;
33469
33632
  }
33633
+ /** FOR GROUPS group OF wa IN itab GROUP BY key, returns the itab source */
33634
+ static runGroups(node, groupsToken, input) {
33635
+ var _a;
33636
+ const tableSource = node.findExpressionAfterToken("IN");
33637
+ let rowType = basic_1.VoidType.get("ForGroups");
33638
+ if ((tableSource === null || tableSource === void 0 ? void 0 : tableSource.get()) instanceof Expressions.Source) {
33639
+ const tableType = source_1.Source.runSyntax(tableSource, input);
33640
+ if (tableType instanceof basic_1.TableType) {
33641
+ rowType = tableType.getRowType();
33642
+ }
33643
+ }
33644
+ const waToken = (_a = node.findExpressionAfterToken("OF")) === null || _a === void 0 ? void 0 : _a.getFirstToken();
33645
+ if (waToken !== undefined) {
33646
+ const wa = new _typed_identifier_1.TypedIdentifier(waToken, input.filename, rowType, ["inline" /* IdentifierMeta.InlineDefinition */]);
33647
+ input.scope.addIdentifier(wa);
33648
+ input.scope.addReference(waToken, wa, _reference_1.ReferenceType.DataWriteReference, input.filename);
33649
+ }
33650
+ const keyType = node.findDirectTokenByText("BY") !== undefined
33651
+ ? loop_group_by_1.LoopGroupBy.runKey(node, input)
33652
+ : basic_1.VoidType.get("ForGroups");
33653
+ const group = new _typed_identifier_1.TypedIdentifier(groupsToken, input.filename, keyType, ["inline" /* IdentifierMeta.InlineDefinition */]);
33654
+ input.scope.addIdentifier(group);
33655
+ input.scope.addReference(groupsToken, group, _reference_1.ReferenceType.DataWriteReference, input.filename);
33656
+ input.scope.setGroupMemberType(group, rowType);
33657
+ return (tableSource === null || tableSource === void 0 ? void 0 : tableSource.get()) instanceof Expressions.Source ? tableSource : undefined;
33658
+ }
33470
33659
  }
33471
33660
  exports.For = For;
33472
33661
  //# sourceMappingURL=for.js.map
@@ -34056,6 +34245,7 @@ const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/
34056
34245
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
34057
34246
  const _reference_1 = __webpack_require__(/*! ../_reference */ "../core/build/src/abap/5_syntax/_reference.js");
34058
34247
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
34248
+ const loop_group_by_1 = __webpack_require__(/*! ./loop_group_by */ "../core/build/src/abap/5_syntax/expressions/loop_group_by.js");
34059
34249
  class InlineLoopDefinition {
34060
34250
  static runSyntax(node, input) {
34061
34251
  if (node === undefined) {
@@ -34068,8 +34258,12 @@ class InlineLoopDefinition {
34068
34258
  const source = node.findDirectExpression(Expressions.Source);
34069
34259
  if (source && target) {
34070
34260
  const sourceType = source_1.Source.runSyntax(source, input);
34071
- let rowType = undefined;
34072
- if (sourceType instanceof basic_1.TableType) {
34261
+ const inGroup = node.concatTokens().toUpperCase().includes(" IN GROUP ");
34262
+ let rowType = inGroup ? loop_group_by_1.LoopGroupBy.findMemberType(source, input) : undefined;
34263
+ if (rowType !== undefined) {
34264
+ // FOR ... IN GROUP, the members have the row type of the grouped table
34265
+ }
34266
+ else if (sourceType instanceof basic_1.TableType) {
34073
34267
  rowType = sourceType.getRowType();
34074
34268
  }
34075
34269
  else if (sourceType instanceof basic_1.VoidType) {
@@ -34081,7 +34275,7 @@ class InlineLoopDefinition {
34081
34275
  return;
34082
34276
  }
34083
34277
  if (rowType === undefined
34084
- && node.concatTokens().toUpperCase().includes(" IN GROUP ")
34278
+ && inGroup
34085
34279
  && sourceType !== undefined) {
34086
34280
  rowType = sourceType;
34087
34281
  }
@@ -34227,34 +34421,144 @@ var __importStar = (this && this.__importStar) || (function () {
34227
34421
  Object.defineProperty(exports, "__esModule", ({ value: true }));
34228
34422
  exports.LoopGroupBy = void 0;
34229
34423
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
34424
+ const nodes_1 = __webpack_require__(/*! ../../nodes */ "../core/build/src/abap/nodes/index.js");
34230
34425
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
34231
- const component_compare_1 = __webpack_require__(/*! ./component_compare */ "../core/build/src/abap/5_syntax/expressions/component_compare.js");
34426
+ const _reference_1 = __webpack_require__(/*! ../_reference */ "../core/build/src/abap/5_syntax/_reference.js");
34232
34427
  const inline_data_1 = __webpack_require__(/*! ./inline_data */ "../core/build/src/abap/5_syntax/expressions/inline_data.js");
34233
34428
  const fstarget_1 = __webpack_require__(/*! ./fstarget */ "../core/build/src/abap/5_syntax/expressions/fstarget.js");
34234
34429
  const target_1 = __webpack_require__(/*! ./target */ "../core/build/src/abap/5_syntax/expressions/target.js");
34235
34430
  const source_1 = __webpack_require__(/*! ./source */ "../core/build/src/abap/5_syntax/expressions/source.js");
34431
+ const field_chain_1 = __webpack_require__(/*! ./field_chain */ "../core/build/src/abap/5_syntax/expressions/field_chain.js");
34236
34432
  class LoopGroupBy {
34237
- static runSyntax(node, input) {
34238
- for (const t of node.findAllExpressions(Expressions.Target)) {
34239
- const inline = t.findDirectExpression(Expressions.InlineData);
34433
+ /**
34434
+ * @param rowType row type of the grouped table, the type of the members of each group
34435
+ * @param representative the row target of the LOOP, it is the group when GROUP BY has no target
34436
+ */
34437
+ static runSyntax(node, input, rowType, representative) {
34438
+ var _a;
34439
+ const keyType = this.runKey(node, input);
34440
+ const groupTarget = node.findDirectExpression(Expressions.LoopGroupByTarget);
34441
+ const target = groupTarget === null || groupTarget === void 0 ? void 0 : groupTarget.findDirectExpression(Expressions.Target);
34442
+ const fsTarget = groupTarget === null || groupTarget === void 0 ? void 0 : groupTarget.findDirectExpression(Expressions.FSTarget);
34443
+ if (target) {
34444
+ const inline = target.findDirectExpression(Expressions.InlineData);
34240
34445
  if (inline) {
34241
- inline_data_1.InlineData.runSyntax(inline, input, basic_1.VoidType.get("todoGroupBy"));
34446
+ const isReference = (groupTarget === null || groupTarget === void 0 ? void 0 : groupTarget.findDirectTokenByText("REFERENCE")) !== undefined;
34447
+ inline_data_1.InlineData.runSyntax(inline, input, isReference ? new basic_1.DataReference(keyType) : keyType);
34242
34448
  }
34243
34449
  else {
34244
- target_1.Target.runSyntax(t, input);
34450
+ target_1.Target.runSyntax(target, input);
34245
34451
  }
34246
34452
  }
34247
- for (const t of node.findAllExpressions(Expressions.FSTarget)) {
34248
- fstarget_1.FSTarget.runSyntax(t, input, basic_1.VoidType.get("todoGroupBy"));
34453
+ else if (fsTarget) {
34454
+ fstarget_1.FSTarget.runSyntax(fsTarget, input, keyType);
34455
+ }
34456
+ // bind the group until ENDLOOP, see unbind(), also when the row type is unknown
34457
+ const group = this.findTargetIdentifier((_a = target !== null && target !== void 0 ? target : fsTarget) !== null && _a !== void 0 ? _a : representative, input.scope);
34458
+ if (group) {
34459
+ input.scope.setGroupMemberType(group, rowType !== null && rowType !== void 0 ? rowType : basic_1.VoidType.get("GroupMember"));
34460
+ }
34461
+ }
34462
+ /** the row target of a LOOP, it is the group when GROUP BY has no target */
34463
+ static findRepresentative(loop) {
34464
+ var _a;
34465
+ const loopTarget = loop.findDirectExpression(Expressions.LoopTarget);
34466
+ return (_a = loopTarget === null || loopTarget === void 0 ? void 0 : loopTarget.findDirectExpression(Expressions.Target)) !== null && _a !== void 0 ? _a : loopTarget === null || loopTarget === void 0 ? void 0 : loopTarget.findDirectExpression(Expressions.FSTarget);
34467
+ }
34468
+ /** called at the end of a LOOP structure, the group of a LOOP AT ... GROUP BY is not bound after its ENDLOOP */
34469
+ static unbind(loop, scope) {
34470
+ var _a, _b;
34471
+ const groupBy = loop.findDirectExpression(Expressions.LoopGroupBy);
34472
+ if (groupBy === undefined) {
34473
+ return;
34474
+ }
34475
+ const groupTarget = groupBy.findDirectExpression(Expressions.LoopGroupByTarget);
34476
+ const node = (_b = (_a = groupTarget === null || groupTarget === void 0 ? void 0 : groupTarget.findDirectExpression(Expressions.Target)) !== null && _a !== void 0 ? _a : groupTarget === null || groupTarget === void 0 ? void 0 : groupTarget.findDirectExpression(Expressions.FSTarget)) !== null && _b !== void 0 ? _b : this.findRepresentative(loop);
34477
+ const group = this.findTargetIdentifier(node, scope);
34478
+ if (group) {
34479
+ scope.removeGroupMemberType(group);
34480
+ }
34481
+ }
34482
+ /** LOOP AT GROUP group, the name of the group when it is a variable that no enclosing group loop binds */
34483
+ static findUnboundGroup(source, input) {
34484
+ if (source === undefined) {
34485
+ return undefined;
34486
+ }
34487
+ const name = this.groupName(source);
34488
+ const found = input.scope.findVariable(name);
34489
+ if (found === undefined || input.scope.findGroupMemberType(found) !== undefined) {
34490
+ return undefined;
34249
34491
  }
34250
- for (const t of node.findDirectExpressions(Expressions.Source)) {
34251
- source_1.Source.runSyntax(t, input, basic_1.VoidType.get("todoGroupBy"));
34492
+ return name;
34493
+ }
34494
+ /** type of the group key, from GROUP BY expr or GROUP BY ( name = expr ... ) */
34495
+ static runKey(node, input) {
34496
+ const components = node.findDirectExpressions(Expressions.LoopGroupByComponent);
34497
+ if (components.length === 0) {
34498
+ // LOOP: the key is the first child of LoopGroupBy, FOR GROUPS: the key follows GROUP BY
34499
+ const key = node.get() instanceof Expressions.LoopGroupBy ? node.getFirstChild() : node.findExpressionAfterToken("BY");
34500
+ let type = undefined;
34501
+ if (key instanceof nodes_1.ExpressionNode && key.get() instanceof Expressions.Source) {
34502
+ type = source_1.Source.runSyntax(key, input);
34503
+ }
34504
+ else if (key instanceof nodes_1.ExpressionNode && key.get() instanceof Expressions.FieldChain) {
34505
+ type = field_chain_1.FieldChain.runSyntax(key, input, _reference_1.ReferenceType.DataReadReference);
34506
+ }
34507
+ return type !== null && type !== void 0 ? type : basic_1.VoidType.get("GroupKey");
34252
34508
  }
34253
- for (const c of node.findDirectExpressions(Expressions.LoopGroupByComponent)) {
34254
- for (const t of c.findDirectExpressions(Expressions.ComponentCompareSingle)) {
34255
- component_compare_1.ComponentCompare.runSyntax(t, input);
34509
+ const fields = [];
34510
+ let dynamic = false;
34511
+ for (const c of components) {
34512
+ const single = c.findDirectExpression(Expressions.ComponentCompareSingle);
34513
+ if (single) {
34514
+ const source = single.findDirectExpression(Expressions.Source);
34515
+ const type = source ? source_1.Source.runSyntax(source, input) : undefined;
34516
+ const name = single.findDirectExpression(Expressions.ComponentChainSimple);
34517
+ if (name === undefined) {
34518
+ dynamic = true;
34519
+ continue;
34520
+ }
34521
+ fields.push({ name: name.concatTokens(), type: type !== null && type !== void 0 ? type : basic_1.VoidType.get("GroupKey") });
34522
+ }
34523
+ else {
34524
+ // GROUP SIZE and GROUP INDEX
34525
+ const name = c.findDirectExpression(Expressions.ComponentName);
34526
+ if (name) {
34527
+ fields.push({ name: name.concatTokens(), type: basic_1.IntegerType.get() });
34528
+ }
34256
34529
  }
34257
34530
  }
34531
+ if (dynamic === true || fields.length === 0) {
34532
+ return basic_1.VoidType.get("GroupKey");
34533
+ }
34534
+ return new basic_1.StructureType(fields);
34535
+ }
34536
+ /** the group variable in LOOP AT GROUP group and FOR ... IN GROUP group */
34537
+ static findMemberType(source, input) {
34538
+ if (source === undefined) {
34539
+ return undefined;
34540
+ }
34541
+ const found = input.scope.findVariable(this.groupName(source));
34542
+ return found ? input.scope.findGroupMemberType(found) : undefined;
34543
+ }
34544
+ static groupName(source) {
34545
+ return source.concatTokens().replace(/\s/g, "").replace(/->\*$/, "");
34546
+ }
34547
+ static findTargetIdentifier(node, scope) {
34548
+ var _a;
34549
+ var _b, _c;
34550
+ if (node === undefined) {
34551
+ return undefined;
34552
+ }
34553
+ const inline = (_b = node.findDirectExpression(Expressions.InlineData)) !== null && _b !== void 0 ? _b : node.findDirectExpression(Expressions.InlineFS);
34554
+ let name;
34555
+ if (inline) {
34556
+ name = (_a = ((_c = inline.findFirstExpression(Expressions.TargetField)) !== null && _c !== void 0 ? _c : inline.findFirstExpression(Expressions.TargetFieldSymbol))) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
34557
+ }
34558
+ else if (node.getChildren().length === 1) {
34559
+ name = node.getFirstToken().getStr();
34560
+ }
34561
+ return scope.findVariable(name);
34258
34562
  }
34259
34563
  }
34260
34564
  exports.LoopGroupBy = LoopGroupBy;
@@ -36047,6 +36351,8 @@ const _reference_1 = __webpack_require__(/*! ../_reference */ "../core/build/src
36047
36351
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
36048
36352
  const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
36049
36353
  const _check_database_fields_1 = __webpack_require__(/*! ./_check_database_fields */ "../core/build/src/abap/5_syntax/expressions/_check_database_fields.js");
36354
+ const field_chain_1 = __webpack_require__(/*! ./field_chain */ "../core/build/src/abap/5_syntax/expressions/field_chain.js");
36355
+ const tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
36050
36356
  const isSimple = /^\w+$/;
36051
36357
  // SQL functions where the result has the same type as the first argument
36052
36358
  const sameTypeAsFirstArgument = new Set(["UPPER", "LOWER", "LTRIM", "RTRIM"]);
@@ -36255,7 +36561,7 @@ class Select {
36255
36561
  if (intoStructure) {
36256
36562
  const inlineList = intoStructure.findAllExpressions(Expressions.InlineData);
36257
36563
  if (inlineList.length === 1) {
36258
- inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input.scope, from));
36564
+ inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input, from));
36259
36565
  }
36260
36566
  else {
36261
36567
  for (const inline of inlineList) {
@@ -36322,13 +36628,19 @@ class Select {
36322
36628
  return basic_1.IntegerType.get();
36323
36629
  }
36324
36630
  }
36325
- static buildStructureType(fields, dbSources, scope, from) {
36631
+ static buildStructureType(fields, dbSources, input, from) {
36326
36632
  var _a, _b, _c, _d, _e, _f;
36633
+ const scope = input.scope;
36327
36634
  if (fields.length === 1 && dbSources.length === 1) {
36328
36635
  // COUNT( * ) yields an integer regardless of the (possibly dynamic) table
36329
36636
  if (/^count\(\s*\*\s*\)$/i.test(fields[0].code)) {
36330
36637
  return this.countResultType(scope);
36331
36638
  }
36639
+ // a host variable yields its own type regardless of the table
36640
+ const hostType = this.findHostFieldType(fields[0], input);
36641
+ if (hostType) {
36642
+ return hostType;
36643
+ }
36332
36644
  const dbType = (_a = dbSources[0]) === null || _a === void 0 ? void 0 : _a.parseType(scope.getRegistry());
36333
36645
  if (dbType === undefined) {
36334
36646
  const name = ((_b = dbSources[0]) === null || _b === void 0 ? void 0 : _b.getName()) || "buildStructureTypeError";
@@ -36480,6 +36792,30 @@ class Select {
36480
36792
  }
36481
36793
  return components;
36482
36794
  }
36795
+ /** returns the type of the field list entry if it is a single ABAP host variable, "@var" or "@( var )" */
36796
+ static findHostFieldType(field, input) {
36797
+ var _a;
36798
+ if (!(field.expression.get() instanceof Expressions.SQLField)) {
36799
+ return undefined;
36800
+ }
36801
+ const children = field.expression.getChildren().filter(c => !(c.get() instanceof Expressions.SQLAsName) && c.concatTokens().toUpperCase() !== "AS");
36802
+ if (!(((_a = children[0]) === null || _a === void 0 ? void 0 : _a.get()) instanceof tokens_1.WAt)) {
36803
+ return undefined;
36804
+ }
36805
+ // "@var" has two children, "@( var )" has four, anything else is an expression
36806
+ const chain = children.length === 2 ? children[1] : children.length === 4 ? children[2] : undefined;
36807
+ if (!(chain instanceof nodes_1.ExpressionNode) || !(chain.get() instanceof Expressions.SimpleFieldChain2)) {
36808
+ return undefined;
36809
+ }
36810
+ // only resolve the type here, errors for the host variable are not reported by this lookup
36811
+ const issues = [];
36812
+ const type = field_chain_1.FieldChain.runSyntax(chain, Object.assign(Object.assign({}, input), { issues }));
36813
+ // a generic host type cannot type the inline declaration, keep it voided
36814
+ if (issues.length > 0 || type === undefined || type.isGeneric()) {
36815
+ return undefined;
36816
+ }
36817
+ return type;
36818
+ }
36483
36819
  /** returns the SQLFunction node if the field list entry is a single SQL function call */
36484
36820
  static findFunctionColumn(field, requireAlias = true) {
36485
36821
  if (requireAlias === true && field.as === "") {
@@ -36670,6 +37006,7 @@ const conv_body_1 = __webpack_require__(/*! ./conv_body */ "../core/build/src/ab
36670
37006
  const filter_body_1 = __webpack_require__(/*! ./filter_body */ "../core/build/src/abap/5_syntax/expressions/filter_body.js");
36671
37007
  const corresponding_body_1 = __webpack_require__(/*! ./corresponding_body */ "../core/build/src/abap/5_syntax/expressions/corresponding_body.js");
36672
37008
  const _builtin_1 = __webpack_require__(/*! ../_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
37009
+ const _builtin_call_1 = __webpack_require__(/*! ../_builtin_call */ "../core/build/src/abap/5_syntax/_builtin_call.js");
36673
37010
  const attribute_chain_1 = __webpack_require__(/*! ./attribute_chain */ "../core/build/src/abap/5_syntax/expressions/attribute_chain.js");
36674
37011
  const dereference_1 = __webpack_require__(/*! ./dereference */ "../core/build/src/abap/5_syntax/expressions/dereference.js");
36675
37012
  const cast_1 = __webpack_require__(/*! ./cast */ "../core/build/src/abap/5_syntax/expressions/cast.js");
@@ -36689,6 +37026,10 @@ const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src
36689
37026
  */
36690
37027
  // TODO: refactor all these method parameters to objects, this is getting messy
36691
37028
  class Source {
37029
+ // the predicate function in this source is already reported by the caller, Source only checks its arguments
37030
+ static predicateReported(source) {
37031
+ this.logicalArguments.add(source);
37032
+ }
36692
37033
  static runSyntax(node, input, targetType, writeReference = false, allowGenericDeference = false, readReference = true) {
36693
37034
  var _a, _b;
36694
37035
  if (node === undefined) {
@@ -36899,6 +37240,14 @@ class Source {
36899
37240
  if (first instanceof nodes_1.ExpressionNode) {
36900
37241
  const get = first.get();
36901
37242
  if (get instanceof Expressions.MethodCallChain) {
37243
+ const predicate = this.predicateCall(node, first, input);
37244
+ if (predicate !== undefined) {
37245
+ const message = `Predicate function "${predicate}" can only be used in a logical expression`;
37246
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, first.getFirstToken(), message));
37247
+ // the arguments are still checked, for their own errors and references
37248
+ method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
37249
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
37250
+ }
36902
37251
  const found = method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
36903
37252
  context = arithmetic === true ? this.infer(context, found, true) : found;
36904
37253
  if (context === undefined) {
@@ -37151,6 +37500,36 @@ class Source {
37151
37500
  }
37152
37501
  return targetType;
37153
37502
  }
37503
+ // a predicate function, line_exists( ) or contains( ), is a logical expression and not a value,
37504
+ // a system reports it as an unknown method in any operand position other than the argument of boolc( ) or xsdbool( ),
37505
+ // which parse as method calls in releases before xsdbool( ) was added, or the bool parameter of boolx( )
37506
+ static predicateCall(source, chain, input) {
37507
+ var _a, _b;
37508
+ if (input.scope.getOpenABAP()) {
37509
+ return undefined;
37510
+ }
37511
+ const call = _builtin_call_1.BuiltInCall.fromChain(chain, input);
37512
+ const name = call === undefined ? undefined : _builtin_call_1.BuiltInCall.callName(call);
37513
+ const upper = name === null || name === void 0 ? void 0 : name.toUpperCase();
37514
+ const param = call === null || call === void 0 ? void 0 : call.findDirectExpression(Expressions.MethodCallParam);
37515
+ if (upper === "BOOLC" || upper === "XSDBOOL") {
37516
+ const argument = param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.Source);
37517
+ if (argument !== undefined) {
37518
+ this.logicalArguments.add(argument);
37519
+ }
37520
+ return undefined;
37521
+ }
37522
+ else if (upper === "BOOLX") {
37523
+ for (const p of ((_a = param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.ParameterListS)) === null || _a === void 0 ? void 0 : _a.findDirectExpressions(Expressions.ParameterS)) || []) {
37524
+ const argument = p.findDirectExpression(Expressions.Source);
37525
+ if (((_b = p.findDirectExpression(Expressions.ParameterName)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase()) === "BOOL" && argument !== undefined) {
37526
+ this.logicalArguments.add(argument);
37527
+ }
37528
+ }
37529
+ return undefined;
37530
+ }
37531
+ return _builtin_1.BuiltIn.isPredicate(name) === true && this.logicalArguments.has(source) === false ? name : undefined;
37532
+ }
37154
37533
  // "NEW ty( )->*" is a syntax error, also in releases where a method call can be dereferenced
37155
37534
  static isNewObjectDereference(node, deref) {
37156
37535
  var _a;
@@ -37163,6 +37542,9 @@ class Source {
37163
37542
  }
37164
37543
  }
37165
37544
  exports.Source = Source;
37545
+ // arguments of boolc( ), xsdbool( ) and the bool parameter of boolx( ) parsed as method calls, where a predicate function is allowed,
37546
+ // and operands where the caller has already reported the predicate function in more specific terms
37547
+ Source.logicalArguments = new WeakSet();
37166
37548
  //# sourceMappingURL=source.js.map
37167
37549
 
37168
37550
  /***/ },
@@ -37959,6 +38341,7 @@ var __importStar = (this && this.__importStar) || (function () {
37959
38341
  Object.defineProperty(exports, "__esModule", ({ value: true }));
37960
38342
  exports.SwitchBody = void 0;
37961
38343
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
38344
+ const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
37962
38345
  const source_1 = __webpack_require__(/*! ./source */ "../core/build/src/abap/5_syntax/expressions/source.js");
37963
38346
  const _raise_message_1 = __webpack_require__(/*! ../_raise_message */ "../core/build/src/abap/5_syntax/_raise_message.js");
37964
38347
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
@@ -37968,6 +38351,11 @@ class SwitchBody {
37968
38351
  if (node === undefined) {
37969
38352
  return;
37970
38353
  }
38354
+ const throwNode = node.findDirectExpression(Expressions.Throw);
38355
+ const throwMessage = throwNode ? new _object_oriented_1.ObjectOriented(input.scope).checkClassBasedException() : undefined;
38356
+ if (throwNode && throwMessage) {
38357
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, throwNode.getFirstToken(), throwMessage));
38358
+ }
37971
38359
  for (const t of node.findDirectExpressions(Expressions.Throw)) {
37972
38360
  _raise_message_1.RaiseMessage.checkThrow(t, input);
37973
38361
  }
@@ -45000,6 +45388,17 @@ class Loop {
45000
45388
  }
45001
45389
  if (sourceType instanceof basic_1.TableType) {
45002
45390
  rowType = sourceType.getRowType();
45391
+ }
45392
+ else if (concat.startsWith("LOOP AT GROUP ")) {
45393
+ const unbound = loop_group_by_1.LoopGroupBy.findUnboundGroup(firstSource, input);
45394
+ if (unbound !== undefined) {
45395
+ const message = `No group is bound to "${unbound}"`;
45396
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
45397
+ return;
45398
+ }
45399
+ rowType = loop_group_by_1.LoopGroupBy.findMemberType(firstSource, input);
45400
+ }
45401
+ if (rowType) {
45003
45402
  sourceType = rowType;
45004
45403
  if (targetConcat === null || targetConcat === void 0 ? void 0 : targetConcat.startsWith("REFERENCE INTO ")) {
45005
45404
  sourceType = new basic_1.DataReference(sourceType);
@@ -45085,7 +45484,7 @@ class Loop {
45085
45484
  }
45086
45485
  const group = node.findDirectExpression(Expressions.LoopGroupBy);
45087
45486
  if (group) {
45088
- loop_group_by_1.LoopGroupBy.runSyntax(group, input);
45487
+ loop_group_by_1.LoopGroupBy.runSyntax(group, input, rowType, loop_group_by_1.LoopGroupBy.findRepresentative(node));
45089
45488
  }
45090
45489
  }
45091
45490
  }
@@ -45209,6 +45608,7 @@ const target_1 = __webpack_require__(/*! ../expressions/target */ "../core/build
45209
45608
  const message_source_1 = __webpack_require__(/*! ../expressions/message_source */ "../core/build/src/abap/5_syntax/expressions/message_source.js");
45210
45609
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
45211
45610
  const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
45611
+ const _builtin_call_1 = __webpack_require__(/*! ../_builtin_call */ "../core/build/src/abap/5_syntax/_builtin_call.js");
45212
45612
  class Message {
45213
45613
  runSyntax(node, input) {
45214
45614
  const exceptionName = node.findDirectExpression(Expressions.ExceptionName);
@@ -45227,7 +45627,16 @@ class Message {
45227
45627
  }
45228
45628
  for (const mss of node.findDirectExpressions(Expressions.MessageSourceSource)) {
45229
45629
  for (const s of mss.findDirectExpressions(Expressions.Source)) {
45630
+ const issueCount = input.issues.length;
45230
45631
  source_1.Source.runSyntax(s, input);
45632
+ // "Arithmetic calculation not permitted here" on a system, whatever the argument
45633
+ const call = issueCount === input.issues.length && input.scope.getOpenABAP() === false
45634
+ ? _builtin_call_1.BuiltInCall.fromSource(s, input) : undefined;
45635
+ if (call !== undefined && _builtin_call_1.BuiltInCall.isNumeric(call)) {
45636
+ const message = `Numeric function "${_builtin_call_1.BuiltInCall.callName(call)}" cannot be used in MESSAGE WITH`;
45637
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
45638
+ return;
45639
+ }
45231
45640
  }
45232
45641
  for (const s of mss.findDirectExpressions(Expressions.SimpleSource3)) {
45233
45642
  source_1.Source.runSyntax(s, input);
@@ -45735,6 +46144,7 @@ const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/
45735
46144
  const nodes_1 = __webpack_require__(/*! ../../nodes */ "../core/build/src/abap/nodes/index.js");
45736
46145
  class Move {
45737
46146
  runSyntax(node, input) {
46147
+ var _a;
45738
46148
  const targets = node.findDirectExpressions(Expressions.Target);
45739
46149
  const firstTarget = targets[0];
45740
46150
  const inline = firstTarget === null || firstTarget === void 0 ? void 0 : firstTarget.findDirectExpression(Expressions.InlineData);
@@ -45775,6 +46185,13 @@ class Move {
45775
46185
  sourceType = dereference_1.Dereference.runSyntax(node, sourceType, input);
45776
46186
  }
45777
46187
  if (inline) {
46188
+ // the length of a text symbol depends on the text pool, "DATA(x) = TEXT-abc." does not compile
46189
+ const sourceChildren = (_a = source === null || source === void 0 ? void 0 : source.getChildren()) !== null && _a !== void 0 ? _a : [];
46190
+ if (sourceChildren.length === 1 && sourceChildren[0].get() instanceof Expressions.TextElement) {
46191
+ const message = `"${source.concatTokens().toUpperCase()}" has a generic type that cannot be used for declarations`;
46192
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, source.getFirstToken(), message));
46193
+ return;
46194
+ }
45778
46195
  if (sourceType instanceof basic_1.PackedType && (source === null || source === void 0 ? void 0 : source.findDirectExpression(Expressions.ArithOperator))) {
45779
46196
  sourceType = new basic_1.PackedType(8, 0);
45780
46197
  }
@@ -46476,6 +46893,11 @@ class Raise {
46476
46893
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, exceptionName.getFirstToken(), classicMessage));
46477
46894
  return;
46478
46895
  }
46896
+ const classBasedMessage = exceptionName === undefined && node.findDirectTokenByText("EXCEPTION")
46897
+ ? helper.checkClassBasedException() : undefined;
46898
+ if (classBasedMessage) {
46899
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), classBasedMessage));
46900
+ }
46479
46901
  const classTok = (_a = node.findDirectExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
46480
46902
  const className = classTok === null || classTok === void 0 ? void 0 : classTok.getStr();
46481
46903
  if (classTok && className) {
@@ -49879,6 +50301,7 @@ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "../core/build/s
49879
50301
  const field_chain_1 = __webpack_require__(/*! ../expressions/field_chain */ "../core/build/src/abap/5_syntax/expressions/field_chain.js");
49880
50302
  const _reference_1 = __webpack_require__(/*! ../_reference */ "../core/build/src/abap/5_syntax/_reference.js");
49881
50303
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
50304
+ const _builtin_call_1 = __webpack_require__(/*! ../_builtin_call */ "../core/build/src/abap/5_syntax/_builtin_call.js");
49882
50305
  class Write {
49883
50306
  runSyntax(node, input) {
49884
50307
  // todo, more
@@ -49888,7 +50311,16 @@ class Write {
49888
50311
  second = node.getChildren()[2];
49889
50312
  }
49890
50313
  for (const s of node.findDirectExpressions(Expressions.Source)) {
50314
+ const issueCount = input.issues.length;
49891
50315
  const type = source_1.Source.runSyntax(s, input);
50316
+ // "Arithmetic calculation not permitted here" on a system, while abs( x ) or lines( itab ) is fine
50317
+ const call = s === second && issueCount === input.issues.length && input.scope.getOpenABAP() === false
50318
+ ? _builtin_call_1.BuiltInCall.fromSource(s, input) : undefined;
50319
+ if (call !== undefined && _builtin_call_1.BuiltInCall.isNumeric(call) && _builtin_call_1.BuiltInCall.hasDataObjectArgument(call) === false) {
50320
+ const message = `Numeric function "${_builtin_call_1.BuiltInCall.callName(call)}" in WRITE takes only a single data object as argument`;
50321
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
50322
+ return;
50323
+ }
49892
50324
  if (s === second
49893
50325
  && new _type_utils_1.TypeUtils(input.scope).isCharLike(type) === false
49894
50326
  && new _type_utils_1.TypeUtils(input.scope).isHexLike(type) === false) {
@@ -51025,6 +51457,7 @@ const statics_1 = __webpack_require__(/*! ./structures/statics */ "../core/build
51025
51457
  const constants_1 = __webpack_require__(/*! ./structures/constants */ "../core/build/src/abap/5_syntax/structures/constants.js");
51026
51458
  const cleanup_1 = __webpack_require__(/*! ./structures/cleanup */ "../core/build/src/abap/5_syntax/structures/cleanup.js");
51027
51459
  const try_1 = __webpack_require__(/*! ./structures/try */ "../core/build/src/abap/5_syntax/structures/try.js");
51460
+ const loop_group_by_1 = __webpack_require__(/*! ./expressions/loop_group_by */ "../core/build/src/abap/5_syntax/expressions/loop_group_by.js");
51028
51461
  const class_definition_1 = __webpack_require__(/*! ../types/class_definition */ "../core/build/src/abap/types/class_definition.js");
51029
51462
  const interface_definition_1 = __webpack_require__(/*! ../types/interface_definition */ "../core/build/src/abap/types/interface_definition.js");
51030
51463
  const delete_memory_1 = __webpack_require__(/*! ./statements/delete_memory */ "../core/build/src/abap/5_syntax/statements/delete_memory.js");
@@ -51450,6 +51883,12 @@ class SyntaxLogic {
51450
51883
  if (loop === true) {
51451
51884
  this.loopTables.pop();
51452
51885
  }
51886
+ if (node instanceof nodes_1.StructureNode && node.get() instanceof Structures.Loop) {
51887
+ const loopStatement = node.findDirectStatement(Statements.Loop);
51888
+ if (loopStatement) {
51889
+ loop_group_by_1.LoopGroupBy.unbind(loopStatement, this.scope);
51890
+ }
51891
+ }
51453
51892
  if (node instanceof nodes_1.StructureNode) {
51454
51893
  this.sortedLines.leave(node);
51455
51894
  }
@@ -55653,6 +56092,7 @@ const Expressions = __importStar(__webpack_require__(/*! ../2_statements/express
55653
56092
  const events_1 = __webpack_require__(/*! ../2_statements/statements/events */ "../core/build/src/abap/2_statements/statements/events.js");
55654
56093
  const expressions_1 = __webpack_require__(/*! ../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js");
55655
56094
  const method_param_1 = __webpack_require__(/*! ../5_syntax/expressions/method_param */ "../core/build/src/abap/5_syntax/expressions/method_param.js");
56095
+ const _syntax_input_1 = __webpack_require__(/*! ../5_syntax/_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
55656
56096
  class EventDefinition extends _identifier_1.Identifier {
55657
56097
  constructor(node, _visibility, input) {
55658
56098
  if (!(node.get() instanceof events_1.Events)) {
@@ -55675,10 +56115,21 @@ class EventDefinition extends _identifier_1.Identifier {
55675
56115
  }
55676
56116
  ///////////////
55677
56117
  parse(node, input) {
56118
+ var _a;
56119
+ var _b;
55678
56120
  for (const e of node.findAllExpressions(expressions_1.MethodParam)) {
56121
+ if (this.isPassByValue(e) === false) {
56122
+ const name = (_b = (_a = e.findDirectExpression(Expressions.MethodParamName)) === null || _a === void 0 ? void 0 : _a.concatTokens()) !== null && _b !== void 0 ? _b : "";
56123
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, e.getFirstToken(), "Event parameter " + name + " must be passed by VALUE"));
56124
+ }
55679
56125
  this.parameters.push(method_param_1.MethodParam.runSyntax(e, input, []));
55680
56126
  }
55681
56127
  }
56128
+ // event parameters can only be passed by value
56129
+ isPassByValue(param) {
56130
+ const first = param.getFirstToken().getStr().toUpperCase();
56131
+ return first === "VALUE" || first === "!VALUE";
56132
+ }
55682
56133
  }
55683
56134
  exports.EventDefinition = EventDefinition;
55684
56135
  //# sourceMappingURL=event_definition.js.map
@@ -55854,6 +56305,13 @@ class FunctionModuleDefinition {
55854
56305
  isGlobalParameters() {
55855
56306
  return this.globalParameters;
55856
56307
  }
56308
+ /** the classic exceptions, or the exception classes if isClassBasedExceptions() */
56309
+ getExceptions() {
56310
+ return this.exceptions;
56311
+ }
56312
+ isClassBasedExceptions() {
56313
+ return this.classBasedExceptions;
56314
+ }
55857
56315
  ///////////////
55858
56316
  parse(data) {
55859
56317
  if (data.FUNCNAME === undefined) {
@@ -55863,6 +56321,8 @@ class FunctionModuleDefinition {
55863
56321
  this.description = data.SHORT_TEXT;
55864
56322
  this.parameters = [];
55865
56323
  this.globalParameters = data.GLOBAL_FLAG === "X";
56324
+ this.exceptions = [];
56325
+ this.classBasedExceptions = data.EXCEPTION_CLASSES === "X";
55866
56326
  this.moduleType = FunctionModuleType.regular;
55867
56327
  if (data.REMOTE_CALL === "R") {
55868
56328
  this.moduleType = FunctionModuleType.remote;
@@ -55931,6 +56391,13 @@ class FunctionModuleDefinition {
55931
56391
  });
55932
56392
  }
55933
56393
  }
56394
+ if (data.EXCEPTION) {
56395
+ for (const exception of (0, xml_utils_1.xmlToArray)(data.EXCEPTION.RSEXC)) {
56396
+ if (typeof exception.EXCEPTION === "string") {
56397
+ this.exceptions.push(exception.EXCEPTION);
56398
+ }
56399
+ }
56400
+ }
55934
56401
  }
55935
56402
  }
55936
56403
  exports.FunctionModuleDefinition = FunctionModuleDefinition;
@@ -74063,7 +74530,7 @@ class Registry {
74063
74530
  }
74064
74531
  static abaplintVersion() {
74065
74532
  // magic, see build script "version.js"
74066
- return "2.120.110";
74533
+ return "2.120.112";
74067
74534
  }
74068
74535
  getDDICReferences() {
74069
74536
  return this.ddicReferences;
@@ -89332,6 +89799,11 @@ ${indentation} output = ${uniqueName}.\n`;
89332
89799
  if (this.lowReg.getConfig().isOpenABAP()) {
89333
89800
  return undefined;
89334
89801
  }
89802
+ else if (node.get() instanceof Statements.Loop
89803
+ && node.concatTokens().toUpperCase().startsWith("LOOP AT GROUP ")) {
89804
+ // rewritten by the LOOP GROUP downport, the inline target is outlined afterwards
89805
+ return undefined;
89806
+ }
89335
89807
  for (const i of node.findAllExpressionsRecursive(Expressions.InlineData)) {
89336
89808
  const nameToken = (_a = i.findDirectExpression(Expressions.TargetField)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
89337
89809
  if (nameToken === undefined) {
@@ -92520,6 +92992,155 @@ exports.FullyTypeITabs = FullyTypeITabs;
92520
92992
 
92521
92993
  /***/ },
92522
92994
 
92995
+ /***/ "../core/build/src/rules/function_module_parameter_names.js"
92996
+ /*!******************************************************************!*\
92997
+ !*** ../core/build/src/rules/function_module_parameter_names.js ***!
92998
+ \******************************************************************/
92999
+ (__unused_webpack_module, exports, __webpack_require__) {
93000
+
93001
+ "use strict";
93002
+
93003
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
93004
+ exports.FunctionModuleParameterNames = exports.FunctionModuleParameterNamesConf = void 0;
93005
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
93006
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
93007
+ const function_group_1 = __webpack_require__(/*! ../objects/function_group */ "../core/build/src/objects/function_group.js");
93008
+ const _naming_rule_config_1 = __webpack_require__(/*! ./_naming_rule_config */ "../core/build/src/rules/_naming_rule_config.js");
93009
+ const name_validator_1 = __webpack_require__(/*! ../utils/name_validator */ "../core/build/src/utils/name_validator.js");
93010
+ const function_module_definition_1 = __webpack_require__(/*! ../abap/types/function_module_definition */ "../core/build/src/abap/types/function_module_definition.js");
93011
+ const position_1 = __webpack_require__(/*! ../position */ "../core/build/src/position.js");
93012
+ class FunctionModuleParameterNamesConf extends _naming_rule_config_1.NamingRuleConfig {
93013
+ constructor() {
93014
+ super(...arguments);
93015
+ /** The pattern for importing parameters */
93016
+ this.importing = "^I._.+$";
93017
+ /** The pattern for exporting parameters */
93018
+ this.exporting = "^E._.+$";
93019
+ /** The pattern for changing parameters */
93020
+ this.changing = "^C._.+$";
93021
+ /** The pattern for tables parameters */
93022
+ this.tables = "^T._.+$";
93023
+ }
93024
+ }
93025
+ exports.FunctionModuleParameterNamesConf = FunctionModuleParameterNamesConf;
93026
+ class FunctionModuleParameterNames {
93027
+ constructor() {
93028
+ this.conf = new FunctionModuleParameterNamesConf();
93029
+ this.regex = this.compile();
93030
+ }
93031
+ getMetadata() {
93032
+ return {
93033
+ key: "function_module_parameter_names",
93034
+ title: "Function module parameter naming conventions",
93035
+ shortDescription: `Allows you to enforce a pattern, such as a prefix, for function module parameter names`,
93036
+ extendedInformation: `Checks the parameters of function modules in function groups,
93037
+ with a separate pattern for importing, exporting, changing and tables parameters.`,
93038
+ tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
93039
+ badExample: `FUNCTION z_get_name.
93040
+ *" IMPORTING
93041
+ *" VALUE(CUSTOMER) TYPE STRING
93042
+ *" EXPORTING
93043
+ *" VALUE(NAME) TYPE STRING
93044
+ ENDFUNCTION.`,
93045
+ goodExample: `FUNCTION z_get_name.
93046
+ *" IMPORTING
93047
+ *" VALUE(IV_CUSTOMER) TYPE STRING
93048
+ *" EXPORTING
93049
+ *" VALUE(EV_NAME) TYPE STRING
93050
+ ENDFUNCTION.`,
93051
+ };
93052
+ }
93053
+ getDescription(expected, actual) {
93054
+ return this.conf.patternKind === "required" ?
93055
+ "Function module parameter name does not match pattern " + expected + ": " + actual :
93056
+ "Function module parameter name must not match pattern " + expected + ": " + actual;
93057
+ }
93058
+ getConfig() {
93059
+ return this.conf;
93060
+ }
93061
+ setConfig(conf) {
93062
+ this.conf = conf;
93063
+ this.regex = this.compile();
93064
+ }
93065
+ compile() {
93066
+ return {
93067
+ importing: new RegExp(this.conf.importing, "i"),
93068
+ exporting: new RegExp(this.conf.exporting, "i"),
93069
+ changing: new RegExp(this.conf.changing, "i"),
93070
+ tables: new RegExp(this.conf.tables, "i"),
93071
+ ignorePatterns: name_validator_1.NameValidator.compileIgnorePatterns(this.conf),
93072
+ };
93073
+ }
93074
+ initialize(_reg) {
93075
+ return this;
93076
+ }
93077
+ run(obj) {
93078
+ if (this.conf.patternKind === undefined) {
93079
+ this.conf.patternKind = "required";
93080
+ }
93081
+ if (!(obj instanceof function_group_1.FunctionGroup)) {
93082
+ return [];
93083
+ }
93084
+ let ret = [];
93085
+ for (const module of obj.getModules()) {
93086
+ ret = ret.concat(this.checkModule(obj, module));
93087
+ }
93088
+ return ret;
93089
+ }
93090
+ checkModule(obj, module) {
93091
+ const ret = [];
93092
+ for (const p of module.getParameters()) {
93093
+ let expected;
93094
+ let regex;
93095
+ switch (p.direction) {
93096
+ case function_module_definition_1.FunctionModuleParameterDirection.importing:
93097
+ expected = this.conf.importing;
93098
+ regex = this.regex.importing;
93099
+ break;
93100
+ case function_module_definition_1.FunctionModuleParameterDirection.exporting:
93101
+ expected = this.conf.exporting;
93102
+ regex = this.regex.exporting;
93103
+ break;
93104
+ case function_module_definition_1.FunctionModuleParameterDirection.changing:
93105
+ expected = this.conf.changing;
93106
+ regex = this.regex.changing;
93107
+ break;
93108
+ case function_module_definition_1.FunctionModuleParameterDirection.tables:
93109
+ expected = this.conf.tables;
93110
+ regex = this.regex.tables;
93111
+ break;
93112
+ default:
93113
+ continue;
93114
+ }
93115
+ const issue = this.checkParameter(obj, module, p, expected, regex);
93116
+ if (issue) {
93117
+ ret.push(issue);
93118
+ }
93119
+ }
93120
+ return ret;
93121
+ }
93122
+ checkParameter(obj, module, param, expected, regex) {
93123
+ if (!name_validator_1.NameValidator.violatesRule(param.name, regex, this.conf, this.regex.ignorePatterns)) {
93124
+ return undefined;
93125
+ }
93126
+ // the parameter is only defined in the XML, so report at the start of the module file, if it exists
93127
+ const file = this.findModuleFile(obj, module) || obj.getMainABAPFile();
93128
+ if (file === undefined) {
93129
+ return undefined;
93130
+ }
93131
+ const message = this.getDescription(expected, param.name);
93132
+ return issue_1.Issue.atPosition(file, new position_1.Position(1, 1), message, this.getMetadata().key, this.conf.severity);
93133
+ }
93134
+ findModuleFile(obj, module) {
93135
+ const search = "." + module.getName().toLowerCase().replace(/\//g, "#") + ".abap";
93136
+ return obj.getABAPFiles().find(f => f.getFilename().toLowerCase().endsWith(search));
93137
+ }
93138
+ }
93139
+ exports.FunctionModuleParameterNames = FunctionModuleParameterNames;
93140
+ //# sourceMappingURL=function_module_parameter_names.js.map
93141
+
93142
+ /***/ },
93143
+
92523
93144
  /***/ "../core/build/src/rules/function_module_recommendations.js"
92524
93145
  /*!******************************************************************!*\
92525
93146
  !*** ../core/build/src/rules/function_module_recommendations.js ***!
@@ -94968,6 +95589,7 @@ __exportStar(__webpack_require__(/*! ./forbidden_void_type */ "../core/build/src
94968
95589
  __exportStar(__webpack_require__(/*! ./form_tables_obsolete */ "../core/build/src/rules/form_tables_obsolete.js"), exports);
94969
95590
  __exportStar(__webpack_require__(/*! ./fully_type_constants */ "../core/build/src/rules/fully_type_constants.js"), exports);
94970
95591
  __exportStar(__webpack_require__(/*! ./fully_type_itabs */ "../core/build/src/rules/fully_type_itabs.js"), exports);
95592
+ __exportStar(__webpack_require__(/*! ./function_module_parameter_names */ "../core/build/src/rules/function_module_parameter_names.js"), exports);
94971
95593
  __exportStar(__webpack_require__(/*! ./function_module_recommendations */ "../core/build/src/rules/function_module_recommendations.js"), exports);
94972
95594
  __exportStar(__webpack_require__(/*! ./functional_writing */ "../core/build/src/rules/functional_writing.js"), exports);
94973
95595
  __exportStar(__webpack_require__(/*! ./generic_regex */ "../core/build/src/rules/generic_regex.js"), exports);
@@ -95096,6 +95718,7 @@ __exportStar(__webpack_require__(/*! ./try_without_catch */ "../core/build/src/r
95096
95718
  __exportStar(__webpack_require__(/*! ./type_form_parameters */ "../core/build/src/rules/type_form_parameters.js"), exports);
95097
95719
  __exportStar(__webpack_require__(/*! ./types_naming */ "../core/build/src/rules/types_naming.js"), exports);
95098
95720
  __exportStar(__webpack_require__(/*! ./uncaught_exception */ "../core/build/src/rules/uncaught_exception.js"), exports);
95721
+ __exportStar(__webpack_require__(/*! ./unhandled_classic_exception */ "../core/build/src/rules/unhandled_classic_exception.js"), exports);
95099
95722
  __exportStar(__webpack_require__(/*! ./unit_test_assertions */ "../core/build/src/rules/unit_test_assertions.js"), exports);
95100
95723
  __exportStar(__webpack_require__(/*! ./unknown_types */ "../core/build/src/rules/unknown_types.js"), exports);
95101
95724
  __exportStar(__webpack_require__(/*! ./unnecessary_chaining */ "../core/build/src/rules/unnecessary_chaining.js"), exports);
@@ -97508,6 +98131,7 @@ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js"
97508
98131
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
97509
98132
  const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
97510
98133
  const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
98134
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
97511
98135
  class LoopTargetMisuseConf extends _basic_rule_config_1.BasicRuleConfig {
97512
98136
  constructor() {
97513
98137
  super(...arguments);
@@ -97516,6 +98140,9 @@ class LoopTargetMisuseConf extends _basic_rule_config_1.BasicRuleConfig {
97516
98140
  /** Report LOOP AT ... INTO <fs> and READ TABLE ... INTO <fs> when the local field symbol is only bound by ASSIGNING,
97517
98141
  * so the statement overwrites a table row */
97518
98142
  this.intoFieldSymbol = true;
98143
+ /** Report a field symbol of LOOP AT ... ASSIGNING used after ENDLOOP, and a field symbol of READ TABLE ... ASSIGNING
98144
+ * used after the check of sy-subrc, outside the branch that found the row */
98145
+ this.usedAfterLoop = true;
97519
98146
  }
97520
98147
  }
97521
98148
  exports.LoopTargetMisuseConf = LoopTargetMisuseConf;
@@ -97541,7 +98168,21 @@ Option intoFieldSymbol: LOOP AT ... INTO <fs> or READ TABLE ... INTO <fs>. INTO
97541
98168
  into the data object the field symbol points to. When <fs> was bound by ASSIGNING, that data
97542
98169
  object is a row of a table, and the statement overwrites it. ASSIGNING was meant.
97543
98170
  Reported only for a field symbol declared in the method, form or function module, and only when
97544
- no ASSIGN and no STRUCTURE ... DEFAULT binds it there, so it can only point to a table row.`,
98171
+ no ASSIGN and no STRUCTURE ... DEFAULT binds it there, so it can only point to a table row.
98172
+
98173
+ Option usedAfterLoop: a field symbol of LOOP AT ... ASSIGNING used after ENDLOOP. It points to
98174
+ the last row the loop processed. When the loop processed no row, it is not assigned, and the use
98175
+ raises GETWA_NOT_ASSIGNED, or it still points to what it was bound to before the loop.
98176
+ Also a field symbol of READ TABLE ... ASSIGNING used after sy-subrc was checked, outside the
98177
+ branch of that check. When the READ fails, the field symbol keeps its previous binding.
98178
+ Reported at the first such use in the method, form or function module.
98179
+ Not reported: a use inside IF, ELSEIF, CASE or WHILE whose condition reads sy-subrc, the table of
98180
+ the loop or a variable the loop body sets (a flag), a use after such a check that leaves with
98181
+ RETURN, EXIT, CONTINUE, CHECK, RAISE or MESSAGE or that does not use the field symbol, a use after
98182
+ CHECK or ASSERT of such a condition, and any use after IS ASSIGNED, UNASSIGN or another binding of
98183
+ the field symbol, or after a macro call. Work areas of INTO are not checked, they keep a value.
98184
+ A READ TABLE whose sy-subrc is not checked at all is left to check_subrc, a LOOP inside a LOOP
98185
+ with the same field symbol to the option nestedLoop.`,
97545
98186
  tags: [_irule_1.RuleTag.SingleFile],
97546
98187
  badExample: `LOOP AT lt_header INTO ls_row.
97547
98188
  LOOP AT lt_items INTO ls_row WHERE parent = ls_row-id.
@@ -97553,7 +98194,12 @@ ENDLOOP.
97553
98194
 
97554
98195
  LOOP AT lt_a ASSIGNING <ls_a>.
97555
98196
  ENDLOOP.
97556
- READ TABLE lt_a INTO <ls_a> INDEX 1.`,
98197
+ READ TABLE lt_a INTO <ls_a> INDEX 1.
98198
+
98199
+ LOOP AT lt_a ASSIGNING <ls_a> WHERE id = lv_id.
98200
+ EXIT.
98201
+ ENDLOOP.
98202
+ <ls_a>-flag = abap_true.`,
97557
98203
  goodExample: `LOOP AT lt_header INTO ls_row.
97558
98204
  LOOP AT lt_items INTO ls_item WHERE parent = ls_row-id.
97559
98205
  lv_sum = lv_sum + ls_item-amount.
@@ -97564,7 +98210,14 @@ ENDLOOP.
97564
98210
 
97565
98211
  LOOP AT lt_a ASSIGNING <ls_a>.
97566
98212
  ENDLOOP.
97567
- READ TABLE lt_a ASSIGNING <ls_a> INDEX 1.`,
98213
+ READ TABLE lt_a ASSIGNING <ls_a> INDEX 1.
98214
+
98215
+ LOOP AT lt_a ASSIGNING <ls_a> WHERE id = lv_id.
98216
+ EXIT.
98217
+ ENDLOOP.
98218
+ IF sy-subrc = 0.
98219
+ <ls_a>-flag = abap_true.
98220
+ ENDIF.`,
97568
98221
  };
97569
98222
  }
97570
98223
  getConfig() {
@@ -97582,6 +98235,14 @@ READ TABLE lt_a ASSIGNING <ls_a> INDEX 1.`,
97582
98235
  if (this.conf.intoFieldSymbol !== false) {
97583
98236
  issues.push(...this.checkIntoFieldSymbol(file, statements));
97584
98237
  }
98238
+ if (this.conf.usedAfterLoop !== false) {
98239
+ for (const issue of this.checkUsedAfterLoop(file, statements)) {
98240
+ // a READ TABLE ... INTO <fs> after the loop is already reported by the option intoFieldSymbol
98241
+ if (issues.some(i => i.getStart().equals(issue.getStart())) === false) {
98242
+ issues.push(issue);
98243
+ }
98244
+ }
98245
+ }
97585
98246
  return issues;
97586
98247
  }
97587
98248
  ////////////////
@@ -97638,7 +98299,7 @@ READ TABLE lt_a ASSIGNING <ls_a> INDEX 1.`,
97638
98299
  let depth = 0;
97639
98300
  for (let i = index + 1; i < statements.length && this.isBlockBoundary(statements[i]) === false; i++) {
97640
98301
  const s = statements[i].get();
97641
- if (s instanceof Statements.Loop) {
98302
+ if (s instanceof Statements.Loop || s instanceof Statements.LoopAtScreen || s instanceof Statements.LoopExtract) {
97642
98303
  depth++;
97643
98304
  }
97644
98305
  else if (s instanceof Statements.EndLoop) {
@@ -97747,6 +98408,232 @@ READ TABLE lt_a ASSIGNING <ls_a> INDEX 1.`,
97747
98408
  var _a;
97748
98409
  return (_a = fsTarget.findFirstExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
97749
98410
  }
98411
+ checkUsedAfterLoop(file, statements) {
98412
+ var _a;
98413
+ const issues = [];
98414
+ // the field symbols of the open LOOPs, undefined for a LOOP without field symbol
98415
+ let open = [];
98416
+ for (let i = 0; i < statements.length; i++) {
98417
+ const statement = statements[i];
98418
+ const s = statement.get();
98419
+ if (this.isBlockBoundary(statement)) {
98420
+ open = [];
98421
+ continue;
98422
+ }
98423
+ else if (s instanceof Statements.EndLoop) {
98424
+ open.pop();
98425
+ continue;
98426
+ }
98427
+ let use = undefined;
98428
+ let name = undefined;
98429
+ let what = "";
98430
+ if (s instanceof Statements.Loop) {
98431
+ const node = this.loopTarget(statement);
98432
+ name = (node === null || node === void 0 ? void 0 : node.get()) instanceof Expressions.FSTarget ? this.targetName(node) : undefined;
98433
+ const end = this.findEndLoop(statements, i);
98434
+ // a LOOP inside a LOOP with the same field symbol is left to the option nestedLoop
98435
+ if (name !== undefined && end !== undefined && open.includes(name) === false) {
98436
+ const guards = this.loopGuards(statements, i, end, name);
98437
+ use = this.findUncheckedUse(statements, end + 1, name, guards, false);
98438
+ what = `after ENDLOOP, it points to the last row, or is not assigned when the loop processed no row`;
98439
+ }
98440
+ open.push(name);
98441
+ }
98442
+ else if (s instanceof Statements.LoopAtScreen || s instanceof Statements.LoopExtract) {
98443
+ open.push(undefined);
98444
+ }
98445
+ else if (s instanceof Statements.ReadTable) {
98446
+ const fs = (_a = statement.findDirectExpression(Expressions.ReadTableTarget)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.FSTarget);
98447
+ name = fs ? this.targetName(fs) : undefined;
98448
+ if (name !== undefined) {
98449
+ use = this.findUncheckedUse(statements, i + 1, name, new Set(), true);
98450
+ what = `outside the check of sy-subrc, when the READ TABLE fails it is not assigned or points to an earlier row`;
98451
+ }
98452
+ }
98453
+ if (use !== undefined && name !== undefined) {
98454
+ const token = statements[use].getTokens().find(t => t.getStr().toUpperCase() === name);
98455
+ const message = `${token === null || token === void 0 ? void 0 : token.getStr()} is used ${what}`;
98456
+ issues.push(issue_1.Issue.atStatement(file, statements[use], message, this.getMetadata().key, this.conf.severity));
98457
+ }
98458
+ }
98459
+ return issues;
98460
+ }
98461
+ /** upper case names of the variables whose check counts as a check that the LOOP processed a row:
98462
+ * the table and the variables the loop body writes */
98463
+ loopGuards(statements, loop, end, name) {
98464
+ var _a;
98465
+ const guards = new Set();
98466
+ const first = (_a = statements[loop].findDirectExpression(Expressions.LoopSource)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr().toUpperCase();
98467
+ if (first !== undefined) {
98468
+ guards.add(first);
98469
+ }
98470
+ for (let i = loop + 1; i < end; i++) {
98471
+ for (const target of statements[i].findAllExpressions(Expressions.Target)) {
98472
+ guards.add(this.firstName(target));
98473
+ }
98474
+ }
98475
+ guards.delete(name);
98476
+ return guards;
98477
+ }
98478
+ /** upper case name of the variable a Target writes, also declared inline */
98479
+ firstName(target) {
98480
+ const inline = target.findFirstExpression(Expressions.TargetField);
98481
+ return (inline ? inline.getFirstToken() : target.getFirstToken()).getStr().toUpperCase();
98482
+ }
98483
+ /** index of the first statement from the index on that uses the field symbol without a check before it,
98484
+ * looking until the end of the method, form or function module or until the field symbol is bound again.
98485
+ * With checkFirst, only a use after a check is returned, an unchecked READ TABLE is left to check_subrc */
98486
+ findUncheckedUse(statements, from, name, guards, checkFirst) {
98487
+ const frames = [];
98488
+ let checked = false;
98489
+ let sawCheck = false;
98490
+ for (let i = from; i < statements.length && this.isBlockBoundary(statements[i]) === false; i++) {
98491
+ const statement = statements[i];
98492
+ const s = statement.get();
98493
+ if (s instanceof _statement_1.MacroCall || s instanceof _statement_1.Unknown || this.bindsOrTests(statement, name)) {
98494
+ return undefined;
98495
+ }
98496
+ const isCondition = s instanceof Statements.If || s instanceof Statements.ElseIf || s instanceof Statements.Case
98497
+ || s instanceof Statements.When || s instanceof Statements.While
98498
+ || s instanceof Statements.Check || s instanceof Statements.Assert;
98499
+ const guard = isCondition && this.isGuard(statement, guards);
98500
+ sawCheck = sawCheck || guard;
98501
+ if ((s instanceof Statements.Check || s instanceof Statements.Assert) && guard) {
98502
+ checked = true;
98503
+ }
98504
+ if (s instanceof Statements.FieldSymbol === false && this.mentions(statement, name)) {
98505
+ if (guard || checked || frames.some(f => f.guard)) {
98506
+ frames.forEach(f => f.uses = true);
98507
+ }
98508
+ else if (checkFirst === false || sawCheck === true) {
98509
+ return i;
98510
+ }
98511
+ }
98512
+ if (guard || frames.some(f => f.guard)) {
98513
+ // a flag set where the check holds, like lv_found = abap_true, checks it as well
98514
+ for (const target of statement.findAllExpressions(Expressions.Target)) {
98515
+ guards.add(this.firstName(target));
98516
+ }
98517
+ guards.delete(name);
98518
+ }
98519
+ if (this.leaves(statement)) {
98520
+ frames.forEach(f => f.leaves = true);
98521
+ }
98522
+ if (this.opensBlock(statement)) {
98523
+ frames.push({ guard, uses: false, leaves: false });
98524
+ }
98525
+ else if (this.isBranch(statement)) {
98526
+ if (frames.length === 0) {
98527
+ // another branch of a block around the binding, it does not run after it
98528
+ return undefined;
98529
+ }
98530
+ frames[frames.length - 1].guard = frames[frames.length - 1].guard || guard;
98531
+ }
98532
+ else if (this.closesBlock(statement)) {
98533
+ const frame = frames.pop();
98534
+ // IF sy-subrc <> 0. RETURN. ENDIF., or a check that sets a flag
98535
+ if (frame && frame.guard && (frame.leaves || frame.uses === false)) {
98536
+ checked = true;
98537
+ }
98538
+ }
98539
+ }
98540
+ return undefined;
98541
+ }
98542
+ /** true when the statement binds the field symbol again, unassigns it, or checks IS ASSIGNED */
98543
+ bindsOrTests(statement, name) {
98544
+ if (statement.get() instanceof Statements.Unassign && this.mentions(statement, name)) {
98545
+ return true;
98546
+ }
98547
+ for (const fsTarget of statement.findAllExpressions(Expressions.FSTarget)) {
98548
+ if (this.targetName(fsTarget) === name) {
98549
+ return true;
98550
+ }
98551
+ }
98552
+ const tokens = statement.getTokens().map(t => t.getStr().toUpperCase());
98553
+ for (let i = 0; i < tokens.length - 2; i++) {
98554
+ if (tokens[i] === name && tokens[i + 1] === "IS"
98555
+ && (tokens[i + 2] === "ASSIGNED" || (tokens[i + 2] === "NOT" && tokens[i + 3] === "ASSIGNED"))) {
98556
+ return true;
98557
+ }
98558
+ }
98559
+ return false;
98560
+ }
98561
+ /** true when the condition reads sy-subrc or one of the variables */
98562
+ isGuard(statement, guards) {
98563
+ var _a, _b;
98564
+ const tokens = statement.getTokens();
98565
+ for (let i = 0; i < tokens.length; i++) {
98566
+ const str = tokens[i].getStr().toUpperCase();
98567
+ const previous = i > 0 ? tokens[i - 1].getStr() : "";
98568
+ if (["-", "->", "=>", "~"].includes(previous)) {
98569
+ continue;
98570
+ }
98571
+ if ((str === "SY" && ((_a = tokens[i + 1]) === null || _a === void 0 ? void 0 : _a.getStr()) === "-" && ((_b = tokens[i + 2]) === null || _b === void 0 ? void 0 : _b.getStr().toUpperCase()) === "SUBRC")
98572
+ || guards.has(str)) {
98573
+ return true;
98574
+ }
98575
+ }
98576
+ return false;
98577
+ }
98578
+ mentions(statement, name) {
98579
+ return statement.getTokens().some(t => t.getStr().toUpperCase() === name);
98580
+ }
98581
+ /** true for a statement that can leave the current block, a call of a method named like RAISE counts */
98582
+ leaves(statement) {
98583
+ const s = statement.get();
98584
+ return s instanceof Statements.Return
98585
+ || s instanceof Statements.Exit
98586
+ || s instanceof Statements.Continue
98587
+ || s instanceof Statements.Check
98588
+ || s instanceof Statements.Raise
98589
+ || s instanceof Statements.Leave
98590
+ || s instanceof Statements.Message
98591
+ || s instanceof Statements.Assert
98592
+ || (s instanceof Statements.Call && statement.getTokens().some(t => /raise/i.test(t.getStr())));
98593
+ }
98594
+ opensBlock(statement) {
98595
+ const s = statement.get();
98596
+ return s instanceof Statements.If
98597
+ || s instanceof Statements.Case
98598
+ || s instanceof Statements.CaseType
98599
+ || s instanceof Statements.Loop
98600
+ || s instanceof Statements.LoopAtScreen
98601
+ || s instanceof Statements.LoopExtract
98602
+ || s instanceof Statements.Do
98603
+ || s instanceof Statements.While
98604
+ || s instanceof Statements.Try
98605
+ || s instanceof Statements.SelectLoop
98606
+ || s instanceof Statements.At
98607
+ || s instanceof Statements.AtFirst
98608
+ || s instanceof Statements.AtLast
98609
+ || s instanceof Statements.OnChange
98610
+ || s instanceof Statements.Provide
98611
+ || s instanceof Statements.CatchSystemExceptions;
98612
+ }
98613
+ isBranch(statement) {
98614
+ const s = statement.get();
98615
+ return s instanceof Statements.ElseIf
98616
+ || s instanceof Statements.Else
98617
+ || s instanceof Statements.When
98618
+ || s instanceof Statements.WhenOthers
98619
+ || s instanceof Statements.WhenType
98620
+ || s instanceof Statements.Catch
98621
+ || s instanceof Statements.Cleanup;
98622
+ }
98623
+ closesBlock(statement) {
98624
+ const s = statement.get();
98625
+ return s instanceof Statements.EndIf
98626
+ || s instanceof Statements.EndCase
98627
+ || s instanceof Statements.EndLoop
98628
+ || s instanceof Statements.EndDo
98629
+ || s instanceof Statements.EndWhile
98630
+ || s instanceof Statements.EndTry
98631
+ || s instanceof Statements.EndSelect
98632
+ || s instanceof Statements.EndAt
98633
+ || s instanceof Statements.EndOn
98634
+ || s instanceof Statements.EndProvide
98635
+ || s instanceof Statements.EndCatch;
98636
+ }
97750
98637
  isBlockBoundary(statement) {
97751
98638
  return this.startsBlock(statement) || this.endsBlock(statement);
97752
98639
  }
@@ -106765,8 +107652,16 @@ text = text.`,
106765
107652
  if (structure === undefined) {
106766
107653
  continue;
106767
107654
  }
107655
+ const sources = structure.findAllExpressionsRecursive(Expressions.Source);
107656
+ // Sources that are an operand of an enclosing Source, e.g. "2 * CONV i( a + b )" or "- CONV i( a + b )"
107657
+ const operands = new Set();
107658
+ for (const source of sources) {
107659
+ if (source.getChildren().length > 1) {
107660
+ source.findDirectExpressions(Expressions.Source).forEach(operand => operands.add(operand));
107661
+ }
107662
+ }
106768
107663
  // recursive, a CONV can be the argument of a built-in function, which is itself a Source
106769
- for (const source of structure.findAllExpressionsRecursive(Expressions.Source)) {
107664
+ for (const source of sources) {
106770
107665
  if (source.getFirstToken().getStr().toUpperCase() !== "CONV") {
106771
107666
  continue;
106772
107667
  }
@@ -106799,8 +107694,12 @@ text = text.`,
106799
107694
  if (closingParen === undefined) {
106800
107695
  continue;
106801
107696
  }
106802
- const preserveParentheses = bodySource.findDirectExpression(Expressions.ArithOperator) !== undefined
106803
- || bodySource.findDirectTokenByText("&&") !== undefined;
107697
+ // parentheses are only needed when the CONV takes part in a surrounding operation,
107698
+ // "CONV type ( body )" alone has 5 children, more means a trailing operator
107699
+ const partOfOperation = source.getChildren().length !== 5 || operands.has(source);
107700
+ const preserveParentheses = partOfOperation
107701
+ && (bodySource.findDirectExpression(Expressions.ArithOperator) !== undefined
107702
+ || bodySource.findDirectTokenByText("&&") !== undefined);
106804
107703
  // Apply the later edit first so the original positions remain valid when
106805
107704
  // both parts of the CONV wrapper are changed on the same line.
106806
107705
  const fix = edit_helper_1.EditHelper.merge(edit_helper_1.EditHelper.replaceRange(file, bodySource.getLastToken().getEnd(), closingParen.getEnd(), preserveParentheses ? ")" : ""), edit_helper_1.EditHelper.replaceRange(file, source.getFirstToken().getStart(), bodySource.getFirstToken().getStart(), preserveParentheses ? "(" : ""));
@@ -107390,6 +108289,15 @@ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/sta
107390
108289
  const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
107391
108290
  const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
107392
108291
  class RFCErrorHandlingConf extends _basic_rule_config_1.BasicRuleConfig {
108292
+ constructor() {
108293
+ super(...arguments);
108294
+ /** Also check CALL FUNCTION ... STARTING NEW TASK without DESTINATION, an asynchronous RFC to the destination NONE */
108295
+ this.startingNewTask = true;
108296
+ /** Report error_message in the EXCEPTIONS of an RFC call, it is ignored in RFC */
108297
+ this.errorMessage = true;
108298
+ /** Report SYSTEM_FAILURE and COMMUNICATION_FAILURE without the addition MESSAGE, the error text is lost */
108299
+ this.requireMessage = false;
108300
+ }
107393
108301
  }
107394
108302
  exports.RFCErrorHandlingConf = RFCErrorHandlingConf;
107395
108303
  class RFCErrorHandling extends _abap_rule_1.ABAPRule {
@@ -107405,11 +108313,35 @@ class RFCErrorHandling extends _abap_rule_1.ABAPRule {
107405
108313
  shortDescription: `Checks that exceptions 'system_failure' and 'communication_failure' are handled in RFC calls`,
107406
108314
  extendedInformation: `RESOURCE_FAILURE is also required for asynchronous calls with DESTINATION IN GROUP.
107407
108315
 
107408
- https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenrfc_exception.html`,
108316
+ Checked are CALL FUNCTION ... DESTINATION and, with startingNewTask, CALL FUNCTION ... STARTING NEW TASK
108317
+ without DESTINATION, which is an asynchronous RFC to the destination NONE.
108318
+ CALL FUNCTION ... IN BACKGROUND TASK is not checked, it cannot have EXCEPTIONS.
108319
+
108320
+ errorMessage: reports error_message in the EXCEPTIONS of an RFC call. It is ignored in RFC, a message of
108321
+ type A, E or X ends the called function module and raises SYSTEM_FAILURE, use system_failure = n MESSAGE msg
108322
+ to get the message text. Exception: with a DESTINATION that is blank at runtime, the call is local.
108323
+
108324
+ requireMessage: reports SYSTEM_FAILURE and COMMUNICATION_FAILURE without the addition MESSAGE.
108325
+
108326
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenrfc_exception.html
108327
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapcall_function_destination_para.html`,
107409
108328
  badExample: `CALL FUNCTION 'ZRFC'
107410
- DESTINATION lv_rfc.`,
108329
+ DESTINATION lv_rfc.
108330
+
108331
+ CALL FUNCTION 'ZRFC'
108332
+ STARTING NEW TASK 'TASK'
108333
+ EXCEPTIONS
108334
+ error_message = 1
108335
+ OTHERS = 2.`,
107411
108336
  goodExample: `CALL FUNCTION 'ZRFC'
107412
108337
  DESTINATION lv_rfc
108338
+ EXCEPTIONS
108339
+ system_failure = 1 MESSAGE msg
108340
+ communication_failure = 2 MESSAGE msg
108341
+ OTHERS = 3.
108342
+
108343
+ CALL FUNCTION 'ZRFC'
108344
+ STARTING NEW TASK 'TASK'
107413
108345
  EXCEPTIONS
107414
108346
  system_failure = 1 MESSAGE msg
107415
108347
  communication_failure = 2 MESSAGE msg
@@ -107434,28 +108366,45 @@ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenrfc_exceptio
107434
108366
  continue;
107435
108367
  }
107436
108368
  const destination = stat.findFirstExpression(Expressions.Destination);
107437
- if (destination === undefined) {
108369
+ const starting = stat.findDirectTokenByText("STARTING") !== undefined;
108370
+ if (destination === undefined && (starting === false || this.conf.startingNewTask === false)) {
108371
+ continue;
108372
+ }
108373
+ if (stat.findDirectTokenByText("BACKGROUND") !== undefined) {
108374
+ // transactional RFC, it has no EXCEPTIONS
107438
108375
  continue;
107439
108376
  }
107440
- const requireResourceFailure = stat.findDirectTokenByText("STARTING") !== undefined
107441
- && destination.findDirectTokenByText("GROUP") !== undefined;
108377
+ const requireResourceFailure = starting === true
108378
+ && (destination === null || destination === void 0 ? void 0 : destination.findDirectTokenByText("GROUP")) !== undefined;
107442
108379
  const list = stat.findFirstExpression(Expressions.ParameterListExceptions);
107443
108380
  if (list === undefined) {
107444
108381
  const issue = issue_1.Issue.atToken(file, token, this.getMessage(requireResourceFailure), this.getMetadata().key, this.conf.severity);
107445
108382
  output.push(issue);
107446
108383
  continue;
107447
108384
  }
107448
- const parameters = list.findAllExpressions(Expressions.ParameterName);
107449
- const names = [];
107450
- for (const par of parameters) {
107451
- names.push(par.getFirstToken().getStr().toUpperCase());
108385
+ const exceptions = new Map();
108386
+ for (const exception of list.findDirectExpressions(Expressions.ParameterException)) {
108387
+ exceptions.set(exception.getFirstToken().getStr().toUpperCase(), exception);
107452
108388
  }
107453
- if (names.indexOf("SYSTEM_FAILURE") < 0
107454
- || names.indexOf("COMMUNICATION_FAILURE") < 0
107455
- || (requireResourceFailure && names.indexOf("RESOURCE_FAILURE") < 0)) {
108389
+ if (exceptions.has("SYSTEM_FAILURE") === false
108390
+ || exceptions.has("COMMUNICATION_FAILURE") === false
108391
+ || (requireResourceFailure && exceptions.has("RESOURCE_FAILURE") === false)) {
107456
108392
  const issue = issue_1.Issue.atToken(file, token, this.getMessage(requireResourceFailure), this.getMetadata().key, this.conf.severity);
107457
108393
  output.push(issue);
107458
- continue;
108394
+ }
108395
+ const errorMessage = exceptions.get("ERROR_MESSAGE");
108396
+ if (this.conf.errorMessage !== false && errorMessage !== undefined) {
108397
+ const message = "error_message is ignored in RFC, messages of type A, E and X raise SYSTEM_FAILURE, use system_failure = n MESSAGE msg";
108398
+ output.push(issue_1.Issue.atToken(file, errorMessage.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
108399
+ }
108400
+ if (this.conf.requireMessage === true) {
108401
+ for (const name of ["SYSTEM_FAILURE", "COMMUNICATION_FAILURE"]) {
108402
+ const exception = exceptions.get(name);
108403
+ if (exception !== undefined && exception.findDirectTokenByText("MESSAGE") === undefined) {
108404
+ const message = `${name} without MESSAGE, the error text is lost, use ${name.toLowerCase()} = n MESSAGE msg`;
108405
+ output.push(issue_1.Issue.atToken(file, exception.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
108406
+ }
108407
+ }
107459
108408
  }
107460
108409
  }
107461
108410
  return output;
@@ -113465,6 +114414,321 @@ exports.UncaughtException = UncaughtException;
113465
114414
 
113466
114415
  /***/ },
113467
114416
 
114417
+ /***/ "../core/build/src/rules/unhandled_classic_exception.js"
114418
+ /*!**************************************************************!*\
114419
+ !*** ../core/build/src/rules/unhandled_classic_exception.js ***!
114420
+ \**************************************************************/
114421
+ (__unused_webpack_module, exports, __webpack_require__) {
114422
+
114423
+ "use strict";
114424
+
114425
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
114426
+ if (k2 === undefined) k2 = k;
114427
+ var desc = Object.getOwnPropertyDescriptor(m, k);
114428
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
114429
+ desc = { enumerable: true, get: function() { return m[k]; } };
114430
+ }
114431
+ Object.defineProperty(o, k2, desc);
114432
+ }) : (function(o, m, k, k2) {
114433
+ if (k2 === undefined) k2 = k;
114434
+ o[k2] = m[k];
114435
+ }));
114436
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
114437
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
114438
+ }) : function(o, v) {
114439
+ o["default"] = v;
114440
+ });
114441
+ var __importStar = (this && this.__importStar) || (function () {
114442
+ var ownKeys = function(o) {
114443
+ ownKeys = Object.getOwnPropertyNames || function (o) {
114444
+ var ar = [];
114445
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
114446
+ return ar;
114447
+ };
114448
+ return ownKeys(o);
114449
+ };
114450
+ return function (mod) {
114451
+ if (mod && mod.__esModule) return mod;
114452
+ var result = {};
114453
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
114454
+ __setModuleDefault(result, mod);
114455
+ return result;
114456
+ };
114457
+ })();
114458
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
114459
+ exports.UnhandledClassicException = exports.UnhandledClassicExceptionConf = void 0;
114460
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
114461
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
114462
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
114463
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
114464
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
114465
+ const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
114466
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
114467
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
114468
+ const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
114469
+ const types_1 = __webpack_require__(/*! ../abap/types */ "../core/build/src/abap/types/index.js");
114470
+ const virtual_position_1 = __webpack_require__(/*! ../virtual_position */ "../core/build/src/virtual_position.js");
114471
+ class UnhandledClassicExceptionConf extends _basic_rule_config_1.BasicRuleConfig {
114472
+ constructor() {
114473
+ super(...arguments);
114474
+ this.severity = severity_1.Severity.Warning;
114475
+ /** Report an EXCEPTIONS list without OTHERS, unless the method or function module is known and all its exceptions are listed */
114476
+ this.missingOthers = true;
114477
+ /** Report a call without EXCEPTIONS, including a functional call, of a method or function module that declares classic exceptions */
114478
+ this.missingExceptions = true;
114479
+ /** missingExceptions: do not report a method call whose arguments are all literals or me, like describe_by_name( 'T100' ) */
114480
+ this.allowLiteralArguments = true;
114481
+ /** Report CALL FUNCTION without error_message, the policy "always list error_message", for code that runs outside dialog */
114482
+ this.missingErrorMessage = false;
114483
+ }
114484
+ }
114485
+ exports.UnhandledClassicExceptionConf = UnhandledClassicExceptionConf;
114486
+ class UnhandledClassicException extends _abap_rule_1.ABAPRule {
114487
+ constructor() {
114488
+ super(...arguments);
114489
+ this.conf = new UnhandledClassicExceptionConf();
114490
+ }
114491
+ getMetadata() {
114492
+ return {
114493
+ key: "unhandled_classic_exception",
114494
+ title: "Unhandled classic exception",
114495
+ shortDescription: `Finds calls that do not map every classic exception the callee can raise`,
114496
+ extendedInformation: `A classic exception that is raised with RAISE and not mapped in the EXCEPTIONS addition of the call
114497
+ ends in the runtime error RAISE_EXCEPTION. TRY ... CATCH cx_root does not catch it.
114498
+
114499
+ missingOthers: reports CALL FUNCTION and method calls with an EXCEPTIONS list without OTHERS.
114500
+ Not reported if the function module or method is known and every exception it declares is listed,
114501
+ for CALL FUNCTION ... DESTINATION this includes SYSTEM_FAILURE and COMMUNICATION_FAILURE.
114502
+ CALL FUNCTION ... STARTING NEW TASK, IN UPDATE TASK and IN BACKGROUND are not checked.
114503
+
114504
+ missingExceptions: reports calls without EXCEPTIONS of a method or function module that declares classic exceptions,
114505
+ this includes functional calls, which cannot have EXCEPTIONS.
114506
+ With allowLiteralArguments, a method call whose arguments are all literals or me is not reported.
114507
+
114508
+ missingErrorMessage, off by default: reports every CALL FUNCTION that does not list the predefined exception error_message,
114509
+ the policy "always list error_message". Any function module can send a MESSAGE without RAISING, directly or from a
114510
+ function module it calls, and OTHERS does not catch it. Outside dialog, in HTTP handlers, RFC and background jobs,
114511
+ a message of type E or A ends the processing. Use it together with check_subrc, otherwise error_message turns a
114512
+ visible abort into a silent failure. Not reported: DESTINATION, STARTING NEW TASK, IN UPDATE TASK, IN BACKGROUND,
114513
+ EXCEPTION-TABLE, and function modules in the registry with class-based exceptions.
114514
+
114515
+ Signatures are taken from the registry, including dependencies. Methods and function modules that are not
114516
+ found (void) are only checked by missingOthers.
114517
+
114518
+ Does not report any issues if the code contains syntax errors`,
114519
+ tags: [_irule_1.RuleTag.Syntax],
114520
+ badExample: `CALL FUNCTION 'Z_READ'
114521
+ EXCEPTIONS
114522
+ not_found = 1.
114523
+
114524
+ lo_type = cl_abap_typedescr=>describe_by_name( lv_name ).`,
114525
+ goodExample: `CALL FUNCTION 'Z_READ'
114526
+ EXCEPTIONS
114527
+ not_found = 1
114528
+ OTHERS = 2.
114529
+
114530
+ cl_abap_typedescr=>describe_by_name(
114531
+ EXPORTING
114532
+ p_name = lv_name
114533
+ RECEIVING
114534
+ p_descr_ref = lo_type
114535
+ EXCEPTIONS
114536
+ type_not_found = 1
114537
+ OTHERS = 2 ).`,
114538
+ };
114539
+ }
114540
+ initialize(reg) {
114541
+ super.initialize(reg);
114542
+ this.functionModules = undefined;
114543
+ return this;
114544
+ }
114545
+ getConfig() {
114546
+ return this.conf;
114547
+ }
114548
+ setConfig(conf) {
114549
+ this.conf = conf;
114550
+ }
114551
+ runParsed(file, obj) {
114552
+ var _a;
114553
+ if (obj.getType() === "INTF" || file.getStructure() === undefined) {
114554
+ return [];
114555
+ }
114556
+ const syntax = new syntax_1.SyntaxLogic(this.reg, obj).run();
114557
+ if (syntax.issues.length > 0) {
114558
+ return [];
114559
+ }
114560
+ const methods = new Map();
114561
+ this.findMethodReferences(syntax.spaghetti.getTop(), file.getFilename(), methods);
114562
+ const issues = [];
114563
+ for (const statement of file.getStatements()) {
114564
+ if (statement.get() instanceof Statements.CallFunction) {
114565
+ issues.push(...this.checkCallFunction(statement, file));
114566
+ continue;
114567
+ }
114568
+ if (statement.get() instanceof Statements.Call) {
114569
+ const source = statement.findDirectExpression(Expressions.MethodSource);
114570
+ const body = statement.findDirectExpression(Expressions.MethodCallBody);
114571
+ const nameNode = source === null || source === void 0 ? void 0 : source.getLastChild();
114572
+ if (nameNode) {
114573
+ const token = nameNode.getFirstToken();
114574
+ const callee = nameNode.get() instanceof Expressions.Dynamic ? undefined : this.findMethod(methods, token);
114575
+ const issue = this.checkCall(file, token, callee, body === null || body === void 0 ? void 0 : body.findDirectExpression(Expressions.MethodParameters), (body === null || body === void 0 ? void 0 : body.findDirectTokenByText("EXCEPTION")) !== undefined, false, this.onlyLiterals(body));
114576
+ if (issue) {
114577
+ issues.push(issue);
114578
+ }
114579
+ }
114580
+ }
114581
+ for (const call of statement.findAllExpressionsRecursive(Expressions.MethodCall)) {
114582
+ const token = (_a = call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
114583
+ if (token === undefined) {
114584
+ continue;
114585
+ }
114586
+ const param = call.findDirectExpression(Expressions.MethodCallParam);
114587
+ const parameters = param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.MethodParameters);
114588
+ const issue = this.checkCall(file, token, this.findMethod(methods, token), parameters, false, false, this.onlyLiterals(param));
114589
+ if (issue) {
114590
+ issues.push(issue);
114591
+ }
114592
+ }
114593
+ }
114594
+ return issues;
114595
+ }
114596
+ checkCallFunction(statement, file) {
114597
+ var _a;
114598
+ if (statement.findDirectTokenByText("STARTING")
114599
+ || statement.findDirectTokenByText("UPDATE")
114600
+ || statement.findDirectTokenByText("BACKGROUND")) {
114601
+ return [];
114602
+ }
114603
+ const nameNode = statement.findDirectExpression(Expressions.FunctionName);
114604
+ if (nameNode === undefined) {
114605
+ return [];
114606
+ }
114607
+ let callee = undefined;
114608
+ let classBased = false;
114609
+ if (nameNode.findFirstExpression(Expressions.FieldChain) === undefined) {
114610
+ const name = nameNode.concatTokens().replace(/'/g, "").replace(/`/g, "");
114611
+ const module = this.findFunctionModule(name);
114612
+ if (module) {
114613
+ classBased = module.isClassBasedExceptions();
114614
+ callee = {
114615
+ name: module.getName(),
114616
+ exceptions: classBased ? [] : module.getExceptions().map(e => e.toUpperCase()),
114617
+ };
114618
+ }
114619
+ }
114620
+ const issues = [];
114621
+ const parameters = statement.findDirectExpression(Expressions.FunctionParameters);
114622
+ const exceptionTable = statement.findDirectTokenByText("EXCEPTION") !== undefined;
114623
+ const destination = statement.findDirectExpression(Expressions.Destination) !== undefined;
114624
+ const issue = this.checkCall(file, nameNode.getFirstToken(), callee, parameters, exceptionTable, destination, false);
114625
+ if (issue) {
114626
+ issues.push(issue);
114627
+ }
114628
+ if (this.conf.missingErrorMessage === true && exceptionTable === false && destination === false && classBased === false) {
114629
+ const listed = (_a = parameters === null || parameters === void 0 ? void 0 : parameters.findDirectExpression(Expressions.ParameterListExceptions)) === null || _a === void 0 ? void 0 : _a.findDirectExpressions(Expressions.ParameterException).some(e => e.getFirstChild().concatTokens().toUpperCase() === "ERROR_MESSAGE");
114630
+ if (listed !== true) {
114631
+ const position = (parameters === null || parameters === void 0 ? void 0 : parameters.findDirectTokenByText("EXCEPTIONS")) || nameNode.getFirstToken();
114632
+ const message = "No error_message, OTHERS does not catch a message that the function module sends without RAISING";
114633
+ issues.push(issue_1.Issue.atToken(file, position, message, this.getMetadata().key, this.conf.severity));
114634
+ }
114635
+ }
114636
+ return issues;
114637
+ }
114638
+ checkCall(file, token, callee, parameters, exceptionTable, destination, onlyLiterals) {
114639
+ if (exceptionTable === true) {
114640
+ return undefined;
114641
+ }
114642
+ const list = parameters === null || parameters === void 0 ? void 0 : parameters.findDirectExpression(Expressions.ParameterListExceptions);
114643
+ if (list === undefined) {
114644
+ if (this.conf.missingExceptions === false
114645
+ || callee === undefined
114646
+ || callee.exceptions.length === 0
114647
+ || (this.conf.allowLiteralArguments === true && onlyLiterals === true)) {
114648
+ return undefined;
114649
+ }
114650
+ const message = `Classic exceptions of "${callee.name}" not handled: ${callee.exceptions.join(", ")}, call it with EXCEPTIONS`;
114651
+ return issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity);
114652
+ }
114653
+ if (this.conf.missingOthers === false) {
114654
+ return undefined;
114655
+ }
114656
+ const listed = list.findDirectExpressions(Expressions.ParameterException)
114657
+ .map(e => e.getFirstChild().concatTokens().toUpperCase());
114658
+ if (listed.includes("OTHERS")) {
114659
+ return undefined;
114660
+ }
114661
+ const position = parameters.findDirectTokenByText("EXCEPTIONS") || list.getFirstToken();
114662
+ if (callee === undefined) {
114663
+ const message = "EXCEPTIONS without OTHERS, an exception that is not listed ends in a runtime error";
114664
+ return issue_1.Issue.atToken(file, position, message, this.getMetadata().key, this.conf.severity);
114665
+ }
114666
+ const expected = [...callee.exceptions];
114667
+ if (destination === true) {
114668
+ expected.push("SYSTEM_FAILURE", "COMMUNICATION_FAILURE");
114669
+ }
114670
+ const missing = expected.filter(e => listed.includes(e) === false);
114671
+ if (missing.length === 0) {
114672
+ return undefined;
114673
+ }
114674
+ const message = `EXCEPTIONS without OTHERS, not mapped: ${missing.join(", ")}`;
114675
+ return issue_1.Issue.atToken(file, position, message, this.getMetadata().key, this.conf.severity);
114676
+ }
114677
+ /** true if the call has arguments and all of them are literals or me, like describe_by_name( 'T100' ) */
114678
+ onlyLiterals(node) {
114679
+ if (node === undefined || node.findFirstExpression(Expressions.MethodCall) !== undefined) {
114680
+ return false;
114681
+ }
114682
+ const sources = node.findAllExpressions(Expressions.Source);
114683
+ return sources.length > 0
114684
+ && sources.every(s => { var _a; return (s.getChildren().length === 1 && ((_a = s.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.Constant)
114685
+ || s.concatTokens().toUpperCase() === "ME"; });
114686
+ }
114687
+ findMethod(methods, token) {
114688
+ const method = methods.get(UnhandledClassicException.positionKey(token.getStart()));
114689
+ if (method === undefined) {
114690
+ return undefined;
114691
+ }
114692
+ return {
114693
+ name: method.getName(),
114694
+ exceptions: method.getExceptions().map(e => e.toUpperCase()),
114695
+ };
114696
+ }
114697
+ findMethodReferences(node, filename, found) {
114698
+ for (const r of node.getData().references) {
114699
+ if (r.referenceType === _reference_1.ReferenceType.MethodReference
114700
+ && r.position.getFilename() === filename
114701
+ && r.resolved instanceof types_1.MethodDefinition) {
114702
+ found.set(UnhandledClassicException.positionKey(r.position.getStart()), r.resolved);
114703
+ }
114704
+ }
114705
+ for (const child of node.getChildren()) {
114706
+ this.findMethodReferences(child, filename, found);
114707
+ }
114708
+ }
114709
+ findFunctionModule(name) {
114710
+ if (this.functionModules === undefined) {
114711
+ this.functionModules = new Map();
114712
+ for (const fugr of this.reg.getObjectsByType("FUGR")) {
114713
+ for (const module of fugr.getModules()) {
114714
+ this.functionModules.set(module.getName().toUpperCase(), module);
114715
+ }
114716
+ }
114717
+ }
114718
+ return this.functionModules.get(name.toUpperCase());
114719
+ }
114720
+ static positionKey(p) {
114721
+ if (p instanceof virtual_position_1.VirtualPosition) {
114722
+ return p.getRow() + ":" + p.getCol() + ":" + p.vrow + ":" + p.vcol;
114723
+ }
114724
+ return p.getRow() + ":" + p.getCol();
114725
+ }
114726
+ }
114727
+ exports.UnhandledClassicException = UnhandledClassicException;
114728
+ //# sourceMappingURL=unhandled_classic_exception.js.map
114729
+
114730
+ /***/ },
114731
+
113468
114732
  /***/ "../core/build/src/rules/unit_test_assertions.js"
113469
114733
  /*!*******************************************************!*\
113470
114734
  !*** ../core/build/src/rules/unit_test_assertions.js ***!