@abaplint/core 2.115.14 → 2.115.15

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.
@@ -2870,12 +2870,14 @@ declare class FunctionModuleDefinition {
2870
2870
  private name;
2871
2871
  private description;
2872
2872
  private parameters;
2873
+ private globalParameters;
2873
2874
  private moduleType;
2874
2875
  constructor(data: any);
2875
2876
  getParameters(): readonly IFunctionModuleParameter[];
2876
2877
  getModuleType(): FunctionModuleType | undefined;
2877
2878
  getDescription(): string | undefined;
2878
2879
  getName(): string;
2880
+ isGlobalParameters(): boolean;
2879
2881
  private parse;
2880
2882
  }
2881
2883
 
@@ -72,8 +72,25 @@ class Procedural {
72
72
  }
73
73
  return undefined;
74
74
  }
75
+ findFunctionGroupScope(fg) {
76
+ var _a, _b, _c;
77
+ for (const module of fg.getModules()) {
78
+ if (module.isGlobalParameters() === false) {
79
+ continue;
80
+ }
81
+ // console.dir(fg.getSequencedFiles());
82
+ const fmFile = fg.getSequencedFiles().find((f) => { return f.getFilename().endsWith(".fugr." + module.getName().toLowerCase().replace(/\//g, "#") + ".abap"); });
83
+ if (fmFile === undefined) {
84
+ continue;
85
+ }
86
+ const nameToken = (_c = (_b = (_a = fmFile.getStructure()) === null || _a === void 0 ? void 0 : _a.findFirstStatement(Statements.FunctionModule)) === null || _b === void 0 ? void 0 : _b.findFirstExpression(Expressions.Field)) === null || _c === void 0 ? void 0 : _c.getFirstToken();
87
+ if (nameToken === undefined) {
88
+ continue;
89
+ }
90
+ this.addFunctionScope(module, nameToken, fmFile.getFilename(), true);
91
+ }
92
+ }
75
93
  findFunctionScope(obj, node, filename) {
76
- var _a, _b, _c, _d, _e;
77
94
  if (!(obj instanceof objects_1.FunctionGroup)) {
78
95
  throw new Error("findFunctionScope, expected function group input");
79
96
  }
@@ -84,6 +101,13 @@ class Procedural {
84
101
  if (definition === undefined) {
85
102
  throw new Error("Function module definition \"" + name + "\" not found");
86
103
  }
104
+ if (definition.isGlobalParameters() === true) {
105
+ return; // already added at global level
106
+ }
107
+ this.addFunctionScope(definition, nameToken, filename);
108
+ }
109
+ addFunctionScope(definition, nameToken, filename, ignoreIfAlreadyExists = false) {
110
+ var _a, _b, _c, _d, _e;
87
111
  const ddic = new ddic_1.DDIC(this.reg);
88
112
  const allNames = new Set();
89
113
  for (const param of definition.getParameters()) {
@@ -169,7 +193,15 @@ class Procedural {
169
193
  }
170
194
  else {
171
195
  const type = new _typed_identifier_1.TypedIdentifier(nameToken, filename, found);
172
- this.scope.addNamedIdentifier(param.name, type);
196
+ if (ignoreIfAlreadyExists === true) {
197
+ const exists = this.scope.findVariable(param.name);
198
+ if (exists === undefined) {
199
+ this.scope.addNamedIdentifier(param.name, type);
200
+ }
201
+ }
202
+ else {
203
+ this.scope.addNamedIdentifier(param.name, type);
204
+ }
173
205
  allNames.add(param.name.toUpperCase());
174
206
  }
175
207
  }
@@ -338,6 +338,9 @@ class SyntaxLogic {
338
338
  stype = _scope_type_1.ScopeType.FunctionGroup;
339
339
  }
340
340
  this.scope.push(stype, this.object.getName(), new position_1.Position(1, 1), main.getFilename());
341
+ if (this.object instanceof objects_1.FunctionGroup) {
342
+ this.helpers.proc.findFunctionGroupScope(this.object);
343
+ }
341
344
  }
342
345
  }
343
346
  else if (this.object instanceof objects_1.TypePool) {
@@ -31,6 +31,9 @@ class FunctionModuleDefinition {
31
31
  getName() {
32
32
  return this.name;
33
33
  }
34
+ isGlobalParameters() {
35
+ return this.globalParameters;
36
+ }
34
37
  ///////////////
35
38
  parse(data) {
36
39
  if (data.FUNCNAME === undefined) {
@@ -39,6 +42,7 @@ class FunctionModuleDefinition {
39
42
  this.name = data.FUNCNAME;
40
43
  this.description = data.SHORT_TEXT;
41
44
  this.parameters = [];
45
+ this.globalParameters = data.GLOBAL_FLAG === "X";
42
46
  this.moduleType = FunctionModuleType.regular;
43
47
  if (data.REMOTE_CALL === "R") {
44
48
  this.moduleType = FunctionModuleType.remote;
@@ -74,7 +74,7 @@ class Registry {
74
74
  }
75
75
  static abaplintVersion() {
76
76
  // magic, see build script "version.sh"
77
- return "2.115.14";
77
+ return "2.115.15";
78
78
  }
79
79
  getDDICReferences() {
80
80
  return this.ddicReferences;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FMGlobalParametersObsolete = exports.FMGlobalParametersObsoleteConf = void 0;
4
+ const issue_1 = require("../issue");
5
+ const Objects = require("../objects");
6
+ const _basic_rule_config_1 = require("./_basic_rule_config");
7
+ const position_1 = require("../position");
8
+ class FMGlobalParametersObsoleteConf extends _basic_rule_config_1.BasicRuleConfig {
9
+ }
10
+ exports.FMGlobalParametersObsoleteConf = FMGlobalParametersObsoleteConf;
11
+ class FMGlobalParametersObsolete {
12
+ constructor() {
13
+ this.conf = new FMGlobalParametersObsoleteConf();
14
+ }
15
+ getMetadata() {
16
+ return {
17
+ key: "fm_global_parameters_obsolete",
18
+ title: "FM Global Parameters Obsolete",
19
+ shortDescription: `Check for function modules with global parameteers`,
20
+ extendedInformation: `https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenglobal_parameters_obsolete.htm`,
21
+ tags: [],
22
+ };
23
+ }
24
+ initialize(_reg) {
25
+ return this;
26
+ }
27
+ getConfig() {
28
+ return this.conf;
29
+ }
30
+ setConfig(conf) {
31
+ this.conf = conf;
32
+ }
33
+ run(obj) {
34
+ if (!(obj instanceof Objects.FunctionGroup)) {
35
+ return [];
36
+ }
37
+ const issues = [];
38
+ for (const module of obj.getModules()) {
39
+ if (module.isGlobalParameters() === true) {
40
+ const file = obj.getMainABAPFile();
41
+ if (file === undefined) {
42
+ continue;
43
+ }
44
+ const message = `Function Module "${module.getName()}" uses obsolete global parameters`;
45
+ issues.push(issue_1.Issue.atPosition(file, new position_1.Position(1, 1), message, this.getMetadata().key, this.conf.severity));
46
+ }
47
+ }
48
+ return issues;
49
+ }
50
+ }
51
+ exports.FMGlobalParametersObsolete = FMGlobalParametersObsolete;
52
+ //# sourceMappingURL=fm_global_parameters_obsolete.js.map
@@ -65,6 +65,7 @@ __exportStar(require("./empty_structure"), exports);
65
65
  __exportStar(require("./exit_or_check"), exports);
66
66
  __exportStar(require("./expand_macros"), exports);
67
67
  __exportStar(require("./exporting"), exports);
68
+ __exportStar(require("./fm_global_parameters_obsolete"), exports);
68
69
  __exportStar(require("./forbidden_identifier"), exports);
69
70
  __exportStar(require("./forbidden_pseudo_and_pragma"), exports);
70
71
  __exportStar(require("./forbidden_void_type"), exports);
@@ -78,6 +79,7 @@ __exportStar(require("./identical_conditions"), exports);
78
79
  __exportStar(require("./identical_contents"), exports);
79
80
  __exportStar(require("./identical_descriptions"), exports);
80
81
  __exportStar(require("./identical_form_names"), exports);
82
+ __exportStar(require("./identical_move"), exports);
81
83
  __exportStar(require("./if_in_if"), exports);
82
84
  __exportStar(require("./implement_methods"), exports);
83
85
  __exportStar(require("./implicit_start_of_selection"), exports);
@@ -89,7 +91,6 @@ __exportStar(require("./intf_referencing_clas"), exports);
89
91
  __exportStar(require("./invalid_table_index"), exports);
90
92
  __exportStar(require("./keep_single_parameter_on_one_line"), exports);
91
93
  __exportStar(require("./keyword_case"), exports);
92
- __exportStar(require("./identical_move"), exports);
93
94
  __exportStar(require("./line_break_multiple_parameters"), exports);
94
95
  __exportStar(require("./line_break_style"), exports);
95
96
  __exportStar(require("./line_length"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.115.14",
3
+ "version": "2.115.15",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",