@abaplint/cli 2.105.26 → 2.106.1

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 +182 -19
  2. package/package.json +4 -4
package/build/cli.js CHANGED
@@ -11104,9 +11104,9 @@ class Concatenate {
11104
11104
  getMatcher() {
11105
11105
  const mode = (0, combi_1.seq)("IN", (0, combi_1.altPrio)("BYTE", "CHARACTER"), "MODE");
11106
11106
  const blanks = (0, combi_1.str)("RESPECTING BLANKS");
11107
- const sep = (0, combi_1.seq)("SEPARATED BY", expressions_1.Source);
11107
+ const sep = (0, combi_1.seq)("SEPARATED BY", expressions_1.SimpleSource3);
11108
11108
  const options = (0, combi_1.per)(mode, blanks, sep);
11109
- const sourc = (0, combi_1.seq)(expressions_1.Source, (0, combi_1.plus)(expressions_1.Source));
11109
+ const sourc = (0, combi_1.seq)(expressions_1.SimpleSource3, (0, combi_1.plus)(expressions_1.SimpleSource3));
11110
11110
  const lines = (0, combi_1.seq)("LINES OF", expressions_1.Source);
11111
11111
  return (0, combi_1.seq)("CONCATENATE", (0, combi_1.altPrio)(lines, sourc), "INTO", expressions_1.Target, (0, combi_1.optPrio)(options));
11112
11112
  }
@@ -22136,6 +22136,7 @@ class Procedural {
22136
22136
  throw new Error("Function module definition \"" + name + "\" not found");
22137
22137
  }
22138
22138
  const ddic = new ddic_1.DDIC(this.reg);
22139
+ const allNames = new Set();
22139
22140
  for (const param of definition.getParameters()) {
22140
22141
  let found = undefined;
22141
22142
  if (param.type === undefined || param.type === "") {
@@ -22212,8 +22213,16 @@ class Procedural {
22212
22213
  if (found instanceof basic_1.UnknownType && new ddic_1.DDIC(this.reg).inErrorNamespace(param.type) === false) {
22213
22214
  found = new basic_1.VoidType(param.type);
22214
22215
  }
22215
- const type = new _typed_identifier_1.TypedIdentifier(nameToken, filename, found);
22216
- this.scope.addNamedIdentifier(param.name, type);
22216
+ if (allNames.has(param.name.toUpperCase())) {
22217
+ // yea, IMPORTING and EXPORTING can have the same name
22218
+ // workaround to avoid false postivies, can be improved
22219
+ continue;
22220
+ }
22221
+ else {
22222
+ const type = new _typed_identifier_1.TypedIdentifier(nameToken, filename, found);
22223
+ this.scope.addNamedIdentifier(param.name, type);
22224
+ allNames.add(param.name.toUpperCase());
22225
+ }
22217
22226
  }
22218
22227
  }
22219
22228
  }
@@ -26867,6 +26876,8 @@ class Source {
26867
26876
  if (writeReference) {
26868
26877
  type.push(_reference_1.ReferenceType.DataWriteReference);
26869
26878
  }
26879
+ let hexExpected = false;
26880
+ let hexNext = false;
26870
26881
  while (children.length >= 0) {
26871
26882
  if (first instanceof nodes_1.ExpressionNode && first.get() instanceof Expressions.MethodCallChain) {
26872
26883
  context = new method_call_chain_1.MethodCallChain().runSyntax(first, scope, filename, targetType);
@@ -26898,10 +26909,29 @@ class Source {
26898
26909
  if (first.concatTokens() === "**") {
26899
26910
  context = new basic_1.FloatType();
26900
26911
  }
26912
+ const operator = first.concatTokens().toUpperCase();
26913
+ if (operator === "BIT-OR" || operator === "BIT-AND" || operator === "BIT-XOR") {
26914
+ hexExpected = true;
26915
+ hexNext = true;
26916
+ }
26901
26917
  }
26902
26918
  else if (first instanceof nodes_1.ExpressionNode && first.get() instanceof Expressions.AttributeChain) {
26903
26919
  context = new attribute_chain_1.AttributeChain().runSyntax(context, first, scope, filename, type);
26904
26920
  }
26921
+ if (hexExpected === true) {
26922
+ if (!(context instanceof basic_1.VoidType)
26923
+ && !(context instanceof basic_1.XStringType)
26924
+ && !(context instanceof basic_1.HexType)
26925
+ && !(context instanceof basic_1.XGenericType)
26926
+ && !(context instanceof basic_1.XSequenceType)
26927
+ && !(context instanceof unknown_type_1.UnknownType)) {
26928
+ throw new Error("Operator only valid for XSTRING or HEX");
26929
+ }
26930
+ if (hexNext === false) {
26931
+ hexExpected = false;
26932
+ }
26933
+ hexNext = false;
26934
+ }
26905
26935
  first = children.shift();
26906
26936
  if (first === undefined) {
26907
26937
  break;
@@ -28291,8 +28321,15 @@ class Append {
28291
28321
  else if (targetType instanceof basic_1.VoidType) {
28292
28322
  rowType = targetType;
28293
28323
  }
28294
- const sourceType = new source_1.Source().runSyntax(source, scope, filename, rowType);
28324
+ let sourceType = new source_1.Source().runSyntax(source, scope, filename, rowType);
28295
28325
  if (node.findDirectTokenByText("LINES")) {
28326
+ // hmm, checking only the row types are compatible will not check the table type, e.g. sorted or hashed
28327
+ if (sourceType instanceof basic_1.TableType) {
28328
+ sourceType = sourceType.getRowType();
28329
+ }
28330
+ if (targetType instanceof basic_1.TableType) {
28331
+ targetType = targetType.getRowType();
28332
+ }
28296
28333
  if (new _type_utils_1.TypeUtils(scope).isAssignable(sourceType, targetType) === false) {
28297
28334
  throw new Error("Incompatible types");
28298
28335
  }
@@ -29104,7 +29141,7 @@ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/
29104
29141
  class Concatenate {
29105
29142
  runSyntax(node, scope, filename) {
29106
29143
  const byteMode = node.findDirectTokenByText("BYTE") !== undefined;
29107
- let linesMode = node.findDirectTokenByText("LINES") !== undefined;
29144
+ const linesMode = node.findDirectTokenByText("LINES") !== undefined;
29108
29145
  const target = node.findFirstExpression(Expressions.Target);
29109
29146
  const inline = target === null || target === void 0 ? void 0 : target.findDirectExpression(Expressions.InlineData);
29110
29147
  if (inline) {
@@ -29122,18 +29159,21 @@ class Concatenate {
29122
29159
  throw new Error("Target type not compatible");
29123
29160
  }
29124
29161
  }
29125
- for (const s of node.findDirectExpressions(Expressions.Source)) {
29126
- const type = new source_1.Source().runSyntax(s, scope, filename);
29127
- if (linesMode) {
29162
+ if (linesMode) {
29163
+ for (const s of node.findDirectExpressions(Expressions.Source)) {
29164
+ const type = new source_1.Source().runSyntax(s, scope, filename);
29128
29165
  if (!(type instanceof basic_1.UnknownType) && !(type instanceof basic_1.VoidType) && !(type instanceof basic_1.TableType)) {
29129
29166
  throw new Error("Source must be an internal table");
29130
29167
  }
29131
- linesMode = false;
29132
- continue;
29133
29168
  }
29134
- const compatible = byteMode ? new _type_utils_1.TypeUtils(scope).isHexLike(type) : new _type_utils_1.TypeUtils(scope).isCharLikeStrict(type);
29135
- if (compatible === false) {
29136
- throw new Error("Source type not compatible");
29169
+ }
29170
+ else {
29171
+ for (const s of node.findDirectExpressions(Expressions.SimpleSource3)) {
29172
+ const type = new source_1.Source().runSyntax(s, scope, filename);
29173
+ const compatible = byteMode ? new _type_utils_1.TypeUtils(scope).isHexLike(type) : new _type_utils_1.TypeUtils(scope).isCharLikeStrict(type);
29174
+ if (compatible === false) {
29175
+ throw new Error("Source type not compatible");
29176
+ }
29137
29177
  }
29138
29178
  }
29139
29179
  }
@@ -31046,7 +31086,8 @@ class ModifyInternal {
31046
31086
  new source_1.Source().runSyntax(s, scope, filename);
31047
31087
  }
31048
31088
  // there is only one
31049
- const targetExpression = node.findFirstExpression(Expressions.Target);
31089
+ const target = node.findFirstExpression(Expressions.Target);
31090
+ const targetExpression = target;
31050
31091
  if (targetExpression) {
31051
31092
  // it might be a dynamic target
31052
31093
  const targetType = new target_1.Target().runSyntax(targetExpression, scope, filename);
@@ -31063,13 +31104,19 @@ class ModifyInternal {
31063
31104
  throw new Error("Table does not have header line");
31064
31105
  }
31065
31106
  }
31107
+ else if (targetType instanceof basic_1.StructureType) {
31108
+ // it might originate from a TABLES statement
31109
+ if (target.concatTokens().toUpperCase() !== targetType.getDDICName()) {
31110
+ throw new Error("Not an internal table");
31111
+ }
31112
+ }
31066
31113
  else {
31067
31114
  throw new Error("Not an internal table");
31068
31115
  }
31069
31116
  }
31070
- const target = node.findDirectExpression(Expressions.FSTarget);
31071
- if (target) {
31072
- new fstarget_1.FSTarget().runSyntax(target, scope, filename, undefined);
31117
+ const fstarget = node.findDirectExpression(Expressions.FSTarget);
31118
+ if (fstarget) {
31119
+ new fstarget_1.FSTarget().runSyntax(fstarget, scope, filename, undefined);
31073
31120
  }
31074
31121
  for (const t of node.findDirectExpressions(Expressions.ComponentCond)) {
31075
31122
  new component_cond_1.ComponentCond().runSyntax(t, scope, filename);
@@ -51336,7 +51383,7 @@ class Registry {
51336
51383
  }
51337
51384
  static abaplintVersion() {
51338
51385
  // magic, see build script "version.sh"
51339
- return "2.105.26";
51386
+ return "2.106.1";
51340
51387
  }
51341
51388
  getDDICReferences() {
51342
51389
  return this.ddicReferences;
@@ -60598,6 +60645,18 @@ class IdenticalConditions extends _abap_rule_1.ABAPRule {
60598
60645
 
60599
60646
  Prerequsites: code is pretty printed with identical cAsE`,
60600
60647
  tags: [_irule_1.RuleTag.SingleFile],
60648
+ badExample: `IF foo = bar OR 1 = a OR foo = bar.
60649
+ ENDIF.
60650
+ CASE bar.
60651
+ WHEN '1'.
60652
+ WHEN 'A' OR '1'.
60653
+ ENDCASE.`,
60654
+ goodExample: `IF foo = bar OR 1 = a.
60655
+ ENDIF.
60656
+ CASE bar.
60657
+ WHEN '1'.
60658
+ WHEN 'A'.
60659
+ ENDCASE.`,
60601
60660
  };
60602
60661
  }
60603
60662
  getConfig() {
@@ -61753,6 +61812,7 @@ __exportStar(__webpack_require__(/*! ./in_statement_indentation */ "./node_modul
61753
61812
  __exportStar(__webpack_require__(/*! ./indentation */ "./node_modules/@abaplint/core/build/src/rules/indentation.js"), exports);
61754
61813
  __exportStar(__webpack_require__(/*! ./inline_data_old_versions */ "./node_modules/@abaplint/core/build/src/rules/inline_data_old_versions.js"), exports);
61755
61814
  __exportStar(__webpack_require__(/*! ./intf_referencing_clas */ "./node_modules/@abaplint/core/build/src/rules/intf_referencing_clas.js"), exports);
61815
+ __exportStar(__webpack_require__(/*! ./invalid_table_index */ "./node_modules/@abaplint/core/build/src/rules/invalid_table_index.js"), exports);
61756
61816
  __exportStar(__webpack_require__(/*! ./keep_single_parameter_on_one_line */ "./node_modules/@abaplint/core/build/src/rules/keep_single_parameter_on_one_line.js"), exports);
61757
61817
  __exportStar(__webpack_require__(/*! ./keyword_case */ "./node_modules/@abaplint/core/build/src/rules/keyword_case.js"), exports);
61758
61818
  __exportStar(__webpack_require__(/*! ./line_break_multiple_parameters */ "./node_modules/@abaplint/core/build/src/rules/line_break_multiple_parameters.js"), exports);
@@ -62017,6 +62077,89 @@ exports.IntfReferencingClas = IntfReferencingClas;
62017
62077
 
62018
62078
  /***/ }),
62019
62079
 
62080
+ /***/ "./node_modules/@abaplint/core/build/src/rules/invalid_table_index.js":
62081
+ /*!****************************************************************************!*\
62082
+ !*** ./node_modules/@abaplint/core/build/src/rules/invalid_table_index.js ***!
62083
+ \****************************************************************************/
62084
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
62085
+
62086
+ "use strict";
62087
+
62088
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
62089
+ exports.InvalidTableIndex = exports.InvalidTableIndexConf = void 0;
62090
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
62091
+ const Expressions = __webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
62092
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
62093
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
62094
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
62095
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
62096
+ const statements_1 = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
62097
+ class InvalidTableIndexConf extends _basic_rule_config_1.BasicRuleConfig {
62098
+ }
62099
+ exports.InvalidTableIndexConf = InvalidTableIndexConf;
62100
+ class InvalidTableIndex extends _abap_rule_1.ABAPRule {
62101
+ constructor() {
62102
+ super(...arguments);
62103
+ this.conf = new InvalidTableIndexConf();
62104
+ }
62105
+ getMetadata() {
62106
+ return {
62107
+ key: "invalid_table_index",
62108
+ title: "Invalid Table Index",
62109
+ shortDescription: `Issues error for constant table index zero, as ABAP starts from 1`,
62110
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
62111
+ badExample: `DATA(first) = table[ 0 ].
62112
+ READ TABLE gt_stack ASSIGNING <ls_stack> INDEX 0.`,
62113
+ goodExample: `DATA(first) = table[ 1 ].
62114
+ READ TABLE gt_stack ASSIGNING <ls_stack> INDEX 1.`,
62115
+ };
62116
+ }
62117
+ getConfig() {
62118
+ return this.conf;
62119
+ }
62120
+ setConfig(conf) {
62121
+ this.conf = conf;
62122
+ }
62123
+ runParsed(file) {
62124
+ var _a, _b, _c, _d, _e, _f;
62125
+ const issues = [];
62126
+ const stru = file.getStructure();
62127
+ if (stru === undefined) {
62128
+ return issues; // parser error
62129
+ }
62130
+ const expr = stru.findAllExpressionsRecursive(Expressions.TableExpression);
62131
+ for (const e of expr) {
62132
+ const token = (_c = (_b = (_a = e.findDirectExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Constant)) === null || _b === void 0 ? void 0 : _b.findFirstExpression(Expressions.Integer)) === null || _c === void 0 ? void 0 : _c.getFirstToken();
62133
+ if (token === undefined) {
62134
+ continue;
62135
+ }
62136
+ if (token.getStr() === "0") {
62137
+ const message = "Table index starts from 1";
62138
+ const fix = edit_helper_1.EditHelper.replaceToken(file, token, "1");
62139
+ const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity, fix);
62140
+ issues.push(issue);
62141
+ }
62142
+ }
62143
+ for (const rt of stru.findAllStatements(statements_1.ReadTable)) {
62144
+ const token = (_f = (_e = (_d = rt.findExpressionAfterToken("INDEX")) === null || _d === void 0 ? void 0 : _d.findDirectExpression(Expressions.Constant)) === null || _e === void 0 ? void 0 : _e.findFirstExpression(Expressions.Integer)) === null || _f === void 0 ? void 0 : _f.getFirstToken();
62145
+ if (token === undefined) {
62146
+ continue;
62147
+ }
62148
+ if (token.getStr() === "0") {
62149
+ const message = "Table index starts from 1";
62150
+ const fix = edit_helper_1.EditHelper.replaceToken(file, token, "1");
62151
+ const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity, fix);
62152
+ issues.push(issue);
62153
+ }
62154
+ }
62155
+ return issues;
62156
+ }
62157
+ }
62158
+ exports.InvalidTableIndex = InvalidTableIndex;
62159
+ //# sourceMappingURL=invalid_table_index.js.map
62160
+
62161
+ /***/ }),
62162
+
62020
62163
  /***/ "./node_modules/@abaplint/core/build/src/rules/keep_single_parameter_on_one_line.js":
62021
62164
  /*!******************************************************************************************!*\
62022
62165
  !*** ./node_modules/@abaplint/core/build/src/rules/keep_single_parameter_on_one_line.js ***!
@@ -69075,6 +69218,24 @@ class SlowParameterPassing {
69075
69218
  shortDescription: `Detects slow pass by value passing for methods where parameter is not changed`,
69076
69219
  extendedInformation: `Method parameters defined in interfaces is not checked`,
69077
69220
  tags: [_irule_1.RuleTag.Performance],
69221
+ badExample: `CLASS lcl DEFINITION.
69222
+ PUBLIC SECTION.
69223
+ METHODS bar IMPORTING VALUE(sdf) TYPE string.
69224
+ ENDCLASS.
69225
+ CLASS lcl IMPLEMENTATION.
69226
+ METHOD bar.
69227
+ WRITE sdf.
69228
+ ENDMETHOD.
69229
+ ENDCLASS.`,
69230
+ goodExample: `CLASS lcl DEFINITION.
69231
+ PUBLIC SECTION.
69232
+ METHODS bar IMPORTING sdf TYPE string.
69233
+ ENDCLASS.
69234
+ CLASS lcl IMPLEMENTATION.
69235
+ METHOD bar.
69236
+ WRITE sdf.
69237
+ ENDMETHOD.
69238
+ ENDCLASS.`,
69078
69239
  };
69079
69240
  }
69080
69241
  getConfig() {
@@ -69779,6 +69940,8 @@ Also see separate rule sql_escape_host_variables
69779
69940
 
69780
69941
  Activates from v750 and up`,
69781
69942
  tags: [_irule_1.RuleTag.Upport, _irule_1.RuleTag.Quickfix],
69943
+ badExample: `SELECT * FROM ztabl INTO TABLE @rt_content WHERE type = @iv_type ORDER BY PRIMARY KEY.`,
69944
+ goodExample: `SELECT * FROM ztabl WHERE type = @iv_type ORDER BY PRIMARY KEY INTO TABLE @rt_content.`,
69782
69945
  };
69783
69946
  }
69784
69947
  getConfig() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.105.26",
3
+ "version": "2.106.1",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -38,12 +38,12 @@
38
38
  },
39
39
  "homepage": "https://abaplint.org",
40
40
  "devDependencies": {
41
- "@abaplint/core": "^2.105.26",
41
+ "@abaplint/core": "^2.106.1",
42
42
  "@types/chai": "^4.3.12",
43
43
  "@types/glob": "^8.1.0",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.6",
46
- "@types/node": "^20.11.22",
46
+ "@types/node": "^20.11.25",
47
47
  "@types/progress": "^2.0.7",
48
48
  "chai": "^4.4.1",
49
49
  "chalk": "^5.3.0",
@@ -54,7 +54,7 @@
54
54
  "minimist": "^1.2.8",
55
55
  "mocha": "^10.3.0",
56
56
  "progress": "^2.0.3",
57
- "typescript": "^5.3.3",
57
+ "typescript": "^5.4.2",
58
58
  "webpack": "^5.90.3",
59
59
  "webpack-cli": "^5.1.4",
60
60
  "xml-js": "^1.6.11"