@abaplint/cli 2.110.8 → 2.111.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 +134 -56
  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) {
@@ -24221,7 +24239,7 @@ class ComponentCompareSimple {
24221
24239
  }
24222
24240
  }
24223
24241
  else {
24224
- throw "ComponentCompareSimple, unexpected node";
24242
+ throw new Error("ComponentCompareSimple, unexpected node");
24225
24243
  }
24226
24244
  }
24227
24245
  }
@@ -24605,12 +24623,18 @@ exports.Default = void 0;
24605
24623
  const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
24606
24624
  const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_chain.js");
24607
24625
  const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
24626
+ const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/constant.js");
24608
24627
  class Default {
24609
24628
  runSyntax(node, scope, filename) {
24610
24629
  const chain = node.findDirectExpression(Expressions.FieldChain);
24611
24630
  if (chain) {
24612
- new field_chain_1.FieldChain().runSyntax(chain, scope, filename, _reference_1.ReferenceType.DataReadReference);
24631
+ return new field_chain_1.FieldChain().runSyntax(chain, scope, filename, _reference_1.ReferenceType.DataReadReference);
24632
+ }
24633
+ const constant = node.findDirectExpression(Expressions.Constant);
24634
+ if (constant) {
24635
+ return new constant_1.Constant().runSyntax(constant);
24613
24636
  }
24637
+ return undefined;
24614
24638
  }
24615
24639
  }
24616
24640
  exports.Default = Default;
