@abaplint/core 2.119.16 → 2.119.18
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 +4 -0
- 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/abap/5_syntax/statements/call_function.js +6 -0
- package/build/src/abap/5_syntax/statements/fetch_next_cursor.js +4 -0
- package/build/src/config.js +4 -0
- package/build/src/registry.js +20 -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
package/build/abaplint.d.ts
CHANGED
|
@@ -3487,6 +3487,8 @@ declare interface IGlobalConfig {
|
|
|
3487
3487
|
useApackDependencies?: boolean;
|
|
3488
3488
|
/** Do not report any issues for includes without main programs */
|
|
3489
3489
|
skipIncludesWithoutMain?: boolean;
|
|
3490
|
+
/** Throw an error if multiple files with the same filename are added to the registry, ignores package.devc.xml */
|
|
3491
|
+
errorOnDuplicateFilenames?: boolean;
|
|
3490
3492
|
/** list of files to exclude, these files are not added when running syntax check or any other rules, case insensitive regex
|
|
3491
3493
|
* @uniqueItems true
|
|
3492
3494
|
*/
|
|
@@ -5769,6 +5771,8 @@ export declare class Registry implements IRegistry {
|
|
|
5769
5771
|
updateFile(file: IFile): IRegistry;
|
|
5770
5772
|
removeFile(file: IFile): IRegistry;
|
|
5771
5773
|
private _addFiles;
|
|
5774
|
+
private checkDuplicateFilename;
|
|
5775
|
+
private static filenameBasename;
|
|
5772
5776
|
addFiles(files: readonly IFile[]): IRegistry;
|
|
5773
5777
|
addDependencies(files: readonly IFile[]): IRegistry;
|
|
5774
5778
|
addDependency(file: IFile): IRegistry;
|
|
@@ -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) {
|
|
@@ -31,6 +31,12 @@ class CallFunction {
|
|
|
31
31
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
32
32
|
source_1.Source.runSyntax(s, input);
|
|
33
33
|
}
|
|
34
|
+
for (const d of node.findDirectExpressions(Expressions.Destination)) {
|
|
35
|
+
const source = d.findFirstExpression(Expressions.Source);
|
|
36
|
+
if (source) {
|
|
37
|
+
source_1.Source.runSyntax(source, input);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
34
40
|
const fp = node.findDirectExpression(Expressions.FunctionParameters);
|
|
35
41
|
if (fp) {
|
|
36
42
|
function_parameters_1.FunctionParameters.runSyntax(fp, input);
|
|
@@ -3,11 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FetchNextCursor = void 0;
|
|
4
4
|
const Expressions = require("../../2_statements/expressions");
|
|
5
5
|
const target_1 = require("../expressions/target");
|
|
6
|
+
const sql_source_1 = require("../expressions/sql_source");
|
|
6
7
|
class FetchNextCursor {
|
|
7
8
|
runSyntax(node, input) {
|
|
8
9
|
for (const t of node.findAllExpressions(Expressions.Target)) {
|
|
9
10
|
target_1.Target.runSyntax(t, input);
|
|
10
11
|
}
|
|
12
|
+
for (const s of node.findAllExpressions(Expressions.SQLSourceSimple)) {
|
|
13
|
+
sql_source_1.SQLSource.runSyntax(s, input);
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
}
|
|
13
17
|
exports.FetchNextCursor = FetchNextCursor;
|
package/build/src/config.js
CHANGED
|
@@ -33,6 +33,7 @@ class Config {
|
|
|
33
33
|
skipGeneratedProxyInterfaces: false,
|
|
34
34
|
useApackDependencies: false,
|
|
35
35
|
skipIncludesWithoutMain: false,
|
|
36
|
+
errorOnDuplicateFilenames: false,
|
|
36
37
|
},
|
|
37
38
|
dependencies: [{
|
|
38
39
|
url: "https://github.com/abaplint/deps",
|
|
@@ -96,6 +97,9 @@ class Config {
|
|
|
96
97
|
if (this.config.global.skipIncludesWithoutMain === undefined) {
|
|
97
98
|
this.config.global.skipIncludesWithoutMain = false;
|
|
98
99
|
}
|
|
100
|
+
if (this.config.global.errorOnDuplicateFilenames === undefined) {
|
|
101
|
+
this.config.global.errorOnDuplicateFilenames = false;
|
|
102
|
+
}
|
|
99
103
|
this.checkVersion();
|
|
100
104
|
}
|
|
101
105
|
get() {
|
package/build/src/registry.js
CHANGED
|
@@ -74,7 +74,7 @@ class Registry {
|
|
|
74
74
|
}
|
|
75
75
|
static abaplintVersion() {
|
|
76
76
|
// magic, see build script "version.sh"
|
|
77
|
-
return "2.119.
|
|
77
|
+
return "2.119.18";
|
|
78
78
|
}
|
|
79
79
|
getDDICReferences() {
|
|
80
80
|
return this.ddicReferences;
|
|
@@ -194,10 +194,29 @@ class Registry {
|
|
|
194
194
|
this.removeDependency(found);
|
|
195
195
|
found = this.findOrCreate(f.getObjectName(), f.getObjectType());
|
|
196
196
|
}
|
|
197
|
+
if (this.conf.getGlobal().errorOnDuplicateFilenames === true) {
|
|
198
|
+
this.checkDuplicateFilename(filename, found.getFiles());
|
|
199
|
+
}
|
|
197
200
|
found.addFile(f);
|
|
198
201
|
}
|
|
199
202
|
return this;
|
|
200
203
|
}
|
|
204
|
+
checkDuplicateFilename(filename, files) {
|
|
205
|
+
const basename = Registry.filenameBasename(filename);
|
|
206
|
+
if (basename === "PACKAGE.DEVC.XML") {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
for (const existingFile of files) {
|
|
210
|
+
if (Registry.filenameBasename(existingFile.getFilename()) === basename) {
|
|
211
|
+
throw new Error("Duplicate filename: " + filename + " already exists as " + existingFile.getFilename());
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
static filenameBasename(filename) {
|
|
216
|
+
const normalized = filename.replace(/\\/g, "/");
|
|
217
|
+
const last = normalized.split("/").pop();
|
|
218
|
+
return (last !== null && last !== void 0 ? last : normalized).toUpperCase();
|
|
219
|
+
}
|
|
201
220
|
addFiles(files) {
|
|
202
221
|
this._addFiles(files, false);
|
|
203
222
|
return this;
|
|
@@ -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
|