@abaplint/core 2.119.16 → 2.119.17
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/src/abap/2_statements/expressions/parameter_exception.js +2 -1
- package/build/src/abap/5_syntax/_type_utils.js +21 -9
- package/build/src/abap/5_syntax/expressions/field_chain.js +2 -2
- package/build/src/registry.js +1 -1
- package/build/src/rules/parser_bad_exceptions.js +21 -4
- package/build/src/rules/superclass_final.js +32 -0
- package/package.json +1 -1
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParameterException = void 0;
|
|
4
4
|
const combi_1 = require("../combi");
|
|
5
|
+
const tokens_1 = require("../../1_lexer/tokens");
|
|
5
6
|
const _1 = require(".");
|
|
6
7
|
class ParameterException extends combi_1.Expression {
|
|
7
8
|
getRunnable() {
|
|
8
|
-
const name = (0, combi_1.altPrio)("OTHERS", _1.ParameterName);
|
|
9
|
+
const name = (0, combi_1.altPrio)("OTHERS", (0, combi_1.seq)(_1.ParameterName, (0, combi_1.tok)(tokens_1.Dash), _1.ComponentName), _1.ParameterName);
|
|
9
10
|
return (0, combi_1.seq)(name, (0, combi_1.optPrio)((0, combi_1.seq)("=", (0, combi_1.altPrio)(_1.Integer, _1.SimpleFieldChain), (0, combi_1.optPrio)((0, combi_1.seq)("MESSAGE", _1.Target)))));
|
|
10
11
|
}
|
|
11
12
|
}
|
|
@@ -7,6 +7,7 @@ const table_type_1 = require("../types/basic/table_type");
|
|
|
7
7
|
const enum_type_1 = require("../types/basic/enum_type");
|
|
8
8
|
const cgeneric_type_1 = require("../types/basic/cgeneric_type");
|
|
9
9
|
const Expressions = require("../2_statements/expressions");
|
|
10
|
+
const nodes_1 = require("../nodes");
|
|
10
11
|
// todo: refactor to static? for performance
|
|
11
12
|
class TypeUtils {
|
|
12
13
|
constructor(scope) {
|
|
@@ -257,6 +258,18 @@ class TypeUtils {
|
|
|
257
258
|
return false;
|
|
258
259
|
}
|
|
259
260
|
*/
|
|
261
|
+
var _a;
|
|
262
|
+
if (node.getChildren().length === 4
|
|
263
|
+
&& node.getFirstChild() instanceof nodes_1.TokenNodeRegex
|
|
264
|
+
&& ((_a = node.getFirstChild()) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase()) === "BOOLC") {
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
if (node.getChildren().length >= 3) {
|
|
268
|
+
const second = node.getChildren()[1];
|
|
269
|
+
if (second.getFirstToken().getStr() === "&&") {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
260
273
|
const calculated = node.findFirstExpression(Expressions.MethodCallChain) !== undefined
|
|
261
274
|
|| node.findFirstExpression(Expressions.StringTemplate) !== undefined
|
|
262
275
|
|| node.findFirstExpression(Expressions.ArithOperator) !== undefined;
|
|
@@ -270,7 +283,7 @@ class TypeUtils {
|
|
|
270
283
|
return this.isAssignable(source, target);
|
|
271
284
|
}
|
|
272
285
|
isAssignableStrict(source, target, node) {
|
|
273
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
286
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
274
287
|
const calculated = node ? this.isCalculated(node) : false;
|
|
275
288
|
/*
|
|
276
289
|
console.dir(source);
|
|
@@ -329,16 +342,15 @@ class TypeUtils {
|
|
|
329
342
|
else if (source instanceof basic_1.StringType) {
|
|
330
343
|
if (target instanceof basic_1.StructureType && this.structureContainsString(target)) {
|
|
331
344
|
return false;
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (source.getAbstractTypeData()
|
|
335
|
-
|
|
345
|
+
}
|
|
346
|
+
else if (target instanceof basic_1.CharacterType) {
|
|
347
|
+
if (((_g = source.getAbstractTypeData()) === null || _g === void 0 ? void 0 : _g.derivedFromConstant) === true) {
|
|
348
|
+
return true;
|
|
336
349
|
}
|
|
337
350
|
return false;
|
|
338
|
-
*/
|
|
339
351
|
}
|
|
340
352
|
else if (target instanceof basic_1.IntegerType) {
|
|
341
|
-
if (((
|
|
353
|
+
if (((_h = source.getAbstractTypeData()) === null || _h === void 0 ? void 0 : _h.derivedFromConstant) === true) {
|
|
342
354
|
return true;
|
|
343
355
|
}
|
|
344
356
|
return false;
|
|
@@ -348,7 +360,7 @@ class TypeUtils {
|
|
|
348
360
|
return false;
|
|
349
361
|
}
|
|
350
362
|
else if (target instanceof basic_1.XSequenceType || target instanceof basic_1.XStringType) {
|
|
351
|
-
if (((
|
|
363
|
+
if (((_j = source.getAbstractTypeData()) === null || _j === void 0 ? void 0 : _j.derivedFromConstant) === true) {
|
|
352
364
|
return true;
|
|
353
365
|
}
|
|
354
366
|
return false;
|
|
@@ -392,7 +404,7 @@ class TypeUtils {
|
|
|
392
404
|
return false;
|
|
393
405
|
}
|
|
394
406
|
else if (target instanceof basic_1.Integer8Type || target instanceof basic_1.PackedType) {
|
|
395
|
-
if (((
|
|
407
|
+
if (((_k = source.getAbstractTypeData()) === null || _k === void 0 ? void 0 : _k.derivedFromConstant) === true) {
|
|
396
408
|
return true;
|
|
397
409
|
}
|
|
398
410
|
return false;
|
|
@@ -24,8 +24,8 @@ class FieldChain {
|
|
|
24
24
|
&& node.findDirectExpression(Expressions.ComponentName)) {
|
|
25
25
|
// workaround for names with dashes, eg. "sy-repid"
|
|
26
26
|
const concat = node.concatTokens().replace(/ /g, "");
|
|
27
|
-
const offset = ((_b = node.findDirectExpression(Expressions.FieldOffset)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "";
|
|
28
|
-
const length = ((_c = node.findDirectExpression(Expressions.FieldLength)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "";
|
|
27
|
+
const offset = ((_b = node.findDirectExpression(Expressions.FieldOffset)) === null || _b === void 0 ? void 0 : _b.concatTokens().replace(/ /g, "")) || "";
|
|
28
|
+
const length = ((_c = node.findDirectExpression(Expressions.FieldLength)) === null || _c === void 0 ? void 0 : _c.concatTokens().replace(/ /g, "")) || "";
|
|
29
29
|
const found = input.scope.findVariable(concat.replace(offset, "").replace(length, ""));
|
|
30
30
|
if (found) {
|
|
31
31
|
if (refType) {
|
package/build/src/registry.js
CHANGED
|
@@ -22,10 +22,6 @@ class ParserBadExceptions extends _abap_rule_1.ABAPRule {
|
|
|
22
22
|
title: "Parser Error, bad EXCEPTIONS in CALL FUNCTION",
|
|
23
23
|
shortDescription: `Checks for syntax not recognized by abaplint, related to EXCEPTIONS in CALL FUNCTION.`,
|
|
24
24
|
tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.SingleFile],
|
|
25
|
-
/*
|
|
26
|
-
badExample: `IF ( foo = 'bar').`,
|
|
27
|
-
goodExample: `IF ( foo = 'bar' ).`,
|
|
28
|
-
*/
|
|
29
25
|
};
|
|
30
26
|
}
|
|
31
27
|
getConfig() {
|
|
@@ -40,6 +36,15 @@ class ParserBadExceptions extends _abap_rule_1.ABAPRule {
|
|
|
40
36
|
if (!(statement.get() instanceof Statements.CallFunction)) {
|
|
41
37
|
continue;
|
|
42
38
|
}
|
|
39
|
+
const exceptionTokens = this.findExceptionTokens(statement);
|
|
40
|
+
if (exceptionTokens !== undefined
|
|
41
|
+
&& this.containsMixedExceptionSyntax(statement.findAllExpressions(Expressions.ParameterException))) {
|
|
42
|
+
const message = "Bad EXCEPTIONS syntax in CALL FUNCTION";
|
|
43
|
+
for (const token of exceptionTokens) {
|
|
44
|
+
issues.push(issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity));
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
43
48
|
for (const e of statement.findAllExpressions(Expressions.ParameterException)) {
|
|
44
49
|
if (e.findDirectTokenByText("=") === undefined) {
|
|
45
50
|
const message = "Bad EXCEPTIONS syntax in CALL FUNCTION";
|
|
@@ -49,6 +54,18 @@ class ParserBadExceptions extends _abap_rule_1.ABAPRule {
|
|
|
49
54
|
}
|
|
50
55
|
return issues;
|
|
51
56
|
}
|
|
57
|
+
containsMixedExceptionSyntax(exceptions) {
|
|
58
|
+
return exceptions.some(e => e.findDirectTokenByText("=") === undefined)
|
|
59
|
+
&& exceptions.some(e => e.findDirectTokenByText("=") !== undefined);
|
|
60
|
+
}
|
|
61
|
+
findExceptionTokens(statement) {
|
|
62
|
+
const tokens = statement.getTokens();
|
|
63
|
+
const index = tokens.findIndex(t => t.getStr().toUpperCase() === "EXCEPTIONS");
|
|
64
|
+
if (index === -1) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return tokens.slice(index).filter(t => t.getStr() !== ".");
|
|
68
|
+
}
|
|
52
69
|
}
|
|
53
70
|
exports.ParserBadExceptions = ParserBadExceptions;
|
|
54
71
|
//# sourceMappingURL=parser_bad_exceptions.js.map
|
|
@@ -6,6 +6,7 @@ const _abap_rule_1 = require("./_abap_rule");
|
|
|
6
6
|
const Objects = require("../objects");
|
|
7
7
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
8
8
|
const _irule_1 = require("./_irule");
|
|
9
|
+
const include_graph_1 = require("../utils/include_graph");
|
|
9
10
|
class SuperclassFinalConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
10
11
|
}
|
|
11
12
|
exports.SuperclassFinalConf = SuperclassFinalConf;
|
|
@@ -13,6 +14,7 @@ class SuperclassFinal extends _abap_rule_1.ABAPRule {
|
|
|
13
14
|
constructor() {
|
|
14
15
|
super(...arguments);
|
|
15
16
|
this.conf = new SuperclassFinalConf();
|
|
17
|
+
this.graph = undefined;
|
|
16
18
|
}
|
|
17
19
|
getMetadata() {
|
|
18
20
|
return {
|
|
@@ -51,6 +53,9 @@ class SuperclassFinal extends _abap_rule_1.ABAPRule {
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
}
|
|
56
|
+
if (found === undefined && obj instanceof Objects.Program) {
|
|
57
|
+
found = this.findInRelatedProgramIncludes(file, sup);
|
|
58
|
+
}
|
|
54
59
|
if (found === undefined) {
|
|
55
60
|
const clas = this.reg.getObject("CLAS", sup);
|
|
56
61
|
if (clas) {
|
|
@@ -70,6 +75,33 @@ class SuperclassFinal extends _abap_rule_1.ABAPRule {
|
|
|
70
75
|
}
|
|
71
76
|
return output;
|
|
72
77
|
}
|
|
78
|
+
findInRelatedProgramIncludes(file, superClassName) {
|
|
79
|
+
if (this.graph === undefined) {
|
|
80
|
+
this.graph = new include_graph_1.IncludeGraph(this.reg);
|
|
81
|
+
}
|
|
82
|
+
const mainFilenames = this.graph.listMainForInclude(file.getFilename());
|
|
83
|
+
if (mainFilenames.length === 0) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
for (const object of this.reg.getObjectsByType("PROG")) {
|
|
87
|
+
if (!(object instanceof Objects.Program)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const programFile = object.getMainABAPFile();
|
|
91
|
+
if (programFile === undefined) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const programMainFilenames = this.graph.listMainForInclude(programFile.getFilename());
|
|
95
|
+
if (mainFilenames.some(filename => programMainFilenames.includes(filename)) === false) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const found = programFile.getInfo().getClassDefinitionByName(superClassName);
|
|
99
|
+
if (found !== undefined) {
|
|
100
|
+
return found;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
73
105
|
}
|
|
74
106
|
exports.SuperclassFinal = SuperclassFinal;
|
|
75
107
|
//# sourceMappingURL=superclass_final.js.map
|