@@ -24749,29 +24773,25 @@ const source_field_symbol_1 = __webpack_require__(/*! ./source_field_symbol */ "
24749
24773
  const source_field_1 = __webpack_require__(/*! ./source_field */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field.js");
24750
24774
  class FieldChain {
24751
24775
  runSyntax(node, scope, filename, refType) {
24752
- var _a, _b, _c, _d, _e;
24753
- const children = node.getChildren();
24754
- let context = undefined;
24755
- try {
24756
- context = this.findTop(children[0], scope, filename, refType);
24757
- }
24758
- catch (error) {
24776
+ var _a, _b, _c;
24777
+ if (((_a = node.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.SourceField
24778
+ && node.findDirectExpression(Expressions.ComponentName)) {
24779
+ // workaround for names with dashes, eg. "sy-repid"
24759
24780
  const concat = node.concatTokens();
24760
- if (concat.includes("-") && ((_a = node.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.SourceField) {
24761
- // workaround for names with dashes, eg. "sy-repid"
24762
- const offset = ((_b = node.findDirectExpression(Expressions.FieldOffset)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "";
24763
- const length = ((_c = node.findDirectExpression(Expressions.FieldLength)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "";
24764
- const found = scope.findVariable(concat.replace(offset, "").replace(length, ""));
24765
- if (found) {
24766
- if (refType) {
24767
- scope.addReference(node.getFirstToken(), found, refType, filename);
24768
- }
24769
- // this is not completely correct, but will work, dashes in names is a mess anyhow
24770
- return found.getType();
24781
+ const offset = ((_b = node.findDirectExpression(Expressions.FieldOffset)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "";
24782
+ const length = ((_c = node.findDirectExpression(Expressions.FieldLength)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "";
24783
+ const found = scope.findVariable(concat.replace(offset, "").replace(length, ""));
24784
+ if (found) {
24785
+ if (refType) {
24786
+ scope.addReference(node.getFirstToken(), found, refType, filename);
24771
24787
  }
24788
+ // this is not completely correct, but will work, dashes in names is a mess anyhow
24789
+ return found.getType();
24772
24790
  }
24773
- throw error;
24774
24791
  }
24792
+ let context = undefined;
24793
+ const children = node.getChildren();
24794
+ context = this.findTop(children[0], scope, filename, refType);
24775
24795
  for (let i = 1; i < children.length; i++) {
24776
24796
  const current = children[i];
24777
24797
  if (current === undefined) {
@@ -24822,30 +24842,7 @@ class FieldChain {
24822
24842
  if (context instanceof basic_1.TableType && context.isWithHeader()) {
24823
24843
  context = context.getRowType();
24824
24844
  }
24825
- try {
24826
- context = new component_name_1.ComponentName().runSyntax(context, current);
24827
- }
24828
- catch (error) {
24829
- const concat = node.concatTokens();
24830
- if (concat.includes("-")) {
24831
- // workaround for names with dashes, eg. "sy-repid"
24832
- const offset = ((_d = node.findDirectExpression(Expressions.FieldOffset)) === null || _d === void 0 ? void 0 : _d.concatTokens()) || "";
24833
- const length = ((_e = node.findDirectExpression(Expressions.FieldLength)) === null || _e === void 0 ? void 0 : _e.concatTokens()) || "";
24834
- const found = scope.findVariable(concat.replace(offset, "").replace(length, ""));
24835
- if (found) {
24836
- if (refType) {
24837
- scope.addReference(node.getFirstToken(), found, refType, filename);
24838
- }
24839
- context = found.getType();
24840
- }
24841
- else {
24842
- throw error;
24843
- }
24844
- }
24845
- else {
24846
- throw error;
24847
- }
24848
- }
24845
+ context = new component_name_1.ComponentName().runSyntax(context, current);
24849
24846
  }
24850
24847
  else if (current instanceof nodes_1.ExpressionNode
24851
24848
  && current.get() instanceof Expressions.TableExpression) {
@@ -26560,10 +26557,11 @@ const sql_source_1 = __webpack_require__(/*! ./sql_source */ "./node_modules/@ab
26560
26557
  const sql_compare_1 = __webpack_require__(/*! ./sql_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_compare.js");
26561
26558
  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
26559
  const dynamic_1 = __webpack_require__(/*! ./dynamic */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/dynamic.js");
26560
+ const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
26563
26561
  const isSimple = /^\w+$/;
26564
26562
  class Select {
26565
26563
  runSyntax(node, scope, filename, skipImplicitInto = false) {
26566
- var _a, _b;
26564
+ var _a;
26567
26565
  const token = node.getFirstToken();
26568
26566
  const from = node.findDirectExpression(Expressions.SQLFrom);
26569
26567
  const dbSources = from ? new sql_from_1.SQLFrom().runSyntax(from, scope, filename) : [];
@@ -26593,9 +26591,15 @@ class Select {
26593
26591
  const fields = (_a = node.findFirstExpression(Expressions.SQLAggregation)) === null || _a === void 0 ? void 0 : _a.concatTokens();
26594
26592
  const c = new RegExp(/^count\(\s*\*\s*\)$/, "i");
26595
26593
  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`);
26594
+ const nameToken = from === null || from === void 0 ? void 0 : from.findDirectExpression(Expressions.SQLFromSource);
26595
+ if (nameToken) {
26596
+ const found = scope.findVariable(nameToken.concatTokens());
26597
+ if (found) {
26598
+ scope.addReference(nameToken.getFirstToken(), found, _reference_1.ReferenceType.DataWriteReference, filename);
26599
+ }
26600
+ else {
26601
+ throw new Error(`Target variable ${nameToken.concatTokens()} not found in scope`);
26602
+ }
26599
26603
  }
26600
26604
  }
26601
26605
  }
@@ -32755,6 +32759,7 @@ exports.Tables = void 0;
32755
32759
  const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
32756
32760
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
32757
32761
  const unknown_type_1 = __webpack_require__(/*! ../../types/basic/unknown_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/unknown_type.js");
32762
+ const _scope_type_1 = __webpack_require__(/*! ../_scope_type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js");
32758
32763
  class Tables {
32759
32764
  runSyntax(node, scope, filename) {
32760
32765
  var _a, _b;
@@ -32770,7 +32775,13 @@ class Tables {
32770
32775
  const found = (_b = scope.getDDIC()) === null || _b === void 0 ? void 0 : _b.lookupTableOrView(name);
32771
32776
  if (found) {
32772
32777
  scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found.object, filename: filename, token: nameToken });
32773
- scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(nameToken, filename, found.type));
32778
+ if (scope.getType() === _scope_type_1.ScopeType.Form || scope.getType() === _scope_type_1.ScopeType.FunctionModule) {
32779
+ // hoist TABLES definitions to global scope
32780
+ scope.addNamedIdentifierToParent(nameToken.getStr(), new _typed_identifier_1.TypedIdentifier(nameToken, filename, found.type));
32781
+ }
32782
+ else {
32783
+ scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(nameToken, filename, found.type));
32784
+ }
32774
32785
  return;
32775
32786
  }
32776
32787
  // this should never happen,
@@ -51788,7 +51799,7 @@ class Registry {
51788
51799
  }
51789
51800
  static abaplintVersion() {
51790
51801
  // magic, see build script "version.sh"
51791
- return "2.110.8";
51802
+ return "2.111.1";
51792
51803
  }
51793
51804
  getDDICReferences() {
51794
51805
  return this.ddicReferences;
@@ -62658,6 +62669,7 @@ __exportStar(__webpack_require__(/*! ./superclass_final */ "./node_modules/@abap
62658
62669
  __exportStar(__webpack_require__(/*! ./superfluous_value */ "./node_modules/@abaplint/core/build/src/rules/superfluous_value.js"), exports);
62659
62670
  __exportStar(__webpack_require__(/*! ./sy_modification */ "./node_modules/@abaplint/core/build/src/rules/sy_modification.js"), exports);
62660
62671
  __exportStar(__webpack_require__(/*! ./tabl_enhancement_category */ "./node_modules/@abaplint/core/build/src/rules/tabl_enhancement_category.js"), exports);
62672
+ __exportStar(__webpack_require__(/*! ./tables_declared_locally */ "./node_modules/@abaplint/core/build/src/rules/tables_declared_locally.js"), exports);
62661
62673
  __exportStar(__webpack_require__(/*! ./try_without_catch */ "./node_modules/@abaplint/core/build/src/rules/try_without_catch.js"), exports);
62662
62674
  __exportStar(__webpack_require__(/*! ./type_form_parameters */ "./node_modules/@abaplint/core/build/src/rules/type_form_parameters.js"), exports);
62663
62675
  __exportStar(__webpack_require__(/*! ./types_naming */ "./node_modules/@abaplint/core/build/src/rules/types_naming.js"), exports);
@@ -64041,7 +64053,7 @@ class MacroNaming extends _abap_rule_1.ABAPRule {
64041
64053
  key: "macro_naming",
64042
64054
  title: "Macro naming conventions",
64043
64055
  shortDescription: `Allows you to enforce a pattern for macro definitions`,
64044
- extendedInformation: `Use rule "avoid_use" to avoid macros alotogether.`,
64056
+ extendedInformation: `Use rule "avoid_use" to avoid macros altogether.`,
64045
64057
  tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
64046
64058
  badExample: `DEFINE something.
64047
64059
  END-OF-DEFINITION.`,
@@ -71195,6 +71207,72 @@ exports.TABLEnhancementCategory = TABLEnhancementCategory;
71195
71207
 
71196
71208
  /***/ }),
71197
71209
 
71210
+ /***/ "./node_modules/@abaplint/core/build/src/rules/tables_declared_locally.js":
71211
+ /*!********************************************************************************!*\
71212
+ !*** ./node_modules/@abaplint/core/build/src/rules/tables_declared_locally.js ***!
71213
+ \********************************************************************************/
71214
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
71215
+
71216
+ "use strict";
71217
+
71218
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
71219
+ exports.TablesDeclaredLocally = exports.TablesDeclaredLocallyConf = void 0;
71220
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
71221
+ const Statements = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
71222
+ const Structures = __webpack_require__(/*! ../abap/3_structures/structures */ "./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js");
71223
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
71224
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
71225
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
71226
+ class TablesDeclaredLocallyConf extends _basic_rule_config_1.BasicRuleConfig {
71227
+ }
71228
+ exports.TablesDeclaredLocallyConf = TablesDeclaredLocallyConf;
71229
+ class TablesDeclaredLocally extends _abap_rule_1.ABAPRule {
71230
+ constructor() {
71231
+ super(...arguments);
71232
+ this.conf = new TablesDeclaredLocallyConf();
71233
+ }
71234
+ getMetadata() {
71235
+ return {
71236
+ key: "tables_declared_locally",
71237
+ title: "Check for locally declared TABLES",
71238
+ shortDescription: `TABLES are always global, so declare them globally`,
71239
+ extendedInformation: `https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abaptables.htm`,
71240
+ tags: [_irule_1.RuleTag.SingleFile],
71241
+ badExample: `FORM foo.
71242
+ TABLES t100.
71243
+ ENDFORM.`,
71244
+ goodExample: `TABLES t000.`,
71245
+ };
71246
+ }
71247
+ getConfig() {
71248
+ return this.conf;
71249
+ }
71250
+ setConfig(conf) {
71251
+ this.conf = conf;
71252
+ }
71253
+ runParsed(file) {
71254
+ const issues = [];
71255
+ const structure = file.getStructure();
71256
+ if (structure === undefined) {
71257
+ return issues;
71258
+ }
71259
+ const procedures = structure.findAllStructuresMulti([Structures.Form, Structures.FunctionModule]);
71260
+ for (const p of procedures) {
71261
+ const tablesStatement = p.findFirstStatement(Statements.Tables);
71262
+ if (tablesStatement) {
71263
+ const message = "Declare TABLES globaly";
71264
+ const issue = issue_1.Issue.atStatement(file, tablesStatement, message, this.getMetadata().key, this.conf.severity);
71265
+ issues.push(issue);
71266
+ }
71267
+ }
71268
+ return issues;
71269
+ }
71270
+ }
71271
+ exports.TablesDeclaredLocally = TablesDeclaredLocally;
71272
+ //# sourceMappingURL=tables_declared_locally.js.map
71273
+
71274
+ /***/ }),
71275
+
71198
71276
  /***/ "./node_modules/@abaplint/core/build/src/rules/try_without_catch.js":
71199
71277
  /*!**************************************************************************!*\
71200
71278
  !*** ./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.1",
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.1",
42
42
  "@types/chai": "^4.3.16",
43
43
  "@types/glob": "^8.1.0",
44
44
  "@types/minimist": "^1.2.5",