@abaplint/cli 2.110.7 → 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 +118 -14
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -4084,7 +4084,7 @@ exports.AttributeName = void 0;
4084
4084
  const combi_1 = __webpack_require__(/*! ../combi */ "./node_modules/@abaplint/core/build/src/abap/2_statements/combi.js");
4085
4085
  class AttributeName extends combi_1.Expression {
4086
4086
  getRunnable() {
4087
- return (0, combi_1.regex)(/^(\/\w+\/)?[\w\d_\*\~%]+$/);
4087
+ return (0, combi_1.regex)(/^(\/\w+\/)?(?!\*)[\w\d_\*\~%]+$/);
4088
4088
  }
4089
4089
  }
4090
4090
  exports.AttributeName = AttributeName;
@@ -7703,7 +7703,8 @@ class Source extends combi_1.Expression {
7703
7703
  getRunnable() {
7704
7704
  const comp = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.Dash), _1.ComponentChain);
7705
7705
  const attr = (0, combi_1.seq)(_1.Arrow, attribute_chain_1.AttributeChain);
7706
- const method = (0, combi_1.seq)(_1.MethodCallChain, (0, combi_1.optPrio)((0, combi_1.altPrio)(attr, comp)), (0, combi_1.optPrio)(dereference_1.Dereference));
7706
+ const deref = (0, combi_1.optPrio)((0, combi_1.ver)(version_1.Version.v756, dereference_1.Dereference));
7707
+ const method = (0, combi_1.seq)(_1.MethodCallChain, (0, combi_1.optPrio)((0, combi_1.altPrio)(attr, comp)), deref);
7707
7708
  const rparen = (0, combi_1.tok)(tokens_1.WParenRightW);
7708
7709
  const rparenNoSpace = (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenRightW), (0, combi_1.tok)(tokens_1.WParenRightW));
7709
7710
  // paren used for eg. "( 2 + 1 ) * 4"
@@ -7711,7 +7712,7 @@ class Source extends combi_1.Expression {
7711
7712
  const after = (0, combi_1.seq)((0, combi_1.altPrio)("&", "&&", _1.ArithOperator), Source);
7712
7713
  const bool = (0, combi_1.seq)((0, combi_1.altPrio)((0, combi_1.ver)(version_1.Version.v702, (0, combi_1.regex)(/^BOOLC$/i)), (0, combi_1.ver)(version_1.Version.v740sp08, (0, combi_1.regex)(/^XSDBOOL$/i))), (0, combi_1.tok)(tokens_1.ParenLeftW), _1.Cond, ")");
7713
7714
  const prefix = (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WPlus), "BIT-NOT");
7714
- const old = (0, combi_1.seq)((0, combi_1.optPrio)(prefix), (0, combi_1.altPrio)(_1.Constant, _1.StringTemplate, text_element_1.TextElement, bool, method, (0, combi_1.seq)(_1.FieldChain, (0, combi_1.optPrio)(dereference_1.Dereference)), paren), (0, combi_1.optPrio)(after));
7715
+ const old = (0, combi_1.seq)((0, combi_1.optPrio)(prefix), (0, combi_1.altPrio)(_1.Constant, _1.StringTemplate, text_element_1.TextElement, bool, method, (0, combi_1.seq)(_1.FieldChain, deref), paren), (0, combi_1.optPrio)(after));
7715
7716
  const corr = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("CORRESPONDING", _1.TypeNameOrInfer, (0, combi_1.tok)(tokens_1.ParenLeftW), _1.CorrespondingBody, rparen, (0, combi_1.optPrio)(after)));
7716
7717
  const conv = (0, combi_1.ver)(version_1.Version.v740sp02, (0, combi_1.seq)("CONV", _1.TypeNameOrInfer, (0, combi_1.tok)(tokens_1.ParenLeftW), _1.ConvBody, rparenNoSpace, (0, combi_1.optPrio)(after)));
7717
7718
  const swit = (0, combi_1.ver)(version_1.Version.v740sp02, (0, combi_1.seq)("SWITCH", _1.TypeNameOrInfer, (0, combi_1.tok)(tokens_1.ParenLeftW), _1.SwitchBody, rparenNoSpace, (0, combi_1.optPrio)(after)));
@@ -21431,6 +21432,23 @@ class CurrentScope {
21431
21432
  }
21432
21433
  this.current.getData().vars[upper] = identifier;
21433
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
+ }
21434
21452
  addIdentifier(identifier) {
21435
21453
  if (identifier === undefined) {
21436
21454
  return;
@@ -23046,17 +23064,18 @@ class BasicTypes {
23046
23064
  }
23047
23065
  }
23048
23066
  else { // field name
23049
- let sub = undefined;
23050
23067
  if (type instanceof Types.TableType) {
23051
23068
  type = type.getRowType();
23052
23069
  }
23053
23070
  if (type instanceof Types.StructureType) {
23054
- 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
+ }
23055
23075
  }
23056
- if (sub === undefined) {
23076
+ else if (!(type instanceof Types.VoidType)) {
23057
23077
  return new Types.UnknownType("Type error, field not part of structure " + fullName);
23058
23078
  }
23059
- type = sub;
23060
23079
  }
23061
23080
  }
