@abaplint/cli 2.113.82 → 2.113.83

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 +84 -2
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -15090,7 +15090,8 @@ const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/
15090
15090
  const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
15091
15091
  class Module {
15092
15092
  getMatcher() {
15093
- const ret = (0, combi_1.seq)("MODULE", expressions_1.FormName, (0, combi_1.opt)((0, combi_1.alt)("INPUT", "OUTPUT", "ON CHAIN-REQUEST")));
15093
+ const sw = (0, combi_1.seq)("SWITCH", expressions_1.NamespaceSimpleName);
15094
+ const ret = (0, combi_1.seq)("MODULE", expressions_1.FormName, (0, combi_1.opt)((0, combi_1.alt)("INPUT", "OUTPUT", "ON CHAIN-REQUEST", "ON CHAIN-INPUT", sw)));
15094
15095
  return (0, combi_1.verNot)(version_1.Version.Cloud, ret);
15095
15096
  }
15096
15097
  }
@@ -27364,10 +27365,55 @@ class Select {
27364
27365
  for (const s of node.findDirectExpressions(Expressions.SQLOrderBy)) {
27365
27366
  new sql_order_by_1.SQLOrderBy().runSyntax(s, input);
27366
27367
  }
27368
+ if (this.isStrictMode(node)) {
27369
+ this.strictModeChecks(node, input);
27370
+ }
27367
27371
  if (input.scope.getType() === _scope_type_1.ScopeType.OpenSQL) {
27368
27372
  input.scope.pop(node.getLastToken().getEnd());
27369
27373
  }
27370
27374
  }
27375
+ // there are multiple rules, but gotta start somewhere
27376
+ isStrictMode(node) {
27377
+ const into = node.findDirectExpressionsMulti([Expressions.SQLIntoList, Expressions.SQLIntoStructure, Expressions.SQLIntoTable])[0];
27378
+ const where = node.findDirectExpression(Expressions.SQLCond);
27379
+ // INTO is after WHERE
27380
+ if (into && where && into.getFirstToken().getStart().isAfter(where.getFirstToken().getStart())) {
27381
+ return true;
27382
+ }
27383
+ // FIELDS is used
27384
+ if (node.findFirstExpression(Expressions.SQLFields)) {
27385
+ return true;
27386
+ }
27387
+ // any field is escaped with @
27388
+ for (const source of node.findAllExpressions(Expressions.SQLSource)) {
27389
+ if (source.getFirstToken().getStr() === "@") {
27390
+ return true;
27391
+ }
27392
+ }
27393
+ // comma used in FROM
27394
+ const fieldList = node.findFirstExpression(Expressions.SQLFieldList);
27395
+ if (fieldList && fieldList.findDirectTokenByText(",")) {
27396
+ return true;
27397
+ }
27398
+ return false;
27399
+ }
27400
+ strictModeChecks(node, input) {
27401
+ const sources = node.findAllExpressions(Expressions.SQLSource);
27402
+ for (const source of sources) {
27403
+ const first = source.getFirstChild();
27404
+ if ((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.SQLAliasField) {
27405
+ continue;
27406
+ }
27407
+ else if ((first === null || first === void 0 ? void 0 : first.getFirstToken().getStr()) === "@") {
27408
+ continue;
27409
+ }
27410
+ else if ((first === null || first === void 0 ? void 0 : first.getChildren()[0].get()) instanceof Expressions.Constant) {
27411
+ continue;
27412
+ }
27413
+ const message = `SELECT: "${source.concatTokens()}" must be escaped with @ in strict mode`;
27414
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
27415
+ }
27416
+ }
27371
27417
  handleInto(node, input, fields, dbSources) {
27372
27418
  const intoTable = node.findDirectExpression(Expressions.SQLIntoTable);
27373
27419
  if (intoTable) {
@@ -33195,6 +33241,7 @@ const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ ".
33195
33241
  const select_1 = __webpack_require__(/*! ../expressions/select */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/select.js");
33196
33242
  class Select {
33197
33243
  runSyntax(node, input) {
33244
+ // for UNION statements there are multiple select parts
33198
33245
  const selects = node.findDirectExpressions(Expressions.Select);
33199
33246
  for (let i = 0; i < selects.length; i++) {
33200
33247
  const last = i === selects.length - 1;
@@ -53581,7 +53628,7 @@ class Registry {
53581
53628
  }
53582
53629
  static abaplintVersion() {
53583
53630
  // magic, see build script "version.sh"
53584
- return "2.113.82";
53631
+ return "2.113.83";
53585
53632
  }
53586
53633
  getDDICReferences() {
53587
53634
  return this.ddicReferences;
@@ -59068,6 +59115,10 @@ Make sure to test the downported code, it might not always be completely correct
59068
59115
  if (found) {
59069
59116
  return found;
59070
59117
  }
59118
+ found = this.downportSQLMoveInto(low, high, lowFile, highSyntax);
59119
+ if (found) {
59120
+ return found;
59121
+ }
59071
59122
  found = this.downportSQLExtras(low, high, lowFile, highSyntax);
59072
59123
  if (found) {
59073
59124
  return found;
@@ -59201,6 +59252,37 @@ Make sure to test the downported code, it might not always be completely correct
59201
59252
  return undefined;
59202
59253
  }
59203
59254
  //////////////////////////////////////////
59255
+ /** move INTO from after WHERE to after FROM */
59256
+ downportSQLMoveInto(low, high, lowFile, _highSyntax) {
59257
+ if (!(low.get() instanceof _statement_1.Unknown)) {
59258
+ return undefined;
59259
+ }
59260
+ const where = high.findFirstExpression(Expressions.SQLCond);
59261
+ if (where === undefined) {
59262
+ return undefined;
59263
+ }
59264
+ let into = high.findFirstExpression(Expressions.SQLIntoList);
59265
+ if (into === undefined) {
59266
+ into = high.findFirstExpression(Expressions.SQLIntoStructure);
59267
+ }
59268
+ if (into === undefined) {
59269
+ into = high.findFirstExpression(Expressions.SQLIntoTable);
59270
+ }
59271
+ if (into === undefined) {
59272
+ return undefined;
59273
+ }
59274
+ if (where.getLastToken().getEnd().isBefore(into.getFirstToken().getStart()) === false) {
59275
+ return undefined;
59276
+ }
59277
+ const from = high.findFirstExpression(Expressions.SQLFrom);
59278
+ if (from === undefined) {
59279
+ return undefined;
59280
+ }
59281
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, from.getLastToken().getEnd(), ` ` + into.concatTokens());
59282
+ const fix2 = edit_helper_1.EditHelper.deleteRange(lowFile, into.getFirstToken().getStart(), into.getLastToken().getEnd());
59283
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
59284
+ return issue_1.Issue.atToken(lowFile, low.getFirstToken(), "SQL, move INTO", this.getMetadata().key, this.conf.severity, fix);
59285
+ }
59204
59286
  /** removes @'s and commas */
59205
59287
  downportSQLExtras(low, high, lowFile, highSyntax) {
59206
59288
  if (!(low.get() instanceof _statement_1.Unknown)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.113.82",
3
+ "version": "2.113.83",
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.113.82",
41
+ "@abaplint/core": "^2.113.83",
42
42
  "@types/chai": "^4.3.20",
43
43
  "@types/glob": "^8.1.0",
44
44
  "@types/minimist": "^1.2.5",