@abaplint/cli 2.120.60 → 2.120.62

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 +60 -9
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -53,9 +53,8 @@ const BUFS = new Set([
53
53
  CH_DOT, CH_COMMA, CH_COLON, 40 /* ( */, 41 /* ) */, 91 /* [ */,
54
54
  93 /* ] */, 43 /* + */, CH_AT
55
55
  ]);
56
- // characters that may follow the closing "'", "`" or "|" of a literal, anything else
57
- // is a syntax error, "There must be a space or equivalent character after ...",
58
- // note that "(" is allowed, ie. text elements like 'text'(001)
56
+ // characters treated as separators after ping literals and string templates.
57
+ // Single-quoted text literals always end at their closing quote.
59
58
  const AFTER_LITERAL = new Set([
60
59
  EOF, CH_SPACE, CH_TAB, CH_NL, CH_DOT, CH_COMMA, CH_COLON, CH_DQUOTE,
61
60
  40 /* ( */, 41 /* ) */, 91 /* [ */, 93 /* ] */
@@ -373,9 +372,7 @@ class Lexer {
373
372
  && ahead !== CH_QUOTE
374
373
  && this.buffer.countIsEven(CH_QUOTE)) {
375
374
  // end of string
376
- if (AFTER_LITERAL.has(ahead)) {
377
- this.add();
378
- }
375
+ this.add();
379
376
  if (ahead === CH_DQUOTE) {
380
377
  this.m = ModeComment;
381
378
  }
@@ -3094,7 +3091,8 @@ class ExpandMacros {
3094
3091
  for (const input of inputs) {
3095
3092
  const search = "&" + i;
3096
3093
  const reg = new RegExp(search, "g");
3097
- str = str.replace(reg, input);
3094
+ // a function replacement: "$`" and "$'" in the argument are text, not patterns
3095
+ str = str.replace(reg, () => input);
3098
3096
  i++;
3099
3097
  }
3100
3098
  const file = new memory_file_1.MemoryFile("expand_macros.abap.prog", str);
@@ -16838,7 +16836,7 @@ class ModifyEntities {
16838
16836
  const mapped = (0, combi_1.seq)("MAPPED", expressions_1.Target);
16839
16837
  const reported = (0, combi_1.seq)("REPORTED", expressions_1.Target);
16840
16838
  const end = (0, combi_1.optPrio)((0, combi_1.per)(failed, result, mapped, reported));
16841
- const entities = (0, combi_1.seq)((0, combi_1.optPrio)("AUGMENTING"), "ENTITIES OF", expressions_1.NamespaceSimpleName, (0, combi_1.opt)("IN LOCAL MODE"), (0, combi_1.plusPrio)((0, combi_1.seq)("ENTITY", expressions_1.NamespaceSimpleName, (0, combi_1.plus)(operation))));
16839
+ const entities = (0, combi_1.seq)((0, combi_1.optPrio)("AUGMENTING"), "ENTITIES OF", expressions_1.NamespaceSimpleName, (0, combi_1.optPrio)((0, combi_1.altPrio)("IN LOCAL MODE", (0, combi_1.seq)((0, combi_1.opt)("FORWARDING"), "PRIVILEGED"))), (0, combi_1.plusPrio)((0, combi_1.seq)("ENTITY", expressions_1.NamespaceSimpleName, (0, combi_1.plus)(operation))));
16842
16840
  const dynamic = (0, combi_1.seq)("ENTITIES", (0, combi_1.optPrio)((0, combi_1.altPrio)("IN LOCAL MODE", (0, combi_1.seq)((0, combi_1.opt)("FORWARDING"), "PRIVILEGED"))), "OPERATIONS", expressions_1.Source);
16843
16841
  const create2 = (0, combi_1.seq)("CREATE", fieldsWith, (0, combi_1.opt)((0, combi_1.seq)("CREATE BY", expressions_1.EMLEntityPath, fieldsWith)));
16844
16842
  const create3 = (0, combi_1.seq)("CREATE BY", expressions_1.EMLEntityPath, fieldsWith);
@@ -24936,6 +24934,12 @@ class BuiltIn {
24936
24934
  }
24937
24935
  return this.buildDefinition(def, name);
24938
24936
  }
24937
+ static hasUnnamedArgument(name) {
24938
+ if (name === undefined) {
24939
+ return false;
24940
+ }
24941
+ return BuiltIn.unnamedArgument.has(name.toUpperCase());
24942
+ }
24939
24943
  static isPredicate(name) {
24940
24944
  if (name === undefined) {
24941
24945
  return undefined;
@@ -26037,6 +26041,12 @@ BuiltIn.methods = {
26037
26041
  return: basic_1.IntegerType.get(),
26038
26042
  },
26039
26043
  };
26044
+ // functions called with exactly one unnamed argument, all others take named arguments like "val"
26045
+ BuiltIn.unnamedArgument = new Set([
26046
+ "ABS", "ACOS", "ASIN", "ATAN", "BOOLC", "CEIL", "CHARLEN", "COS", "COSH", "DBMAXLEN", "EXP", "FLOOR",
26047
+ "FRAC", "LINES", "LOG", "LOG10", "NUMOFCHAR", "SIGN", "SIN", "SINH", "SQRT", "STRLEN", "TAN", "TANH",
26048
+ "TRUNC", "XSTRLEN"
26049
+ ]);
26040
26050
  //# sourceMappingURL=_builtin.js.map
26041
26051
 
26042
26052
  /***/ },
@@ -38090,17 +38100,54 @@ var __importStar = (this && this.__importStar) || (function () {
38090
38100
  })();
38091
38101
  Object.defineProperty(exports, "__esModule", ({ value: true }));
38092
38102
  exports.Case = void 0;
38103
+ exports.checkCaseOperand = checkCaseOperand;
38093
38104
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
38094
38105
  const source_1 = __webpack_require__(/*! ../expressions/source */ "../core/build/src/abap/5_syntax/expressions/source.js");
38106
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
38107
+ const _builtin_1 = __webpack_require__(/*! ../_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
38108
+ const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
38109
+ const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
38110
+ const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
38095
38111
  class Case {
38096
38112
  runSyntax(node, input) {
38097
38113
  // just recurse
38098
38114
  for (const s of node.findDirectExpressions(Expressions.Source)) {
38099
38115
  source_1.Source.runSyntax(s, input);
38116
+ checkCaseOperand(s, input);
38100
38117
  }
38101
38118
  }
38102
38119
  }
38103
38120
  exports.Case = Case;
38121
+ // Before 7.40 SP02 the operands of CASE and WHEN are enhanced functional operand positions: besides
38122
+ // data objects and functional methods, only built-in functions with exactly one unnamed argument are allowed
38123
+ function checkCaseOperand(source, input) {
38124
+ var _a, _b;
38125
+ if ((0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v740sp02)
38126
+ || input.scope.getLanguageVersion() === version_1.LanguageVersion.Cloud
38127
+ || input.scope.getOpenABAP()) {
38128
+ return;
38129
+ }
38130
+ const chain = source.findDirectExpression(Expressions.MethodCallChain);
38131
+ if (chain === undefined || source.getChildren().length !== 1 || chain.getChildren().length !== 1) {
38132
+ return;
38133
+ }
38134
+ const call = chain.findDirectExpression(Expressions.MethodCall);
38135
+ const nameToken = (_a = call === null || call === void 0 ? void 0 : call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
38136
+ const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.getStr();
38137
+ if (nameToken === undefined || _builtin_1.BuiltIn.searchBuiltin(name) === undefined || _builtin_1.BuiltIn.hasUnnamedArgument(name)) {
38138
+ return;
38139
+ }
38140
+ // a method of the enclosing class takes precedence over the built-in function
38141
+ const meType = (_b = input.scope.findVariable("me")) === null || _b === void 0 ? void 0 : _b.getType();
38142
+ if (meType instanceof basic_1.ObjectReferenceType) {
38143
+ const def = input.scope.findObjectDefinition(meType.getIdentifierName());
38144
+ if (new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(def, name).method !== undefined) {
38145
+ return;
38146
+ }
38147
+ }
38148
+ const message = "Built-in function " + name + " not allowed as CASE/WHEN operand before v740sp02";
38149
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, nameToken, message));
38150
+ }
38104
38151
  //# sourceMappingURL=case.js.map
38105
38152
 
38106
38153
  /***/ },
@@ -47174,11 +47221,15 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
47174
47221
  exports.When = void 0;
47175
47222
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
47176
47223
  const source_1 = __webpack_require__(/*! ../expressions/source */ "../core/build/src/abap/5_syntax/expressions/source.js");
47224
+ const case_1 = __webpack_require__(/*! ./case */ "../core/build/src/abap/5_syntax/statements/case.js");
47177
47225
  class When {
47178
47226
  runSyntax(node, input) {
47179
47227
  for (const s of node.findAllExpressions(Expressions.Source)) {
47180
47228
  source_1.Source.runSyntax(s, input);
47181
47229
  }
47230
+ for (const s of node.findDirectExpressions(Expressions.Source)) {
47231
+ (0, case_1.checkCaseOperand)(s, input);
47232
+ }
47182
47233
  }
47183
47234
  }
47184
47235
  exports.When = When;
@@ -70712,7 +70763,7 @@ class Registry {
70712
70763
  }
70713
70764
  static abaplintVersion() {
70714
70765
  // magic, see build script "version.js"
70715
- return "2.120.60";
70766
+ return "2.120.62";
70716
70767
  }
70717
70768
  getDDICReferences() {
70718
70769
  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.62",
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.62",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",