@abaplint/cli 2.118.4 → 2.118.5

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 +250 -7
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -16307,7 +16307,9 @@ class ReadTable {
16307
16307
  const key = (0, combi_1.seq)((0, combi_1.altPrio)("WITH KEY", "WITH TABLE KEY"), (0, combi_1.alt)(expressions_1.ComponentCompareSimple, components, (0, combi_1.seq)((0, combi_1.optPrio)("="), expressions_1.Source)));
16308
16308
  const using = (0, combi_1.seq)("USING KEY", (0, combi_1.alt)(expressions_1.Field, expressions_1.Dynamic));
16309
16309
  const from = (0, combi_1.seq)("FROM", expressions_1.Source);
16310
- const perm = (0, combi_1.per)((0, combi_1.alt)(index, key, from), expressions_1.ReadTableTarget, using, comparing, "CASTING", (0, combi_1.seq)("TRANSPORTING", (0, combi_1.altPrio)("ALL FIELDS", "NO FIELDS", transporting_fields_1.TransportingFields)), "BINARY SEARCH");
16310
+ const transporting = (0, combi_1.seq)("TRANSPORTING", (0, combi_1.altPrio)("ALL FIELDS", "NO FIELDS", transporting_fields_1.TransportingFields));
16311
+ const common = [expressions_1.ReadTableTarget, comparing, "CASTING", transporting, "BINARY SEARCH"];
16312
+ const perm = (0, combi_1.alt)((0, combi_1.per)((0, combi_1.alt)(index, from), using, ...common), (0, combi_1.per)(key, ...common), (0, combi_1.per)(...common));
16311
16313
  return (0, combi_1.seq)("READ TABLE", (0, combi_1.alt)(expressions_1.SimpleSource2, (0, combi_1.ver)(version_1.Version.v740sp02, expressions_1.Source, version_1.Version.OpenABAP)), (0, combi_1.opt)(perm));
16312
16314
  }
16313
16315
  }
