@abaplint/cli 2.120.45 → 2.120.46

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 +88 -4
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -70343,7 +70343,7 @@ class Registry {
70343
70343
  }
70344
70344
  static abaplintVersion() {
70345
70345
  // magic, see build script "version.js"
70346
- return "2.120.45";
70346
+ return "2.120.46";
70347
70347
  }
70348
70348
  getDDICReferences() {
70349
70349
  return this.ddicReferences;
@@ -71974,7 +71974,7 @@ class AllowedObjectNaming {
71974
71974
  key: "allowed_object_naming",
71975
71975
  title: "Allowed object naming",
71976
71976
  shortDescription: `Enforces basic name length and namespace restrictions, see note SAP 104010`,
71977
- tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
71977
+ tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Syntax],
71978
71978
  };
71979
71979
  }
71980
71980
  initialize(_reg) {
@@ -77831,6 +77831,10 @@ Make sure to test the downported code, it might not always be completely correct
77831
77831
  if (found) {
77832
77832
  return found;
77833
77833
  }
77834
+ found = this.outlineTableExpressionKeyBuiltin(low, high, lowFile, highSyntax);
77835
+ if (found) {
77836
+ return found;
77837
+ }
77834
77838
  found = this.assignWithTable(low, high, lowFile);
77835
77839
  if (found) {
77836
77840
  return found;
@@ -78528,6 +78532,69 @@ ${indentation}`);
78528
78532
  }
78529
78533
  return condition;
78530
78534
  }
78535
+ /** A built-in function is only recognized as one in an operand position that admits an
78536
+ * expression, and "WITH KEY comp = ..." does not become such a position until v740. The
78537
+ * table expression rewrites carry the key operand over verbatim, so
78538
+ * "tab[ comp = to_upper( x ) ]" downports to a READ TABLE that a 702 or 731 compiler can
78539
+ * only read as a functional method call - "method TO_UPPER is unknown", reported as a
78540
+ * SYNTAX_ERROR of the whole class pool. Hoist the call into a variable first, an
78541
+ * assignment IS an expression position at 702.
78542
+ *
78543
+ * Built-ins that predate 702 (lines, strlen, numofchar, ...) carry no release in
78544
+ * BuiltIn.methods; they are accepted in the operand as they are and stay untouched. So do
78545
+ * functional method calls, which are exactly the reading that makes the built-in fail, and
78546
+ * the INDEX operand of "tab[ 1 ]", which is not a key operand. */
78547
+ outlineTableExpressionKeyBuiltin(low, high, lowFile, highSyntax) {
78548
+ if (!(low.get() instanceof _statement_1.Unknown)) {
78549
+ return undefined;
78550
+ }
78551
+ for (const tableExpression of high.findAllExpressionsRecursive(Expressions.TableExpression)) {
78552
+ let afterComponent = false;
78553
+ for (const child of tableExpression.getChildren()) {
78554
+ if (child.get() instanceof Expressions.ComponentChainSimple) {
78555
+ afterComponent = true;
78556
+ continue;
78557
+ }
78558
+ else if (afterComponent === false
78559
+ || !(child.get() instanceof Expressions.Source)
78560
+ || !(child instanceof nodes_1.ExpressionNode)) {
78561
+ continue;
78562
+ }
78563
+ const type = this.builtinReturnType(child, lowFile, highSyntax);
78564
+ if (type === undefined) {
78565
+ continue;
78566
+ }
78567
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
78568
+ const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
78569
+ const code = `DATA ${uniqueName} TYPE ${type}.\n` +
78570
+ indentation + `${uniqueName} = ${child.concatTokens()}.\n` +
78571
+ indentation;
78572
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getStart(), code);
78573
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, child.getFirstToken().getStart(), child.getLastToken().getEnd(), uniqueName);
78574
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
78575
+ return issue_1.Issue.atToken(lowFile, child.getFirstToken(), "Outline built-in function in table expression key", this.getMetadata().key, this.conf.severity, fix);
78576
+ }
78577
+ }
78578
+ return undefined;
78579
+ }
78580
+ /** the ABAP type returned by the built-in function this Source starts with, or undefined
78581
+ * if it does not start with one, or with one that predates 702 */
78582
+ builtinReturnType(source, lowFile, highSyntax) {
78583
+ var _a, _b, _c;
78584
+ const spag = highSyntax.spaghetti.lookupPosition(source.getFirstToken().getStart(), lowFile.getFilename());
78585
+ for (const r of (spag === null || spag === void 0 ? void 0 : spag.getData().references) || []) {
78586
+ if (r.referenceType !== _reference_1.ReferenceType.BuiltinMethodReference
78587
+ || r.position.getStart().equals(source.getFirstToken().getStart()) === false) {
78588
+ continue;
78589
+ }
78590
+ const name = r.position.getName().toUpperCase();
78591
+ if (((_a = _builtin_1.BuiltIn.methods[name]) === null || _a === void 0 ? void 0 : _a.release) === undefined) {
78592
+ return undefined;
78593
+ }
78594
+ return (_c = (_b = _builtin_1.BuiltIn.searchBuiltin(name)) === null || _b === void 0 ? void 0 : _b.getParameters().getReturning()) === null || _c === void 0 ? void 0 : _c.getType().toABAP();
78595
+ }
78596
+ return undefined;
78597
+ }
78531
78598
  outlineCatchSimple(node, lowFile) {
78532
78599
  // outlines "CATCH cx_bcs INTO DATA(lx_bcs_excep).", note that this does not need to look at types
78533
78600
  var _a, _b;
@@ -80138,9 +80205,13 @@ ${indentation} output = ${uniqueName}.\n`;
80138
80205
  continue;
80139
80206
  }
80140
80207
  const uniqueName = this.uniqueName(i.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
80141
- const type = this.findType(i, lowFile, highSyntax);
80142
80208
  const indent = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
80143
- const abap = `DATA ${uniqueName} TYPE ${type}.\n` +
80209
+ // the CONV type might just be a component of the row type, so prefer the row type
80210
+ const rowOf = this.findRowTypeOf(high, i);
80211
+ const declaration = rowOf === undefined
80212
+ ? `DATA ${uniqueName} TYPE ${this.findType(i, lowFile, highSyntax)}.`
80213
+ : `DATA ${uniqueName} LIKE LINE OF ${rowOf}.`;
80214
+ const abap = declaration + "\n" +
80144
80215
  indent + `${uniqueName} = ${body}.\n` +
80145
80216
  indent;
80146
80217
  const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getStart(), abap);
@@ -80150,6 +80221,19 @@ ${indentation} output = ${uniqueName}.\n`;
80150
80221
  }
80151
80222
  return undefined;
80152
80223
  }
80224
+ /** if the source expression is the complete source of an INSERT or APPEND statement, then the
80225
+ * outlined variable must be typed via the row type of the table, returns the table name */
80226
+ findRowTypeOf(high, source) {
80227
+ var _a;
80228
+ if (!(high.get() instanceof Statements.InsertInternal)
80229
+ && !(high.get() instanceof Statements.Append)) {
80230
+ return undefined;
80231
+ }
80232
+ else if (high.getChildren()[1] !== source) {
80233
+ return undefined;
80234
+ }
80235
+ return (_a = high.findDirectExpression(Expressions.Target)) === null || _a === void 0 ? void 0 : _a.concatTokens();
80236
+ }
80153
80237
  // "CAST" to "?="
80154
80238
  outlineCast(low, high, lowFile, highSyntax) {
80155
80239
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.45",
3
+ "version": "2.120.46",
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.45",
42
+ "@abaplint/core": "^2.120.46",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",