@abaplint/core 2.120.2 → 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.
@@ -3535,6 +3535,10 @@ export declare const enum IdentifierMeta {
3535
3535
  MethodExporting = "exporting",
3536
3536
  MethodChanging = "changing",
3537
3537
  MethodReturning = "returning",
3538
+ FunctionModuleImporting = "function_module_importing",
3539
+ FunctionModuleExporting = "function_module_exporting",
3540
+ FunctionModuleChanging = "function_module_changing",
3541
+ FunctionModuleTables = "function_module_tables",
3538
3542
  EventParameter = "event_parameter",
3539
3543
  FormParameter = "form_parameter",
3540
3544
  ReadOnly = "read_only",
@@ -3625,6 +3629,7 @@ declare interface IFunctionModuleParameter {
3625
3629
  type: string | undefined;
3626
3630
  optional: boolean;
3627
3631
  defaultValue: string | undefined;
3632
+ passByValue: boolean;
3628
3633
  }
3629
3634
 
3630
3635
  declare interface IGlobalConfig {
@@ -4882,6 +4887,7 @@ declare class MethodParameters_2 implements IMethodParameters {
4882
4887
  private checkDuplicateNames;
4883
4888
  private workaroundRAP;
4884
4889
  private add;
4890
+ private isPassByValue;
4885
4891
  }
4886
4892
 
4887
4893
  declare class MethodParamName extends Expression {
@@ -46,6 +46,7 @@ const basic_1 = require("../types/basic");
46
46
  const ddic_1 = require("../../ddic");
47
47
  const _object_oriented_1 = require("./_object_oriented");
48
48
  const _reference_1 = require("./_reference");
49
+ const tokens_1 = require("../1_lexer/tokens");
49
50
  class Procedural {
50
51
  constructor(reg, scope) {
51
52
  this.scope = scope;
@@ -225,7 +226,8 @@ class Procedural {
225
226
  continue;
226
227
  }
227
228
  else {
228
- const type = new _typed_identifier_1.TypedIdentifier(nameToken, filename, found);
229
+ const token = new tokens_1.Identifier(nameToken.getStart(), param.name);
230
+ const type = new _typed_identifier_1.TypedIdentifier(token, filename, found, this.functionModuleParameterMeta(param));
229
231
  if (ignoreIfAlreadyExists === true) {
230
232
  const exists = this.scope.findVariable(param.name);
231
233
  if (exists === undefined) {
@@ -239,6 +241,25 @@ class Procedural {
239
241
  }
240
242
  }
241
243
  }
244
+ functionModuleParameterMeta(param) {
245
+ const ret = [];
246
+ if (param.direction === types_1.FunctionModuleParameterDirection.importing) {
247
+ ret.push("function_module_importing" /* IdentifierMeta.FunctionModuleImporting */);
248
+ }
249
+ else if (param.direction === types_1.FunctionModuleParameterDirection.exporting) {
250
+ ret.push("function_module_exporting" /* IdentifierMeta.FunctionModuleExporting */);
251
+ }
252
+ else if (param.direction === types_1.FunctionModuleParameterDirection.changing) {
253
+ ret.push("function_module_changing" /* IdentifierMeta.FunctionModuleChanging */);
254
+ }
255
+ else if (param.direction === types_1.FunctionModuleParameterDirection.tables) {
256
+ ret.push("function_module_tables" /* IdentifierMeta.FunctionModuleTables */);
257
+ }
258
+ if (param.passByValue) {
259
+ ret.push("pass_by_value" /* IdentifierMeta.PassByValue */);
260
+ }
261
+ return ret;
262
+ }
242
263
  }
243
264
  exports.Procedural = Procedural;
244
265
  //# sourceMappingURL=_procedural.js.map
@@ -61,6 +61,7 @@ class FunctionModuleDefinition {
61
61
  type: param.TYP || param.DBFIELD,
62
62
  optional: param.OPTIONAL === "X",
63
63
  defaultValue: param.DEFAULT,
64
+ passByValue: param.REFERENCE !== "X",
64
65
  });
65
66
  }
66
67
  }
@@ -75,6 +76,7 @@ class FunctionModuleDefinition {
75
76
  type: param.TYP || param.DBFIELD,
76
77
  optional: param.OPTIONAL === "X",
77
78
  defaultValue: param.DEFAULT,
79
+ passByValue: param.REFERENCE !== "X",
78
80
  });
79
81
  }
