@abaplint/cli 2.120.60 → 2.120.61

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 +54 -1
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -24936,6 +24936,12 @@ class BuiltIn {
24936
24936
  }
24937
24937
  return this.buildDefinition(def, name);
24938
24938
  }
24939
+ static hasUnnamedArgument(name) {
24940
+ if (name === undefined) {
24941
+ return false;
24942
+ }
24943
+ return BuiltIn.unnamedArgument.has(name.toUpperCase());
24944
+ }
24939
24945
  static isPredicate(name) {
24940
24946
  if (name === undefined) {
24941
24947
  return undefined;
@@ -26037,6 +26043,12 @@ BuiltIn.methods = {
26037
26043
  return: basic_1.IntegerType.get(),
26038
26044
  },
26039
26045
  };
26046
+ // functions called with exactly one unnamed argument, all others take named arguments like "val"
26047
+ BuiltIn.unnamedArgument = new Set([
26048
+ "ABS", "ACOS", "ASIN", "ATAN", "BOOLC", "CEIL", "CHARLEN", "COS", "COSH", "DBMAXLEN", "EXP", "FLOOR",
26049
+ "FRAC", "LINES", "LOG", "LOG10", "NUMOFCHAR", "SIGN", "SIN", "SINH", "SQRT", "STRLEN", "TAN", "TANH",
26050
+ "TRUNC", "XSTRLEN"
26051
+ ]);
26040
26052
  //# sourceMappingURL=_builtin.js.map
26041
26053
 
26042
26054
  /***/ },
@@ -38090,17 +38102,54 @@ var __importStar = (this && this.__importStar) || (function () {
38090
38102
  })();
38091
38103
  Object.defineProperty(exports, "__esModule", ({ value: true }));
38092
38104
  exports.Case = void 0;
38105
+ exports.checkCaseOperand = checkCaseOperand;
38093
38106
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
38094
38107
  const source_1 = __webpack_require__(/*! ../expressions/source */ "../core/build/src/abap/5_syntax/expressions/source.js");
38108
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
38109
+ const _builtin_1 = __webpack_require__(/*! ../_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
38110
+ const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
38111
+ const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
38112
+ const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
38095
38113
  class Case {
38096
38114
  runSyntax(node, input) {
38097
38115
  // just recurse
38098
38116
  for (const s of node.findDirectExpressions(Expressions.Source)) {
38099
38117
  source_1.Source.runSyntax(s, input);
38118
+ checkCaseOperand(s, input);
38100
38119
  }
38101
38120
  }
38102
38121
  }
38103
38122
  exports.Case = Case;
38123
+ // Before 7.40 SP02 the operands of CASE and WHEN are enhanced functional operand positions: besides
38124
+ // data objects and functional methods, only built-in functions with exactly one unnamed argument are allowed
38125
+ function checkCaseOperand(source, input) {
38126
+ var _a, _b;
38127
+ if ((0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v740sp02)
38128
+ || input.scope.getLanguageVersion() === version_1.LanguageVersion.Cloud
38129
+ || input.scope.getOpenABAP()) {
38130
+ return;
38131
+ }
38132
+ const chain = source.findDirectExpression(Expressions.MethodCallChain);
38133
+ if (chain === undefined || source.getChildren().length !== 1 || chain.getChildren().length !== 1) {
38134
+ return;
38135
+ }
38136
+ const call = chain.findDirectExpression(Expressions.MethodCall);
38137
+ const nameToken = (_a = call === null || call === void 0 ? void 0 : call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
38138
+ const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.getStr();
38139
+ if (nameToken === undefined || _builtin_1.BuiltIn.searchBuiltin(name) === undefined || _builtin_1.BuiltIn.hasUnnamedArgument(name)) {
38140
+ return;
38141
+ }
38142
+ // a method of the enclosing class takes precedence over the built-in function
38143
+ const meType = (_b = input.scope.findVariable("me")) === null || _b === void 0 ? void 0 : _b.getType();
38144
+ if (meType instanceof basic_1.ObjectReferenceType) {
38145
+ const def = input.scope.findObjectDefinition(meType.getIdentifierName());
38146
+ if (new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(def, name).method !== undefined) {
38147
+ return;
38148
+ }
38149
+ }
38150
+ const message = "Built-in function " + name + " not allowed as CASE/WHEN operand before v740sp02";
38151
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, nameToken, message));
38152
+ }
38104
38153
  //# sourceMappingURL=case.js.map
38105
38154
 
38106
38155
  /***/ },
@@ -47174,11 +47223,15 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
47174
47223
  exports.When = void 0;
47175
47224
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
47176
47225
  const source_1 = __webpack_require__(/*! ../expressions/source */ "../core/build/src/abap/5_syntax/expressions/source.js");
47226
+ const case_1 = __webpack_require__(/*! ./case */ "../core/build/src/abap/5_syntax/statements/case.js");
47177
47227
  class When {
47178
47228
  runSyntax(node, input) {
47179
47229
  for (const s of node.findAllExpressions(Expressions.Source)) {
47180
47230
  source_1.Source.runSyntax(s, input);
47181
47231
  }
47232
+ for (const s of node.findDirectExpressions(Expressions.Source)) {
47233
+ (0, case_1.checkCaseOperand)(s, input);
47234
+ }
47182
47235
  }
47183
47236
  }
47184
47237
  exports.When = When;
@@ -70712,7 +70765,7 @@ class Registry {
70712
70765
  }
70713
70766
  static abaplintVersion() {
70714
70767
  // magic, see build script "version.js"
70715
- return "2.120.60";
70768
+ return "2.120.61";
70716
70769
  }
70717
70770
  getDDICReferences() {
70718
70771
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.60",
3
+ "version": "2.120.61",
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.60",
42
+ "@abaplint/core": "^2.120.61",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",