@abaplint/cli 2.109.2 → 2.110.0

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 +115 -10
  2. package/package.json +3 -3
package/build/cli.js CHANGED
@@ -41676,6 +41676,7 @@ const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "./n
41676
41676
  const _builtin_1 = __webpack_require__(/*! ../abap/5_syntax/_builtin */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js");
41677
41677
  const _scope_type_1 = __webpack_require__(/*! ../abap/5_syntax/_scope_type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js");
41678
41678
  const types_1 = __webpack_require__(/*! ../abap/types */ "./node_modules/@abaplint/core/build/src/abap/types/index.js");
41679
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/_statement.js");
41679
41680
  class LSPLookup {
41680
41681
  static lookup(cursor, reg, obj) {
41681
41682
  var _a, _b;
@@ -41792,6 +41793,18 @@ class LSPLookup {
41792
41793
  scope: bottomScope,
41793
41794
  };
41794
41795
  }
41796
+ if (cursor.snode.get() instanceof _statement_1.MacroCall) {
41797
+ const macroDefinition = reg.getMacroReferences().findDefinitionByUsage(cursor.identifier.getFilename(), cursor.snode.getFirstToken());
41798
+ if (macroDefinition) {
41799
+ return {
41800
+ hover: "Macro Call",
41801
+ definition: {
41802
+ uri: macroDefinition === null || macroDefinition === void 0 ? void 0 : macroDefinition.filename,
41803
+ range: _lsp_utils_1.LSPUtils.tokenToRange(macroDefinition.token),
41804
+ },
41805
+ };
41806
+ }
41807
+ }
41795
41808
  if (hoverValue !== "") {
41796
41809
  return { hover: hoverValue, scope: bottomScope };
41797
41810
  }
@@ -43263,6 +43276,7 @@ class References {
43263
43276
  const locs = this.search(lookup.definitionId, lookup.scope);
43264
43277
  return locs.map(_lsp_utils_1.LSPUtils.identiferToLocation);
43265
43278
  }
43279
+ ////////////////////////////////////////////
43266
43280
  // todo, cleanup this mehtod, some of the method parameters are not used anymore?
43267
43281
  search(identifier, node, exitAfterFound = false, removeDuplicates = true) {
43268
43282
  let ret = [];
@@ -43290,7 +43304,6 @@ class References {
43290
43304
  return ret;
43291
43305
  }
43292
43306
  }
43293
- ////////////////////////////////////////////
43294
43307
  removeDuplicates(arr) {
43295
43308
  const values = {};
43296
43309
  return arr.filter(item => {
@@ -43740,7 +43753,7 @@ class MacroReferences {
43740
43753
  }
43741
43754
  this.definitions[ref.filename].push({ token: ref.token, start, end });
43742
43755
  }
43743
- getDefinitionPosition(filename, token) {
43756
+ getDefinitionRange(filename, token) {
43744
43757
  for (const d of this.definitions[filename] || []) {
43745
43758
  if (d.token.getStart().equals(token.getStart())) {
43746
43759
  return { start: d.start, end: d.end };
@@ -43775,6 +43788,22 @@ class MacroReferences {
43775
43788
  delete this.definitions[filename];
43776
43789
  delete this.references[filename];
43777
43790
  }
43791
+ findDefinitionByUsage(filename, token) {
43792
+ const tokenStr = token.getStr().toUpperCase();
43793
+ for (const ref of this.references[filename] || []) {
43794
+ if (ref.token.getStart().equals(token.getStart())) {
43795
+ for (const d of this.definitions[ref.filename] || []) {
43796
+ if (d.token.getStr().toUpperCase() === tokenStr) {
43797
+ return {
43798
+ filename: ref.filename,
43799
+ token: d.token,
43800
+ };
43801
+ }
43802
+ }
43803
+ }
43804
+ }
43805
+ return undefined;
43806
+ }
43778
43807
  }
43779
43808
  exports.MacroReferences = MacroReferences;
43780
43809
  //# sourceMappingURL=macro_references.js.map
@@ -51745,7 +51774,7 @@ class Registry {
51745
51774
  }
51746
51775
  static abaplintVersion() {
51747
51776
  // magic, see build script "version.sh"
51748
- return "2.109.2";
51777
+ return "2.110.0";
51749
51778
  }
51750
51779
  getDDICReferences() {
51751
51780
  return this.ddicReferences;
@@ -62487,7 +62516,6 @@ __exportStar(__webpack_require__(/*! ./cds_legacy_view */ "./node_modules/@abapl
62487
62516
  __exportStar(__webpack_require__(/*! ./cds_parser_error */ "./node_modules/@abaplint/core/build/src/rules/cds_parser_error.js"), exports);
62488
62517
  __exportStar(__webpack_require__(/*! ./chain_mainly_declarations */ "./node_modules/@abaplint/core/build/src/rules/chain_mainly_declarations.js"), exports);
62489
62518
  __exportStar(__webpack_require__(/*! ./change_if_to_case */ "./node_modules/@abaplint/core/build/src/rules/change_if_to_case.js"), exports);
62490
- __exportStar(__webpack_require__(/*! ./unused_macros */ "./node_modules/@abaplint/core/build/src/rules/unused_macros.js"), exports);
62491
62519
  __exportStar(__webpack_require__(/*! ./check_abstract */ "./node_modules/@abaplint/core/build/src/rules/check_abstract.js"), exports);
62492
62520
  __exportStar(__webpack_require__(/*! ./check_comments */ "./node_modules/@abaplint/core/build/src/rules/check_comments.js"), exports);
62493
62521
  __exportStar(__webpack_require__(/*! ./check_ddic */ "./node_modules/@abaplint/core/build/src/rules/check_ddic.js"), exports);
@@ -62549,6 +62577,7 @@ __exportStar(__webpack_require__(/*! ./line_only_punc */ "./node_modules/@abapli
62549
62577
  __exportStar(__webpack_require__(/*! ./local_class_naming */ "./node_modules/@abaplint/core/build/src/rules/local_class_naming.js"), exports);
62550
62578
  __exportStar(__webpack_require__(/*! ./local_testclass_consistency */ "./node_modules/@abaplint/core/build/src/rules/local_testclass_consistency.js"), exports);
62551
62579
  __exportStar(__webpack_require__(/*! ./local_variable_names */ "./node_modules/@abaplint/core/build/src/rules/local_variable_names.js"), exports);
62580
+ __exportStar(__webpack_require__(/*! ./macro_naming */ "./node_modules/@abaplint/core/build/src/rules/macro_naming.js"), exports);
62552
62581
  __exportStar(__webpack_require__(/*! ./main_file_contents */ "./node_modules/@abaplint/core/build/src/rules/main_file_contents.js"), exports);
62553
62582
  __exportStar(__webpack_require__(/*! ./many_parentheses */ "./node_modules/@abaplint/core/build/src/rules/many_parentheses.js"), exports);
62554
62583
  __exportStar(__webpack_require__(/*! ./max_one_method_parameter_per_line */ "./node_modules/@abaplint/core/build/src/rules/max_one_method_parameter_per_line.js"), exports);
@@ -62626,6 +62655,7 @@ __exportStar(__webpack_require__(/*! ./unnecessary_return */ "./node_modules/@ab
62626
62655
  __exportStar(__webpack_require__(/*! ./unreachable_code */ "./node_modules/@abaplint/core/build/src/rules/unreachable_code.js"), exports);
62627
62656
  __exportStar(__webpack_require__(/*! ./unsecure_fae */ "./node_modules/@abaplint/core/build/src/rules/unsecure_fae.js"), exports);
62628
62657
  __exportStar(__webpack_require__(/*! ./unused_ddic */ "./node_modules/@abaplint/core/build/src/rules/unused_ddic.js"), exports);
62658
+ __exportStar(__webpack_require__(/*! ./unused_macros */ "./node_modules/@abaplint/core/build/src/rules/unused_macros.js"), exports);
62629
62659
  __exportStar(__webpack_require__(/*! ./unused_methods */ "./node_modules/@abaplint/core/build/src/rules/unused_methods.js"), exports);
62630
62660
  __exportStar(__webpack_require__(/*! ./unused_types */ "./node_modules/@abaplint/core/build/src/rules/unused_types.js"), exports);
62631
62661
  __exportStar(__webpack_require__(/*! ./unused_variables */ "./node_modules/@abaplint/core/build/src/rules/unused_variables.js"), exports);
@@ -63962,6 +63992,83 @@ exports.LocalVariableNames = LocalVariableNames;
63962
63992
 
63963
63993
  /***/ }),
63964
63994
 
63995
+ /***/ "./node_modules/@abaplint/core/build/src/rules/macro_naming.js":
63996
+ /*!*********************************************************************!*\
63997
+ !*** ./node_modules/@abaplint/core/build/src/rules/macro_naming.js ***!
63998
+ \*********************************************************************/
63999
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
64000
+
64001
+ "use strict";
64002
+
64003
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
64004
+ exports.MacroNaming = exports.MacroNamingConf = void 0;
64005
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
64006
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
64007
+ const Statements = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
64008
+ const Expressions = __webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
64009
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
64010
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
64011
+ const objects_1 = __webpack_require__(/*! ../objects */ "./node_modules/@abaplint/core/build/src/objects/index.js");
64012
+ class MacroNamingConf extends _basic_rule_config_1.BasicRuleConfig {
64013
+ constructor() {
64014
+ super(...arguments);
64015
+ /** The pattern for macros, case insensitive */
64016
+ this.pattern = "^_.+$";
64017
+ }
64018
+ }
64019
+ exports.MacroNamingConf = MacroNamingConf;
64020
+ class MacroNaming extends _abap_rule_1.ABAPRule {
64021
+ constructor() {
64022
+ super(...arguments);
64023
+ this.conf = new MacroNamingConf();
64024
+ }
64025
+ getMetadata() {
64026
+ return {
64027
+ key: "macro_naming",
64028
+ title: "Macro naming conventions",
64029
+ shortDescription: `Allows you to enforce a pattern for macro definitions`,
64030
+ extendedInformation: `Use rule "avoid_use" to avoid macros alotogether.`,
64031
+ tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
64032
+ };
64033
+ }
64034
+ getConfig() {
64035
+ return this.conf;
64036
+ }
64037
+ setConfig(conf) {
64038
+ this.conf = conf;
64039
+ }
64040
+ runParsed(file, obj) {
64041
+ const issues = [];
64042
+ const testRegex = new RegExp(this.conf.pattern, "i");
64043
+ if (obj instanceof objects_1.TypePool) {
64044
+ return [];
64045
+ }
64046
+ for (const stat of file.getStatements()) {
64047
+ if (!(stat.get() instanceof Statements.Define)) {
64048
+ continue;
64049
+ }
64050
+ const expr = stat.findDirectExpression(Expressions.MacroName);
64051
+ if (expr === undefined) {
64052
+ continue;
64053
+ }
64054
+ const token = expr.getFirstToken();
64055
+ if (testRegex.exec(token.getStr())) {
64056
+ continue;
64057
+ }
64058
+ else {
64059
+ const message = "Bad macro name naming, expected \"" + this.conf.pattern + "\", got \"" + token.getStr() + "\"";
64060
+ const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity);
64061
+ issues.push(issue);
64062
+ }
64063
+ }
64064
+ return issues;
64065
+ }
64066
+ }
64067
+ exports.MacroNaming = MacroNaming;
64068
+ //# sourceMappingURL=macro_naming.js.map
64069
+
64070
+ /***/ }),
64071
+
63965
64072
  /***/ "./node_modules/@abaplint/core/build/src/rules/main_file_contents.js":
63966
64073
  /*!***************************************************************************!*\
63967
64074
  !*** ./node_modules/@abaplint/core/build/src/rules/main_file_contents.js ***!
@@ -69111,11 +69218,9 @@ class RFCErrorHandling extends _abap_rule_1.ABAPRule {
69111
69218
  tags: [_irule_1.RuleTag.SingleFile],
69112
69219
  shortDescription: `Checks that exceptions 'system_failure' and 'communication_failure' are handled in RFC calls`,
69113
69220
  extendedInformation: `https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenrfc_exception.htm`,
69114
- badExample: `
69115
- CALL FUNCTION 'ZRFC'
69221
+ badExample: `CALL FUNCTION 'ZRFC'
69116
69222
  DESTINATION lv_rfc.`,
69117
- goodExample: `
69118
- CALL FUNCTION 'ZRFC'
69223
+ goodExample: `CALL FUNCTION 'ZRFC'
69119
69224
  DESTINATION lv_rfc
69120
69225
  EXCEPTIONS
69121
69226
  system_failure = 1 MESSAGE msg
@@ -71222,7 +71327,7 @@ const objects_1 = __webpack_require__(/*! ../objects */ "./node_modules/@abaplin
71222
71327
  class TypesNamingConf extends _basic_rule_config_1.BasicRuleConfig {
71223
71328
  constructor() {
71224
71329
  super(...arguments);
71225
- /** The pattern for TYPES */
71330
+ /** The pattern for TYPES, case insensitive */
71226
71331
  this.pattern = "^TY_.+$";
71227
71332
  }
71228
71333
  }
@@ -72436,7 +72541,7 @@ foobar2.`,
72436
72541
  const usages = references.listUsagesbyMacro(file.getFilename(), macroToken);
72437
72542
  if (usages.length === 0 && ((_a = this.conf.skipNames) === null || _a === void 0 ? void 0 : _a.includes(macroToken.getStr().toUpperCase())) === false) {
72438
72543
  const message = "Unused macro definition: " + macroToken.getStr();
72439
- const pos = references.getDefinitionPosition(file.getFilename(), macroToken);
72544
+ const pos = references.getDefinitionRange(file.getFilename(), macroToken);
72440
72545
  const fix = edit_helper_1.EditHelper.deleteRange(file, pos.start, pos.end);
72441
72546
  result.push(issue_1.Issue.atToken(file, macroToken, message, this.getMetadata().key, this.conf.severity, fix));
72442
72547
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.109.2",
3
+ "version": "2.110.0",
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.109.2",
41
+ "@abaplint/core": "^2.110.0",
42
42
  "@types/chai": "^4.3.16",
43
43
  "@types/glob": "^8.1.0",
44
44
  "@types/minimist": "^1.2.5",
@@ -55,7 +55,7 @@
55
55
  "mocha": "^10.4.0",
56
56
  "progress": "^2.0.3",
57
57
  "typescript": "^5.4.5",
58
- "webpack": "^5.91.0",
58
+ "webpack": "^5.92.0",
59
59
  "webpack-cli": "^5.1.4",
60
60
  "xml-js": "^1.6.11"
61
61
  },