80
82
  }
@@ -89,6 +91,7 @@ class FunctionModuleDefinition {
89
91
  type: param.TYP || param.DBFIELD,
90
92
  optional: true,
91
93
  defaultValue: undefined,
94
+ passByValue: param.REFERENCE !== "X",
92
95
  });
93
96
  }
94
97
  }
@@ -104,6 +107,7 @@ class FunctionModuleDefinition {
104
107
  type: param.DBSTRUCT || param.TYP,
105
108
  optional: param.OPTIONAL === "X",
106
109
  defaultValue: undefined,
110
+ passByValue: false,
107
111
  });
108
112
  }
109
113
  }
@@ -267,14 +267,14 @@ class MethodParameters {
267
267
  }
268
268
  }
269
269
  add(target, source, input, meta, abstractMethod) {
270
- var _a, _b;
270
+ var _a;
271
271
  for (const opt of source.findAllExpressions(Expressions.MethodParamOptional)) {
272
272
  const p = opt.findDirectExpression(Expressions.MethodParam);
273
273
  if (p === undefined) {
274
274
  continue;
275
275
  }
276
276
  const extraMeta = [];
277
- if (p.getFirstToken().getStr().toUpperCase() === "VALUE" && ((_a = p.getChildren()[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "(") {
277
+ if (this.isPassByValue(p)) {
278
278
  extraMeta.push("pass_by_value" /* IdentifierMeta.PassByValue */);
279
279
  }
280
280
  else if (meta.includes("importing" /* IdentifierMeta.MethodImporting */)) {
@@ -293,7 +293,7 @@ class MethodParameters {
293
293
  else if (opt.findFirstExpression(Expressions.Default)) {
294
294
  const name = target[target.length - 1].getName().toUpperCase();
295
295
  this.optional.push(name);
296
- const val = (_b = opt.findFirstExpression(Expressions.Default)) === null || _b === void 0 ? void 0 : _b.getLastChild();
296
+ const val = (_a = opt.findFirstExpression(Expressions.Default)) === null || _a === void 0 ? void 0 : _a.getLastChild();
297
297
  if (val && val instanceof nodes_1.ExpressionNode) {
298
298
  this.defaults[name] = val;
299
299
  }
@@ -304,9 +304,15 @@ class MethodParameters {
304
304
  }
305
305
  const params = source.findAllExpressions(Expressions.MethodParam);
306
306
  for (const param of params) {
307
- target.push(method_param_1.MethodParam.runSyntax(param, input, meta));
307
+ const extraMeta = this.isPassByValue(param) ? ["pass_by_value" /* IdentifierMeta.PassByValue */] : [];
308
+ target.push(method_param_1.MethodParam.runSyntax(param, input, [...meta, ...extraMeta]));
308
309
  }
309
310
  }
311
+ isPassByValue(param) {
312
+ var _a;
313
+ return param.getFirstToken().getStr().toUpperCase() === "VALUE"
314
+ && ((_a = param.getChildren()[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "(";
315
+ }
310
316
  }
311
317
  exports.MethodParameters = MethodParameters;
312
318
  //# sourceMappingURL=method_parameters.js.map
@@ -56,10 +56,10 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
56
56
  return undefined;
57
57
  }
58
58
  getMainABAPFile() {
59
- // todo, uris, https://github.com/abaplint/abaplint/issues/673
60
59
  const search = this.getName().replace(/\//g, "#").toLowerCase() + "." + this.getType().toLowerCase() + ".abap";
60
+ const encodedSearch = search.replace(/#/g, "%23");
61
61
  for (const file of this.getABAPFiles()) {
62
- if (file.getFilename().endsWith(search)) {
62
+ if (file.getFilename().endsWith(search) || file.getFilename().endsWith(encodedSearch)) {
63
63
  return file;
64
64
  }
65
65
  }
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.2";
78
+ return "2.120.3";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.ClearExportingParameters = exports.ClearExportingParametersConf = void 0;
37
4
  const issue_1 = require("../issue");
@@ -40,12 +7,11 @@ const _irule_1 = require("./_irule");
40
7
  const syntax_1 = require("../abap/5_syntax/syntax");
41
8
  const _abap_object_1 = require("../objects/_abap_object");
42
9
  const _scope_type_1 = require("../abap/5_syntax/_scope_type");
10
+ const _typed_identifier_1 = require("../abap/types/_typed_identifier");
43
11
  const objects_1 = require("../objects");
44
12
  const _reference_1 = require("../abap/5_syntax/_reference");
45
13
  const basic_1 = require("../abap/types/basic");
46
14
  const _statement_1 = require("../abap/2_statements/statements/_statement");
47
- const edit_helper_1 = require("../edit_helper");
48
- const Expressions = __importStar(require("../abap/2_statements/expressions"));
49
15
  class ClearExportingParametersConf extends _basic_rule_config_1.BasicRuleConfig {
50
16
  constructor() {
51
17
  super(...arguments);
@@ -78,7 +44,7 @@ Reading and writing the parameter in the same statement (e.g. "ev_result = ev_re
78
44
  as the source is evaluated before the parameter is assigned.
79
45
  Objects containing parser or syntax errors are not reported.
80
46
 
81
- Only class and interface method implementations are checked, function module parameters are currently not supported.`,
47
+ Class and interface method implementations and function modules are checked.`,
82
48
  tags: [_irule_1.RuleTag.Styleguide],
83
49
  badExample: `CLASS lcl DEFINITION.
84
50
  PUBLIC SECTION.
@@ -134,19 +100,20 @@ ENDCLASS.`,
134
100
  return issues;
135
101
  }
136
102
  traverse(node, obj, issues) {
137
- if (node.getIdentifier().stype === _scope_type_1.ScopeType.Method) {
138
- this.checkMethod(node, obj, issues);
103
+ if (node.getIdentifier().stype === _scope_type_1.ScopeType.Method
104
+ || node.getIdentifier().stype === _scope_type_1.ScopeType.FunctionModule) {
105
+ this.checkProcedure(node, obj, issues);
139
106
  }
140
107
  for (const child of node.getChildren()) {
141
108
  this.traverse(child, obj, issues);
142
109
  }
143
110
  }
144
- checkMethod(node, obj, issues) {
145
- const parameters = this.findExportingByReference(node, obj);
111
+ checkProcedure(node, obj, issues) {
112
+ const references = this.collectReferences(node);
113
+ const parameters = this.findExportingByReference(node, references);
146
114
  if (parameters.length === 0) {
147
115
  return;
148
116
  }
149
- const references = this.collectReferences(node);
150
117
  for (const parameter of parameters) {
151
118
  const issue = this.checkParameter(parameter, references, obj);
152
119
  if (issue !== undefined) {
@@ -154,52 +121,36 @@ ENDCLASS.`,
154
121
  }
155
122
  }
156
123
  }
157
- findExportingByReference(node, obj) {
124
+ findExportingByReference(node, references) {
158
125
  var _a;
159
126
  const ret = [];
160
- const vars = node.getData().vars;
161
- for (const name in vars) {
162
- const parameter = vars[name];
127
+ const candidates = new Set(Object.values(node.getData().vars));
128
+ for (const reference of references) {
129
+ if (reference.resolved instanceof _typed_identifier_1.TypedIdentifier) {
130
+ candidates.add(reference.resolved);
131
+ }
132
+ }
133
+ for (const parameter of candidates) {
163
134
  const meta = parameter.getMeta();
164
- if (meta.includes("exporting" /* IdentifierMeta.MethodExporting */) === false
135
+ const exporting = meta.includes("exporting" /* IdentifierMeta.MethodExporting */)
136
+ || meta.includes("function_module_exporting" /* IdentifierMeta.FunctionModuleExporting */);
137
+ if (exporting === false
165
138
  || meta.includes("pass_by_value" /* IdentifierMeta.PassByValue */) === true) {
166
139
  continue;
167
140
  }
168
- else if ((_a = this.conf.skipNames) === null || _a === void 0 ? void 0 : _a.some(s => s.toUpperCase() === name.toUpperCase())) {
141
+ else if ((_a = this.conf.skipNames) === null || _a === void 0 ? void 0 : _a.some(s => s.toUpperCase() === parameter.getName().toUpperCase())) {
169
142
  continue;
170
143
  }
171
144
  const type = parameter.getType();
172
145
  if (type instanceof basic_1.VoidType || type instanceof basic_1.UnknownType) {
173
146
  continue; // e.g. RAP magic parameters, or unresolved types
174
147
  }
175
- else if (this.isPassByValue(parameter, obj) === true) {
176
- continue; // VALUE(..) parameters are always initialized
177
- }
178
148
  ret.push(parameter);
179
149
  }
180
150
  return ret;
181
151
  }
182
- isPassByValue(parameter, obj) {
183
- var _a;
184
- // the PassByValue meta is not set for EXPORTING parameters, so determine it from the definition
185
- const file = obj.getABAPFileByName(parameter.getFilename());
186
- if (file === undefined) {
187
- return false;
188
- }
189
- const statement = edit_helper_1.EditHelper.findStatement(parameter.getToken(), file);
190
- if (statement === undefined) {
191
- return false;
192
- }
193
- for (const param of statement.findAllExpressions(Expressions.MethodParam)) {
194
- const nameToken = (_a = param.findFirstExpression(Expressions.MethodParamName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
195
- if (nameToken !== undefined && nameToken.getStart().equals(parameter.getStart())) {
196
- return param.getFirstToken().getStr().toUpperCase() === "VALUE";
197
- }
198
- }
199
- return false;
200
- }
201
152
  collectReferences(node) {
202
- // methods do not nest, so all descendant scopes (FOR, LET, ...) belong to this method
153
+ // procedures do not nest, so all descendant scopes (FOR, LET, ...) belong to this procedure
203
154
  const ret = [...node.getData().references];
204
155
  for (const child of node.getChildren()) {
205
156
  ret.push(...this.collectReferences(child));
@@ -210,7 +161,9 @@ ENDCLASS.`,
210
161
  let firstRead = undefined;
211
162
  let earliestWrite = undefined;
212
163
  for (const reference of references) {
213
- if (reference.resolved === undefined || parameter.equals(reference.resolved) === false) {
164
+ if (reference.resolved === undefined
165
+ || parameter.equals(reference.resolved) === false
166
+ || parameter.getName().toUpperCase() !== reference.resolved.getName().toUpperCase()) {
214
167
  continue;
215
168
  }
216
169
  const pos = reference.position.getStart();
@@ -69,7 +69,8 @@ ENDCLASS.`,
69
69
  }
70
70
  for (const v in vars) {
71
71
  const id = vars[v];
72
- if (id.getMeta().includes("pass_by_value" /* IdentifierMeta.PassByValue */) === false) {
72
+ if (id.getMeta().includes("importing" /* IdentifierMeta.MethodImporting */) === false
73
+ || id.getMeta().includes("pass_by_value" /* IdentifierMeta.PassByValue */) === false) {
73
74
  continue;
74
75
  }
75
76
  else if (this.reg.isFileDependency(id.getFilename()) === true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.2",
3
+ "version": "2.120.3",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",