@abaplint/cli 2.120.28 → 2.120.29

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 +197 -22
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -26676,6 +26676,31 @@ class ObjectOriented {
26676
26676
  }
26677
26677
  return ret;
26678
26678
  }
26679
+ // does the supplied class have friendship with "friendName"?
26680
+ // note that interfaces of the friend, and subclasses of the friend also have friendship
26681
+ hasFriendship(cd, friendName) {
26682
+ var _a;
26683
+ const friends = cd.getFriends().map(f => f.toUpperCase());
26684
+ const isFriend = (name) => friends.includes(name.toUpperCase()) || this.scope.isLocalFriend(cd.getName(), name);
26685
+ if (isFriend(friendName)) {
26686
+ return true;
26687
+ }
26688
+ const friendDefinition = this.scope.findClassDefinition(friendName);
26689
+ if (friendDefinition === undefined) {
26690
+ return false;
26691
+ }
26692
+ if (this.findInterfaces(friendDefinition).some(i => friends.includes(i.name.toUpperCase()))) {
26693
+ return true;
26694
+ }
26695
+ let sup = friendDefinition.getSuperClass();
26696
+ while (sup !== undefined) {
26697
+ if (isFriend(sup)) {
26698
+ return true;
26699
+ }
26700
+ sup = (_a = this.scope.findClassDefinition(sup)) === null || _a === void 0 ? void 0 : _a.getSuperClass();
26701
+ }
26702
+ return false;
26703
+ }
26679
26704
  searchEvent(def, name) {
26680
26705
  if (def === undefined || name === undefined) {
26681
26706
  return undefined;
@@ -27865,6 +27890,9 @@ class TypeUtils {
27865
27890
  console.dir(source);
27866
27891
  console.dir(target);
27867
27892
  */
27893
+ if (source instanceof basic_1.UTCLongType || target instanceof basic_1.UTCLongType) {
27894
+ return this.isUTCLongAssignable(source, target);
27895
+ }
27868
27896
  if (target instanceof basic_1.TableType) {
27869
27897
  if (target.isWithHeader()) {
27870
27898
  return this.isAssignable(source, target.getRowType());
@@ -28016,6 +28044,33 @@ class TypeUtils {
28016
28044
  }
28017
28045
  return true;
28018
28046
  }
28047
+ // utclong can only be converted to and from character like types
28048
+ isUTCLongAssignable(source, target) {
28049
+ if (this.isGenericOrVoid(source) || this.isGenericOrVoid(target)) {
28050
+ return true;
28051
+ }
28052
+ else if (source instanceof basic_1.UTCLongType && target instanceof basic_1.UTCLongType) {
28053
+ return true;
28054
+ }
28055
+ else if (source instanceof basic_1.UTCLongType) {
28056
+ return this.isTextLike(target);
28057
+ }
28058
+ return this.isTextLike(source);
28059
+ }
28060
+ isGenericOrVoid(type) {
28061
+ return type instanceof basic_1.VoidType
28062
+ || type instanceof basic_1.AnyType
28063
+ || type instanceof basic_1.DataType
28064
+ || type instanceof basic_1.UnknownType;
28065
+ }
28066
+ isTextLike(type) {
28067
+ return type instanceof basic_1.CharacterType
28068
+ || type instanceof basic_1.StringType
28069
+ || type instanceof basic_1.CLikeType
28070
+ || type instanceof basic_1.CSequenceType
28071
+ || type instanceof cgeneric_type_1.CGenericType
28072
+ || type instanceof basic_1.SimpleType;
28073
+ }
28019
28074
  }
28020
28075
  exports.TypeUtils = TypeUtils;
28021
28076
  //# sourceMappingURL=_type_utils.js.map
@@ -32311,6 +32366,8 @@ const _reference_1 = __webpack_require__(/*! ../_reference */ "../core/build/src
32311
32366
  const component_name_1 = __webpack_require__(/*! ./component_name */ "../core/build/src/abap/5_syntax/expressions/component_name.js");
32312
32367
  const attribute_name_1 = __webpack_require__(/*! ./attribute_name */ "../core/build/src/abap/5_syntax/expressions/attribute_name.js");
32313
32368
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
32369
+ const visibility_1 = __webpack_require__(/*! ../../4_file_information/visibility */ "../core/build/src/abap/4_file_information/visibility.js");
32370
+ const class_definition_1 = __webpack_require__(/*! ../../types/class_definition */ "../core/build/src/abap/types/class_definition.js");
32314
32371
  class MethodCallChain {
32315
32372
  static runSyntax(node, input, targetType) {
32316
32373
  var _a, _b;
@@ -32359,6 +32416,12 @@ class MethodCallChain {
32359
32416
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
32360
32417
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
32361
32418
  }
32419
+ const notVisible = method ? this.checkVisibility(method, def, foundDef, input) : undefined;
32420
+ if (notVisible !== undefined) {
32421
+ const message = `Method "${methodName}" is ${notVisible} and cannot be accessed`;
32422
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
32423
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
32424
+ }
32362
32425
  const voidedName = context instanceof basic_1.VoidType ? context.getVoided() : undefined;
32363
32426
  const extra = helper.methodReferenceExtras(foundDef, className || voidedName);
32364
32427
  input.scope.addReference(methodToken, method, _reference_1.ReferenceType.MethodReference, input.filename, extra);
@@ -32401,6 +32464,47 @@ class MethodCallChain {
32401
32464
  return context;
32402
32465
  }
32403
32466
  //////////////////////////////////////
32467
+ // returns the visibility as text if the method cannot be accessed from the current scope
32468
+ static checkVisibility(method, def, foundDef, input) {
32469
+ var _a, _b, _c;
32470
+ const visibility = method.getVisibility();
32471
+ if (visibility === visibility_1.Visibility.Public || foundDef === undefined) {
32472
+ return undefined;
32473
+ }
32474
+ else if (!(foundDef instanceof class_definition_1.ClassDefinition)) {
32475
+ // interface members are always public
32476
+ return undefined;
32477
+ }
32478
+ const name = foundDef.getName().toUpperCase();
32479
+ const enclosing = (_a = input.scope.getEnclosingClassName()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
32480
+ if (enclosing === undefined || enclosing === name) {
32481
+ return undefined;
32482
+ }
32483
+ // friendship with the class used at the call site also gives access to inherited members
32484
+ const helper = new _object_oriented_1.ObjectOriented(input.scope);
32485
+ const visited = [];
32486
+ let current = def instanceof class_definition_1.ClassDefinition ? def : foundDef;
32487
+ while (current !== undefined && visited.includes(current.getName().toUpperCase()) === false) {
32488
+ visited.push(current.getName().toUpperCase());
32489
+ if (helper.hasFriendship(current, enclosing)) {
32490
+ return undefined;
32491
+ }
32492
+ const sup = current.getSuperClass();
32493
+ current = sup === undefined ? undefined : input.scope.findClassDefinition(sup);
32494
+ }
32495
+ if (visibility === visibility_1.Visibility.Protected) {
32496
+ // subclasses can access protected members
32497
+ let sup = (_b = input.scope.findClassDefinition(enclosing)) === null || _b === void 0 ? void 0 : _b.getSuperClass();
32498
+ while (sup !== undefined) {
32499
+ if (sup.toUpperCase() === name) {
32500
+ return undefined;
32501
+ }
32502
+ sup = (_c = input.scope.findClassDefinition(sup)) === null || _c === void 0 ? void 0 : _c.getSuperClass();
32503
+ }
32504
+ return "protected";
32505
+ }
32506
+ return "private";
32507
+ }
32404
32508
  static findTop(first, input, targetType) {
32405
32509
  var _a;
32406
32510
  if (first.get() instanceof Expressions.ClassName) {
@@ -35069,6 +35173,7 @@ const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/
35069
35173
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
35070
35174
  const sql_set_op_group_1 = __webpack_require__(/*! ./sql_set_op_group */ "../core/build/src/abap/5_syntax/expressions/sql_set_op_group.js");
35071
35175
  const sql_source_1 = __webpack_require__(/*! ./sql_source */ "../core/build/src/abap/5_syntax/expressions/sql_source.js");
35176
+ const RANGE_COMPONENTS = ["SIGN", "OPTION", "LOW", "HIGH"];
35072
35177
  class SQLIn {
35073
35178
  static runSyntax(node, input) {
35074
35179
  const setop = node.findDirectExpression(Expressions.SQLSetOpGroup);
@@ -35088,6 +35193,12 @@ class SQLIn {
35088
35193
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
35089
35194
  return;
35090
35195
  }
35196
+ if (intype instanceof basic_1.TableType && this.isRangeRow(intype.getRowType()) === false) {
35197
+ const name = insource.concatTokens().replace(/^@/, "").replace(/\[\]$/, "");
35198
+ const message = `row structure of ${name} is not correct`;
35199
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
35200
+ return;
35201
+ }
35091
35202
  }
35092
35203
  return;
35093
35204
  }
@@ -35098,6 +35209,16 @@ class SQLIn {
35098
35209
  sql_source_1.SQLSource.runSyntax(s, input);
35099
35210
  }
35100
35211
  }
35212
+ // "IN itab" expects a ranges table, ie. the row must have SIGN, OPTION, LOW and HIGH
35213
+ static isRangeRow(rowType) {
35214
+ if (rowType instanceof basic_1.VoidType || rowType instanceof basic_1.UnknownType || rowType instanceof basic_1.AnyType) {
35215
+ return true;
35216
+ }
35217
+ else if (!(rowType instanceof basic_1.StructureType)) {
35218
+ return false;
35219
+ }
35220
+ return RANGE_COMPONENTS.every(c => rowType.getComponentByName(c) !== undefined);
35221
+ }
35101
35222
  }
35102
35223
  exports.SQLIn = SQLIn;
35103
35224
  //# sourceMappingURL=sql_in.js.map
@@ -39176,7 +39297,7 @@ class CreateObject {
39176
39297
  this.validateParameters(cdef, node, input);
39177
39298
  }
39178
39299
  static checkInstantiationAllowed(cdef, input) {
39179
- var _a, _b, _c;
39300
+ var _a, _b;
39180
39301
  const createVis = cdef.getCreateVisibility();
39181
39302
  if (createVis === visibility_1.Visibility.Public) {
39182
39303
  return undefined;
@@ -39189,34 +39310,17 @@ class CreateObject {
39189
39310
  if (enclosingClass.toUpperCase() === cdef.getName().toUpperCase()) {
39190
39311
  return undefined;
39191
39312
  }
39192
- if (cdef.getFriends().some(f => f.toUpperCase() === enclosingClass.toUpperCase()) ||
39193
- input.scope.isLocalFriend(cdef.getName(), enclosingClass)) {
39313
+ if (new _object_oriented_1.ObjectOriented(input.scope).hasFriendship(cdef, enclosingClass)) {
39194
39314
  return undefined;
39195
39315
  }
39196
- const enclosingDefinition = input.scope.findClassDefinition(enclosingClass);
39197
- if (enclosingDefinition !== undefined) {
39198
- const implementedInterfaces = new _object_oriented_1.ObjectOriented(input.scope).findInterfaces(enclosingDefinition);
39199
- if (cdef.getFriends().some(friend => implementedInterfaces.some(implemented => implemented.name.toUpperCase() === friend.toUpperCase()))) {
39200
- return undefined;
39201
- }
39202
- }
39203
- // subclasses of friends also have friendship
39204
- let enclosingSup = enclosingDefinition === null || enclosingDefinition === void 0 ? void 0 : enclosingDefinition.getSuperClass();
39205
- while (enclosingSup !== undefined) {
39206
- if (cdef.getFriends().some(f => f.toUpperCase() === enclosingSup.toUpperCase()) ||
39207
- input.scope.isLocalFriend(cdef.getName(), enclosingSup)) {
39208
- return undefined;
39209
- }
39210
- enclosingSup = (_a = input.scope.findClassDefinition(enclosingSup)) === null || _a === void 0 ? void 0 : _a.getSuperClass();
39211
- }
39212
39316
  if (createVis === visibility_1.Visibility.Protected) {
39213
39317
  // subclasses are also allowed
39214
- let sup = (_b = input.scope.findClassDefinition(enclosingClass)) === null || _b === void 0 ? void 0 : _b.getSuperClass();
39318
+ let sup = (_a = input.scope.findClassDefinition(enclosingClass)) === null || _a === void 0 ? void 0 : _a.getSuperClass();
39215
39319
  while (sup !== undefined) {
39216
39320
  if (sup.toUpperCase() === cdef.getName().toUpperCase()) {
39217
39321
  return undefined;
39218
39322
  }
39219
- sup = (_c = input.scope.findClassDefinition(sup)) === null || _c === void 0 ? void 0 : _c.getSuperClass();
39323
+ sup = (_b = input.scope.findClassDefinition(sup)) === null || _b === void 0 ? void 0 : _b.getSuperClass();
39220
39324
  }
39221
39325
  }
39222
39326
  return cdef.getName() + " cannot be instantiated, class is defined as " +
@@ -39480,6 +39584,7 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "../core/build
39480
39584
  const dynamic_1 = __webpack_require__(/*! ../expressions/dynamic */ "../core/build/src/abap/5_syntax/expressions/dynamic.js");
39481
39585
  const database_table_1 = __webpack_require__(/*! ../expressions/database_table */ "../core/build/src/abap/5_syntax/expressions/database_table.js");
39482
39586
  const _check_database_fields_1 = __webpack_require__(/*! ../expressions/_check_database_fields */ "../core/build/src/abap/5_syntax/expressions/_check_database_fields.js");
39587
+ const sql_in_1 = __webpack_require__(/*! ../expressions/sql_in */ "../core/build/src/abap/5_syntax/expressions/sql_in.js");
39483
39588
  class DeleteDatabase {
39484
39589
  runSyntax(node, input) {
39485
39590
  for (const s of node.findAllExpressions(Expressions.Source)) {
@@ -39491,6 +39596,12 @@ class DeleteDatabase {
39491
39596
  for (const d of node.findAllExpressions(Expressions.Dynamic)) {
39492
39597
  dynamic_1.Dynamic.runSyntax(d, input);
39493
39598
  }
39599
+ for (const compare of node.findAllExpressions(Expressions.SQLCompare)) {
39600
+ const sqlin = compare.findDirectExpression(Expressions.SQLIn);
39601
+ if (sqlin !== undefined) {
39602
+ sql_in_1.SQLIn.runSyntax(sqlin, input);
39603
+ }
39604
+ }
39494
39605
  const dbtab = node.findFirstExpression(Expressions.DatabaseTable);
39495
39606
  if (dbtab !== undefined) {
39496
39607
  const dbSource = database_table_1.DatabaseTable.runSyntax(dbtab, input);
@@ -69851,7 +69962,7 @@ class Registry {
69851
69962
  }
69852
69963
  static abaplintVersion() {
69853
69964
  // magic, see build script "version.js"
69854
- return "2.120.28";
69965
+ return "2.120.29";
69855
69966
  }
69856
69967
  getDDICReferences() {
69857
69968
  return this.ddicReferences;
@@ -72538,6 +72649,11 @@ class CDSCheckSyntaxConf extends _basic_rule_config_1.BasicRuleConfig {
72538
72649
  exports.CDSCheckSyntaxConf = CDSCheckSyntaxConf;
72539
72650
  const KNOWN_QUAN_DATA_ELEMENTS = ["MENGE_D"];
72540
72651
  const KNOWN_CURR_DATA_ELEMENTS = ["BWERT", "DZWERT"];
72652
+ // Reserved names, cannot be used as element names, see DDIC table TRESE
72653
+ const RESERVED_ELEMENT_NAMES = ["BEGIN", "NUMBER", "POSITION"];
72654
+ const MAX_LABEL_LENGTH = 40;
72655
+ // Annotations which are not supported in CDS view entities
72656
+ const VIEW_ENTITY_FORBIDDEN_ANNOTATIONS = ["Semantics.unitOfMeasure"];
72541
72657
  class CDSCheckSyntax {
72542
72658
  constructor() {
72543
72659
  this.conf = new CDSCheckSyntaxConf();
@@ -72579,6 +72695,9 @@ Missing objects are only reported when their names match the configured errorNam
72579
72695
  this.checkTypes(tree, ddic, issues, file);
72580
72696
  this.checkRootProjection(tree, ddic, issues, file);
72581
72697
  this.checkFieldAnnotations(tree, ddic, issues, file);
72698
+ this.checkLabels(tree, issues, file);
72699
+ this.checkViewEntityAnnotations(tree, issues, file);
72700
+ this.checkReservedNames(tree, issues, file);
72582
72701
  this.checkFields(tree, sources, object, issues, file);
72583
72702
  return issues;
72584
72703
  }
@@ -72763,6 +72882,62 @@ Missing objects are only reported when their names match the configured errorNam
72763
72882
  || a.toUpperCase().includes("@SEMANTICS:{CURRENCYCODE:TRUE"));
72764
72883
  }
72765
72884
  }
72885
+ checkLabels(tree, issues, file) {
72886
+ for (const annotation of tree.findAllExpressionsRecursive(expressions_1.CDSAnnotation)) {
72887
+ const concatenated = annotation.concatTokens();
72888
+ if (/@\s*<?\s*EndUserText/i.test(concatenated) === false) {
72889
+ continue;
72890
+ }
72891
+ const expression = /label\s*:\s*'((?:[^']|'')*)'/gi;
72892
+ let match = expression.exec(concatenated);
72893
+ while (match !== null) {
72894
+ const label = match[1].replace(/''/g, "'");
72895
+ if (label.length > MAX_LABEL_LENGTH) {
72896
+ const message = `CDS label is ${label.length} characters, maximum is ${MAX_LABEL_LENGTH}`;
72897
+ issues.push(issue_1.Issue.atToken(file, annotation.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
72898
+ }
72899
+ match = expression.exec(concatenated);
72900
+ }
72901
+ }
72902
+ }
72903
+ checkViewEntityAnnotations(tree, issues, file) {
72904
+ const view = tree.findFirstExpression(expressions_1.CDSDefineView);
72905
+ if (view === undefined || view.findDirectTokenByText("ENTITY") === undefined) {
72906
+ return;
72907
+ }
72908
+ for (const annotation of tree.findAllExpressionsRecursive(expressions_1.CDSAnnotation)) {
72909
+ const normalized = annotation.concatTokens().replace(/\s/g, "").toUpperCase().replace(/^@</, "@");
72910
+ for (const forbidden of VIEW_ENTITY_FORBIDDEN_ANNOTATIONS) {
72911
+ const upper = forbidden.toUpperCase();
72912
+ if (normalized.startsWith("@" + upper) === false
72913
+ && normalized.startsWith("@" + upper.replace(".", ":{")) === false) {
72914
+ continue;
72915
+ }
72916
+ const message = `Annotation ${forbidden} is not allowed in view entities`;
72917
+ issues.push(issue_1.Issue.atToken(file, annotation.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
72918
+ }
72919
+ }
72920
+ }
72921
+ checkReservedNames(tree, issues, file) {
72922
+ var _a, _b;
72923
+ for (const element of tree.findAllExpressionsRecursive(expressions_1.CDSElement)) {
72924
+ if (element.findDirectTokenByText("INCLUDE") !== undefined) {
72925
+ continue;
72926
+ }
72927
+ let nameNode = (_a = element.findDirectExpression(expressions_1.CDSAs)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(expressions_1.CDSName);
72928
+ if (nameNode === undefined) {
72929
+ const names = ((_b = element.findDirectExpression(expressions_1.CDSPrefixedName)) === null || _b === void 0 ? void 0 : _b.findDirectExpressions(expressions_1.CDSName)) || [];
72930
+ nameNode = names[names.length - 1];
72931
+ }
72932
+ if (nameNode === undefined) {
72933
+ continue;
72934
+ }
72935
+ const name = this.name(nameNode);
72936
+ if (RESERVED_ELEMENT_NAMES.includes(name.toUpperCase())) {
72937
+ issues.push(issue_1.Issue.atToken(file, nameNode.getFirstToken(), `CDS element name "${name}" is reserved`, this.getMetadata().key, this.conf.severity));
72938
+ }
72939
+ }
72940
+ }
72766
72941
  checkFields(tree, sources, object, issues, file) {
72767
72942
  var _a;
72768
72943
  const associationNames = new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.28",
3
+ "version": "2.120.29",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://abaplint.org",
41
41
  "devDependencies": {
42
- "@abaplint/core": "^2.120.28",
42
+ "@abaplint/core": "^2.120.29",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",