@abaplint/cli 2.108.13 → 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 +179 -22
- package/package.json +3 -3
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);
|
|
@@ -42143,6 +42164,9 @@ class CodeActions {
|
|
|
42143
42164
|
const diagnostics = [];
|
|
42144
42165
|
const fixes = [];
|
|
42145
42166
|
for (const i of issues) {
|
|
42167
|
+
if (i.getKey() !== key) {
|
|
42168
|
+
continue;
|
|
42169
|
+
}
|
|
42146
42170
|
const fix = i.getDefaultFix();
|
|
42147
42171
|
if (fix === undefined) {
|
|
42148
42172
|
continue;
|
|
@@ -42831,10 +42855,11 @@ exports.Highlight = Highlight;
|
|
|
42831
42855
|
|
|
42832
42856
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
42833
42857
|
exports.Hover = void 0;
|
|
42858
|
+
const Tokens = __webpack_require__(/*! ../abap/1_lexer/tokens */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js");
|
|
42859
|
+
const Statements = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
|
|
42834
42860
|
const LServer = __webpack_require__(/*! vscode-languageserver-types */ "./node_modules/vscode-languageserver-types/lib/umd/main.js");
|
|
42835
42861
|
const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "./node_modules/@abaplint/core/build/src/objects/_abap_object.js");
|
|
42836
42862
|
const _lsp_utils_1 = __webpack_require__(/*! ./_lsp_utils */ "./node_modules/@abaplint/core/build/src/lsp/_lsp_utils.js");
|
|
42837
|
-
const Tokens = __webpack_require__(/*! ../abap/1_lexer/tokens */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js");
|
|
42838
42863
|
const _lookup_1 = __webpack_require__(/*! ./_lookup */ "./node_modules/@abaplint/core/build/src/lsp/_lookup.js");
|
|
42839
42864
|
class Hover {
|
|
42840
42865
|
constructor(reg) {
|
|
@@ -42859,6 +42884,9 @@ class Hover {
|
|
|
42859
42884
|
|| found.token instanceof Tokens.StringTemplateMiddle) {
|
|
42860
42885
|
return { kind: LServer.MarkupKind.Markdown, value: "String Template" };
|
|
42861
42886
|
}
|
|
42887
|
+
else if (found.snode.get() instanceof Statements.Define && found.stack.length === 2) {
|
|
42888
|
+
return { kind: LServer.MarkupKind.Markdown, value: "Macro Name" };
|
|
42889
|
+
}
|
|
42862
42890
|
else if (found.token instanceof Tokens.Comment) {
|
|
42863
42891
|
let type = "Comment";
|
|
42864
42892
|
if (found.token.getStr().startsWith(`"!`)) {
|
|
@@ -43680,6 +43708,56 @@ exports.Symbols = Symbols;
|
|
|
43680
43708
|
|
|
43681
43709
|
/***/ }),
|
|
43682
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
|
+
|
|
43683
43761
|
/***/ "./node_modules/@abaplint/core/build/src/msag_references.js":
|
|
43684
43762
|
/*!******************************************************************!*\
|
|
43685
43763
|
!*** ./node_modules/@abaplint/core/build/src/msag_references.js ***!
|
|
@@ -51585,6 +51663,7 @@ const excludeHelper_1 = __webpack_require__(/*! ./utils/excludeHelper */ "./node
|
|
|
51585
51663
|
const ddic_references_1 = __webpack_require__(/*! ./ddic_references */ "./node_modules/@abaplint/core/build/src/ddic_references.js");
|
|
51586
51664
|
const rules_runner_1 = __webpack_require__(/*! ./rules_runner */ "./node_modules/@abaplint/core/build/src/rules_runner.js");
|
|
51587
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");
|
|
51588
51667
|
// todo, this should really be an instance in case there are multiple Registry'ies
|
|
51589
51668
|
class ParsingPerformance {
|
|
51590
51669
|
static clear() {
|
|
@@ -51639,10 +51718,11 @@ class Registry {
|
|
|
51639
51718
|
this.conf = conf ? conf : config_1.Config.getDefault();
|
|
51640
51719
|
this.ddicReferences = new ddic_references_1.DDICReferences();
|
|
51641
51720
|
this.msagReferences = new msag_references_1.MSAGReferences();
|
|
51721
|
+
this.macroReferences = new macro_references_1.MacroReferences();
|
|
51642
51722
|
}
|
|
51643
51723
|
static abaplintVersion() {
|
|
51644
51724
|
// magic, see build script "version.sh"
|
|
51645
|
-
return "2.
|
|
51725
|
+
return "2.109.0";
|
|
51646
51726
|
}
|
|
51647
51727
|
getDDICReferences() {
|
|
51648
51728
|
return this.ddicReferences;
|
|
@@ -51650,6 +51730,9 @@ class Registry {
|
|
|
51650
51730
|
getMSAGReferences() {
|
|
51651
51731
|
return this.msagReferences;
|
|
51652
51732
|
}
|
|
51733
|
+
getMacroReferences() {
|
|
51734
|
+
return this.macroReferences;
|
|
51735
|
+
}
|
|
51653
51736
|
*getObjects() {
|
|
51654
51737
|
for (const name in this.objects) {
|
|
51655
51738
|
for (const type in this.objects[name]) {
|
|
@@ -62381,6 +62464,7 @@ __exportStar(__webpack_require__(/*! ./cds_legacy_view */ "./node_modules/@abapl
|
|
|
62381
62464
|
__exportStar(__webpack_require__(/*! ./cds_parser_error */ "./node_modules/@abaplint/core/build/src/rules/cds_parser_error.js"), exports);
|
|
62382
62465
|
__exportStar(__webpack_require__(/*! ./chain_mainly_declarations */ "./node_modules/@abaplint/core/build/src/rules/chain_mainly_declarations.js"), exports);
|
|
62383
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);
|
|
62384
62468
|
__exportStar(__webpack_require__(/*! ./check_abstract */ "./node_modules/@abaplint/core/build/src/rules/check_abstract.js"), exports);
|
|
62385
62469
|
__exportStar(__webpack_require__(/*! ./check_comments */ "./node_modules/@abaplint/core/build/src/rules/check_comments.js"), exports);
|
|
62386
62470
|
__exportStar(__webpack_require__(/*! ./check_ddic */ "./node_modules/@abaplint/core/build/src/rules/check_ddic.js"), exports);
|
|
@@ -72259,6 +72343,79 @@ exports.UnusedDDIC = UnusedDDIC;
|
|
|
72259
72343
|
|
|
72260
72344
|
/***/ }),
|
|
72261
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
|
+
|
|
72262
72419
|
/***/ "./node_modules/@abaplint/core/build/src/rules/unused_methods.js":
|
|
72263
72420
|
/*!***********************************************************************!*\
|
|
72264
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,12 +38,12 @@
|
|
|
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",
|
|
45
45
|
"@types/mocha": "^10.0.6",
|
|
46
|
-
"@types/node": "^20.14.
|
|
46
|
+
"@types/node": "^20.14.2",
|
|
47
47
|
"@types/progress": "^2.0.7",
|
|
48
48
|
"chai": "^4.4.1",
|
|
49
49
|
"chalk": "^5.3.0",
|