@@ -21633,7 +21635,7 @@ BuiltIn.methods = {
21633
21635
  "CONCAT_LINES_OF": {
21634
21636
  counter: BuiltIn.counter++,
21635
21637
  mandatory: {
21636
- "table": new basic_1.TableType(basic_1.AnyType.get(), { withHeader: false, keyType: basic_1.TableKeyType.default }),
21638
+ "table": new basic_1.TableType(basic_1.AnyType.get(), { withHeader: false, keyType: basic_1.TableKeyType.user }),
21637
21639
  },
21638
21640
  optional: {
21639
21641
  "sep": basic_1.CLikeType.get(),
@@ -21931,7 +21933,7 @@ BuiltIn.methods = {
21931
21933
  "LINES": {
21932
21934
  counter: BuiltIn.counter++,
21933
21935
  mandatory: {
21934
- "val": new basic_1.TableType(basic_1.AnyType.get(), { withHeader: false, keyType: basic_1.TableKeyType.default }),
21936
+ "val": new basic_1.TableType(basic_1.AnyType.get(), { withHeader: false, keyType: basic_1.TableKeyType.user }),
21935
21937
  },
21936
21938
  return: basic_1.IntegerType.get(),
21937
21939
  },
@@ -22376,6 +22378,7 @@ class CurrentScope {
22376
22378
  }
22377
22379
  }
22378
22380
  constructor(reg, obj) {
22381
+ this.localFriends = new Map();
22379
22382
  this.current = undefined;
22380
22383
  this.parentObj = obj;
22381
22384
  this.reg = reg;
@@ -22799,6 +22802,27 @@ class CurrentScope {
22799
22802
  }
22800
22803
  return false;
22801
22804
  }
22805
+ addLocalFriend(className, friendName) {
22806
+ var _a;
22807
+ const key = className.toUpperCase();
22808
+ const list = (_a = this.localFriends.get(key)) !== null && _a !== void 0 ? _a : [];
22809
+ list.push(friendName.toUpperCase());
22810
+ this.localFriends.set(key, list);
22811
+ }
22812
+ isLocalFriend(className, friendName) {
22813
+ var _a;
22814
+ return ((_a = this.localFriends.get(className.toUpperCase())) === null || _a === void 0 ? void 0 : _a.includes(friendName.toUpperCase())) === true;
22815
+ }
22816
+ getEnclosingClassName() {
22817
+ let curr = this.current;
22818
+ while (curr !== undefined) {
22819
+ if (curr.getIdentifier().stype === _scope_type_1.ScopeType.ClassImplementation) {
22820
+ return curr.getIdentifier().sname;
22821
+ }
22822
+ curr = curr.getParent();
22823
+ }
22824
+ return undefined;
22825
+ }
22802
22826
  isGlobalOO() {
22803
22827
  return this.parentObj.getType() === "INTF" || this.parentObj.getType() === "CLAS";
22804
22828
  }
@@ -23552,6 +23576,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
23552
23576
  exports.TypeUtils = void 0;
23553
23577
  const types_1 = __webpack_require__(/*! ../types */ "./node_modules/@abaplint/core/build/src/abap/types/index.js");
23554
23578
  const basic_1 = __webpack_require__(/*! ../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
23579
+ const table_type_1 = __webpack_require__(/*! ../types/basic/table_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/table_type.js");
23555
23580
  const enum_type_1 = __webpack_require__(/*! ../types/basic/enum_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/enum_type.js");
23556
23581
  const cgeneric_type_1 = __webpack_require__(/*! ../types/basic/cgeneric_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/cgeneric_type.js");
23557
23582
  const Expressions = __webpack_require__(/*! ../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
@@ -23980,6 +24005,13 @@ class TypeUtils {
23980
24005
  }
23981
24006
  else if (source instanceof basic_1.TableType) {
23982
24007
  if (target instanceof basic_1.TableType) {
24008
+ const sourceKeyType = source.getOptions().keyType;
24009
+ const targetKeyType = target.getOptions().keyType;
24010
+ if (sourceKeyType !== targetKeyType
24011
+ && sourceKeyType !== table_type_1.TableKeyType.user
24012
+ && targetKeyType !== table_type_1.TableKeyType.user) {
24013
+ return false;
24014
+ }
23983
24015
  return this.isAssignableStrict(source.getRowType(), target.getRowType());
23984
24016
  }
23985
24017
  else if (target instanceof basic_1.UnknownType
@@ -24037,6 +24069,13 @@ class TypeUtils {
24037
24069
  return false;
24038
24070
  }
24039
24071
  }
24072
+ const sourceKeyType = source.getOptions().keyType;
24073
+ const targetKeyType = target.getOptions().keyType;
24074
+ if (sourceKeyType !== targetKeyType
24075
+ && sourceKeyType !== table_type_1.TableKeyType.user
24076
+ && targetKeyType !== table_type_1.TableKeyType.user) {
24077
+ return false;
24078
+ }
24040
24079
  return true;
24041
24080
  }
24042
24081
  return false;
@@ -24708,7 +24747,7 @@ class BasicTypes {
24708
24747
  || text === "TYPE HASHED TABLE"
24709
24748
  || text === "TYPE INDEX TABLE"
24710
24749
  || text === "TYPE ANY TABLE") {
24711
- return new Types.TableType(Types.AnyType.get(), { withHeader: node.concatTokens().toUpperCase().includes("WITH HEADER LINE"), keyType: Types.TableKeyType.default });
24750
+ return new Types.TableType(Types.AnyType.get(), { withHeader: node.concatTokens().toUpperCase().includes("WITH HEADER LINE"), keyType: Types.TableKeyType.user });
24712
24751
  }
24713
24752
  else if (text.startsWith("LIKE ")) {
24714
24753
  let sub = node.findFirstExpression(Expressions.Type);
@@ -27897,6 +27936,7 @@ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/
27897
27936
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
27898
27937
  const assert_error_1 = __webpack_require__(/*! ../assert_error */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/assert_error.js");
27899
27938
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
27939
+ const create_object_1 = __webpack_require__(/*! ../statements/create_object */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/create_object.js");
27900
27940
  class NewObject {
27901
27941
  static runSyntax(node, input, targetType) {
27902
27942
  let ret = undefined;
@@ -27930,6 +27970,13 @@ class NewObject {
27930
27970
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
27931
27971
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
27932
27972
  }
27973
+ if (clas) {
27974
+ const err = create_object_1.CreateObject.checkInstantiationAllowed(clas, input);
27975
+ if (err) {
27976
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), err));
27977
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
27978
+ }
27979
+ }
27933
27980
  }
27934
27981
  else if (typeName === "#" && targetType) {
27935
27982
  ret = targetType;
@@ -27951,6 +27998,13 @@ class NewObject {
27951
27998
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
27952
27999
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
27953
28000
  }
28001
+ if (clas) {
28002
+ const err = create_object_1.CreateObject.checkInstantiationAllowed(clas, input);
28003
+ if (err) {
28004
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), err));
28005
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
28006
+ }
28007
+ }
27954
28008
  ret = objref;
27955
28009
  }
