@abaplint/cli 2.120.1 → 2.120.3

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 +80 -92
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -26953,6 +26953,7 @@ const basic_1 = __webpack_require__(/*! ../types/basic */ "../core/build/src/aba
26953
26953
  const ddic_1 = __webpack_require__(/*! ../../ddic */ "../core/build/src/ddic.js");
26954
26954
  const _object_oriented_1 = __webpack_require__(/*! ./_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
26955
26955
  const _reference_1 = __webpack_require__(/*! ./_reference */ "../core/build/src/abap/5_syntax/_reference.js");
26956
+ const tokens_1 = __webpack_require__(/*! ../1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
26956
26957
  class Procedural {
26957
26958
  constructor(reg, scope) {
26958
26959
  this.scope = scope;
@@ -27132,7 +27133,8 @@ class Procedural {
27132
27133
  continue;
27133
27134
  }
27134
27135
  else {
27135
- const type = new _typed_identifier_1.TypedIdentifier(nameToken, filename, found);
27136
+ const token = new tokens_1.Identifier(nameToken.getStart(), param.name);
27137
+ const type = new _typed_identifier_1.TypedIdentifier(token, filename, found, this.functionModuleParameterMeta(param));
27136
27138
  if (ignoreIfAlreadyExists === true) {
27137
27139
  const exists = this.scope.findVariable(param.name);
27138
27140
  if (exists === undefined) {
@@ -27146,6 +27148,25 @@ class Procedural {
27146
27148
  }
27147
27149
  }
27148
27150
  }
27151
+ functionModuleParameterMeta(param) {
27152
+ const ret = [];
27153
+ if (param.direction === types_1.FunctionModuleParameterDirection.importing) {
27154
+ ret.push("function_module_importing" /* IdentifierMeta.FunctionModuleImporting */);
27155
+ }
27156
+ else if (param.direction === types_1.FunctionModuleParameterDirection.exporting) {
27157
+ ret.push("function_module_exporting" /* IdentifierMeta.FunctionModuleExporting */);
27158
+ }
27159
+ else if (param.direction === types_1.FunctionModuleParameterDirection.changing) {
27160
+ ret.push("function_module_changing" /* IdentifierMeta.FunctionModuleChanging */);
27161
+ }
27162
+ else if (param.direction === types_1.FunctionModuleParameterDirection.tables) {
27163
+ ret.push("function_module_tables" /* IdentifierMeta.FunctionModuleTables */);
27164
+ }
27165
+ if (param.passByValue) {
27166
+ ret.push("pass_by_value" /* IdentifierMeta.PassByValue */);
27167
+ }
27168
+ return ret;
27169
+ }
27149
27170
  }
27150
27171
  exports.Procedural = Procedural;
27151
27172
  //# sourceMappingURL=_procedural.js.map
@@ -34057,6 +34078,7 @@ class Source {
34057
34078
  else {
34058
34079
  this.addIfInferred(node, input, foundType);
34059
34080
  }
34081
+ this.traverseRemainingChildren(children, input);
34060
34082
  return foundType ? foundType : bodyType;
34061
34083
  }
34062
34084
  case "SWITCH":
@@ -37127,8 +37149,10 @@ const inline_data_1 = __webpack_require__(/*! ../expressions/inline_data */ "../
37127
37149
  const dynamic_1 = __webpack_require__(/*! ../expressions/dynamic */ "../core/build/src/abap/5_syntax/expressions/dynamic.js");
37128
37150
  class CallTransformation {
37129
37151
  runSyntax(node, input) {
37152
+ const resultParameters = node.findExpressionAfterToken("RESULT");
37153
+ const resultSources = new Set((resultParameters === null || resultParameters === void 0 ? void 0 : resultParameters.findAllExpressions(Expressions.SimpleSource3)) || []);
37130
37154
  for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
37131
- source_1.Source.runSyntax(s, input);
37155
+ source_1.Source.runSyntax(s, input, undefined, resultSources.has(s));
37132
37156
  }
37133
37157
  for (const d of node.findAllExpressions(Expressions.Dynamic)) {
37134
37158
  dynamic_1.Dynamic.runSyntax(d, input);
@@ -51701,6 +51725,7 @@ class FunctionModuleDefinition {
51701
51725
  type: param.TYP || param.DBFIELD,
51702
51726
  optional: param.OPTIONAL === "X",
51703
51727
  defaultValue: param.DEFAULT,
51728
+ passByValue: param.REFERENCE !== "X",
51704
51729
  });
51705
51730
  }
51706
51731
  }
