@abaplint/cli 2.110.8 → 2.111.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 +110 -11
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -21432,6 +21432,23 @@ class CurrentScope {
21432
21432
  }
21433
21433
  this.current.getData().vars[upper] = identifier;
21434
21434
  }
21435
+ addNamedIdentifierToParent(name, identifier) {
21436
+ if (this.current === undefined) {
21437
+ return;
21438
+ }
21439
+ const parent = this.current.getParent();
21440
+ if (parent === undefined) {
21441
+ return;
21442
+ }
21443
+ const upper = name.toUpperCase();
21444
+ if (parent.getData().vars[upper] !== undefined) {
21445
+ throw new Error(`Variable name "${name}" already defined`);
21446
+ }
21447
+ else if (this.isOO() && parent.getData().types[upper] !== undefined) {
21448
+ throw new Error(`"${name}" already defined`);
21449
+ }
21450
+ parent.getData().vars[upper] = identifier;
21451
+ }
21435
21452
  addIdentifier(identifier) {
21436
21453
  if (identifier === undefined) {
21437
21454
  return;
@@ -23047,17 +23064,18 @@ class BasicTypes {
23047
23064
  }
23048
23065
  }
23049
23066
  else { // field name
23050
- let sub = undefined;
23051
23067
  if (type instanceof Types.TableType) {
23052
23068
  type = type.getRowType();
23053
23069
  }
23054
23070
  if (type instanceof Types.StructureType) {
23055
- sub = type.getComponentByName(child.getFirstToken().getStr());
23071
+ type = type.getComponentByName(child.getFirstToken().getStr());
23072
+ if (type === undefined) {
23073
+ return new Types.UnknownType("Type error, field not part of structure " + fullName);
23074
+ }
23056
23075
  }
23057
- if (sub === undefined) {
23076
+ else if (!(type instanceof Types.VoidType)) {
23058
23077
  return new Types.UnknownType("Type error, field not part of structure " + fullName);
23059
23078
  }
23060
- type = sub;
23061
23079
  }
23062
23080
  }
23063
23081
  if (type instanceof Types.VoidType) {
@@ -26560,10 +26578,11 @@ const sql_source_1 = __webpack_require__(/*! ./sql_source */ "./node_modules/@ab
26560
26578
  const sql_compare_1 = __webpack_require__(/*! ./sql_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_compare.js");
26561
26579
  const sql_order_by_1 = __webpack_require__(/*! ./sql_order_by */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_order_by.js");
26562
26580
  const dynamic_1 = __webpack_require__(/*! ./dynamic */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/dynamic.js");
26581
+ const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
26563
26582
  const isSimple = /^\w+$/;
26564
26583
  class Select {
26565
26584
  runSyntax(node, scope, filename, skipImplicitInto = false) {
26566
- var _a, _b;
26585
+ var _a;
26567
26586
  const token = node.getFirstToken();
26568
26587
  const from = node.findDirectExpression(Expressions.SQLFrom);
26569
26588
  const dbSources = from ? new sql_from_1.SQLFrom().runSyntax(from, scope, filename) : [];
@@ -26593,9 +26612,15 @@ class Select {
26593
26612
  const fields = (_a = node.findFirstExpression(Expressions.SQLAggregation)) === null || _a === void 0 ? void 0 : _a.concatTokens();
26594
26613
  const c = new RegExp(/^count\(\s*\*\s*\)$/, "i");
26595
26614
  if (fields === undefined || c.test(fields) === false) {
26596
- const name = (_b = from === null || from === void 0 ? void 0 : from.findDirectExpression(Expressions.SQLFromSource)) === null || _b === void 0 ? void 0 : _b.concatTokens();
26597
- if (name && scope.findVariable(name) === undefined) {
26598
- throw new Error(`Target variable ${name} not found in scope`);
26615
+ const nameToken = from === null || from === void 0 ? void 0 : from.findDirectExpression(Expressions.SQLFromSource);
26616
+ if (nameToken) {
26617
+ const found = scope.findVariable(nameToken.concatTokens());
26618
+ if (found) {
26619
+ scope.addReference(nameToken.getFirstToken(), found, _reference_1.ReferenceType.DataWriteReference, filename);
26620
+ }
26621
+ else {
26622
+ throw new Error(`Target variable ${nameToken.concatTokens()} not found in scope`);
26623
+ }
26599
26624
  }
26600
26625
  }
26601
26626
  }
@@ -32755,6 +32780,7 @@ exports.Tables = void 0;
32755
32780
  const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
32756
32781
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
32757
32782
  const unknown_type_1 = __webpack_require__(/*! ../../types/basic/unknown_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/unknown_type.js");
32783
+ const _scope_type_1 = __webpack_require__(/*! ../_scope_type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js");
32758
32784
  class Tables {
32759
32785
  runSyntax(node, scope, filename) {
32760
32786
  var _a, _b;
@@ -32770,7 +32796,13 @@ class Tables {
32770
32796
  const found = (_b = scope.getDDIC()) === null || _b === void 0 ? void 0 : _b.lookupTableOrView(name);
32771
32797
  if (found) {
32772
32798
  scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found.object, filename: filename, token: nameToken });
32773
- scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(nameToken, filename, found.type));
32799
+ if (scope.getType() === _scope_type_1.ScopeType.Form || scope.getType() === _scope_type_1.ScopeType.FunctionModule) {
32800
+ // hoist TABLES definitions to global scope
32801
+ scope.addNamedIdentifierToParent(nameToken.getStr(), new _typed_identifier_1.TypedIdentifier(nameToken, filename, found.type));
32802
+ }
32803
+ else {
32804
+ scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(nameToken, filename, found.type));
32805
+ }
32774
32806
  return;
32775
32807
  }
32776
32808
  // this should never happen,
@@ -51788,7 +51820,7 @@ class Registry {
51788
51820
  }
51789
51821
  static abaplintVersion() {
51790
51822
  // magic, see build script "version.sh"
51791
- return "2.110.8";
51823
+ return "2.111.0";
51792
51824
  }
51793
51825
  getDDICReferences() {
51794
51826
  return this.ddicReferences;
@@ -62658,6 +62690,7 @@ __exportStar(__webpack_require__(/*! ./superclass_final */ "./node_modules/@abap
62658
62690
  __exportStar(__webpack_require__(/*! ./superfluous_value */ "./node_modules/@abaplint/core/build/src/rules/superfluous_value.js"), exports);
62659
62691
  __exportStar(__webpack_require__(/*! ./sy_modification */ "./node_modules/@abaplint/core/build/src/rules/sy_modification.js"), exports);
62660
62692
  __exportStar(__webpack_require__(/*! ./tabl_enhancement_category */ "./node_modules/@abaplint/core/build/src/rules/tabl_enhancement_category.js"), exports);
62693
+ __exportStar(__webpack_require__(/*! ./tables_declared_locally */ "./node_modules/@abaplint/core/build/src/rules/tables_declared_locally.js"), exports);
62661
62694
  __exportStar(__webpack_require__(/*! ./try_without_catch */ "./node_modules/@abaplint/core/build/src/rules/try_without_catch.js"), exports);
62662
62695
  __exportStar(__webpack_require__(/*! ./type_form_parameters */ "./node_modules/@abaplint/core/build/src/rules/type_form_parameters.js"), exports);
62663
62696
  __exportStar(__webpack_require__(/*! ./types_naming */ "./node_modules/@abaplint/core/build/src/rules/types_naming.js"), exports);
@@ -64041,7 +64074,7 @@ class MacroNaming extends _abap_rule_1.ABAPRule {
64041
64074
  key: "macro_naming",
64042
64075
  title: "Macro naming conventions",
64043
64076
  shortDescription: `Allows you to enforce a pattern for macro definitions`,
64044
- extendedInformation: `Use rule "avoid_use" to avoid macros alotogether.`,
64077
+ extendedInformation: `Use rule "avoid_use" to avoid macros altogether.`,
64045
64078
  tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
64046
64079
  badExample: `DEFINE something.
64047
64080
  END-OF-DEFINITION.`,
@@ -71195,6 +71228,72 @@ exports.TABLEnhancementCategory = TABLEnhancementCategory;
71195
71228
 
71196
71229
  /***/ }),
71197
71230
 
71231
+ /***/ "./node_modules/@abaplint/core/build/src/rules/tables_declared_locally.js":
71232
+ /*!********************************************************************************!*\
71233
+ !*** ./node_modules/@abaplint/core/build/src/rules/tables_declared_locally.js ***!
71234
+ \********************************************************************************/
71235
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
71236
+
71237
+ "use strict";
71238
+
71239
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
71240
+ exports.TablesDeclaredLocally = exports.TablesDeclaredLocallyConf = void 0;
71241
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
71242
+ const Statements = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
71243
+ const Structures = __webpack_require__(/*! ../abap/3_structures/structures */ "./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js");
71244
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
71245
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
71246
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
71247
+ class TablesDeclaredLocallyConf extends _basic_rule_config_1.BasicRuleConfig {
71248
+ }
71249
+ exports.TablesDeclaredLocallyConf = TablesDeclaredLocallyConf;
71250
+ class TablesDeclaredLocally extends _abap_rule_1.ABAPRule {
71251
+ constructor() {
71252
+ super(...arguments);
71253
+ this.conf = new TablesDeclaredLocallyConf();
71254
+ }
71255
+ getMetadata() {
71256
+ return {
71257
+ key: "tables_declared_locally",
71258
+ title: "Check for locally declared TABLES",
71259
+ shortDescription: `TABLES are always global, so declare them globally`,
71260
+ extendedInformation: `https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abaptables.htm`,
71261
+ tags: [_irule_1.RuleTag.SingleFile],
71262
+ badExample: `FORM foo.
71263
+ TABLES t100.
71264
+ ENDFORM.`,
71265
+ goodExample: `TABLES t000.`,
71266
+ };
71267
+ }
71268
+ getConfig() {
71269
+ return this.conf;
71270
+ }
71271
+ setConfig(conf) {
71272
+ this.conf = conf;
71273
+ }
71274
+ runParsed(file) {
71275
+ const issues = [];
71276
+ const structure = file.getStructure();
71277
+ if (structure === undefined) {
71278
+ return issues;
71279
+ }
71280
+ const procedures = structure.findAllStructuresMulti([Structures.Form, Structures.FunctionModule]);
71281
+ for (const p of procedures) {
71282
+ const tablesStatement = p.findFirstStatement(Statements.Tables);
71283
+ if (tablesStatement) {
71284
+ const message = "Declare TABLES globaly";
71285
+ const issue = issue_1.Issue.atStatement(file, tablesStatement, message, this.getMetadata().key, this.conf.severity);
71286
+ issues.push(issue);
71287
+ }
71288
+ }
71289
+ return issues;
71290
+ }
71291
+ }
71292
+ exports.TablesDeclaredLocally = TablesDeclaredLocally;
71293
+ //# sourceMappingURL=tables_declared_locally.js.map
71294
+
71295
+ /***/ }),
71296
+
71198
71297
  /***/ "./node_modules/@abaplint/core/build/src/rules/try_without_catch.js":
71199
71298
  /*!**************************************************************************!*\
71200
71299
  !*** ./node_modules/@abaplint/core/build/src/rules/try_without_catch.js ***!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.110.8",
3
+ "version": "2.111.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.110.8",
41
+ "@abaplint/core": "^2.111.0",
42
42
  "@types/chai": "^4.3.16",
43
43
  "@types/glob": "^8.1.0",
44
44
  "@types/minimist": "^1.2.5",