@abaplint/cli 2.108.14 → 2.109.0
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/cli.js +171 -21
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -3648,17 +3648,23 @@ class Macros {
|
|
|
3648
3648
|
constructor(globalMacros) {
|
|
3649
3649
|
this.macros = {};
|
|
3650
3650
|
for (const m of globalMacros) {
|
|
3651
|
-
this.macros[m.toUpperCase()] =
|
|
3651
|
+
this.macros[m.toUpperCase()] = {
|
|
3652
|
+
statements: [],
|
|
3653
|
+
filename: undefined,
|
|
3654
|
+
};
|
|
3652
3655
|
}
|
|
3653
3656
|
}
|
|
3654
|
-
addMacro(name, contents) {
|
|
3657
|
+
addMacro(name, contents, filename) {
|
|
3655
3658
|
if (this.isMacro(name)) {
|
|
3656
3659
|
return;
|
|
3657
3660
|
}
|
|
3658
|
-
this.macros[name.toUpperCase()] =
|
|
3661
|
+
this.macros[name.toUpperCase()] = {
|
|
3662
|
+
statements: contents,
|
|
3663
|
+
filename: filename,
|
|
3664
|
+
};
|
|
3659
3665
|
}
|
|
3660
3666
|
getContents(name) {
|
|
3661
|
-
return this.macros[name.toUpperCase()];
|
|
3667
|
+
return this.macros[name.toUpperCase()].statements;
|
|
3662
3668
|
}
|
|
3663
3669
|
listMacroNames() {
|
|
3664
3670
|
return Object.keys(this.macros);
|
|
@@ -3669,6 +3675,9 @@ class Macros {
|
|
|
3669
3675
|
}
|
|
3670
3676
|
return false;
|
|
3671
3677
|
}
|
|
3678
|
+
getMacroFilename(name) {
|
|
3679
|
+
return this.macros[name.toUpperCase()].filename;
|
|
3680
|
+
}
|
|
3672
3681
|
}
|
|
3673
3682
|
class ExpandMacros {
|
|
3674
3683
|
// "reg" must be supplied if there are cross object macros via INCLUDE
|
|
@@ -3678,35 +3687,38 @@ class ExpandMacros {
|
|
|
3678
3687
|
this.globalMacros = globalMacros;
|
|
3679
3688
|
this.reg = reg;
|
|
3680
3689
|
}
|
|
3681
|
-
find(statements) {
|
|
3682
|
-
var _a, _b;
|
|
3683
|
-
let
|
|
3690
|
+
find(statements, file) {
|
|
3691
|
+
var _a, _b, _c;
|
|
3692
|
+
let nameToken = undefined;
|
|
3684
3693
|
let contents = [];
|
|
3694
|
+
const macroReferences = (_a = this.reg) === null || _a === void 0 ? void 0 : _a.getMacroReferences();
|
|
3695
|
+
macroReferences === null || macroReferences === void 0 ? void 0 : macroReferences.clear(file.getFilename());
|
|
3685
3696
|
for (let i = 0; i < statements.length; i++) {
|
|
3686
3697
|
const statement = statements[i];
|
|
3687
3698
|
const type = statement.get();
|
|
3688
3699
|
if (type instanceof Statements.Define) {
|
|
3689
3700
|
// todo, will this break if first token is a pragma?
|
|
3690
|
-
|
|
3701
|
+
nameToken = statement.getTokens()[1];
|
|
3691
3702
|
contents = [];
|
|
3692
3703
|
}
|
|
3693
3704
|
else if (type instanceof Statements.Include) {
|
|
3694
|
-
const includeName = (
|
|
3705
|
+
const includeName = (_b = statement.findDirectExpression(Expressions.IncludeName)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
3695
3706
|
// todo, this does not take function module includes into account
|
|
3696
|
-
const prog = (
|
|
3707
|
+
const prog = (_c = this.reg) === null || _c === void 0 ? void 0 : _c.getObject("PROG", includeName);
|
|
3697
3708
|
if (prog) {
|
|
3698
3709
|
prog.parse(this.version, this.globalMacros, this.reg);
|
|
3699
|
-
const
|
|
3700
|
-
if (
|
|
3710
|
+
const includeMainFile = prog.getMainABAPFile();
|
|
3711
|
+
if (includeMainFile) {
|
|
3701
3712
|
// slow, this copies everything,
|
|
3702
|
-
this.find([...
|
|
3713
|
+
this.find([...includeMainFile.getStatements()], includeMainFile);
|
|
3703
3714
|
}
|
|
3704
3715
|
}
|
|
3705
3716
|
}
|
|
3706
|
-
else if (
|
|
3717
|
+
else if (nameToken) {
|
|
3707
3718
|
if (type instanceof Statements.EndOfDefinition) {
|
|
3708
|
-
this.macros.addMacro(
|
|
3709
|
-
|
|
3719
|
+
this.macros.addMacro(nameToken.getStr(), contents, file.getFilename());
|
|
3720
|
+
macroReferences === null || macroReferences === void 0 ? void 0 : macroReferences.addDefinition({ filename: file.getFilename(), token: nameToken });
|
|
3721
|
+
nameToken = undefined;
|
|
3710
3722
|
}
|
|
3711
3723
|
else if (!(type instanceof _statement_1.Comment)) {
|
|
3712
3724
|
statements[i] = new statement_node_1.StatementNode(new _statement_1.MacroContent()).setChildren(this.tokensToNodes(statement.getTokens()));
|
|
@@ -3715,17 +3727,26 @@ class ExpandMacros {
|
|
|
3715
3727
|
}
|
|
3716
3728
|
}
|
|
3717
3729
|
}
|
|
3718
|
-
handleMacros(statements) {
|
|
3730
|
+
handleMacros(statements, file) {
|
|
3731
|
+
var _a;
|
|
3719
3732
|
const result = [];
|
|
3720
3733
|
let containsUnknown = false;
|
|
3734
|
+
const macroReferences = (_a = this.reg) === null || _a === void 0 ? void 0 : _a.getMacroReferences();
|
|
3721
3735
|
for (const statement of statements) {
|
|
3722
3736
|
const type = statement.get();
|
|
3723
3737
|
if (type instanceof _statement_1.Unknown || type instanceof _statement_1.MacroCall) {
|
|
3724
3738
|
const macroName = this.findName(statement.getTokens());
|
|
3725
3739
|
if (macroName && this.macros.isMacro(macroName)) {
|
|
3740
|
+
const filename = this.macros.getMacroFilename(macroName);
|
|
3741
|
+
if (filename) {
|
|
3742
|
+
macroReferences === null || macroReferences === void 0 ? void 0 : macroReferences.addReference({
|
|
3743
|
+
filename: filename,
|
|
3744
|
+
token: statement.getFirstToken(),
|
|
3745
|
+
});
|
|
3746
|
+
}
|
|
3726
3747
|
result.push(new statement_node_1.StatementNode(new _statement_1.MacroCall(), statement.getColon()).setChildren(this.tokensToNodes(statement.getTokens())));
|
|
3727
3748
|
const expanded = this.expandContents(macroName, statement);
|
|
3728
|
-
const handled = this.handleMacros(expanded);
|
|
3749
|
+
const handled = this.handleMacros(expanded, file);
|
|
3729
3750
|
for (const e of handled.statements) {
|
|
3730
3751
|
result.push(e);
|
|
3731
3752
|
}
|
|
@@ -9581,10 +9602,10 @@ class StatementParser {
|
|
|
9581
9602
|
for (const w of wa) {
|
|
9582
9603
|
this.process(w);
|
|
9583
9604
|
this.categorize(w);
|
|
9584
|
-
macros.find(w.statements);
|
|
9605
|
+
macros.find(w.statements, w.file);
|
|
9585
9606
|
}
|
|
9586
9607
|
for (const w of wa) {
|
|
9587
|
-
const res = macros.handleMacros(w.statements);
|
|
9608
|
+
const res = macros.handleMacros(w.statements, w.file);
|
|
9588
9609
|
w.statements = res.statements;
|
|
9589
9610
|
if (res.containsUnknown === true) {
|
|
9590
9611
|
this.lazyUnknown(w);
|
|
@@ -43687,6 +43708,56 @@ exports.Symbols = Symbols;
|
|
|
43687
43708
|
|
|
43688
43709
|
/***/ }),
|
|
43689
43710
|
|
|
43711
|
+
/***/ "./node_modules/@abaplint/core/build/src/macro_references.js":
|
|
43712
|
+
/*!*******************************************************************!*\
|
|
43713
|
+
!*** ./node_modules/@abaplint/core/build/src/macro_references.js ***!
|
|
43714
|
+
\*******************************************************************/
|
|
43715
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
43716
|
+
|
|
43717
|
+
"use strict";
|
|
43718
|
+
|
|
43719
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
43720
|
+
exports.MacroReferences = void 0;
|
|
43721
|
+
class MacroReferences {
|
|
43722
|
+
constructor() {
|
|
43723
|
+
this.definitions = {};
|
|
43724
|
+
this.references = {};
|
|
43725
|
+
}
|
|
43726
|
+
addDefinition(ref) {
|
|
43727
|
+
if (this.definitions[ref.filename] === undefined) {
|
|
43728
|
+
this.definitions[ref.filename] = [];
|
|
43729
|
+
}
|
|
43730
|
+
this.definitions[ref.filename].push(ref);
|
|
43731
|
+
}
|
|
43732
|
+
addReference(ref) {
|
|
43733
|
+
if (this.references[ref.filename] === undefined) {
|
|
43734
|
+
this.references[ref.filename] = [];
|
|
43735
|
+
}
|
|
43736
|
+
this.references[ref.filename].push(ref);
|
|
43737
|
+
}
|
|
43738
|
+
listDefinitionsByFile(filename) {
|
|
43739
|
+
return this.definitions[filename] || [];
|
|
43740
|
+
}
|
|
43741
|
+
listUsagesbyMacro(filename, token) {
|
|
43742
|
+
const ret = [];
|
|
43743
|
+
const tokenStr = token.getStr().toUpperCase();
|
|
43744
|
+
for (const ref of this.references[filename] || []) {
|
|
43745
|
+
if (ref.token.getStr().toUpperCase() === tokenStr) {
|
|
43746
|
+
ret.push(ref);
|
|
43747
|
+
}
|
|
43748
|
+
}
|
|
43749
|
+
return ret;
|
|
43750
|
+
}
|
|
43751
|
+
clear(filename) {
|
|
43752
|
+
delete this.definitions[filename];
|
|
43753
|
+
delete this.references[filename];
|
|
43754
|
+
}
|
|
43755
|
+
}
|
|
43756
|
+
exports.MacroReferences = MacroReferences;
|
|
43757
|
+
//# sourceMappingURL=macro_references.js.map
|
|
43758
|
+
|
|
43759
|
+
/***/ }),
|
|
43760
|
+
|
|
43690
43761
|
/***/ "./node_modules/@abaplint/core/build/src/msag_references.js":
|
|
43691
43762
|
/*!******************************************************************!*\
|
|
43692
43763
|
!*** ./node_modules/@abaplint/core/build/src/msag_references.js ***!
|
|
@@ -51592,6 +51663,7 @@ const excludeHelper_1 = __webpack_require__(/*! ./utils/excludeHelper */ "./node
|
|
|
51592
51663
|
const ddic_references_1 = __webpack_require__(/*! ./ddic_references */ "./node_modules/@abaplint/core/build/src/ddic_references.js");
|
|
51593
51664
|
const rules_runner_1 = __webpack_require__(/*! ./rules_runner */ "./node_modules/@abaplint/core/build/src/rules_runner.js");
|
|
51594
51665
|
const msag_references_1 = __webpack_require__(/*! ./msag_references */ "./node_modules/@abaplint/core/build/src/msag_references.js");
|
|
51666
|
+
const macro_references_1 = __webpack_require__(/*! ./macro_references */ "./node_modules/@abaplint/core/build/src/macro_references.js");
|
|
51595
51667
|
// todo, this should really be an instance in case there are multiple Registry'ies
|
|
51596
51668
|
class ParsingPerformance {
|
|
51597
51669
|
static clear() {
|
|
@@ -51646,10 +51718,11 @@ class Registry {
|
|
|
51646
51718
|
this.conf = conf ? conf : config_1.Config.getDefault();
|
|
51647
51719
|
this.ddicReferences = new ddic_references_1.DDICReferences();
|
|
51648
51720
|
this.msagReferences = new msag_references_1.MSAGReferences();
|
|
51721
|
+
this.macroReferences = new macro_references_1.MacroReferences();
|
|
51649
51722
|
}
|
|
51650
51723
|
static abaplintVersion() {
|
|
51651
51724
|
// magic, see build script "version.sh"
|
|
51652
|
-
return "2.
|
|
51725
|
+
return "2.109.0";
|
|
51653
51726
|
}
|
|
51654
51727
|
getDDICReferences() {
|
|
51655
51728
|
return this.ddicReferences;
|
|
@@ -51657,6 +51730,9 @@ class Registry {
|
|
|
51657
51730
|
getMSAGReferences() {
|
|
51658
51731
|
return this.msagReferences;
|
|
51659
51732
|
}
|
|
51733
|
+
getMacroReferences() {
|
|
51734
|
+
return this.macroReferences;
|
|
51735
|
+
}
|
|
51660
51736
|
*getObjects() {
|
|
51661
51737
|
for (const name in this.objects) {
|
|
51662
51738
|
for (const type in this.objects[name]) {
|
|
@@ -62388,6 +62464,7 @@ __exportStar(__webpack_require__(/*! ./cds_legacy_view */ "./node_modules/@abapl
|
|
|
62388
62464
|
__exportStar(__webpack_require__(/*! ./cds_parser_error */ "./node_modules/@abaplint/core/build/src/rules/cds_parser_error.js"), exports);
|
|
62389
62465
|
__exportStar(__webpack_require__(/*! ./chain_mainly_declarations */ "./node_modules/@abaplint/core/build/src/rules/chain_mainly_declarations.js"), exports);
|
|
62390
62466
|
__exportStar(__webpack_require__(/*! ./change_if_to_case */ "./node_modules/@abaplint/core/build/src/rules/change_if_to_case.js"), exports);
|
|
62467
|
+
__exportStar(__webpack_require__(/*! ./unused_macros */ "./node_modules/@abaplint/core/build/src/rules/unused_macros.js"), exports);
|
|
62391
62468
|
__exportStar(__webpack_require__(/*! ./check_abstract */ "./node_modules/@abaplint/core/build/src/rules/check_abstract.js"), exports);
|
|
62392
62469
|
__exportStar(__webpack_require__(/*! ./check_comments */ "./node_modules/@abaplint/core/build/src/rules/check_comments.js"), exports);
|
|
62393
62470
|
__exportStar(__webpack_require__(/*! ./check_ddic */ "./node_modules/@abaplint/core/build/src/rules/check_ddic.js"), exports);
|
|
@@ -72266,6 +72343,79 @@ exports.UnusedDDIC = UnusedDDIC;
|
|
|
72266
72343
|
|
|
72267
72344
|
/***/ }),
|
|
72268
72345
|
|
|
72346
|
+
/***/ "./node_modules/@abaplint/core/build/src/rules/unused_macros.js":
|
|
72347
|
+
/*!**********************************************************************!*\
|
|
72348
|
+
!*** ./node_modules/@abaplint/core/build/src/rules/unused_macros.js ***!
|
|
72349
|
+
\**********************************************************************/
|
|
72350
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
72351
|
+
|
|
72352
|
+
"use strict";
|
|
72353
|
+
|
|
72354
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
72355
|
+
exports.UnusedMacros = exports.UnusedMacrosConf = void 0;
|
|
72356
|
+
const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
|
|
72357
|
+
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
|
|
72358
|
+
const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
|
|
72359
|
+
const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "./node_modules/@abaplint/core/build/src/objects/_abap_object.js");
|
|
72360
|
+
class UnusedMacrosConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
72361
|
+
constructor() {
|
|
72362
|
+
super(...arguments);
|
|
72363
|
+
/** skip specific names, case insensitive
|
|
72364
|
+
* @uniqueItems true
|
|
72365
|
+
*/
|
|
72366
|
+
this.skipNames = [];
|
|
72367
|
+
}
|
|
72368
|
+
}
|
|
72369
|
+
exports.UnusedMacrosConf = UnusedMacrosConf;
|
|
72370
|
+
class UnusedMacros {
|
|
72371
|
+
constructor() {
|
|
72372
|
+
this.conf = new UnusedMacrosConf();
|
|
72373
|
+
}
|
|
72374
|
+
getMetadata() {
|
|
72375
|
+
return {
|
|
72376
|
+
key: "unused_macros",
|
|
72377
|
+
title: "Unused macros",
|
|
72378
|
+
shortDescription: `Checks for unused macro definitions definitions`,
|
|
72379
|
+
tags: [_irule_1.RuleTag.Quickfix],
|
|
72380
|
+
};
|
|
72381
|
+
}
|
|
72382
|
+
getConfig() {
|
|
72383
|
+
return this.conf;
|
|
72384
|
+
}
|
|
72385
|
+
setConfig(conf) {
|
|
72386
|
+
this.conf = conf;
|
|
72387
|
+
if (this.conf.skipNames === undefined) {
|
|
72388
|
+
this.conf.skipNames = [];
|
|
72389
|
+
}
|
|
72390
|
+
}
|
|
72391
|
+
initialize(reg) {
|
|
72392
|
+
this.reg = reg;
|
|
72393
|
+
return this;
|
|
72394
|
+
}
|
|
72395
|
+
run(obj) {
|
|
72396
|
+
var _a;
|
|
72397
|
+
const result = [];
|
|
72398
|
+
if (!(obj instanceof _abap_object_1.ABAPObject)) {
|
|
72399
|
+
return [];
|
|
72400
|
+
}
|
|
72401
|
+
const references = this.reg.getMacroReferences();
|
|
72402
|
+
for (const file of obj.getABAPFiles()) {
|
|
72403
|
+
for (const macro of references.listDefinitionsByFile(file.getFilename())) {
|
|
72404
|
+
const usages = references.listUsagesbyMacro(file.getFilename(), macro.token);
|
|
72405
|
+
if (usages.length === 0 && ((_a = this.conf.skipNames) === null || _a === void 0 ? void 0 : _a.includes(macro.token.getStr().toUpperCase())) === false) {
|
|
72406
|
+
const message = "Unused macro definition: " + macro.token.getStr();
|
|
72407
|
+
result.push(issue_1.Issue.atToken(file, macro.token, message, this.getMetadata().key, this.conf.severity));
|
|
72408
|
+
}
|
|
72409
|
+
}
|
|
72410
|
+
}
|
|
72411
|
+
return result;
|
|
72412
|
+
}
|
|
72413
|
+
}
|
|
72414
|
+
exports.UnusedMacros = UnusedMacros;
|
|
72415
|
+
//# sourceMappingURL=unused_macros.js.map
|
|
72416
|
+
|
|
72417
|
+
/***/ }),
|
|
72418
|
+
|
|
72269
72419
|
/***/ "./node_modules/@abaplint/core/build/src/rules/unused_methods.js":
|
|
72270
72420
|
/*!***********************************************************************!*\
|
|
72271
72421
|
!*** ./node_modules/@abaplint/core/build/src/rules/unused_methods.js ***!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.109.0",
|
|
4
4
|
"description": "abaplint - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://abaplint.org",
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@abaplint/core": "^2.
|
|
41
|
+
"@abaplint/core": "^2.109.0",
|
|
42
42
|
"@types/chai": "^4.3.16",
|
|
43
43
|
"@types/glob": "^8.1.0",
|
|
44
44
|
"@types/minimist": "^1.2.5",
|