27956
28010
  }
@@ -28716,6 +28770,11 @@ class Source {
28716
28770
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
28717
28771
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
28718
28772
  }
28773
+ else if (foundType === null || foundType === void 0 ? void 0 : foundType.isGeneric()) {
28774
+ const message = "Cannot CONV to generic type";
28775
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
28776
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
28777
+ }
28719
28778
  this.addIfInferred(node, input, foundType);
28720
28779
  return foundType;
28721
28780
  }
@@ -31150,6 +31209,7 @@ const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@a
31150
31209
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
31151
31210
  class ClassLocalFriends {
31152
31211
  runSyntax(node, input) {
31212
+ var _a;
31153
31213
  const classNames = node.findAllExpressions(Expressions.ClassName);
31154
31214
  const found = classNames[0];
31155
31215
  if (found) {
@@ -31180,6 +31240,12 @@ class ClassLocalFriends {
31180
31240
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
31181
31241
  return;
31182
31242
  }
31243
+ else {
31244
+ const befriendedName = (_a = classNames[0]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
31245
+ if (befriendedName) {
31246
+ input.scope.addLocalFriend(befriendedName, className);
31247
+ }
31248
+ }
31183
31249
  }
31184
31250
  }
31185
31251
  }
@@ -31661,6 +31727,7 @@ const types_1 = __webpack_require__(/*! ../../types */ "./node_modules/@abaplint
31661
31727
  const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js");
31662
31728
  const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
31663
31729
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
31730
+ const visibility_1 = __webpack_require__(/*! ../../4_file_information/visibility */ "./node_modules/@abaplint/core/build/src/abap/4_file_information/visibility.js");
31664
31731
  class CreateObject {
31665
31732
  runSyntax(node, input) {
31666
31733
  var _a;
@@ -31757,8 +31824,46 @@ class CreateObject {
31757
31824
  ooName = found.getVoided();
31758
31825
  }
31759
31826
  input.scope.addReference(t === null || t === void 0 ? void 0 : t.getFirstToken(), cdef, _reference_1.ReferenceType.ConstructorReference, input.filename, { ooName: ooName });
31827
+ if (cdef !== undefined) {
31828
+ const err = CreateObject.checkInstantiationAllowed(cdef, input);
31829
+ if (err) {
31830
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), err));
31831
+ return;
31832
+ }
31833
+ }
31760
31834
  this.validateParameters(cdef, node, input);
31761
31835
  }
