@abaplint/cli 2.120.72 → 2.120.74
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 +288 -28
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -6623,7 +6623,9 @@ const combi_1 = __webpack_require__(/*! ../combi */ "../core/build/src/abap/2_st
|
|
|
6623
6623
|
const _1 = __webpack_require__(/*! . */ "../core/build/src/abap/2_statements/expressions/index.js");
|
|
6624
6624
|
class MethodParamOptional extends combi_1.Expression {
|
|
6625
6625
|
getRunnable() {
|
|
6626
|
-
|
|
6626
|
+
// not optPrio, a parameter named "optional" can follow one with a DEFAULT value:
|
|
6627
|
+
// "a TYPE i DEFAULT 5 optional TYPE i"
|
|
6628
|
+
return (0, combi_1.seq)(_1.MethodParam, (0, combi_1.opt)("OPTIONAL"));
|
|
6627
6629
|
}
|
|
6628
6630
|
}
|
|
6629
6631
|
exports.MethodParamOptional = MethodParamOptional;
|
|
@@ -28396,6 +28398,7 @@ const Types = __importStar(__webpack_require__(/*! ../types/basic */ "../core/bu
|
|
|
28396
28398
|
const _scope_type_1 = __webpack_require__(/*! ./_scope_type */ "../core/build/src/abap/5_syntax/_scope_type.js");
|
|
28397
28399
|
const _object_oriented_1 = __webpack_require__(/*! ./_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
|
|
28398
28400
|
const class_constant_1 = __webpack_require__(/*! ../types/class_constant */ "../core/build/src/abap/types/class_constant.js");
|
|
28401
|
+
const class_attribute_1 = __webpack_require__(/*! ../types/class_attribute */ "../core/build/src/abap/types/class_attribute.js");
|
|
28399
28402
|
const identifier_1 = __webpack_require__(/*! ../1_lexer/tokens/identifier */ "../core/build/src/abap/1_lexer/tokens/identifier.js");
|
|
28400
28403
|
const _reference_1 = __webpack_require__(/*! ./_reference */ "../core/build/src/abap/5_syntax/_reference.js");
|
|
28401
28404
|
const basic_1 = __webpack_require__(/*! ../types/basic */ "../core/build/src/abap/types/basic/index.js");
|
|
@@ -29246,15 +29249,18 @@ class BasicTypes {
|
|
|
29246
29249
|
const firstName = firstToken.getStr();
|
|
29247
29250
|
if (firstNode.get() instanceof Expressions.Field) {
|
|
29248
29251
|
const found = this.input.scope.findVariable(firstName);
|
|
29249
|
-
|
|
29250
|
-
|
|
29251
|
-
this.input.
|
|
29252
|
-
return
|
|
29252
|
+
if (found === undefined) {
|
|
29253
|
+
const message = `"${firstName}" not found, findTop`;
|
|
29254
|
+
this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, firstToken, message));
|
|
29255
|
+
return undefined;
|
|
29253
29256
|
}
|
|
29254
|
-
|
|
29255
|
-
|
|
29257
|
+
this.input.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.input.filename);
|
|
29258
|
+
if (this.isConstant(found) === false) {
|
|
29259
|
+
const message = `VALUE, ${expr.concatTokens().toLowerCase()} is not a constant`;
|
|
29260
|
+
this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, firstToken, message));
|
|
29261
|
+
return undefined;
|
|
29256
29262
|
}
|
|
29257
|
-
return
|
|
29263
|
+
return this.constantValue(expr, found.getValue());
|
|
29258
29264
|
}
|
|
29259
29265
|
else if (firstNode.get() instanceof Expressions.ClassName
|
|
29260
29266
|
&& firstName.toLowerCase() === this.input.scope.getName().toLowerCase()
|
|
@@ -29263,12 +29269,18 @@ class BasicTypes {
|
|
|
29263
29269
|
const children = expr.getChildren();
|
|
29264
29270
|
const token = (_a = children[2]) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
29265
29271
|
const found = this.input.scope.findVariable(token.getStr());
|
|
29266
|
-
|
|
29267
|
-
|
|
29268
|
-
this.input.
|
|
29269
|
-
return
|
|
29272
|
+
if (found === undefined) {
|
|
29273
|
+
const message = `"${token.getStr()}" not found, findTop`;
|
|
29274
|
+
this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, token, message));
|
|
29275
|
+
return undefined;
|
|
29270
29276
|
}
|
|
29271
|
-
|
|
29277
|
+
this.input.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.input.filename);
|
|
29278
|
+
if (this.isConstant(found) === false) {
|
|
29279
|
+
const message = `VALUE, ${expr.concatTokens().toLowerCase()} is not a constant`;
|
|
29280
|
+
this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, token, message));
|
|
29281
|
+
return undefined;
|
|
29282
|
+
}
|
|
29283
|
+
return this.constantValue(expr, found.getValue());
|
|
29272
29284
|
}
|
|
29273
29285
|
else if (firstNode.get() instanceof Expressions.ClassName) {
|
|
29274
29286
|
const obj = this.input.scope.findObjectDefinition(firstName);
|
|
@@ -29291,24 +29303,58 @@ class BasicTypes {
|
|
|
29291
29303
|
if (c instanceof class_constant_1.ClassConstant) {
|
|
29292
29304
|
this.input.scope.addReference(firstToken, obj, _reference_1.ReferenceType.ObjectOrientedReference, this.input.filename, { ooName: obj.getName() });
|
|
29293
29305
|
this.input.scope.addReference(token, c, _reference_1.ReferenceType.DataReadReference, this.input.filename);
|
|
29294
|
-
|
|
29295
|
-
|
|
29296
|
-
|
|
29297
|
-
|
|
29298
|
-
|
|
29299
|
-
|
|
29300
|
-
|
|
29301
|
-
|
|
29302
|
-
|
|
29303
|
-
}
|
|
29306
|
+
return this.constantValue(expr, c.getValue());
|
|
29307
|
+
}
|
|
29308
|
+
const helper = new _object_oriented_1.ObjectOriented(this.input.scope);
|
|
29309
|
+
const attribute = helper.searchAttributeName(obj, attr);
|
|
29310
|
+
if (attribute) {
|
|
29311
|
+
this.input.scope.addReference(firstToken, obj, _reference_1.ReferenceType.ObjectOrientedReference, this.input.filename, { ooName: obj.getName() });
|
|
29312
|
+
this.input.scope.addReference(token, attribute, _reference_1.ReferenceType.DataReadReference, this.input.filename);
|
|
29313
|
+
const message = `VALUE, ${expr.concatTokens().toLowerCase()} is not a constant`;
|
|
29314
|
+
this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, token, message));
|
|
29304
29315
|
return undefined;
|
|
29305
29316
|
}
|
|
29306
|
-
|
|
29317
|
+
const message = `Attribute or constant "${attr}" not found in "${obj.getName()}"`;
|
|
29318
|
+
this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, token, message));
|
|
29319
|
+
return undefined;
|
|
29307
29320
|
}
|
|
29308
29321
|
else {
|
|
29309
29322
|
throw new Error("resolveConstantValue, unexpected structure");
|
|
29310
29323
|
}
|
|
29311
29324
|
}
|
|
29325
|
+
isConstant(identifier) {
|
|
29326
|
+
if (identifier instanceof class_attribute_1.ClassAttribute) {
|
|
29327
|
+
return false;
|
|
29328
|
+
}
|
|
29329
|
+
const meta = identifier.getMeta();
|
|
29330
|
+
if (meta.includes("read_only" /* IdentifierMeta.ReadOnly */) === false) {
|
|
29331
|
+
return false;
|
|
29332
|
+
}
|
|
29333
|
+
if (meta.includes("static" /* IdentifierMeta.Static */)) {
|
|
29334
|
+
return true;
|
|
29335
|
+
}
|
|
29336
|
+
// Built-in constants and built-in system fields share ReadOnly/BuiltIn metadata.
|
|
29337
|
+
// Only the constants have a value; system fields such as SY-INDEX do not.
|
|
29338
|
+
return meta.includes("built-in" /* IdentifierMeta.BuiltIn */) && identifier.getValue() !== undefined;
|
|
29339
|
+
}
|
|
29340
|
+
constantValue(expr, value) {
|
|
29341
|
+
if (typeof value === "string") {
|
|
29342
|
+
return value;
|
|
29343
|
+
}
|
|
29344
|
+
else if (typeof value === "object" && value !== null) {
|
|
29345
|
+
let current = value;
|
|
29346
|
+
for (const child of expr.getChildren().slice(1)) {
|
|
29347
|
+
if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.ComponentName) {
|
|
29348
|
+
if (typeof current !== "object" || current === null) {
|
|
29349
|
+
return undefined;
|
|
29350
|
+
}
|
|
29351
|
+
current = current[child.getFirstToken().getStr()];
|
|
29352
|
+
}
|
|
29353
|
+
}
|
|
29354
|
+
return typeof current === "string" ? current : undefined;
|
|
29355
|
+
}
|
|
29356
|
+
return undefined;
|
|
29357
|
+
}
|
|
29312
29358
|
resolveTypeRef(chain) {
|
|
29313
29359
|
var _a;
|
|
29314
29360
|
if (chain === undefined) {
|
|
@@ -53971,6 +54017,7 @@ const Expressions = __importStar(__webpack_require__(/*! ../2_statements/express
|
|
|
53971
54017
|
const method_parameters_1 = __webpack_require__(/*! ./method_parameters */ "../core/build/src/abap/types/method_parameters.js");
|
|
53972
54018
|
const _identifier_1 = __webpack_require__(/*! ../4_file_information/_identifier */ "../core/build/src/abap/4_file_information/_identifier.js");
|
|
53973
54019
|
const _reference_1 = __webpack_require__(/*! ../5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
|
|
54020
|
+
const _syntax_input_1 = __webpack_require__(/*! ../5_syntax/_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
53974
54021
|
class MethodDefinition extends _identifier_1.Identifier {
|
|
53975
54022
|
// todo: final flag
|
|
53976
54023
|
constructor(node, visibility, input) {
|
|
@@ -54012,6 +54059,7 @@ class MethodDefinition extends _identifier_1.Identifier {
|
|
|
54012
54059
|
this.static = true;
|
|
54013
54060
|
}
|
|
54014
54061
|
this.raising = [];
|
|
54062
|
+
this.checkRaisingParameter(node, input);
|
|
54015
54063
|
for (const r of ((_c = node.findDirectExpression(Expressions.MethodDefRaising)) === null || _c === void 0 ? void 0 : _c.findAllExpressions(Expressions.ClassName)) || []) {
|
|
54016
54064
|
const token = r.getFirstToken();
|
|
54017
54065
|
const name = token.getStr();
|
|
@@ -54036,6 +54084,26 @@ class MethodDefinition extends _identifier_1.Identifier {
|
|
|
54036
54084
|
this.visibility = visibility;
|
|
54037
54085
|
this.parameters = new method_parameters_1.MethodParameters(node, input, this.abstract);
|
|
54038
54086
|
}
|
|
54087
|
+
// A system reads a parameter named RAISING as the RAISING addition, measured on 758:
|
|
54088
|
+
// "IMPORTING a TYPE i raising TYPE i" fails with 'Type "TYPE" is unknown'
|
|
54089
|
+
checkRaisingParameter(node, input) {
|
|
54090
|
+
const raising = node.findDirectExpression(Expressions.MethodDefRaising);
|
|
54091
|
+
const first = raising === null || raising === void 0 ? void 0 : raising.getChildren()[1];
|
|
54092
|
+
if (raising === undefined
|
|
54093
|
+
|| first === undefined
|
|
54094
|
+
|| !(first.get() instanceof Expressions.ClassName)
|
|
54095
|
+
|| ["TYPE", "LIKE"].includes(first.getFirstToken().getStr().toUpperCase()) === false) {
|
|
54096
|
+
return;
|
|
54097
|
+
}
|
|
54098
|
+
if (node.findDirectExpression(Expressions.MethodDefImporting) === undefined
|
|
54099
|
+
&& node.findDirectExpression(Expressions.MethodDefExporting) === undefined
|
|
54100
|
+
&& node.findDirectExpression(Expressions.MethodDefChanging) === undefined) {
|
|
54101
|
+
return;
|
|
54102
|
+
}
|
|
54103
|
+
const token = raising.getFirstToken();
|
|
54104
|
+
const message = "Parameter \"" + token.getStr() + "\" is read as the RAISING addition, rename it or escape it as !" + token.getStr();
|
|
54105
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message));
|
|
54106
|
+
}
|
|
54039
54107
|
getVisibility() {
|
|
54040
54108
|
return this.visibility;
|
|
54041
54109
|
}
|
|
@@ -54303,6 +54371,12 @@ const _reference_1 = __webpack_require__(/*! ../5_syntax/_reference */ "../core/
|
|
|
54303
54371
|
const identifier_1 = __webpack_require__(/*! ../1_lexer/tokens/identifier */ "../core/build/src/abap/1_lexer/tokens/identifier.js");
|
|
54304
54372
|
const _scope_type_1 = __webpack_require__(/*! ../5_syntax/_scope_type */ "../core/build/src/abap/5_syntax/_scope_type.js");
|
|
54305
54373
|
const _syntax_input_1 = __webpack_require__(/*! ../5_syntax/_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
54374
|
+
// the keywords that can follow a parameter in each section, a plain parameter name is read as them
|
|
54375
|
+
const KEYWORDS_AFTER = {
|
|
54376
|
+
"IMPORTING": ["PREFERRED", "EXPORTING", "CHANGING", "RETURNING", "RAISING", "EXCEPTIONS"],
|
|
54377
|
+
"EXPORTING": ["CHANGING", "RETURNING", "RAISING", "EXCEPTIONS"],
|
|
54378
|
+
"CHANGING": ["RETURNING", "RAISING", "EXCEPTIONS"],
|
|
54379
|
+
};
|
|
54306
54380
|
// todo:
|
|
54307
54381
|
// this.exceptions = [];
|
|
54308
54382
|
// also consider RAISING vs EXCEPTIONS
|
|
@@ -54547,6 +54621,7 @@ class MethodParameters {
|
|
|
54547
54621
|
}
|
|
54548
54622
|
add(target, source, input, meta, abstractMethod) {
|
|
54549
54623
|
var _a;
|
|
54624
|
+
this.checkKeywordNames(source, input);
|
|
54550
54625
|
for (const opt of source.findAllExpressions(Expressions.MethodParamOptional)) {
|
|
54551
54626
|
const p = opt.findDirectExpression(Expressions.MethodParam);
|
|
54552
54627
|
if (p === undefined) {
|
|
@@ -54587,6 +54662,56 @@ class MethodParameters {
|
|
|
54587
54662
|
target.push(method_param_1.MethodParam.runSyntax(param, input, [...meta, ...extraMeta]));
|
|
54588
54663
|
}
|
|
54589
54664
|
}
|
|
54665
|
+
// A system reads a plain parameter name as a keyword wherever that keyword can stand, measured on 758:
|
|
54666
|
+
// "val TYPE clike default TYPE i" makes default the DEFAULT addition of val, and then fails
|
|
54667
|
+
// with "Unable to interpret ..." on what follows. "!default" and "VALUE(default)" are names
|
|
54668
|
+
checkKeywordNames(section, input) {
|
|
54669
|
+
var _a;
|
|
54670
|
+
const following = KEYWORDS_AFTER[section.getFirstToken().getStr().toUpperCase()];
|
|
54671
|
+
if (following === undefined) {
|
|
54672
|
+
return;
|
|
54673
|
+
}
|
|
54674
|
+
// undefined: no parameter before in this section, true: the one before has OPTIONAL or DEFAULT
|
|
54675
|
+
let previousHasAddition = undefined;
|
|
54676
|
+
for (const child of section.getChildren()) {
|
|
54677
|
+
if (!(child instanceof nodes_1.ExpressionNode)) {
|
|
54678
|
+
continue;
|
|
54679
|
+
}
|
|
54680
|
+
let param = undefined;
|
|
54681
|
+
let optional = false;
|
|
54682
|
+
if (child.get() instanceof Expressions.MethodParamOptional) {
|
|
54683
|
+
param = child.findDirectExpression(Expressions.MethodParam);
|
|
54684
|
+
optional = child.findDirectTokenByText("OPTIONAL") !== undefined;
|
|
54685
|
+
}
|
|
54686
|
+
else if (child.get() instanceof Expressions.MethodParam) {
|
|
54687
|
+
param = child;
|
|
54688
|
+
}
|
|
54689
|
+
else if (child.get() instanceof Expressions.MethodParamName) {
|
|
54690
|
+
// "TYPE ANY STRUCTURE", not measured, so never reported after it
|
|
54691
|
+
previousHasAddition = true;
|
|
54692
|
+
continue;
|
|
54693
|
+
}
|
|
54694
|
+
if (param === undefined) {
|
|
54695
|
+
continue;
|
|
54696
|
+
}
|
|
54697
|
+
const first = param.getFirstToken();
|
|
54698
|
+
const name = first.getStr().toUpperCase();
|
|
54699
|
+
if (((_a = param.getChildren()[0]) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.MethodParamName) {
|
|
54700
|
+
let readAs = undefined;
|
|
54701
|
+
if (following.includes(name)) {
|
|
54702
|
+
readAs = "the " + (name === "PREFERRED" ? "PREFERRED PARAMETER" : name) + " addition";
|
|
54703
|
+
}
|
|
54704
|
+
else if ((name === "DEFAULT" || name === "OPTIONAL") && previousHasAddition === false) {
|
|
54705
|
+
readAs = "the " + name + " addition of the parameter before it";
|
|
54706
|
+
}
|
|
54707
|
+
if (readAs !== undefined) {
|
|
54708
|
+
const message = "Parameter \"" + first.getStr() + "\" is read as " + readAs + ", rename it or escape it as !" + first.getStr();
|
|
54709
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, first, message));
|
|
54710
|
+
}
|
|
54711
|
+
}
|
|
54712
|
+
previousHasAddition = optional || param.findFirstExpression(Expressions.Default) !== undefined;
|
|
54713
|
+
}
|
|
54714
|
+
}
|
|
54590
54715
|
isPassByValue(param) {
|
|
54591
54716
|
var _a;
|
|
54592
54717
|
// "!" is the identifier escape, generated code has eg. "IMPORTING !VALUE(iv_foo)"
|
|
@@ -63395,6 +63520,8 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
63395
63520
|
super(...arguments);
|
|
63396
63521
|
this.parserError = undefined;
|
|
63397
63522
|
this.parsedData = undefined;
|
|
63523
|
+
this.typeCache = undefined;
|
|
63524
|
+
this.typeCacheData = undefined;
|
|
63398
63525
|
}
|
|
63399
63526
|
getType() {
|
|
63400
63527
|
return "DDLS";
|
|
@@ -63422,7 +63549,11 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
63422
63549
|
}
|
|
63423
63550
|
parseType(reg) {
|
|
63424
63551
|
this.parse();
|
|
63425
|
-
|
|
63552
|
+
if (this.typeCache === undefined || this.typeCacheData !== this.parsedData) {
|
|
63553
|
+
this.typeCacheData = this.parsedData;
|
|
63554
|
+
this.typeCache = new cds_determine_types_1.CDSDetermineTypes().parseType(reg, this.parsedData, this.getName());
|
|
63555
|
+
}
|
|
63556
|
+
return this.typeCache;
|
|
63426
63557
|
}
|
|
63427
63558
|
getParsedData() {
|
|
63428
63559
|
return this.parsedData;
|
|
@@ -63434,6 +63565,8 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
63434
63565
|
}
|
|
63435
63566
|
setDirty() {
|
|
63436
63567
|
this.parsedData = undefined;
|
|
63568
|
+
this.typeCache = undefined;
|
|
63569
|
+
this.typeCacheData = undefined;
|
|
63437
63570
|
this.parserError = undefined;
|
|
63438
63571
|
super.setDirty();
|
|
63439
63572
|
}
|
|
@@ -70708,7 +70841,7 @@ class Registry {
|
|
|
70708
70841
|
}
|
|
70709
70842
|
static abaplintVersion() {
|
|
70710
70843
|
// magic, see build script "version.js"
|
|
70711
|
-
return "2.120.
|
|
70844
|
+
return "2.120.74";
|
|
70712
70845
|
}
|
|
70713
70846
|
getDDICReferences() {
|
|
70714
70847
|
return this.ddicReferences;
|
|
@@ -83493,6 +83626,102 @@ exports.FunctionalWriting = FunctionalWriting;
|
|
|
83493
83626
|
|
|
83494
83627
|
/***/ },
|
|
83495
83628
|
|
|
83629
|
+
/***/ "../core/build/src/rules/generic_regex.js"
|
|
83630
|
+
/*!************************************************!*\
|
|
83631
|
+
!*** ../core/build/src/rules/generic_regex.js ***!
|
|
83632
|
+
\************************************************/
|
|
83633
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
83634
|
+
|
|
83635
|
+
"use strict";
|
|
83636
|
+
|
|
83637
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
83638
|
+
exports.GenericRegex = exports.GenericRegexConf = void 0;
|
|
83639
|
+
const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
|
|
83640
|
+
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
|
|
83641
|
+
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
83642
|
+
class GenericRegexConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
83643
|
+
constructor() {
|
|
83644
|
+
super(...arguments);
|
|
83645
|
+
/** List of forbidden regular expressions, case insensitive, checked against each line of every file.
|
|
83646
|
+
* Patterns use JavaScript regex syntax without enclosing slashes or flags.
|
|
83647
|
+
* @uniqueItems true
|
|
83648
|
+
*/
|
|
83649
|
+
this.regexes = [];
|
|
83650
|
+
}
|
|
83651
|
+
}
|
|
83652
|
+
exports.GenericRegexConf = GenericRegexConf;
|
|
83653
|
+
class GenericRegex {
|
|
83654
|
+
constructor() {
|
|
83655
|
+
this.conf = new GenericRegexConf();
|
|
83656
|
+
this.regexes = [];
|
|
83657
|
+
}
|
|
83658
|
+
getMetadata() {
|
|
83659
|
+
return {
|
|
83660
|
+
key: "generic_regex",
|
|
83661
|
+
title: "Generic regex",
|
|
83662
|
+
shortDescription: "Report an issue for each match of a configured regular expression.",
|
|
83663
|
+
extendedInformation: `Checks each line of every object file, including comments, strings, and XML.
|
|
83664
|
+
Patterns use JavaScript regular expression syntax without enclosing slashes or flags.
|
|
83665
|
+
Matching is case insensitive and does not span multiple lines. Each non-overlapping match is reported.
|
|
83666
|
+
Use the standard exclude configuration to skip files.
|
|
83667
|
+
|
|
83668
|
+
Example configuration: \`{"generic_regex": {"regexes": ["TODO", "BREAK-POINT"]}}\``,
|
|
83669
|
+
tags: [_irule_1.RuleTag.SingleFile],
|
|
83670
|
+
};
|
|
83671
|
+
}
|
|
83672
|
+
getConfig() {
|
|
83673
|
+
return this.conf;
|
|
83674
|
+
}
|
|
83675
|
+
setConfig(conf) {
|
|
83676
|
+
var _a;
|
|
83677
|
+
this.conf = Object.assign(new GenericRegexConf(), conf);
|
|
83678
|
+
this.conf.regexes = (_a = this.conf.regexes) !== null && _a !== void 0 ? _a : [];
|
|
83679
|
+
}
|
|
83680
|
+
initialize(_reg) {
|
|
83681
|
+
this.regexes = this.conf.regexes.map(pattern => {
|
|
83682
|
+
try {
|
|
83683
|
+
return new RegExp(pattern, "gi");
|
|
83684
|
+
}
|
|
83685
|
+
catch (_a) {
|
|
83686
|
+
throw new Error(`generic_regex: Invalid regular expression "${pattern}"`);
|
|
83687
|
+
}
|
|
83688
|
+
});
|
|
83689
|
+
return this;
|
|
83690
|
+
}
|
|
83691
|
+
run(obj) {
|
|
83692
|
+
const issues = [];
|
|
83693
|
+
if (this.regexes.length === 0) {
|
|
83694
|
+
return issues;
|
|
83695
|
+
}
|
|
83696
|
+
for (const file of obj.getFiles()) {
|
|
83697
|
+
const rows = file.getRawRows();
|
|
83698
|
+
for (let row = 0; row < rows.length; row++) {
|
|
83699
|
+
const text = rows[row].replace(/\r$/, "");
|
|
83700
|
+
for (const regex of this.regexes) {
|
|
83701
|
+
regex.lastIndex = 0;
|
|
83702
|
+
for (;;) {
|
|
83703
|
+
const match = regex.exec(text);
|
|
83704
|
+
if (match === null) {
|
|
83705
|
+
break;
|
|
83706
|
+
}
|
|
83707
|
+
const startCol = match.index + 1;
|
|
83708
|
+
const message = `Text matches forbidden regular expression "${regex.source}"`;
|
|
83709
|
+
issues.push(issue_1.Issue.atRowRange(file, row + 1, startCol, startCol + match[0].length, message, this.getMetadata().key, this.conf.severity));
|
|
83710
|
+
if (match[0].length === 0) {
|
|
83711
|
+
regex.lastIndex++;
|
|
83712
|
+
}
|
|
83713
|
+
}
|
|
83714
|
+
}
|
|
83715
|
+
}
|
|
83716
|
+
}
|
|
83717
|
+
return issues;
|
|
83718
|
+
}
|
|
83719
|
+
}
|
|
83720
|
+
exports.GenericRegex = GenericRegex;
|
|
83721
|
+
//# sourceMappingURL=generic_regex.js.map
|
|
83722
|
+
|
|
83723
|
+
/***/ },
|
|
83724
|
+
|
|
83496
83725
|
/***/ "../core/build/src/rules/global_class.js"
|
|
83497
83726
|
/*!***********************************************!*\
|
|
83498
83727
|
!*** ../core/build/src/rules/global_class.js ***!
|
|
@@ -85407,6 +85636,7 @@ __exportStar(__webpack_require__(/*! ./fully_type_constants */ "../core/build/sr
|
|
|
85407
85636
|
__exportStar(__webpack_require__(/*! ./fully_type_itabs */ "../core/build/src/rules/fully_type_itabs.js"), exports);
|
|
85408
85637
|
__exportStar(__webpack_require__(/*! ./function_module_recommendations */ "../core/build/src/rules/function_module_recommendations.js"), exports);
|
|
85409
85638
|
__exportStar(__webpack_require__(/*! ./functional_writing */ "../core/build/src/rules/functional_writing.js"), exports);
|
|
85639
|
+
__exportStar(__webpack_require__(/*! ./generic_regex */ "../core/build/src/rules/generic_regex.js"), exports);
|
|
85410
85640
|
__exportStar(__webpack_require__(/*! ./global_class */ "../core/build/src/rules/global_class.js"), exports);
|
|
85411
85641
|
__exportStar(__webpack_require__(/*! ./identical_conditions */ "../core/build/src/rules/identical_conditions.js"), exports);
|
|
85412
85642
|
__exportStar(__webpack_require__(/*! ./identical_contents */ "../core/build/src/rules/identical_contents.js"), exports);
|
|
@@ -89841,6 +90071,31 @@ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "..
|
|
|
89841
90071
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
89842
90072
|
const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
|
|
89843
90073
|
const tokens_1 = __webpack_require__(/*! ../abap/1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
|
|
90074
|
+
const artifacts_1 = __webpack_require__(/*! ../abap/artifacts */ "../core/build/src/abap/artifacts.js");
|
|
90075
|
+
const combi_1 = __webpack_require__(/*! ../abap/2_statements/combi */ "../core/build/src/abap/2_statements/combi.js");
|
|
90076
|
+
let keywords = undefined;
|
|
90077
|
+
/** every word of the statement and expression grammar, upper case */
|
|
90078
|
+
function getKeywords() {
|
|
90079
|
+
if (keywords === undefined) {
|
|
90080
|
+
const list = [];
|
|
90081
|
+
for (const stat of artifacts_1.ArtifactsABAP.getStatements()) {
|
|
90082
|
+
list.push(...combi_1.Combi.listKeywords(stat.getMatcher()));
|
|
90083
|
+
}
|
|
90084
|
+
for (const expr of artifacts_1.ArtifactsABAP.getExpressions()) {
|
|
90085
|
+
list.push(...combi_1.Combi.listKeywords(new expr().getRunnable()));
|
|
90086
|
+
}
|
|
90087
|
+
keywords = new Set();
|
|
90088
|
+
for (const words of list) {
|
|
90089
|
+
// a WordSequence lists eg. "PREFERRED PARAMETER" or "IS-INITIAL" as one entry
|
|
90090
|
+
for (const word of words.replace(/-/g, " ").split(" ")) {
|
|
90091
|
+
if (word !== "") {
|
|
90092
|
+
keywords.add(word.toUpperCase());
|
|
90093
|
+
}
|
|
90094
|
+
}
|
|
90095
|
+
}
|
|
90096
|
+
}
|
|
90097
|
+
return keywords;
|
|
90098
|
+
}
|
|
89844
90099
|
class NoExclamationEscapeConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
89845
90100
|
}
|
|
89846
90101
|
exports.NoExclamationEscapeConf = NoExclamationEscapeConf;
|
|
@@ -89854,8 +90109,10 @@ class NoExclamationEscape extends _abap_rule_1.ABAPRule {
|
|
|
89854
90109
|
key: "no_exclamation_escape",
|
|
89855
90110
|
title: "No exclamation escape",
|
|
89856
90111
|
shortDescription: `Detects and removes exclamation marks (!) used to escape identifiers`,
|
|
89857
|
-
|
|
89858
|
-
|
|
90112
|
+
extendedInformation: `Exclamation marks are not needed when the identifier is not a keyword, or could be avoided by renaming.
|
|
90113
|
+
|
|
90114
|
+
An identifier named like an ABAP keyword is allowed to be escaped, eg. a method parameter "!default",
|
|
90115
|
+
which the system otherwise reads as the DEFAULT addition of the parameter before it.`,
|
|
89859
90116
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
|
|
89860
90117
|
badExample: "methods CONVERT changing !CO_sdf type ref to ZCL_sdf optional.",
|
|
89861
90118
|
goodExample: "methods CONVERT changing CO_sdf type ref to ZCL_sdf optional.",
|
|
@@ -89874,6 +90131,9 @@ class NoExclamationEscape extends _abap_rule_1.ABAPRule {
|
|
|
89874
90131
|
const str = token.getStr();
|
|
89875
90132
|
if (str.startsWith("!")) {
|
|
89876
90133
|
const replacement = str.substring(1);
|
|
90134
|
+
if (getKeywords().has(replacement.toUpperCase())) {
|
|
90135
|
+
continue;
|
|
90136
|
+
}
|
|
89877
90137
|
const fix = edit_helper_1.EditHelper.replaceToken(file, token, replacement);
|
|
89878
90138
|
issues.push(issue_1.Issue.atToken(file, token, "Do not use exclamation mark to escape identifiers", this.getMetadata().key, this.conf.severity, fix));
|
|
89879
90139
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.120.
|
|
3
|
+
"version": "2.120.74",
|
|
4
4
|
"description": "abaplint - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://abaplint.org",
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@abaplint/core": "^2.120.
|
|
42
|
+
"@abaplint/core": "^2.120.74",
|
|
43
43
|
"@types/chai": "^4.3.20",
|
|
44
44
|
"@types/minimist": "^1.2.5",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|