@@ -51715,6 +51740,7 @@ class FunctionModuleDefinition {
51715
51740
  type: param.TYP || param.DBFIELD,
51716
51741
  optional: param.OPTIONAL === "X",
51717
51742
  defaultValue: param.DEFAULT,
51743
+ passByValue: param.REFERENCE !== "X",
51718
51744
  });
51719
51745
  }
51720
51746
  }
@@ -51729,6 +51755,7 @@ class FunctionModuleDefinition {
51729
51755
  type: param.TYP || param.DBFIELD,
51730
51756
  optional: true,
51731
51757
  defaultValue: undefined,
51758
+ passByValue: param.REFERENCE !== "X",
51732
51759
  });
51733
51760
  }
51734
51761
  }
@@ -51744,6 +51771,7 @@ class FunctionModuleDefinition {
51744
51771
  type: param.DBSTRUCT || param.TYP,
51745
51772
  optional: param.OPTIONAL === "X",
51746
51773
  defaultValue: undefined,
51774
+ passByValue: false,
51747
51775
  });
51748
51776
  }
51749
51777
  }
@@ -52596,14 +52624,14 @@ class MethodParameters {
52596
52624
  }
52597
52625
  }
52598
52626
  add(target, source, input, meta, abstractMethod) {
52599
- var _a, _b;
52627
+ var _a;
52600
52628
  for (const opt of source.findAllExpressions(Expressions.MethodParamOptional)) {
52601
52629
  const p = opt.findDirectExpression(Expressions.MethodParam);
52602
52630
  if (p === undefined) {
52603
52631
  continue;
52604
52632
  }
52605
52633
  const extraMeta = [];
52606
- if (p.getFirstToken().getStr().toUpperCase() === "VALUE" && ((_a = p.getChildren()[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "(") {
52634
+ if (this.isPassByValue(p)) {
52607
52635
  extraMeta.push("pass_by_value" /* IdentifierMeta.PassByValue */);
52608
52636
  }
52609
52637
  else if (meta.includes("importing" /* IdentifierMeta.MethodImporting */)) {
@@ -52622,7 +52650,7 @@ class MethodParameters {
52622
52650
  else if (opt.findFirstExpression(Expressions.Default)) {
52623
52651
  const name = target[target.length - 1].getName().toUpperCase();
52624
52652
  this.optional.push(name);
52625
- const val = (_b = opt.findFirstExpression(Expressions.Default)) === null || _b === void 0 ? void 0 : _b.getLastChild();
52653
+ const val = (_a = opt.findFirstExpression(Expressions.Default)) === null || _a === void 0 ? void 0 : _a.getLastChild();
52626
52654
  if (val && val instanceof nodes_1.ExpressionNode) {
52627
52655
  this.defaults[name] = val;
52628
52656
  }
@@ -52633,9 +52661,15 @@ class MethodParameters {
52633
52661
  }
52634
52662
  const params = source.findAllExpressions(Expressions.MethodParam);
52635
52663
  for (const param of params) {
52636
- target.push(method_param_1.MethodParam.runSyntax(param, input, meta));
52664
+ const extraMeta = this.isPassByValue(param) ? ["pass_by_value" /* IdentifierMeta.PassByValue */] : [];
52665
+ target.push(method_param_1.MethodParam.runSyntax(param, input, [...meta, ...extraMeta]));
52637
52666
  }
52638
52667
  }
52668
+ isPassByValue(param) {
52669
+ var _a;
52670
+ return param.getFirstToken().getStr().toUpperCase() === "VALUE"
52671
+ && ((_a = param.getChildren()[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "(";
52672
+ }
52639
52673
  }
52640
52674
  exports.MethodParameters = MethodParameters;
52641
52675
  //# sourceMappingURL=method_parameters.js.map
@@ -59509,10 +59543,10 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
59509
59543
  return undefined;
59510
59544
  }
59511
59545
  getMainABAPFile() {
59512
- // todo, uris, https://github.com/abaplint/abaplint/issues/673
59513
59546
  const search = this.getName().replace(/\//g, "#").toLowerCase() + "." + this.getType().toLowerCase() + ".abap";
59547
+ const encodedSearch = search.replace(/#/g, "%23");
59514
59548
  for (const file of this.getABAPFiles()) {
59515
- if (file.getFilename().endsWith(search)) {
59549
+ if (file.getFilename().endsWith(search) || file.getFilename().endsWith(encodedSearch)) {
59516
59550
  return file;
59517
59551
  }
59518
59552
  }
@@ -68936,7 +68970,7 @@ class Registry {
68936
68970
  }
68937
68971
  static abaplintVersion() {
68938
68972
  // magic, see build script "version.js"
68939
- return "2.120.1";
68973
+ return "2.120.3";
68940
68974
  }
68941
68975
  getDDICReferences() {
68942
68976
  return this.ddicReferences;
@@ -73647,39 +73681,6 @@ exports.ClassicExceptionsOverlap = ClassicExceptionsOverlap;
73647
73681
 
73648
73682
  "use strict";
73649
73683
 
73650
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
73651
- if (k2 === undefined) k2 = k;
73652
- var desc = Object.getOwnPropertyDescriptor(m, k);
73653
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
73654
- desc = { enumerable: true, get: function() { return m[k]; } };
73655
- }
73656
- Object.defineProperty(o, k2, desc);
73657
- }) : (function(o, m, k, k2) {
73658
- if (k2 === undefined) k2 = k;
73659
- o[k2] = m[k];
73660
- }));
73661
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
73662
- Object.defineProperty(o, "default", { enumerable: true, value: v });
73663
- }) : function(o, v) {
73664
- o["default"] = v;
73665
- });
73666
- var __importStar = (this && this.__importStar) || (function () {
73667
- var ownKeys = function(o) {
73668
- ownKeys = Object.getOwnPropertyNames || function (o) {
73669
- var ar = [];
73670
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
73671
- return ar;
73672
- };
73673
- return ownKeys(o);
73674
- };
73675
- return function (mod) {
73676
- if (mod && mod.__esModule) return mod;
73677
- var result = {};
73678
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
73679
- __setModuleDefault(result, mod);
73680
- return result;
73681
- };
73682
- })();
73683
73684
  Object.defineProperty(exports, "__esModule", ({ value: true }));
73684
73685
  exports.ClearExportingParameters = exports.ClearExportingParametersConf = void 0;
73685
73686
  const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
@@ -73688,12 +73689,11 @@ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_i
73688
73689
  const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
73689
73690
  const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
73690
73691
  const _scope_type_1 = __webpack_require__(/*! ../abap/5_syntax/_scope_type */ "../core/build/src/abap/5_syntax/_scope_type.js");
73692
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
73691
73693
  const objects_1 = __webpack_require__(/*! ../objects */ "../core/build/src/objects/index.js");
73692
73694
  const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
73693
73695
  const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
73694
73696
  const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
73695
- const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
73696
- const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
73697
73697
  class ClearExportingParametersConf extends _basic_rule_config_1.BasicRuleConfig {
73698
73698
  constructor() {
73699
73699
  super(...arguments);
@@ -73726,7 +73726,7 @@ Reading and writing the parameter in the same statement (e.g. "ev_result = ev_re
73726
73726
  as the source is evaluated before the parameter is assigned.
73727
73727
  Objects containing parser or syntax errors are not reported.
73728
73728
 
73729
- Only class and interface method implementations are checked, function module parameters are currently not supported.`,
73729
+ Class and interface method implementations and function modules are checked.`,
73730
73730
  tags: [_irule_1.RuleTag.Styleguide],
73731
73731
  badExample: `CLASS lcl DEFINITION.
73732
73732
  PUBLIC SECTION.
@@ -73782,19 +73782,20 @@ ENDCLASS.`,
73782
73782
  return issues;
73783
73783
  }
73784
73784
  traverse(node, obj, issues) {
73785
- if (node.getIdentifier().stype === _scope_type_1.ScopeType.Method) {
73786
- this.checkMethod(node, obj, issues);
73785
+ if (node.getIdentifier().stype === _scope_type_1.ScopeType.Method
73786
+ || node.getIdentifier().stype === _scope_type_1.ScopeType.FunctionModule) {
73787
+ this.checkProcedure(node, obj, issues);
73787
73788
  }
73788
73789
  for (const child of node.getChildren()) {
73789
73790
  this.traverse(child, obj, issues);
73790
73791
  }
73791
73792
  }
73792
- checkMethod(node, obj, issues) {
73793
- const parameters = this.findExportingByReference(node, obj);
73793
+ checkProcedure(node, obj, issues) {
73794
+ const references = this.collectReferences(node);
73795
+ const parameters = this.findExportingByReference(node, references);
73794
73796
  if (parameters.length === 0) {
73795
73797
  return;
73796
73798
  }
73797
- const references = this.collectReferences(node);
73798
73799
  for (const parameter of parameters) {
73799
73800
  const issue = this.checkParameter(parameter, references, obj);
73800
73801
  if (issue !== undefined) {
@@ -73802,52 +73803,36 @@ ENDCLASS.`,
73802
73803
  }
73803
73804
  }
73804
73805
  }
73805
- findExportingByReference(node, obj) {
73806
+ findExportingByReference(node, references) {
73806
73807
  var _a;
73807
73808
  const ret = [];
73808
- const vars = node.getData().vars;
73809
- for (const name in vars) {
73810
- const parameter = vars[name];
73809
+ const candidates = new Set(Object.values(node.getData().vars));
73810
+ for (const reference of references) {
73811
+ if (reference.resolved instanceof _typed_identifier_1.TypedIdentifier) {
73812
+ candidates.add(reference.resolved);
73813
+ }
73814
+ }
73815
+ for (const parameter of candidates) {
73811
73816
  const meta = parameter.getMeta();
73812
- if (meta.includes("exporting" /* IdentifierMeta.MethodExporting */) === false
73817
+ const exporting = meta.includes("exporting" /* IdentifierMeta.MethodExporting */)
73818
+ || meta.includes("function_module_exporting" /* IdentifierMeta.FunctionModuleExporting */);
73819
+ if (exporting === false
73813
73820
  || meta.includes("pass_by_value" /* IdentifierMeta.PassByValue */) === true) {
73814
73821
  continue;
73815
73822
  }
73816
- else if ((_a = this.conf.skipNames) === null || _a === void 0 ? void 0 : _a.some(s => s.toUpperCase() === name.toUpperCase())) {
73823
+ else if ((_a = this.conf.skipNames) === null || _a === void 0 ? void 0 : _a.some(s => s.toUpperCase() === parameter.getName().toUpperCase())) {
73817
73824
  continue;
73818
73825
  }
73819
73826
  const type = parameter.getType();
73820
73827
  if (type instanceof basic_1.VoidType || type instanceof basic_1.UnknownType) {
73821
73828
  continue; // e.g. RAP magic parameters, or unresolved types
73822
73829
  }
73823
- else if (this.isPassByValue(parameter, obj) === true) {
73824
- continue; // VALUE(..) parameters are always initialized
73825
- }
73826
73830
  ret.push(parameter);
73827
73831
  }
73828
73832
  return ret;
73829
73833
  }
73830
- isPassByValue(parameter, obj) {
73831
- var _a;
73832
- // the PassByValue meta is not set for EXPORTING parameters, so determine it from the definition
73833
- const file = obj.getABAPFileByName(parameter.getFilename());
73834
- if (file === undefined) {
73835
- return false;
73836
- }
73837
- const statement = edit_helper_1.EditHelper.findStatement(parameter.getToken(), file);
73838
- if (statement === undefined) {
73839
- return false;
73840
- }
73841
- for (const param of statement.findAllExpressions(Expressions.MethodParam)) {
73842
- const nameToken = (_a = param.findFirstExpression(Expressions.MethodParamName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
73843
- if (nameToken !== undefined && nameToken.getStart().equals(parameter.getStart())) {
73844
- return param.getFirstToken().getStr().toUpperCase() === "VALUE";
73845
- }
73846
- }
73847
- return false;
73848
- }
73849
73834
  collectReferences(node) {
73850
- // methods do not nest, so all descendant scopes (FOR, LET, ...) belong to this method
73835
+ // procedures do not nest, so all descendant scopes (FOR, LET, ...) belong to this procedure
73851
73836
  const ret = [...node.getData().references];
73852
73837
  for (const child of node.getChildren()) {
73853
73838
  ret.push(...this.collectReferences(child));
@@ -73858,7 +73843,9 @@ ENDCLASS.`,
73858
73843
  let firstRead = undefined;
73859
73844
  let earliestWrite = undefined;
73860
73845
  for (const reference of references) {
73861
- if (reference.resolved === undefined || parameter.equals(reference.resolved) === false) {
73846
+ if (reference.resolved === undefined
73847
+ || parameter.equals(reference.resolved) === false
73848
+ || parameter.getName().toUpperCase() !== reference.resolved.getName().toUpperCase()) {
73862
73849
  continue;
73863
73850
  }
73864
73851
  const pos = reference.position.getStart();
@@ -73868,8 +73855,8 @@ ENDCLASS.`,
73868
73855
  }
73869
73856
  }
73870
73857
  else if (reference.referenceType === _reference_1.ReferenceType.DataWriteReference) {
73871
- if (earliestWrite === undefined || pos.isBefore(earliestWrite)) {
73872
- earliestWrite = pos;
73858
+ if (earliestWrite === undefined || pos.isBefore(earliestWrite.position.getStart())) {
73859
+ earliestWrite = reference;
73873
73860
  }
73874
73861
  }
73875
73862
  }
@@ -73877,7 +73864,7 @@ ENDCLASS.`,
73877
73864
  return undefined; // never read, no hazard
73878
73865
  }
73879
73866
  // the parameter is safe only if it is written in a statement strictly before the first read
73880
- const readStatement = this.statementStart(firstRead.position.getStart(), obj);
73867
+ const readStatement = this.statementStart(firstRead, obj);
73881
73868
  const writeStatement = earliestWrite === undefined ? undefined : this.statementStart(earliestWrite, obj);
73882
73869
  if (writeStatement !== undefined && readStatement !== undefined && writeStatement.isBefore(readStatement)) {
73883
73870
  return undefined;
@@ -73885,14 +73872,14 @@ ENDCLASS.`,
73885
73872
  const message = `EXPORTING parameter "${parameter.getName().toLowerCase()}" read before it is cleared or assigned`;
73886
73873
  return issue_1.Issue.atIdentifier(firstRead.position, message, this.getMetadata().key, this.conf.severity);
73887
73874
  }
73888
- statementStart(pos, obj) {
73889
- for (const file of obj.getABAPFiles()) {
73890
- for (const statement of file.getStatements()) {
73891
- const start = statement.getStart();
73892
- const end = statement.getEnd();
73893
- if (pos.equals(start) || (pos.isAfter(start) && pos.isBefore(end))) {
73894
- return start;
73895
- }
73875
+ statementStart(reference, obj) {
73876
+ const file = obj.getABAPFileByName(reference.position.getFilename());
73877
+ for (const statement of (file === null || file === void 0 ? void 0 : file.getStatements()) || []) {
73878
+ const pos = reference.position.getStart();
73879
+ const start = statement.getStart();
73880
+ const end = statement.getEnd();
73881
+ if (pos.equals(start) || (pos.isAfter(start) && pos.isBefore(end))) {
73882
+ return start;
73896
73883
  }
73897
73884
  }
73898
73885
  return undefined;
@@ -93060,7 +93047,8 @@ ENDCLASS.`,
93060
93047
  }
93061
93048
  for (const v in vars) {
93062
93049
  const id = vars[v];
93063
- if (id.getMeta().includes("pass_by_value" /* IdentifierMeta.PassByValue */) === false) {
93050
+ if (id.getMeta().includes("importing" /* IdentifierMeta.MethodImporting */) === false
93051
+ || id.getMeta().includes("pass_by_value" /* IdentifierMeta.PassByValue */) === false) {
93064
93052
  continue;
93065
93053
  }
93066
93054
  else if (this.reg.isFileDependency(id.getFilename()) === true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.1",
3
+ "version": "2.120.3",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://abaplint.org",
41
41
  "devDependencies": {
42
- "@abaplint/core": "^2.120.1",
42
+ "@abaplint/core": "^2.120.3",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",