@abaplint/core 2.120.113 → 2.120.114
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.
- package/build/abaplint.d.ts +2 -1
- package/build/src/abap/5_syntax/basic_types.js +12 -0
- package/build/src/abap/5_syntax/expressions/_check_header_line.js +5 -2
- package/build/src/abap/5_syntax/expressions/method_call_param.js +1 -1
- package/build/src/abap/5_syntax/expressions/method_parameters.js +1 -1
- package/build/src/abap/types/method_parameters.js +21 -13
- package/build/src/registry.js +1 -1
- package/build/src/rules/implement_methods.js +20 -6
- package/package.json +1 -1
package/build/abaplint.d.ts
CHANGED
|
@@ -4924,7 +4924,8 @@ declare class MethodParameters_2 implements IMethodParameters {
|
|
|
4924
4924
|
getExceptions(): string[];
|
|
4925
4925
|
getParameterDefault(parameter: string): ExpressionNode;
|
|
4926
4926
|
private parse;
|
|
4927
|
-
|
|
4927
|
+
/** reports a parameter with the name of an earlier one, the method definition is kept without it */
|
|
4928
|
+
private isDuplicateName;
|
|
4928
4929
|
private checkNameLengths;
|
|
4929
4930
|
private workaroundRAP;
|
|
4930
4931
|
private add;
|
|
@@ -295,6 +295,18 @@ class BasicTypes {
|
|
|
295
295
|
else if (type instanceof Types.TimeType) {
|
|
296
296
|
type = new Types.TimeType(data);
|
|
297
297
|
}
|
|
298
|
+
else if (type instanceof Types.PackedType) {
|
|
299
|
+
type = new Types.PackedType(type.getLength(), type.getDecimals(), data);
|
|
300
|
+
}
|
|
301
|
+
else if (type instanceof Types.DecFloat16Type) {
|
|
302
|
+
type = new Types.DecFloat16Type(data);
|
|
303
|
+
}
|
|
304
|
+
else if (type instanceof Types.DecFloat34Type) {
|
|
305
|
+
type = new Types.DecFloat34Type(data);
|
|
306
|
+
}
|
|
307
|
+
else if (type instanceof Types.UTCLongType) {
|
|
308
|
+
type = new Types.UTCLongType(data);
|
|
309
|
+
}
|
|
298
310
|
else if (type instanceof basic_1.StructureType) {
|
|
299
311
|
type = new basic_1.StructureType(type.getComponents().slice(), qualifiedName, undefined, type.getDescription());
|
|
300
312
|
}
|
|
@@ -37,10 +37,13 @@ exports.checkHeaderLine = checkHeaderLine;
|
|
|
37
37
|
const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
38
38
|
const basic_1 = require("../../types/basic");
|
|
39
39
|
const _syntax_input_1 = require("../_syntax_input");
|
|
40
|
+
const _builtin_1 = require("../_builtin");
|
|
40
41
|
// A table with header line written without [] is the header line, not the table body,
|
|
41
|
-
// so it cannot be passed to a table typed method parameter.
|
|
42
|
-
|
|
42
|
+
// so it cannot be passed to a table typed method parameter. Built-in functions like lines( ) use
|
|
43
|
+
// the table body, so they are not checked. Returns true if an issue was reported.
|
|
44
|
+
function checkHeaderLine(source, sourceType, parameterType, method, input) {
|
|
43
45
|
if (source === undefined
|
|
46
|
+
|| method instanceof _builtin_1.BuiltInMethod
|
|
44
47
|
|| !(parameterType instanceof basic_1.TableType)
|
|
45
48
|
|| !(sourceType instanceof basic_1.TableType)
|
|
46
49
|
|| sourceType.isWithHeader() === false) {
|
|
@@ -123,7 +123,7 @@ class MethodCallParam {
|
|
|
123
123
|
else if ((0, _check_text_symbol_1.checkTextSymbol)(child, targetType, input)) {
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
else if ((0, _check_header_line_1.checkHeaderLine)(child, sourceType, targetType, input)) {
|
|
126
|
+
else if ((0, _check_header_line_1.checkHeaderLine)(child, sourceType, targetType, method, input)) {
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
else if (this.isAssignable(sourceType, targetType, child, method, input) === false) {
|
|
@@ -213,7 +213,7 @@ class MethodParameters {
|
|
|
213
213
|
if ((0, _check_text_symbol_1.checkTextSymbol)(item.source, parameter.getType(), input)) {
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
|
-
else if ((0, _check_header_line_1.checkHeaderLine)(item.source, item.sourceType, parameter.getType(), input)) {
|
|
216
|
+
else if ((0, _check_header_line_1.checkHeaderLine)(item.source, item.sourceType, parameter.getType(), method, input)) {
|
|
217
217
|
return;
|
|
218
218
|
}
|
|
219
219
|
else if (assignable(item.sourceType, parameter.getType(), item.source) === false) {
|
|
@@ -77,7 +77,6 @@ class MethodParameters {
|
|
|
77
77
|
try {
|
|
78
78
|
this.parse(node, input, parentName, abstractMethod);
|
|
79
79
|
this.checkNameLengths(input);
|
|
80
|
-
this.checkDuplicateNames();
|
|
81
80
|
}
|
|
82
81
|
finally {
|
|
83
82
|
input.scope.pop(node.getEnd());
|
|
@@ -214,19 +213,21 @@ class MethodParameters {
|
|
|
214
213
|
}
|
|
215
214
|
const returning = node.findFirstExpression(Expressions.MethodDefReturning);
|
|
216
215
|
if (returning) {
|
|
217
|
-
|
|
216
|
+
const id = method_def_returning_1.MethodDefReturning.runSyntax(returning, input, ["returning" /* IdentifierMeta.MethodReturning */]);
|
|
217
|
+
if (this.isDuplicateName(id, input) === false) {
|
|
218
|
+
this.returning = id;
|
|
219
|
+
}
|
|
218
220
|
}
|
|
219
221
|
this.workaroundRAP(node, input, parentName);
|
|
220
222
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
names.add(name);
|
|
223
|
+
/** reports a parameter with the name of an earlier one, the method definition is kept without it */
|
|
224
|
+
isDuplicateName(id, input) {
|
|
225
|
+
const name = id.getName().toUpperCase();
|
|
226
|
+
if (this.getAll().some(p => p.getName().toUpperCase() === name)) {
|
|
227
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, id.getToken(), `Method parameter "${name}" already defined`));
|
|
228
|
+
return true;
|
|
229
229
|
}
|
|
230
|
+
return false;
|
|
230
231
|
}
|
|
231
232
|
checkNameLengths(input) {
|
|
232
233
|
for (const parameter of this.getAll()) {
|
|
@@ -302,7 +303,8 @@ class MethodParameters {
|
|
|
302
303
|
add(target, source, input, meta, abstractMethod) {
|
|
303
304
|
var _a;
|
|
304
305
|
this.checkKeywordNames(source, input);
|
|
305
|
-
|
|
306
|
+
const optionals = source.findAllExpressions(Expressions.MethodParamOptional);
|
|
307
|
+
for (const opt of optionals) {
|
|
306
308
|
const p = opt.findDirectExpression(Expressions.MethodParam);
|
|
307
309
|
if (p === undefined) {
|
|
308
310
|
continue;
|
|
@@ -318,6 +320,9 @@ class MethodParameters {
|
|
|
318
320
|
extraMeta.push("abstract" /* IdentifierMeta.Abstract */);
|
|
319
321
|
}
|
|
320
322
|
const id = method_param_1.MethodParam.runSyntax(p, input, [...meta, ...extraMeta]);
|
|
323
|
+
if (this.isDuplicateName(id, input)) {
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
321
326
|
input.scope.addIdentifier(id);
|
|
322
327
|
target.push(id);
|
|
323
328
|
const optionalToken = opt.findDirectTokenByText("OPTIONAL");
|
|
@@ -338,13 +343,16 @@ class MethodParameters {
|
|
|
338
343
|
}
|
|
339
344
|
}
|
|
340
345
|
}
|
|
341
|
-
if (
|
|
346
|
+
if (optionals.length > 0) {
|
|
342
347
|
return;
|
|
343
348
|
}
|
|
344
349
|
const params = source.findAllExpressions(Expressions.MethodParam);
|
|
345
350
|
for (const param of params) {
|
|
346
351
|
const extraMeta = this.isPassByValue(param) ? ["pass_by_value" /* IdentifierMeta.PassByValue */] : [];
|
|
347
|
-
|
|
352
|
+
const id = method_param_1.MethodParam.runSyntax(param, input, [...meta, ...extraMeta]);
|
|
353
|
+
if (this.isDuplicateName(id, input) === false) {
|
|
354
|
+
target.push(id);
|
|
355
|
+
}
|
|
348
356
|
}
|
|
349
357
|
}
|
|
350
358
|
// A system reads a plain parameter name as a keyword wherever that keyword can stand, measured on 758:
|
package/build/src/registry.js
CHANGED
|
@@ -303,12 +303,11 @@ class ImplementMethods extends _abap_rule_1.ABAPRule {
|
|
|
303
303
|
const name = m.objectName + "~" + m.method.name;
|
|
304
304
|
let found = impl.methods.find(m => m.getName().toUpperCase() === name.toUpperCase());
|
|
305
305
|
if (found === undefined) {
|
|
306
|
-
// try looking for ALIASes
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
306
|
+
// try looking for ALIASes, also the ones inherited from super classes,
|
|
307
|
+
// "METHODS alias_name REDEFINITION" implements the method through an alias of the super class
|
|
308
|
+
const alias = this.findAlias(def, name);
|
|
309
|
+
if (alias !== undefined) {
|
|
310
|
+
found = impl.methods.find(m => m.getName().toUpperCase() === alias.toUpperCase());
|
|
312
311
|
}
|
|
313
312
|
}
|
|
314
313
|
if (found === undefined && def.superClassName !== undefined) {
|
|
@@ -331,6 +330,21 @@ class ImplementMethods extends _abap_rule_1.ABAPRule {
|
|
|
331
330
|
}
|
|
332
331
|
return found !== undefined;
|
|
333
332
|
}
|
|
333
|
+
/** name of the alias for the component, in the class or in one of its super classes */
|
|
334
|
+
findAlias(def, component) {
|
|
335
|
+
var _a;
|
|
336
|
+
const visited = new Set();
|
|
337
|
+
let current = def;
|
|
338
|
+
while (current !== undefined && !visited.has(current.name.toUpperCase())) {
|
|
339
|
+
visited.add(current.name.toUpperCase());
|
|
340
|
+
const alias = current.aliases.find(a => a.component.toUpperCase() === component.toUpperCase());
|
|
341
|
+
if (alias !== undefined) {
|
|
342
|
+
return alias.name;
|
|
343
|
+
}
|
|
344
|
+
current = current.superClassName ? (_a = this.findClass(current.superClassName)) === null || _a === void 0 ? void 0 : _a.def : undefined;
|
|
345
|
+
}
|
|
346
|
+
return undefined;
|
|
347
|
+
}
|
|
334
348
|
viaAliasInInterface(m, intf, impl) {
|
|
335
349
|
for (const a of intf.aliases) {
|
|
336
350
|
if (a.component.toUpperCase() === m.objectName.toUpperCase() + "~" + m.method.name.toUpperCase()) {
|