23062
23081
  if (type instanceof Types.VoidType) {
@@ -26559,10 +26578,11 @@ const sql_source_1 = __webpack_require__(/*! ./sql_source */ "./node_modules/@ab
26559
26578
  const sql_compare_1 = __webpack_require__(/*! ./sql_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_compare.js");
26560
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");
26561
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");
26562
26582
  const isSimple = /^\w+$/;
26563
26583
  class Select {
26564
26584
  runSyntax(node, scope, filename, skipImplicitInto = false) {
26565
- var _a, _b;
26585
+ var _a;
26566
26586
  const token = node.getFirstToken();
26567
26587
  const from = node.findDirectExpression(Expressions.SQLFrom);
26568
26588
  const dbSources = from ? new sql_from_1.SQLFrom().runSyntax(from, scope, filename) : [];
@@ -26592,9 +26612,15 @@ class Select {
26592
26612
  const fields = (_a = node.findFirstExpression(Expressions.SQLAggregation)) === null || _a === void 0 ? void 0 : _a.concatTokens();
26593
26613
  const c = new RegExp(/^count\(\s*\*\s*\)$/, "i");
26594
26614
  if (fields === undefined || c.test(fields) === false) {
26595
- const name = (_b = from === null || from === void 0 ? void 0 : from.findDirectExpression(Expressions.SQLFromSource)) === null || _b === void 0 ? void 0 : _b.concatTokens();
26596
- if (name && scope.findVariable(name) === undefined) {
26597
- 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
+ }
26598
26624
  }
26599
26625
  }
26600
26626
  }
@@ -32754,6 +32780,7 @@ exports.Tables = void 0;
32754
32780
  const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
32755
32781
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
32756
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");
32757
32784
  class Tables {
32758
32785
  runSyntax(node, scope, filename) {
32759
32786
  var _a, _b;
@@ -32769,7 +32796,13 @@ class Tables {
32769
32796
  const found = (_b = scope.getDDIC()) === null || _b === void 0 ? void 0 : _b.lookupTableOrView(name);
32770
32797
  if (found) {
32771
32798
  scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found.object, filename: filename, token: nameToken });
32772
- 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
+ }
32773
32806
  return;
32774
32807
  }
32775
32808
  // this should never happen,
@@ -51787,7 +51820,7 @@ class Registry {
51787
51820
  }
51788
51821
  static abaplintVersion() {
51789
51822
  // magic, see build script "version.sh"
51790
- return "2.110.7";
51823
+ return "2.111.0";
51791
51824
  }
51792
51825
  getDDICReferences() {
51793
51826
  return this.ddicReferences;
@@ -62657,6 +62690,7 @@ __exportStar(__webpack_require__(/*! ./superclass_final */ "./node_modules/@abap
62657
62690
  __exportStar(__webpack_require__(/*! ./superfluous_value */ "./node_modules/@abaplint/core/build/src/rules/superfluous_value.js"), exports);
62658
62691
  __exportStar(__webpack_require__(/*! ./sy_modification */ "./node_modules/@abaplint/core/build/src/rules/sy_modification.js"), exports);
62659
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);
62660
62694
  __exportStar(__webpack_require__(/*! ./try_without_catch */ "./node_modules/@abaplint/core/build/src/rules/try_without_catch.js"), exports);
62661
62695
  __exportStar(__webpack_require__(/*! ./type_form_parameters */ "./node_modules/@abaplint/core/build/src/rules/type_form_parameters.js"), exports);
62662
62696
  __exportStar(__webpack_require__(/*! ./types_naming */ "./node_modules/@abaplint/core/build/src/rules/types_naming.js"), exports);
@@ -64040,8 +64074,12 @@ class MacroNaming extends _abap_rule_1.ABAPRule {
64040
64074
  key: "macro_naming",
64041
64075
  title: "Macro naming conventions",
64042
64076
  shortDescription: `Allows you to enforce a pattern for macro definitions`,
64043
- extendedInformation: `Use rule "avoid_use" to avoid macros alotogether.`,
64077
+ extendedInformation: `Use rule "avoid_use" to avoid macros altogether.`,
64044
64078
  tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
64079
+ badExample: `DEFINE something.
64080
+ END-OF-DEFINITION.`,
64081
+ goodExample: `DEFINE _something.
64082
+ END-OF-DEFINITION.`,
64045
64083
  };
64046
64084
  }
64047
64085
  getConfig() {
@@ -71190,6 +71228,72 @@ exports.TABLEnhancementCategory = TABLEnhancementCategory;
71190
71228
 
71191
71229
  /***/ }),
71192
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
+
71193
71297
  /***/ "./node_modules/@abaplint/core/build/src/rules/try_without_catch.js":
71194
71298
  /*!**************************************************************************!*\
71195
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.7",
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.7",
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",