31836
+ static checkInstantiationAllowed(cdef, input) {
31837
+ var _a, _b;
31838
+ const createVis = cdef.getCreateVisibility();
31839
+ if (createVis === visibility_1.Visibility.Public) {
31840
+ return undefined;
31841
+ }
31842
+ const enclosingClass = input.scope.getEnclosingClassName();
31843
+ if (enclosingClass === undefined) {
31844
+ return cdef.getName() + " cannot be instantiated, class is defined as " +
31845
+ (createVis === visibility_1.Visibility.Private ? "private" : "protected");
31846
+ }
31847
+ if (enclosingClass.toUpperCase() === cdef.getName().toUpperCase()) {
31848
+ return undefined;
31849
+ }
31850
+ if (cdef.getFriends().some(f => f.toUpperCase() === enclosingClass.toUpperCase()) ||
31851
+ input.scope.isLocalFriend(cdef.getName(), enclosingClass)) {
31852
+ return undefined;
31853
+ }
31854
+ if (createVis === visibility_1.Visibility.Protected) {
31855
+ // subclasses are also allowed
31856
+ let sup = (_a = input.scope.findClassDefinition(enclosingClass)) === null || _a === void 0 ? void 0 : _a.getSuperClass();
31857
+ while (sup !== undefined) {
31858
+ if (sup.toUpperCase() === cdef.getName().toUpperCase()) {
31859
+ return undefined;
31860
+ }
31861
+ sup = (_b = input.scope.findClassDefinition(sup)) === null || _b === void 0 ? void 0 : _b.getSuperClass();
31862
+ }
31863
+ }
31864
+ return cdef.getName() + " cannot be instantiated, class is defined as " +
31865
+ (createVis === visibility_1.Visibility.Private ? "private" : "protected");
31866
+ }
31762
31867
  validateParameters(cdef, node, input) {
31763
31868
  var _a, _b, _c, _d;
31764
31869
  if (cdef === undefined) {
@@ -35135,7 +35240,7 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modu
35135
35240
  class Split {
35136
35241
  runSyntax(node, input) {
35137
35242
  const intoTable = node.findTokenSequencePosition("INTO", "TABLE") !== undefined;
35138
- const type = intoTable ? new basic_1.TableType(basic_1.StringType.get(), { withHeader: false, keyType: basic_1.TableKeyType.default }) : basic_1.StringType.get();
35243
+ const type = intoTable ? new basic_1.TableType(basic_1.StringType.get(), { withHeader: false, keyType: basic_1.TableKeyType.user }) : basic_1.StringType.get();
35139
35244
  for (const target of node.findAllExpressions(Expressions.Target)) {
35140
35245
  const inline = target.findDirectExpression(Expressions.InlineData);
35141
35246
  if (inline) {
@@ -39768,6 +39873,7 @@ class Attributes {
39768
39873
  this.instance = [];
39769
39874
  this.constants = [];
39770
39875
  this.aliases = [];
39876
+ this.declaredInterfaces = [];
39771
39877
  this.tlist = [];
39772
39878
  this.filename = input.filename;
39773
39879
  this.parse(node, input);
@@ -39843,8 +39949,15 @@ class Attributes {
39843
39949
  }
39844
39950
  /////////////////////////////
39845
39951
  parse(node, input) {
39952
+ var _a, _b;
39846
39953
  const cdef = node.findDirectStructure(Structures.ClassDefinition);
39847
39954
  if (cdef) {
39955
+ for (const i of cdef.findAllStatements(Statements.InterfaceDef)) {
39956
+ const name = (_a = i.findFirstExpression(Expressions.InterfaceName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
39957
+ if (name) {
39958
+ this.declaredInterfaces.push(name.toUpperCase());
39959
+ }
39960
+ }
39848
39961
  this.parseSection(cdef.findDirectStructure(Structures.PublicSection), visibility_1.Visibility.Public, input);
39849
39962
  this.parseSection(cdef.findDirectStructure(Structures.ProtectedSection), visibility_1.Visibility.Protected, input);
39850
39963
  this.parseSection(cdef.findDirectStructure(Structures.PrivateSection), visibility_1.Visibility.Private, input);
@@ -39852,6 +39965,12 @@ class Attributes {
39852
39965
  }
39853
39966
  const idef = node.findDirectStructure(Structures.Interface);
39854
39967
  if (idef) {
39968
+ for (const i of idef.findAllStatements(Statements.InterfaceDef)) {
39969
+ const name = (_b = i.findFirstExpression(Expressions.InterfaceName)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
39970
+ if (name) {
39971
+ this.declaredInterfaces.push(name.toUpperCase());
39972
+ }
39973
+ }
39855
39974
  this.parseSection(idef.findDirectStructure(Structures.SectionContents), visibility_1.Visibility.Public, input);
39856
39975
  return;
39857
39976
  }
@@ -39960,6 +40079,12 @@ class Attributes {
39960
40079
  input.scope.addNamedIdentifier(aliasName.getStr(), foundAttribute);
39961
40080
  }
39962
40081
  }
40082
+ else if (this.declaredInterfaces.includes(name.toUpperCase()) || input.scope.getDDIC().inErrorNamespace(name) === false) {
40083
+ input.scope.addReference(compToken, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, input.filename);
40084
+ }
40085
+ else {
40086
+ throw new Error("Interface " + name + " not found");
40087
+ }
39963
40088
  }
39964
40089
  }
39965
40090
  parseAttribute(node, visibility, input) {
@@ -40033,6 +40158,7 @@ const event_definition_1 = __webpack_require__(/*! ./event_definition */ "./node
40033
40158
  const visibility_1 = __webpack_require__(/*! ../4_file_information/visibility */ "./node_modules/@abaplint/core/build/src/abap/4_file_information/visibility.js");
40034
40159
  const _object_oriented_1 = __webpack_require__(/*! ../5_syntax/_object_oriented */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js");
40035
40160
  const _reference_1 = __webpack_require__(/*! ../5_syntax/_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
40161
+ const _syntax_input_1 = __webpack_require__(/*! ../5_syntax/_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
40036
40162
  class ClassDefinition extends _identifier_1.Identifier {
40037
40163
  constructor(node, input) {
40038
40164
  var _a;
@@ -40070,6 +40196,15 @@ class ClassDefinition extends _identifier_1.Identifier {
40070
40196
  this.testing = concat.includes(" FOR TESTING");
40071
40197
  this.sharedMemory = concat.includes(" SHARED MEMORY ENABLED");
40072
40198
  this.abstract = (def === null || def === void 0 ? void 0 : def.findDirectTokenByText("ABSTRACT")) !== undefined;
40199
+ if (concat.includes(" CREATE PRIVATE")) {
40200
+ this.createVisibilityValue = visibility_1.Visibility.Private;
40201
+ }
40202
+ else if (concat.includes(" CREATE PROTECTED")) {
40203
+ this.createVisibilityValue = visibility_1.Visibility.Protected;
40204
+ }
40205
+ else {
40206
+ this.createVisibilityValue = visibility_1.Visibility.Public;
40207
+ }
40073
40208
  // perform checks after everything has been initialized
40074
40209
  this.checkMethodsFromSuperClasses(input.scope);
40075
40210
  this.checkMethodNameLength();
@@ -40113,6 +40248,9 @@ class ClassDefinition extends _identifier_1.Identifier {
40113
40248
  isSharedMemory() {
40114
40249
  return this.sharedMemory;
40115
40250
  }
40251
+ getCreateVisibility() {
40252
+ return this.createVisibilityValue;
40253
+ }
40116
40254
  /*
40117
40255
  public getEvents() {
40118
40256
  }
@@ -40168,8 +40306,20 @@ class ClassDefinition extends _identifier_1.Identifier {
40168
40306
  const result = [];
40169
40307
  for (const n of ((_a = def === null || def === void 0 ? void 0 : def.findDirectExpression(Expressions.ClassFriends)) === null || _a === void 0 ? void 0 : _a.findDirectExpressions(Expressions.ClassName)) || []) {
40170
40308
  const token = n.getFirstToken();
40171
- this.addReference(token, input);
40172
40309
  const name = token.getStr();
40310
+ const s = input.scope.findClassDefinition(name);
40311
+ if (s) {
40312
+ input.scope.addReference(token, s, _reference_1.ReferenceType.ObjectOrientedReference, input.filename, { ooName: name.toUpperCase(), ooType: "CLAS" });
40313
+ }
40314
+ else if (input.scope.existsObject(name) !== undefined) {
40315
+ // DEFINITION DEFERRED friend
40316
+ }
40317
+ else if (input.scope.getDDIC().inErrorNamespace(name) === false) {
40318
+ input.scope.addReference(token, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, input.filename);
40319
+ }
40320
+ else {
40321
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, name.toUpperCase() + " does not exist"));
40322
+ }
40173
40323
  result.push(name);
40174
40324
  }
40175
40325
  return result;
@@ -55889,7 +56039,7 @@ class Registry {
55889
56039
  }
55890
56040
  static abaplintVersion() {
55891
56041
  // magic, see build script "version.sh"
55892
- return "2.118.4";
56042
+ return "2.118.5";
55893
56043
  }
55894
56044
  getDDICReferences() {
55895
56045
  return this.ddicReferences;
@@ -58040,6 +58190,98 @@ exports.CallTransactionAuthorityCheck = CallTransactionAuthorityCheck;
58040
58190
 
58041
58191
  /***/ },
58042
58192
 
58193
+ /***/ "./node_modules/@abaplint/core/build/src/rules/catch_and_raise.js"
58194
+ /*!************************************************************************!*\
58195
+ !*** ./node_modules/@abaplint/core/build/src/rules/catch_and_raise.js ***!
58196
+ \************************************************************************/
58197
+ (__unused_webpack_module, exports, __webpack_require__) {
58198
+
58199
+ "use strict";
58200
+
58201
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
58202
+ exports.CatchAndRaise = exports.CatchAndRaiseConf = void 0;
58203
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
58204
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
58205
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
58206
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
58207
+ const Structures = __webpack_require__(/*! ../abap/3_structures/structures */ "./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js");
58208
+ const Statements = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
58209
+ const Expressions = __webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
58210
+ class CatchAndRaiseConf extends _basic_rule_config_1.BasicRuleConfig {
58211
+ }
58212
+ exports.CatchAndRaiseConf = CatchAndRaiseConf;
58213
+ class CatchAndRaise extends _abap_rule_1.ABAPRule {
58214
+ constructor() {
58215
+ super(...arguments);
58216
+ this.conf = new CatchAndRaiseConf();
58217
+ }
58218
+ getMetadata() {
58219
+ return {
58220
+ key: "catch_and_raise",
58221
+ title: "Catch and re-raise same exception",
58222
+ shortDescription: `Reports CATCH blocks that only re-raise the caught exception without any handling`,
58223
+ badExample: `TRY.\n something( ).\nCATCH zcx_something INTO DATA(lv_exc).\n RAISE EXCEPTION lv_exc.\nENDTRY.`,
58224
+ goodExample: `TRY.\n something( ).\nCATCH zcx_something.\n " handle exception\nENDTRY.`,
58225
+ tags: [_irule_1.RuleTag.SingleFile],
58226
+ };
58227
+ }
58228
+ getConfig() {
58229
+ return this.conf;
58230
+ }
58231
+ setConfig(conf) {
58232
+ this.conf = conf;
58233
+ }
58234
+ runParsed(file) {
58235
+ const issues = [];
58236
+ const stru = file.getStructure();
58237
+ if (stru === undefined) {
58238
+ return [];
58239
+ }
58240
+ for (const catchStruct of stru.findAllStructures(Structures.Catch)) {
58241
+ const catchStatement = catchStruct.findDirectStatement(Statements.Catch);
58242
+ if (catchStatement === undefined) {
58243
+ continue;
58244
+ }
58245
+ const target = catchStatement.findFirstExpression(Expressions.Target);
58246
+ if (target === undefined) {
58247
+ continue;
58248
+ }
58249
+ const targetField = target.findFirstExpression(Expressions.TargetField);
58250
+ if (targetField === undefined) {
58251
+ continue;
58252
+ }
58253
+ const caughtVar = targetField.getFirstToken().getStr().toUpperCase();
58254
+ const allStatements = catchStruct.findAllStatementNodes();
58255
+ if (allStatements.length !== 2) {
58256
+ continue;
58257
+ }
58258
+ if (!(allStatements[1].get() instanceof Statements.Raise)) {
58259
+ continue;
58260
+ }
58261
+ const raiseStatement = allStatements[1];
58262
+ const raiseConcat = raiseStatement.concatTokens().toUpperCase().replace(/\.$/, "").trim();
58263
+ if (!raiseConcat.startsWith("RAISE EXCEPTION ")) {
58264
+ continue;
58265
+ }
58266
+ const parts = raiseConcat.split(/\s+/);
58267
+ if (parts.length !== 3) {
58268
+ continue;
58269
+ }
58270
+ if (parts[2] === caughtVar) {
58271
+ issues.push(issue_1.Issue.atStatement(file, catchStatement, this.getMessage(), this.getMetadata().key, this.conf.severity));
58272
+ }
58273
+ }
58274
+ return issues;
58275
+ }
58276
+ getMessage() {
58277
+ return "Caught exception is immediately re-raised, CATCH block has no effect";
58278
+ }
58279
+ }
58280
+ exports.CatchAndRaise = CatchAndRaise;
58281
+ //# sourceMappingURL=catch_and_raise.js.map
58282
+
58283
+ /***/ },
58284
+
58043
58285
  /***/ "./node_modules/@abaplint/core/build/src/rules/cds_association_name.js"
58044
58286
  /*!*****************************************************************************!*\
58045
58287
  !*** ./node_modules/@abaplint/core/build/src/rules/cds_association_name.js ***!
@@ -67808,6 +68050,7 @@ __exportStar(__webpack_require__(/*! ./avoid_use */ "./node_modules/@abaplint/co
67808
68050
  __exportStar(__webpack_require__(/*! ./begin_end_names */ "./node_modules/@abaplint/core/build/src/rules/begin_end_names.js"), exports);
67809
68051
  __exportStar(__webpack_require__(/*! ./begin_single_include */ "./node_modules/@abaplint/core/build/src/rules/begin_single_include.js"), exports);
67810
68052
  __exportStar(__webpack_require__(/*! ./call_transaction_authority_check */ "./node_modules/@abaplint/core/build/src/rules/call_transaction_authority_check.js"), exports);
68053
+ __exportStar(__webpack_require__(/*! ./catch_and_raise */ "./node_modules/@abaplint/core/build/src/rules/catch_and_raise.js"), exports);
67811
68054
  __exportStar(__webpack_require__(/*! ./cds_association_name */ "./node_modules/@abaplint/core/build/src/rules/cds_association_name.js"), exports);
67812
68055
  __exportStar(__webpack_require__(/*! ./cds_comment_style */ "./node_modules/@abaplint/core/build/src/rules/cds_comment_style.js"), exports);
67813
68056
  __exportStar(__webpack_require__(/*! ./cds_field_order */ "./node_modules/@abaplint/core/build/src/rules/cds_field_order.js"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.118.4",
3
+ "version": "2.118.5",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "homepage": "https://abaplint.org",
40
40
  "devDependencies": {
41
- "@abaplint/core": "^2.118.4",
41
+ "@abaplint/core": "^2.118.5",
42
42
  "@types/chai": "^4.3.20",
43
43
  "@types/minimist": "^1.2.5",
44
44
  "@types/mocha": "^10.0.10",