@abaplint/cli 2.120.77 → 2.120.79
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 +666 -32
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -3083,7 +3083,7 @@ class ExpandMacros {
|
|
|
3083
3083
|
listMacroNames() {
|
|
3084
3084
|
return this.macros.listMacroNames();
|
|
3085
3085
|
}
|
|
3086
|
-
find(statements, file, clear = true) {
|
|
3086
|
+
find(statements, file, clear = true, includePath = new Set()) {
|
|
3087
3087
|
var _a, _b, _c;
|
|
3088
3088
|
let nameToken = undefined;
|
|
3089
3089
|
let start = undefined;
|
|
@@ -3104,14 +3104,16 @@ class ExpandMacros {
|
|
|
3104
3104
|
else if (type instanceof Statements.Include) {
|
|
3105
3105
|
const includeName = (_b = statement.findDirectExpression(Expressions.IncludeName)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
3106
3106
|
// todo, this does not take function module includes into account
|
|
3107
|
-
// todo, workaround for cyclic includes?
|
|
3108
3107
|
const prog = (_c = this.reg) === null || _c === void 0 ? void 0 : _c.getObject("PROG", includeName);
|
|
3109
3108
|
if (prog) {
|
|
3110
3109
|
prog.parse(this.release, this.globalMacros, this.reg, this.languageVersion);
|
|
3111
3110
|
const includeMainFile = prog.getMainABAPFile();
|
|
3112
|
-
|
|
3111
|
+
// an include that is already on the current include path is not walked again
|
|
3112
|
+
if (includeMainFile && includePath.has(includeMainFile.getFilename()) === false) {
|
|
3113
|
+
includePath.add(includeMainFile.getFilename());
|
|
3113
3114
|
// slow, this copies everything,
|
|
3114
|
-
this.find([...includeMainFile.getStatements()], includeMainFile, false);
|
|
3115
|
+
this.find([...includeMainFile.getStatements()], includeMainFile, false, includePath);
|
|
3116
|
+
includePath.delete(includeMainFile.getFilename());
|
|
3115
3117
|
}
|
|
3116
3118
|
}
|
|
3117
3119
|
}
|
|
@@ -13366,11 +13368,11 @@ class Convert {
|
|
|
13366
13368
|
const dat = (0, combi_1.seq)("DATE", expressions_1.Source);
|
|
13367
13369
|
const tim = (0, combi_1.seq)("TIME", expressions_1.Source);
|
|
13368
13370
|
const stamp = (0, combi_1.seq)("INTO TIME STAMP", expressions_1.Target);
|
|
13369
|
-
const intoutc = (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("INTO UTCLONG", expressions_1.Target));
|
|
13371
|
+
const intoutc = (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("INTO UTCLONG", expressions_1.Target), { also: combi_1.AlsoIn.OpenABAP });
|
|
13370
13372
|
const invert = (0, combi_1.seq)("INTO INVERTED-DATE", expressions_1.Target);
|
|
13371
13373
|
const date = (0, combi_1.seq)((0, combi_1.per)(dat, tim), (0, combi_1.per)(daylightSource, stamp, zone, invert, intoutc));
|
|
13372
13374
|
const inv = (0, combi_1.seq)("INVERTED-DATE", expressions_1.Source, "INTO DATE", expressions_1.Target);
|
|
13373
|
-
const utclong = (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("UTCLONG", expressions_1.Source, (0, combi_1.per)(zone, into,
|
|
13375
|
+
const utclong = (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("UTCLONG", expressions_1.Source, (0, combi_1.per)(zone, into, daylightTarget)), { also: combi_1.AlsoIn.OpenABAP });
|
|
13374
13376
|
return (0, combi_1.seq)("CONVERT", (0, combi_1.alt)(time, date, inv, utclong));
|
|
13375
13377
|
}
|
|
13376
13378
|
}
|
|
@@ -26065,9 +26067,9 @@ BuiltIn.methods = {
|
|
|
26065
26067
|
},
|
|
26066
26068
|
optional: {
|
|
26067
26069
|
"days": basic_1.IntegerType.get(),
|
|
26068
|
-
"
|
|
26069
|
-
"minutes": basic_1.
|
|
26070
|
-
"seconds": new basic_1.
|
|
26070
|
+
"hours": basic_1.IntegerType.get(),
|
|
26071
|
+
"minutes": new basic_1.Integer8Type(),
|
|
26072
|
+
"seconds": new basic_1.DecFloat34Type(),
|
|
26071
26073
|
},
|
|
26072
26074
|
return: new basic_1.UTCLongType(),
|
|
26073
26075
|
release: version_1.Release.v754,
|
|
@@ -26083,7 +26085,7 @@ BuiltIn.methods = {
|
|
|
26083
26085
|
"high": new basic_1.UTCLongType(),
|
|
26084
26086
|
"low": new basic_1.UTCLongType(),
|
|
26085
26087
|
},
|
|
26086
|
-
return: new basic_1.
|
|
26088
|
+
return: new basic_1.DecFloat34Type(),
|
|
26087
26089
|
release: version_1.Release.v754,
|
|
26088
26090
|
},
|
|
26089
26091
|
"XSDBOOL": {
|
|
@@ -27435,7 +27437,12 @@ class Procedural {
|
|
|
27435
27437
|
this.scope = scope;
|
|
27436
27438
|
this.reg = reg;
|
|
27437
27439
|
}
|
|
27438
|
-
addAllFormDefinitions(file, obj) {
|
|
27440
|
+
addAllFormDefinitions(file, obj, visited = new Set()) {
|
|
27441
|
+
// an include reached again through a cycle of INCLUDEs is not walked twice
|
|
27442
|
+
if (visited.has(file.getFilename())) {
|
|
27443
|
+
return;
|
|
27444
|
+
}
|
|
27445
|
+
visited.add(file.getFilename());
|
|
27439
27446
|
const structure = file.getStructure();
|
|
27440
27447
|
if (structure) {
|
|
27441
27448
|
const input = {
|
|
@@ -27456,12 +27463,12 @@ class Procedural {
|
|
|
27456
27463
|
for (const node of includes) {
|
|
27457
27464
|
const found = this.findInclude(node, obj);
|
|
27458
27465
|
if (found) {
|
|
27459
|
-
this.addAllFormDefinitions(found, obj);
|
|
27466
|
+
this.addAllFormDefinitions(found, obj, visited);
|
|
27460
27467
|
}
|
|
27461
27468
|
}
|
|
27462
27469
|
}
|
|
27463
27470
|
findInclude(node, obj) {
|
|
27464
|
-
//
|
|
27471
|
+
// cyclic includes are cut by the callers, includes not found are reported by rule "check_include"
|
|
27465
27472
|
// todo: how to make sure code is not duplicated here and in rule "check_include" / include graph?
|
|
27466
27473
|
const expr = node.findFirstExpression(Expressions.IncludeName);
|
|
27467
27474
|
if (expr === undefined) {
|
|
@@ -30131,7 +30138,11 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/bui
|
|
|
30131
30138
|
// On a character or byte field of fixed length the substring must lie inside the field, else it is
|
|
30132
30139
|
// a syntax error. Other types, a dynamic offset or length and "*" (undefined) are left alone, as is
|
|
30133
30140
|
// length 0. The offset is applied first, so the length is compared to what remains after the offset.
|
|
30141
|
+
// A substring of a date, time or numeric text field has type n; its bounds are not checked.
|
|
30134
30142
|
function substringType(context, offset, length, node, input) {
|
|
30143
|
+
if (context instanceof basic_1.DateType || context instanceof basic_1.TimeType || context instanceof basic_1.NumericType) {
|
|
30144
|
+
return numericSubstringType(context, offset, length);
|
|
30145
|
+
}
|
|
30135
30146
|
if (!(context instanceof basic_1.CharacterType) && !(context instanceof basic_1.HexType)) {
|
|
30136
30147
|
return context;
|
|
30137
30148
|
}
|
|
@@ -30154,6 +30165,24 @@ function substringType(context, offset, length, node, input) {
|
|
|
30154
30165
|
}
|
|
30155
30166
|
return context;
|
|
30156
30167
|
}
|
|
30168
|
+
function numericSubstringType(context, offset, length) {
|
|
30169
|
+
const hasOffset = offset !== undefined && offset > 0;
|
|
30170
|
+
const hasLength = length !== undefined && length > 0;
|
|
30171
|
+
if (hasOffset === false && hasLength === false) {
|
|
30172
|
+
return context;
|
|
30173
|
+
}
|
|
30174
|
+
let remaining = context instanceof basic_1.DateType ? 8 : context instanceof basic_1.TimeType ? 6 : context.getLength();
|
|
30175
|
+
if (hasOffset) {
|
|
30176
|
+
remaining = remaining - offset;
|
|
30177
|
+
}
|
|
30178
|
+
if (hasLength) {
|
|
30179
|
+
remaining = Math.min(remaining, length);
|
|
30180
|
+
}
|
|
30181
|
+
if (remaining <= 0) {
|
|
30182
|
+
return context;
|
|
30183
|
+
}
|
|
30184
|
+
return new basic_1.NumericType(remaining);
|
|
30185
|
+
}
|
|
30157
30186
|
// A field symbol typed "c" or "x" is generic, but its type is represented with length 1, so the
|
|
30158
30187
|
// offset or length at "index" is not checked when it directly follows the field symbol
|
|
30159
30188
|
function isFieldSymbolItself(children, index) {
|
|
@@ -40286,6 +40315,16 @@ class Convert {
|
|
|
40286
40315
|
target_1.Target.runSyntax(stampTarget, input);
|
|
40287
40316
|
}
|
|
40288
40317
|
}
|
|
40318
|
+
const utclongTarget = node.findExpressionAfterToken("UTCLONG");
|
|
40319
|
+
if ((utclongTarget === null || utclongTarget === void 0 ? void 0 : utclongTarget.get()) instanceof Expressions.Target) {
|
|
40320
|
+
const inline = utclongTarget === null || utclongTarget === void 0 ? void 0 : utclongTarget.findDirectExpression(Expressions.InlineData);
|
|
40321
|
+
if (inline) {
|
|
40322
|
+
inline_data_1.InlineData.runSyntax(inline, input, new basic_1.UTCLongType());
|
|
40323
|
+
}
|
|
40324
|
+
else {
|
|
40325
|
+
target_1.Target.runSyntax(utclongTarget, input);
|
|
40326
|
+
}
|
|
40327
|
+
}
|
|
40289
40328
|
}
|
|
40290
40329
|
}
|
|
40291
40330
|
exports.Convert = Convert;
|
|
@@ -49806,6 +49845,8 @@ if (Object.keys(map).length === 0) {
|
|
|
49806
49845
|
// -----------------------------------
|
|
49807
49846
|
class SyntaxLogic {
|
|
49808
49847
|
constructor(reg, object) {
|
|
49848
|
+
// files the traversal walked into through INCLUDEs, outermost first
|
|
49849
|
+
this.includeStack = [];
|
|
49809
49850
|
this.reg = reg;
|
|
49810
49851
|
this.issues = [];
|
|
49811
49852
|
this.deferred = [];
|
|
@@ -49913,11 +49954,20 @@ class SyntaxLogic {
|
|
|
49913
49954
|
// walk into INCLUDEs
|
|
49914
49955
|
if (isStatement && child.get() instanceof Statements.Include) {
|
|
49915
49956
|
const file = this.helpers.proc.findInclude(child, this.object);
|
|
49916
|
-
|
|
49957
|
+
// an INCLUDE that leads back to a file already being walked is not followed again
|
|
49958
|
+
const cyclic = file !== undefined && (file.getFilename() === this.currentFile.getFilename()
|
|
49959
|
+
|| this.includeStack.includes(file.getFilename()));
|
|
49960
|
+
if (file !== undefined && file.getStructure() !== undefined && cyclic === false) {
|
|
49917
49961
|
const old = this.currentFile;
|
|
49962
|
+
this.includeStack.push(old.getFilename());
|
|
49918
49963
|
this.currentFile = file;
|
|
49919
|
-
|
|
49920
|
-
|
|
49964
|
+
try {
|
|
49965
|
+
this.traverse(file.getStructure());
|
|
49966
|
+
}
|
|
49967
|
+
finally {
|
|
49968
|
+
this.currentFile = old;
|
|
49969
|
+
this.includeStack.pop();
|
|
49970
|
+
}
|
|
49921
49971
|
}
|
|
49922
49972
|
}
|
|
49923
49973
|
if (isStructure || isStatement) {
|
|
@@ -50327,11 +50377,46 @@ exports.ArtifactsABAP = ArtifactsABAP;
|
|
|
50327
50377
|
|
|
50328
50378
|
"use strict";
|
|
50329
50379
|
|
|
50380
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
50381
|
+
if (k2 === undefined) k2 = k;
|
|
50382
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
50383
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
50384
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
50385
|
+
}
|
|
50386
|
+
Object.defineProperty(o, k2, desc);
|
|
50387
|
+
}) : (function(o, m, k, k2) {
|
|
50388
|
+
if (k2 === undefined) k2 = k;
|
|
50389
|
+
o[k2] = m[k];
|
|
50390
|
+
}));
|
|
50391
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
50392
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
50393
|
+
}) : function(o, v) {
|
|
50394
|
+
o["default"] = v;
|
|
50395
|
+
});
|
|
50396
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
50397
|
+
var ownKeys = function(o) {
|
|
50398
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
50399
|
+
var ar = [];
|
|
50400
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50401
|
+
return ar;
|
|
50402
|
+
};
|
|
50403
|
+
return ownKeys(o);
|
|
50404
|
+
};
|
|
50405
|
+
return function (mod) {
|
|
50406
|
+
if (mod && mod.__esModule) return mod;
|
|
50407
|
+
var result = {};
|
|
50408
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
50409
|
+
__setModuleDefault(result, mod);
|
|
50410
|
+
return result;
|
|
50411
|
+
};
|
|
50412
|
+
})();
|
|
50330
50413
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
50331
50414
|
exports.CrossIncludeMacros = void 0;
|
|
50332
50415
|
const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
|
|
50333
50416
|
const program_1 = __webpack_require__(/*! ../objects/program */ "../core/build/src/objects/program.js");
|
|
50334
50417
|
const _statement_1 = __webpack_require__(/*! ./2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
|
|
50418
|
+
const statements_1 = __webpack_require__(/*! ./2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js");
|
|
50419
|
+
const Expressions = __importStar(__webpack_require__(/*! ./2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
50335
50420
|
const expand_macros_1 = __webpack_require__(/*! ./2_statements/expand_macros */ "../core/build/src/abap/2_statements/expand_macros.js");
|
|
50336
50421
|
const include_graph_1 = __webpack_require__(/*! ../utils/include_graph */ "../core/build/src/utils/include_graph.js");
|
|
50337
50422
|
// Macros can be defined in one include and used in a sibling include, connected
|
|
@@ -50344,6 +50429,7 @@ class CrossIncludeMacros {
|
|
|
50344
50429
|
this.reg = reg;
|
|
50345
50430
|
}
|
|
50346
50431
|
run() {
|
|
50432
|
+
this.reparseCyclicPrograms();
|
|
50347
50433
|
const candidates = this.findCandidates();
|
|
50348
50434
|
if (candidates.length === 0) {
|
|
50349
50435
|
return;
|
|
@@ -50371,6 +50457,45 @@ class CrossIncludeMacros {
|
|
|
50371
50457
|
}
|
|
50372
50458
|
}
|
|
50373
50459
|
//////////////////////////////
|
|
50460
|
+
// A program or include in an INCLUDE cycle can be parsed while the include defining its macros is still
|
|
50461
|
+
// being parsed, depending on the order the files were added. Everything is parsed now, so parse it again.
|
|
50462
|
+
reparseCyclicPrograms() {
|
|
50463
|
+
const config = this.reg.getConfig();
|
|
50464
|
+
for (const obj of this.reg.getObjects()) {
|
|
50465
|
+
if (obj instanceof program_1.Program && this.hasUnknown(obj) && this.isInIncludeCycle(obj)) {
|
|
50466
|
+
obj.setDirty();
|
|
50467
|
+
obj.parse(config.getRelease(), config.getSyntaxSetttings().globalMacros, this.reg, config.getLanguageVersion());
|
|
50468
|
+
}
|
|
50469
|
+
}
|
|
50470
|
+
}
|
|
50471
|
+
hasUnknown(prog) {
|
|
50472
|
+
return prog.getABAPFiles().some(f => f.getStatements().some(s => s.get() instanceof _statement_1.Unknown));
|
|
50473
|
+
}
|
|
50474
|
+
// the include graph does not link INCLUDEs of main programs, so follow the INCLUDEs from the program
|
|
50475
|
+
isInIncludeCycle(prog) {
|
|
50476
|
+
var _a;
|
|
50477
|
+
const seen = new Set();
|
|
50478
|
+
const stack = [prog];
|
|
50479
|
+
while (stack.length > 0) {
|
|
50480
|
+
for (const file of stack.pop().getABAPFiles()) {
|
|
50481
|
+
for (const statement of file.getStatements()) {
|
|
50482
|
+
if (!(statement.get() instanceof statements_1.Include)) {
|
|
50483
|
+
continue;
|
|
50484
|
+
}
|
|
50485
|
+
const name = (_a = statement.findDirectExpression(Expressions.IncludeName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
50486
|
+
const included = this.reg.getObject("PROG", name);
|
|
50487
|
+
if (included === prog) {
|
|
50488
|
+
return true;
|
|
50489
|
+
}
|
|
50490
|
+
else if (included instanceof program_1.Program && seen.has(included) === false) {
|
|
50491
|
+
seen.add(included);
|
|
50492
|
+
stack.push(included);
|
|
50493
|
+
}
|
|
50494
|
+
}
|
|
50495
|
+
}
|
|
50496
|
+
}
|
|
50497
|
+
return false;
|
|
50498
|
+
}
|
|
50374
50499
|
findCandidates() {
|
|
50375
50500
|
const ret = [];
|
|
50376
50501
|
for (const obj of this.reg.getObjects()) {
|
|
@@ -62144,6 +62269,7 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
|
|
|
62144
62269
|
}
|
|
62145
62270
|
constructor(name) {
|
|
62146
62271
|
super(name);
|
|
62272
|
+
this.parsing = false;
|
|
62147
62273
|
this.parsed = [];
|
|
62148
62274
|
this.texts = undefined;
|
|
62149
62275
|
this.rawXMLCache = undefined;
|
|
@@ -62152,11 +62278,19 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
|
|
|
62152
62278
|
return !!x && x instanceof ABAPObject;
|
|
62153
62279
|
}
|
|
62154
62280
|
parse(release, globalMacros, reg, languageVersion = version_1.LanguageVersion.Normal) {
|
|
62155
|
-
|
|
62281
|
+
// an INCLUDE that leads back to this object while it is being parsed is not followed again
|
|
62282
|
+
if (this.isDirty() === false || this.parsing === true) {
|
|
62156
62283
|
return { updated: false, runtime: 0 };
|
|
62157
62284
|
}
|
|
62158
62285
|
const abapFiles = this.getFiles().filter(f => f.getFilename().endsWith(".abap"));
|
|
62159
|
-
|
|
62286
|
+
let result;
|
|
62287
|
+
this.parsing = true;
|
|
62288
|
+
try {
|
|
62289
|
+
result = new abap_parser_1.ABAPParser({ release, globalMacros, reg, languageVersion }).parse(abapFiles);
|
|
62290
|
+
}
|
|
62291
|
+
finally {
|
|
62292
|
+
this.parsing = false;
|
|
62293
|
+
}
|
|
62160
62294
|
this.parsed = result.output;
|
|
62161
62295
|
this.old = result.issues;
|
|
62162
62296
|
this.dirty = false;
|
|
@@ -71373,7 +71507,7 @@ class Registry {
|
|
|
71373
71507
|
}
|
|
71374
71508
|
static abaplintVersion() {
|
|
71375
71509
|
// magic, see build script "version.js"
|
|
71376
|
-
return "2.120.
|
|
71510
|
+
return "2.120.79";
|
|
71377
71511
|
}
|
|
71378
71512
|
getDDICReferences() {
|
|
71379
71513
|
return this.ddicReferences;
|
|
@@ -87122,6 +87256,7 @@ __exportStar(__webpack_require__(/*! ./inline_data_old_versions */ "../core/buil
|
|
|
87122
87256
|
__exportStar(__webpack_require__(/*! ./inline_packed_computation */ "../core/build/src/rules/inline_packed_computation.js"), exports);
|
|
87123
87257
|
__exportStar(__webpack_require__(/*! ./intf_referencing_clas */ "../core/build/src/rules/intf_referencing_clas.js"), exports);
|
|
87124
87258
|
__exportStar(__webpack_require__(/*! ./invalid_table_index */ "../core/build/src/rules/invalid_table_index.js"), exports);
|
|
87259
|
+
__exportStar(__webpack_require__(/*! ./is_assigned_in_loop */ "../core/build/src/rules/is_assigned_in_loop.js"), exports);
|
|
87125
87260
|
__exportStar(__webpack_require__(/*! ./keep_single_parameter_on_one_line */ "../core/build/src/rules/keep_single_parameter_on_one_line.js"), exports);
|
|
87126
87261
|
__exportStar(__webpack_require__(/*! ./keyword_case */ "../core/build/src/rules/keyword_case.js"), exports);
|
|
87127
87262
|
__exportStar(__webpack_require__(/*! ./line_break_multiple_parameters */ "../core/build/src/rules/line_break_multiple_parameters.js"), exports);
|
|
@@ -87187,6 +87322,7 @@ __exportStar(__webpack_require__(/*! ./prefix_is_current_class */ "../core/build
|
|
|
87187
87322
|
__exportStar(__webpack_require__(/*! ./range_row_values */ "../core/build/src/rules/range_row_values.js"), exports);
|
|
87188
87323
|
__exportStar(__webpack_require__(/*! ./reduce_procedural_code */ "../core/build/src/rules/reduce_procedural_code.js"), exports);
|
|
87189
87324
|
__exportStar(__webpack_require__(/*! ./reduce_string_templates */ "../core/build/src/rules/reduce_string_templates.js"), exports);
|
|
87325
|
+
__exportStar(__webpack_require__(/*! ./redundant_cast */ "../core/build/src/rules/redundant_cast.js"), exports);
|
|
87190
87326
|
__exportStar(__webpack_require__(/*! ./redundant_conversion */ "../core/build/src/rules/redundant_conversion.js"), exports);
|
|
87191
87327
|
__exportStar(__webpack_require__(/*! ./release_idoc */ "../core/build/src/rules/release_idoc.js"), exports);
|
|
87192
87328
|
__exportStar(__webpack_require__(/*! ./remove_descriptions */ "../core/build/src/rules/remove_descriptions.js"), exports);
|
|
@@ -87871,6 +88007,258 @@ exports.InvalidTableIndex = InvalidTableIndex;
|
|
|
87871
88007
|
|
|
87872
88008
|
/***/ },
|
|
87873
88009
|
|
|
88010
|
+
/***/ "../core/build/src/rules/is_assigned_in_loop.js"
|
|
88011
|
+
/*!******************************************************!*\
|
|
88012
|
+
!*** ../core/build/src/rules/is_assigned_in_loop.js ***!
|
|
88013
|
+
\******************************************************/
|
|
88014
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
88015
|
+
|
|
88016
|
+
"use strict";
|
|
88017
|
+
|
|
88018
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
88019
|
+
if (k2 === undefined) k2 = k;
|
|
88020
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
88021
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
88022
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
88023
|
+
}
|
|
88024
|
+
Object.defineProperty(o, k2, desc);
|
|
88025
|
+
}) : (function(o, m, k, k2) {
|
|
88026
|
+
if (k2 === undefined) k2 = k;
|
|
88027
|
+
o[k2] = m[k];
|
|
88028
|
+
}));
|
|
88029
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
88030
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
88031
|
+
}) : function(o, v) {
|
|
88032
|
+
o["default"] = v;
|
|
88033
|
+
});
|
|
88034
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
88035
|
+
var ownKeys = function(o) {
|
|
88036
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
88037
|
+
var ar = [];
|
|
88038
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
88039
|
+
return ar;
|
|
88040
|
+
};
|
|
88041
|
+
return ownKeys(o);
|
|
88042
|
+
};
|
|
88043
|
+
return function (mod) {
|
|
88044
|
+
if (mod && mod.__esModule) return mod;
|
|
88045
|
+
var result = {};
|
|
88046
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
88047
|
+
__setModuleDefault(result, mod);
|
|
88048
|
+
return result;
|
|
88049
|
+
};
|
|
88050
|
+
})();
|
|
88051
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
88052
|
+
exports.IsAssignedInLoop = exports.IsAssignedInLoopConf = void 0;
|
|
88053
|
+
const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
|
|
88054
|
+
const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
88055
|
+
const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
|
|
88056
|
+
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
|
|
88057
|
+
const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
|
|
88058
|
+
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
88059
|
+
const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
|
|
88060
|
+
const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
|
|
88061
|
+
class IsAssignedInLoopConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
88062
|
+
constructor() {
|
|
88063
|
+
super(...arguments);
|
|
88064
|
+
this.severity = severity_1.Severity.Warning;
|
|
88065
|
+
}
|
|
88066
|
+
}
|
|
88067
|
+
exports.IsAssignedInLoopConf = IsAssignedInLoopConf;
|
|
88068
|
+
class IsAssignedInLoop extends _abap_rule_1.ABAPRule {
|
|
88069
|
+
constructor() {
|
|
88070
|
+
super(...arguments);
|
|
88071
|
+
this.conf = new IsAssignedInLoopConf();
|
|
88072
|
+
}
|
|
88073
|
+
getMetadata() {
|
|
88074
|
+
return {
|
|
88075
|
+
key: "is_assigned_in_loop",
|
|
88076
|
+
title: "IS ASSIGNED after READ TABLE or ASSIGN in a loop",
|
|
88077
|
+
shortDescription: `Reports IS [NOT] ASSIGNED after a READ TABLE ... ASSIGNING or ASSIGN inside a loop, without UNASSIGN before it`,
|
|
88078
|
+
extendedInformation: `A failed READ TABLE ... ASSIGNING or ASSIGN keeps the previous binding of the field symbol. Inside a
|
|
88079
|
+
loop, the field symbol still points to the row of an earlier iteration, so IS ASSIGNED is true
|
|
88080
|
+
although the statement failed, and the code goes on with the wrong row.
|
|
88081
|
+
|
|
88082
|
+
Add UNASSIGN <fs> before the statement, inside the loop, or check sy-subrc after a READ TABLE.
|
|
88083
|
+
The quick fix inserts the UNASSIGN; it is not offered for a field symbol declared inline in
|
|
88084
|
+
the statement, or for a chained statement.
|
|
88085
|
+
|
|
88086
|
+
Not reported: a check that also reads sy-subrc, an ASSIGN that cannot fail (a static source
|
|
88087
|
+
without dereference, table expression or dynamic part), and loops outside of the
|
|
88088
|
+
method, form or function module of the statement. See also subrc_after_assign.`,
|
|
88089
|
+
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
|
|
88090
|
+
badExample: `LOOP AT lt_cells INTO ls_cell.
|
|
88091
|
+
READ TABLE lt_styles ASSIGNING <style> WITH KEY id = ls_cell-style.
|
|
88092
|
+
IF <style> IS ASSIGNED.
|
|
88093
|
+
ls_cell-format = <style>-format.
|
|
88094
|
+
ENDIF.
|
|
88095
|
+
ENDLOOP.`,
|
|
88096
|
+
goodExample: `LOOP AT lt_cells INTO ls_cell.
|
|
88097
|
+
UNASSIGN <style>.
|
|
88098
|
+
READ TABLE lt_styles ASSIGNING <style> WITH KEY id = ls_cell-style.
|
|
88099
|
+
IF <style> IS ASSIGNED.
|
|
88100
|
+
ls_cell-format = <style>-format.
|
|
88101
|
+
ENDIF.
|
|
88102
|
+
ENDLOOP.`,
|
|
88103
|
+
};
|
|
88104
|
+
}
|
|
88105
|
+
getConfig() {
|
|
88106
|
+
return this.conf;
|
|
88107
|
+
}
|
|
88108
|
+
setConfig(conf) {
|
|
88109
|
+
this.conf = conf;
|
|
88110
|
+
}
|
|
88111
|
+
runParsed(file) {
|
|
88112
|
+
const issues = [];
|
|
88113
|
+
const statements = file.getStatements();
|
|
88114
|
+
for (let i = 0; i < statements.length; i++) {
|
|
88115
|
+
const statement = statements[i];
|
|
88116
|
+
const name = this.boundByFailable(statement);
|
|
88117
|
+
if (name === undefined) {
|
|
88118
|
+
continue;
|
|
88119
|
+
}
|
|
88120
|
+
const fs = name.toUpperCase();
|
|
88121
|
+
const loop = this.innermostLoop(i, statements);
|
|
88122
|
+
if (loop === undefined || this.unassignedBefore(loop, i, statements, fs) === true) {
|
|
88123
|
+
continue;
|
|
88124
|
+
}
|
|
88125
|
+
const check = this.nextCheck(i, statements, fs);
|
|
88126
|
+
if (check === undefined) {
|
|
88127
|
+
continue;
|
|
88128
|
+
}
|
|
88129
|
+
const read = statement.get() instanceof Statements.ReadTable;
|
|
88130
|
+
const message = `${read ? "READ TABLE" : "ASSIGN"} in a loop keeps the previous binding of ${name} when it fails, `
|
|
88131
|
+
+ `UNASSIGN ${name} before it` + (read ? " or check sy-subrc" : "");
|
|
88132
|
+
const fix = this.buildFix(file, statement, name);
|
|
88133
|
+
issues.push(issue_1.Issue.atStatement(file, check, message, this.getMetadata().key, this.conf.severity, fix));
|
|
88134
|
+
}
|
|
88135
|
+
return issues;
|
|
88136
|
+
}
|
|
88137
|
+
////////////////
|
|
88138
|
+
/** the field symbol bound by a READ TABLE ... ASSIGNING or an ASSIGN that can fail */
|
|
88139
|
+
boundByFailable(statement) {
|
|
88140
|
+
var _a, _b, _c;
|
|
88141
|
+
const s = statement.get();
|
|
88142
|
+
if (s instanceof Statements.ReadTable) {
|
|
88143
|
+
const target = (_a = statement.findDirectExpression(Expressions.ReadTableTarget)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.FSTarget);
|
|
88144
|
+
return (_b = target === null || target === void 0 ? void 0 : target.findFirstExpression(Expressions.FieldSymbol)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
88145
|
+
}
|
|
88146
|
+
else if (s instanceof Statements.Assign) {
|
|
88147
|
+
const source = statement.findDirectExpression(Expressions.AssignSource);
|
|
88148
|
+
if (source === undefined) {
|
|
88149
|
+
return undefined;
|
|
88150
|
+
}
|
|
88151
|
+
const first = source.getFirstToken().getStr().toUpperCase();
|
|
88152
|
+
const failable = first === "COMPONENT"
|
|
88153
|
+
|| first === "TABLE"
|
|
88154
|
+
|| source.findFirstExpression(Expressions.Dynamic) !== undefined
|
|
88155
|
+
|| source.findFirstExpression(Expressions.Dereference) !== undefined
|
|
88156
|
+
|| source.findFirstExpression(Expressions.TableExpression) !== undefined
|
|
88157
|
+
|| statement.findDirectTokenByText("INCREMENT") !== undefined;
|
|
88158
|
+
if (failable === false) {
|
|
88159
|
+
return undefined;
|
|
88160
|
+
}
|
|
88161
|
+
const target = statement.findDirectExpression(Expressions.FSTarget);
|
|
88162
|
+
return (_c = target === null || target === void 0 ? void 0 : target.findFirstExpression(Expressions.FieldSymbol)) === null || _c === void 0 ? void 0 : _c.concatTokens();
|
|
88163
|
+
}
|
|
88164
|
+
return undefined;
|
|
88165
|
+
}
|
|
88166
|
+
/** index of the innermost LOOP, DO, WHILE or SELECT loop around the statement, in the same block */
|
|
88167
|
+
innermostLoop(index, statements) {
|
|
88168
|
+
let depth = 0;
|
|
88169
|
+
for (let i = index - 1; i >= 0 && this.startsBlock(statements[i]) === false; i--) {
|
|
88170
|
+
if (this.endsLoop(statements[i])) {
|
|
88171
|
+
depth++;
|
|
88172
|
+
}
|
|
88173
|
+
else if (this.startsLoop(statements[i])) {
|
|
88174
|
+
if (depth === 0) {
|
|
88175
|
+
return i;
|
|
88176
|
+
}
|
|
88177
|
+
depth--;
|
|
88178
|
+
}
|
|
88179
|
+
}
|
|
88180
|
+
return undefined;
|
|
88181
|
+
}
|
|
88182
|
+
unassignedBefore(loop, index, statements, fs) {
|
|
88183
|
+
for (let i = loop + 1; i < index; i++) {
|
|
88184
|
+
if (statements[i].get() instanceof Statements.Unassign && this.mentions(statements[i], fs)) {
|
|
88185
|
+
return true;
|
|
88186
|
+
}
|
|
88187
|
+
}
|
|
88188
|
+
return false;
|
|
88189
|
+
}
|
|
88190
|
+
/** the first IS [NOT] ASSIGNED of the field symbol after the statement, before the end of the loop
|
|
88191
|
+
* or another UNASSIGN or binding of it; a check that also reads sy-subrc is fine */
|
|
88192
|
+
nextCheck(index, statements, fs) {
|
|
88193
|
+
let depth = 0;
|
|
88194
|
+
for (let i = index + 1; i < statements.length && this.startsBlock(statements[i]) === false; i++) {
|
|
88195
|
+
const statement = statements[i];
|
|
88196
|
+
if (this.startsLoop(statement)) {
|
|
88197
|
+
depth++;
|
|
88198
|
+
}
|
|
88199
|
+
else if (this.endsLoop(statement)) {
|
|
88200
|
+
if (depth === 0) {
|
|
88201
|
+
return undefined;
|
|
88202
|
+
}
|
|
88203
|
+
depth--;
|
|
88204
|
+
}
|
|
88205
|
+
const concat = statement.concatTokens().toUpperCase();
|
|
88206
|
+
if (concat.includes(fs + " IS ASSIGNED") || concat.includes(fs + " IS NOT ASSIGNED")) {
|
|
88207
|
+
return concat.includes("SY-SUBRC") ? undefined : statement;
|
|
88208
|
+
}
|
|
88209
|
+
if ((statement.get() instanceof Statements.Unassign && this.mentions(statement, fs))
|
|
88210
|
+
|| this.binds(statement, fs)) {
|
|
88211
|
+
return undefined;
|
|
88212
|
+
}
|
|
88213
|
+
}
|
|
88214
|
+
return undefined;
|
|
88215
|
+
}
|
|
88216
|
+
mentions(statement, fs) {
|
|
88217
|
+
return statement.findAllExpressions(Expressions.FieldSymbol).some(e => e.concatTokens().toUpperCase() === fs);
|
|
88218
|
+
}
|
|
88219
|
+
binds(statement, fs) {
|
|
88220
|
+
return statement.findAllExpressions(Expressions.FSTarget)
|
|
88221
|
+
.some(t => { var _a; return ((_a = t.findFirstExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase()) === fs; });
|
|
88222
|
+
}
|
|
88223
|
+
startsLoop(statement) {
|
|
88224
|
+
const s = statement.get();
|
|
88225
|
+
return s instanceof Statements.Loop
|
|
88226
|
+
|| s instanceof Statements.Do
|
|
88227
|
+
|| s instanceof Statements.While
|
|
88228
|
+
|| s instanceof Statements.SelectLoop;
|
|
88229
|
+
}
|
|
88230
|
+
endsLoop(statement) {
|
|
88231
|
+
const s = statement.get();
|
|
88232
|
+
return s instanceof Statements.EndLoop
|
|
88233
|
+
|| s instanceof Statements.EndDo
|
|
88234
|
+
|| s instanceof Statements.EndWhile
|
|
88235
|
+
|| s instanceof Statements.EndSelect;
|
|
88236
|
+
}
|
|
88237
|
+
startsBlock(statement) {
|
|
88238
|
+
const s = statement.get();
|
|
88239
|
+
return s instanceof Statements.MethodImplementation
|
|
88240
|
+
|| s instanceof Statements.Form
|
|
88241
|
+
|| s instanceof Statements.FunctionModule
|
|
88242
|
+
|| s instanceof Statements.Module
|
|
88243
|
+
|| s instanceof Statements.EndMethod
|
|
88244
|
+
|| s instanceof Statements.EndForm
|
|
88245
|
+
|| s instanceof Statements.EndFunction
|
|
88246
|
+
|| s instanceof Statements.EndModule;
|
|
88247
|
+
}
|
|
88248
|
+
/** UNASSIGN on a line of its own before the statement, with the same indentation */
|
|
88249
|
+
buildFix(file, statement, name) {
|
|
88250
|
+
if (statement.getColon() !== undefined || statement.findFirstExpression(Expressions.InlineFS) !== undefined) {
|
|
88251
|
+
return undefined;
|
|
88252
|
+
}
|
|
88253
|
+
const start = statement.getStart();
|
|
88254
|
+
return edit_helper_1.EditHelper.insertAt(file, start, `UNASSIGN ${name}.\n` + " ".repeat(start.getCol() - 1));
|
|
88255
|
+
}
|
|
88256
|
+
}
|
|
88257
|
+
exports.IsAssignedInLoop = IsAssignedInLoop;
|
|
88258
|
+
//# sourceMappingURL=is_assigned_in_loop.js.map
|
|
88259
|
+
|
|
88260
|
+
/***/ },
|
|
88261
|
+
|
|
87874
88262
|
/***/ "../core/build/src/rules/keep_single_parameter_on_one_line.js"
|
|
87875
88263
|
/*!********************************************************************!*\
|
|
87876
88264
|
!*** ../core/build/src/rules/keep_single_parameter_on_one_line.js ***!
|
|
@@ -89570,7 +89958,11 @@ ENDIF.
|
|
|
89570
89958
|
&& lastChildren[1].getChildren().length === 1
|
|
89571
89959
|
&& lastChildren[1].getFirstToken().getStr().startsWith("-") === false
|
|
89572
89960
|
&& lastChildren[2].getFirstToken().getStr() === ")") {
|
|
89573
|
-
const
|
|
89961
|
+
const fixText = lastChildren[1].concatTokens();
|
|
89962
|
+
const start = lastChildren[0].getFirstToken().getStart();
|
|
89963
|
+
const end = lastChildren[2].getLastToken().getEnd();
|
|
89964
|
+
const fix = edit_helper_1.EditHelper.replaceRange(file, start, end, fixText);
|
|
89965
|
+
const issue = issue_1.Issue.atToken(file, lastChildren[0].getFirstToken(), "Too many parentheses", this.getMetadata().key, this.conf.severity, fix);
|
|
89574
89966
|
issues.push(issue);
|
|
89575
89967
|
}
|
|
89576
89968
|
}
|
|
@@ -89699,6 +90091,7 @@ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js"
|
|
|
89699
90091
|
const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
|
|
89700
90092
|
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
|
|
89701
90093
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
90094
|
+
const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
|
|
89702
90095
|
class MaxOneMethodParameterPerLineConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
89703
90096
|
}
|
|
89704
90097
|
exports.MaxOneMethodParameterPerLineConf = MaxOneMethodParameterPerLineConf;
|
|
@@ -89712,7 +90105,7 @@ class MaxOneMethodParameterPerLine extends _abap_rule_1.ABAPRule {
|
|
|
89712
90105
|
key: "max_one_method_parameter_per_line",
|
|
89713
90106
|
title: "Max one method parameter definition per line",
|
|
89714
90107
|
shortDescription: `Keep max one method parameter description per line`,
|
|
89715
|
-
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace],
|
|
90108
|
+
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix],
|
|
89716
90109
|
badExample: `
|
|
89717
90110
|
METHODS apps_scope_token
|
|
89718
90111
|
IMPORTING
|
|
@@ -89741,7 +90134,8 @@ METHODS apps_scope_token
|
|
|
89741
90134
|
continue;
|
|
89742
90135
|
}
|
|
89743
90136
|
if (prev.getFirstToken().getStart().getRow() === p.getFirstToken().getStart().getRow()) {
|
|
89744
|
-
const
|
|
90137
|
+
const fix = this.buildFix(file, statement, p);
|
|
90138
|
+
const issue = issue_1.Issue.atToken(file, prev.getFirstToken(), this.getMetadata().title, this.getMetadata().key, this.conf.severity, fix);
|
|
89745
90139
|
issues.push(issue);
|
|
89746
90140
|
}
|
|
89747
90141
|
prev = p;
|
|
@@ -89749,8 +90143,32 @@ METHODS apps_scope_token
|
|
|
89749
90143
|
}
|
|
89750
90144
|
return issues;
|
|
89751
90145
|
}
|
|
90146
|
+
/** moves the parameter, or its preceding section keyword, to a new line */
|
|
90147
|
+
buildFix(file, statement, param) {
|
|
90148
|
+
const tokens = statement.getTokens();
|
|
90149
|
+
const index = tokens.indexOf(param.getFirstToken());
|
|
90150
|
+
if (index < 1) {
|
|
90151
|
+
return undefined;
|
|
90152
|
+
}
|
|
90153
|
+
let target = tokens[index];
|
|
90154
|
+
let indent = statement.findFirstExpression(Expressions.MethodParam).getFirstToken().getStart().getCol();
|
|
90155
|
+
const before = tokens[index - 1];
|
|
90156
|
+
if (MaxOneMethodParameterPerLine.SECTIONS.includes(before.getStr().toUpperCase())) {
|
|
90157
|
+
if (index < 2) {
|
|
90158
|
+
return undefined;
|
|
90159
|
+
}
|
|
90160
|
+
target = before;
|
|
90161
|
+
indent = tokens.find(t => MaxOneMethodParameterPerLine.SECTIONS.includes(t.getStr().toUpperCase())).getStart().getCol();
|
|
90162
|
+
}
|
|
90163
|
+
const previous = tokens[tokens.indexOf(target) - 1];
|
|
90164
|
+
if (previous.getEnd().getRow() !== target.getStart().getRow()) {
|
|
90165
|
+
return undefined;
|
|
90166
|
+
}
|
|
90167
|
+
return edit_helper_1.EditHelper.replaceRange(file, previous.getEnd(), target.getStart(), "\n" + " ".repeat(indent - 1));
|
|
90168
|
+
}
|
|
89752
90169
|
}
|
|
89753
90170
|
exports.MaxOneMethodParameterPerLine = MaxOneMethodParameterPerLine;
|
|
90171
|
+
MaxOneMethodParameterPerLine.SECTIONS = ["IMPORTING", "EXPORTING", "CHANGING", "RETURNING"];
|
|
89754
90172
|
//# sourceMappingURL=max_one_method_parameter_per_line.js.map
|
|
89755
90173
|
|
|
89756
90174
|
/***/ },
|
|
@@ -91162,6 +91580,8 @@ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/
|
|
|
91162
91580
|
const sequential_blank_1 = __webpack_require__(/*! ./sequential_blank */ "../core/build/src/rules/sequential_blank.js");
|
|
91163
91581
|
const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
|
|
91164
91582
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
91583
|
+
const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
|
|
91584
|
+
const position_1 = __webpack_require__(/*! ../position */ "../core/build/src/position.js");
|
|
91165
91585
|
var NewlineLogic;
|
|
91166
91586
|
(function (NewlineLogic) {
|
|
91167
91587
|
NewlineLogic["Exact"] = "exact";
|
|
@@ -91191,7 +91611,7 @@ class NewlineBetweenMethods extends _abap_rule_1.ABAPRule {
|
|
|
91191
91611
|
key: "newline_between_methods",
|
|
91192
91612
|
title: "New line between methods",
|
|
91193
91613
|
shortDescription: `Checks for newlines between method implementations.`,
|
|
91194
|
-
tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.SingleFile],
|
|
91614
|
+
tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
|
|
91195
91615
|
};
|
|
91196
91616
|
}
|
|
91197
91617
|
getMessage() {
|
|
@@ -91220,18 +91640,35 @@ class NewlineBetweenMethods extends _abap_rule_1.ABAPRule {
|
|
|
91220
91640
|
continue;
|
|
91221
91641
|
}
|
|
91222
91642
|
let counter = 0;
|
|
91223
|
-
while (sequential_blank_1.SequentialBlank.isBlankOrWhitespace(rows[nextRow])
|
|
91643
|
+
while (sequential_blank_1.SequentialBlank.isBlankOrWhitespace(rows[nextRow])) {
|
|
91224
91644
|
counter++;
|
|
91225
91645
|
nextRow++;
|
|
91226
91646
|
}
|
|
91227
91647
|
if ((counter !== this.conf.count && this.conf.logic === NewlineLogic.Exact)
|
|
91228
91648
|
|| (counter >= this.conf.count && this.conf.logic === NewlineLogic.Less)
|
|
91229
91649
|
|| counter === 0) {
|
|
91230
|
-
|
|
91650
|
+
const fix = this.buildFix(file, rows, statement.getStart().getRow(), counter);
|
|
91651
|
+
issues.push(issue_1.Issue.atStatement(file, statement, this.getMessage(), this.getMetadata().key, this.conf.severity, fix));
|
|
91231
91652
|
}
|
|
91232
91653
|
}
|
|
91233
91654
|
return issues;
|
|
91234
91655
|
}
|
|
91656
|
+
buildFix(file, rows, row, blanks) {
|
|
91657
|
+
let target = this.conf.count;
|
|
91658
|
+
if (this.conf.logic === NewlineLogic.Less) {
|
|
91659
|
+
target = blanks === 0 ? 1 : this.conf.count - 1;
|
|
91660
|
+
}
|
|
91661
|
+
if (blanks < target) {
|
|
91662
|
+
const end = new position_1.Position(row, rows[row - 1].length + 1);
|
|
91663
|
+
return edit_helper_1.EditHelper.insertAt(file, end, "\n".repeat(target - blanks));
|
|
91664
|
+
}
|
|
91665
|
+
else if (blanks > target) {
|
|
91666
|
+
const start = new position_1.Position(row + target, rows[row + target - 1].length + 1);
|
|
91667
|
+
const end = new position_1.Position(row + blanks, rows[row + blanks - 1].length + 1);
|
|
91668
|
+
return edit_helper_1.EditHelper.deleteRange(file, start, end);
|
|
91669
|
+
}
|
|
91670
|
+
return undefined;
|
|
91671
|
+
}
|
|
91235
91672
|
isConfigurationValid() {
|
|
91236
91673
|
if (this.conf.count < 1 || (this.conf.count === 1 && this.conf.logic === NewlineLogic.Less)) {
|
|
91237
91674
|
return false;
|
|
@@ -96156,7 +96593,7 @@ class PreferPragmas extends _abap_rule_1.ABAPRule {
|
|
|
96156
96593
|
return {
|
|
96157
96594
|
key: "prefer_pragmas",
|
|
96158
96595
|
title: "prefer pragmas over pseudo comments ",
|
|
96159
|
-
shortDescription: `prefer pragmas over pseudo comments
|
|
96596
|
+
shortDescription: `prefer pragmas over pseudo comments`,
|
|
96160
96597
|
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-pragmas-to-pseudo-comments`,
|
|
96161
96598
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
|
|
96162
96599
|
badExample: `DATA foo1 TYPE i. "#EC NEEDED`,
|
|
@@ -97673,6 +98110,173 @@ exports.ReduceStringTemplates = ReduceStringTemplates;
|
|
|
97673
98110
|
|
|
97674
98111
|
/***/ },
|
|
97675
98112
|
|
|
98113
|
+
/***/ "../core/build/src/rules/redundant_cast.js"
|
|
98114
|
+
/*!*************************************************!*\
|
|
98115
|
+
!*** ../core/build/src/rules/redundant_cast.js ***!
|
|
98116
|
+
\*************************************************/
|
|
98117
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
98118
|
+
|
|
98119
|
+
"use strict";
|
|
98120
|
+
|
|
98121
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
98122
|
+
if (k2 === undefined) k2 = k;
|
|
98123
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
98124
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
98125
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
98126
|
+
}
|
|
98127
|
+
Object.defineProperty(o, k2, desc);
|
|
98128
|
+
}) : (function(o, m, k, k2) {
|
|
98129
|
+
if (k2 === undefined) k2 = k;
|
|
98130
|
+
o[k2] = m[k];
|
|
98131
|
+
}));
|
|
98132
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
98133
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
98134
|
+
}) : function(o, v) {
|
|
98135
|
+
o["default"] = v;
|
|
98136
|
+
});
|
|
98137
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
98138
|
+
var ownKeys = function(o) {
|
|
98139
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
98140
|
+
var ar = [];
|
|
98141
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
98142
|
+
return ar;
|
|
98143
|
+
};
|
|
98144
|
+
return ownKeys(o);
|
|
98145
|
+
};
|
|
98146
|
+
return function (mod) {
|
|
98147
|
+
if (mod && mod.__esModule) return mod;
|
|
98148
|
+
var result = {};
|
|
98149
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
98150
|
+
__setModuleDefault(result, mod);
|
|
98151
|
+
return result;
|
|
98152
|
+
};
|
|
98153
|
+
})();
|
|
98154
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
98155
|
+
exports.RedundantCast = exports.RedundantCastConf = void 0;
|
|
98156
|
+
const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
98157
|
+
const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
|
|
98158
|
+
const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
|
|
98159
|
+
const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
|
|
98160
|
+
const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
|
|
98161
|
+
const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
|
|
98162
|
+
const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
|
|
98163
|
+
const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
|
|
98164
|
+
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
|
|
98165
|
+
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
98166
|
+
const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
|
|
98167
|
+
const version_1 = __webpack_require__(/*! ../version */ "../core/build/src/version.js");
|
|
98168
|
+
class RedundantCastConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
98169
|
+
}
|
|
98170
|
+
exports.RedundantCastConf = RedundantCastConf;
|
|
98171
|
+
class RedundantCast {
|
|
98172
|
+
constructor() {
|
|
98173
|
+
this.conf = new RedundantCastConf();
|
|
98174
|
+
}
|
|
98175
|
+
getMetadata() {
|
|
98176
|
+
return {
|
|
98177
|
+
key: "redundant_cast",
|
|
98178
|
+
title: "Redundant Cast",
|
|
98179
|
+
shortDescription: `Find redundant CAST expressions`,
|
|
98180
|
+
extendedInformation: `Reports CAST expressions whose operand is already a reference to the cast's target class or interface.`,
|
|
98181
|
+
tags: [_irule_1.RuleTag.Quickfix],
|
|
98182
|
+
badExample: `DATA ref TYPE REF TO lcl.
|
|
98183
|
+
DATA(copy) = CAST lcl( ref ).`,
|
|
98184
|
+
goodExample: `DATA ref TYPE REF TO lcl.
|
|
98185
|
+
DATA(copy) = ref.`,
|
|
98186
|
+
};
|
|
98187
|
+
}
|
|
98188
|
+
getConfig() {
|
|
98189
|
+
return this.conf;
|
|
98190
|
+
}
|
|
98191
|
+
setConfig(conf) {
|
|
98192
|
+
this.conf = conf;
|
|
98193
|
+
}
|
|
98194
|
+
initialize(reg) {
|
|
98195
|
+
this.reg = reg;
|
|
98196
|
+
return this;
|
|
98197
|
+
}
|
|
98198
|
+
run(obj) {
|
|
98199
|
+
var _a;
|
|
98200
|
+
if (!(0, version_1.releaseAtLeast)(this.reg.getConfig().getRelease(), version_1.Release.v740sp02)
|
|
98201
|
+
&& !this.reg.getConfig().isOpenABAP()) {
|
|
98202
|
+
return [];
|
|
98203
|
+
}
|
|
98204
|
+
if (!(obj instanceof _abap_object_1.ABAPObject)) {
|
|
98205
|
+
return [];
|
|
98206
|
+
}
|
|
98207
|
+
const syntax = new syntax_1.SyntaxLogic(this.reg, obj).run();
|
|
98208
|
+
if (syntax.issues.length > 0) {
|
|
98209
|
+
return [];
|
|
98210
|
+
}
|
|
98211
|
+
const issues = [];
|
|
98212
|
+
for (const file of obj.getABAPFiles()) {
|
|
98213
|
+
const structure = file.getStructure();
|
|
98214
|
+
if (structure === undefined) {
|
|
98215
|
+
continue;
|
|
98216
|
+
}
|
|
98217
|
+
for (const cast of structure.findAllExpressionsRecursive(Expressions.Cast)) {
|
|
98218
|
+
const typeExpression = cast.findDirectExpression(Expressions.TypeNameOrInfer);
|
|
98219
|
+
const source = cast.findDirectExpression(Expressions.Source);
|
|
98220
|
+
if (typeExpression === undefined
|
|
98221
|
+
|| source === undefined
|
|
98222
|
+
|| cast.findDirectExpression(Expressions.Let) !== undefined) {
|
|
98223
|
+
continue;
|
|
98224
|
+
}
|
|
98225
|
+
const scope = syntax.spaghetti.lookupPosition(cast.getFirstToken().getStart(), file.getFilename());
|
|
98226
|
+
if (scope === undefined) {
|
|
98227
|
+
continue;
|
|
98228
|
+
}
|
|
98229
|
+
const target = (_a = scope.getData().references.find(reference => reference.referenceType === _reference_1.ReferenceType.InferredType
|
|
98230
|
+
&& reference.position.getStart().equals(typeExpression.getFirstToken().getStart()))) === null || _a === void 0 ? void 0 : _a.resolved;
|
|
98231
|
+
if (!(target instanceof _typed_identifier_1.TypedIdentifier)) {
|
|
98232
|
+
continue;
|
|
98233
|
+
}
|
|
98234
|
+
const operandType = this.sourceType(source, scope);
|
|
98235
|
+
if (operandType === undefined || this.sameType(target.getType(), operandType) === false) {
|
|
98236
|
+
continue;
|
|
98237
|
+
}
|
|
98238
|
+
const closingParen = cast.getDirectTokens().find(token => token.getStr() === ")" && token.getStart().isAfter(source.getLastToken().getStart()));
|
|
98239
|
+
if (closingParen === undefined) {
|
|
98240
|
+
continue;
|
|
98241
|
+
}
|
|
98242
|
+
const fix = edit_helper_1.EditHelper.replaceRange(file, cast.getFirstToken().getStart(), closingParen.getEnd(), source.concatTokens());
|
|
98243
|
+
issues.push(issue_1.Issue.atRange(file, cast.getFirstToken().getStart(), closingParen.getEnd(), "Redundant CAST expression", this.getMetadata().key, this.conf.severity, fix));
|
|
98244
|
+
}
|
|
98245
|
+
}
|
|
98246
|
+
return issues;
|
|
98247
|
+
}
|
|
98248
|
+
/** The type of a plain variable or attribute, undefined for anything more complex */
|
|
98249
|
+
sourceType(source, scope) {
|
|
98250
|
+
var _a;
|
|
98251
|
+
const children = source.getChildren();
|
|
98252
|
+
if (children.length !== 1 || !(children[0].get() instanceof Expressions.FieldChain)) {
|
|
98253
|
+
return undefined;
|
|
98254
|
+
}
|
|
98255
|
+
const fieldChain = children[0];
|
|
98256
|
+
const last = fieldChain.getLastChild();
|
|
98257
|
+
if (!(last instanceof nodes_1.ExpressionNode)
|
|
98258
|
+
|| !(last.get() instanceof Expressions.SourceField || last.get() instanceof Expressions.AttributeName)) {
|
|
98259
|
+
return undefined;
|
|
98260
|
+
}
|
|
98261
|
+
const operand = (_a = scope.getData().references.find(reference => reference.referenceType === _reference_1.ReferenceType.DataReadReference
|
|
98262
|
+
&& reference.position.getStart().equals(last.getFirstToken().getStart()))) === null || _a === void 0 ? void 0 : _a.resolved;
|
|
98263
|
+
if (!(operand instanceof _typed_identifier_1.TypedIdentifier)) {
|
|
98264
|
+
return undefined;
|
|
98265
|
+
}
|
|
98266
|
+
return operand.getType();
|
|
98267
|
+
}
|
|
98268
|
+
sameType(first, second) {
|
|
98269
|
+
if (!(first instanceof basic_1.ObjectReferenceType) || !(second instanceof basic_1.ObjectReferenceType)) {
|
|
98270
|
+
return false;
|
|
98271
|
+
}
|
|
98272
|
+
return first.getIdentifierName().toUpperCase() === second.getIdentifierName().toUpperCase();
|
|
98273
|
+
}
|
|
98274
|
+
}
|
|
98275
|
+
exports.RedundantCast = RedundantCast;
|
|
98276
|
+
//# sourceMappingURL=redundant_cast.js.map
|
|
98277
|
+
|
|
98278
|
+
/***/ },
|
|
98279
|
+
|
|
97676
98280
|
/***/ "../core/build/src/rules/redundant_conversion.js"
|
|
97677
98281
|
/*!*******************************************************!*\
|
|
97678
98282
|
!*** ../core/build/src/rules/redundant_conversion.js ***!
|
|
@@ -97878,9 +98482,9 @@ text = text.`,
|
|
|
97878
98482
|
context = this.infer(context, this.sourceType(child, scope));
|
|
97879
98483
|
}
|
|
97880
98484
|
else if (child.get() instanceof Expressions.ArithOperator) {
|
|
97881
|
-
|
|
97882
|
-
|
|
97883
|
-
|
|
98485
|
+
// the CONV sets the calculation type of arithmetic expressions, only redundant
|
|
98486
|
+
// if the assignment target has the same type, see arithmeticUsesSameTargetType
|
|
98487
|
+
return undefined;
|
|
97884
98488
|
}
|
|
97885
98489
|
else {
|
|
97886
98490
|
return undefined;
|
|
@@ -106559,7 +107163,6 @@ const position_1 = __webpack_require__(/*! ../position */ "../core/build/src/pos
|
|
|
106559
107163
|
const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
|
|
106560
107164
|
const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
|
|
106561
107165
|
const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
|
|
106562
|
-
// todo, check for cycles/circular dependencies, method findTop
|
|
106563
107166
|
// todo, add configurable error for multiple use includes
|
|
106564
107167
|
const FMXXINCLUDE = /^(\/\w+\/)?L.+XX$/;
|
|
106565
107168
|
function getABAPObjects(reg) {
|
|
@@ -106595,11 +107198,33 @@ class Graph {
|
|
|
106595
107198
|
}
|
|
106596
107199
|
this.edges[from.filename].push(toFilename);
|
|
106597
107200
|
}
|
|
106598
|
-
|
|
107201
|
+
// true if "to" is reachable from "from" via the edges, "from" itself counts
|
|
107202
|
+
isReachable(from, to) {
|
|
107203
|
+
const seen = new Set();
|
|
107204
|
+
const stack = [from];
|
|
107205
|
+
while (stack.length > 0) {
|
|
107206
|
+
const current = stack.pop();
|
|
107207
|
+
if (current === to) {
|
|
107208
|
+
return true;
|
|
107209
|
+
}
|
|
107210
|
+
if (seen.has(current) === false) {
|
|
107211
|
+
seen.add(current);
|
|
107212
|
+
stack.push(...this.edges[current] || []);
|
|
107213
|
+
}
|
|
107214
|
+
}
|
|
107215
|
+
return false;
|
|
107216
|
+
}
|
|
107217
|
+
findTop(filename, path = new Set()) {
|
|
106599
107218
|
const ret = [];
|
|
107219
|
+
path.add(filename);
|
|
106600
107220
|
for (const to of this.edges[filename] || []) {
|
|
106601
|
-
|
|
107221
|
+
// an INCLUDE cycle, the file is already on the current path
|
|
107222
|
+
if (path.has(to)) {
|
|
107223
|
+
continue;
|
|
107224
|
+
}
|
|
107225
|
+
ret.push(...this.findTop(to, path));
|
|
106602
107226
|
}
|
|
107227
|
+
path.delete(filename);
|
|
106603
107228
|
if (ret.length === 0) {
|
|
106604
107229
|
const found = this.findVertexByFilename(filename);
|
|
106605
107230
|
if (found !== undefined) {
|
|
@@ -106654,6 +107279,7 @@ class IncludeGraph {
|
|
|
106654
107279
|
///////////////////////////////
|
|
106655
107280
|
build() {
|
|
106656
107281
|
this.addVertices();
|
|
107282
|
+
const included = [];
|
|
106657
107283
|
for (const o of getABAPObjects(this.reg)) {
|
|
106658
107284
|
for (const f of o.getABAPFiles()) {
|
|
106659
107285
|
if (f.getFilename().includes(".prog.screen_") || f.getFilename().includes(".fugr.screen_")) {
|
|
@@ -106684,11 +107310,19 @@ class IncludeGraph {
|
|
|
106684
107310
|
}
|
|
106685
107311
|
else {
|
|
106686
107312
|
this.graph.addEdge(found, f.getFilename());
|
|
107313
|
+
included.push({ file: f, statement: s, vertex: found, name });
|
|
106687
107314
|
}
|
|
106688
107315
|
}
|
|
106689
107316
|
}
|
|
106690
107317
|
}
|
|
106691
107318
|
}
|
|
107319
|
+
// cycles are not followed, but ABAP rejects them, so report them
|
|
107320
|
+
for (const i of included) {
|
|
107321
|
+
if (this.graph.isReachable(i.file.getFilename(), i.vertex.filename)) {
|
|
107322
|
+
const issue = issue_1.Issue.atStatement(i.file, i.statement, "Cyclic INCLUDE, " + i.name, new check_include_1.CheckInclude().getMetadata().key, this.severity);
|
|
107323
|
+
this.issues.push(issue);
|
|
107324
|
+
}
|
|
107325
|
+
}
|
|
106692
107326
|
}
|
|
106693
107327
|
addVertices() {
|
|
106694
107328
|
for (const o of getABAPObjects(this.reg)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.120.
|
|
3
|
+
"version": "2.120.79",
|
|
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.79",
|
|
43
43
|
"@types/chai": "^4.3.20",
|
|
44
44
|
"@types/minimist": "^1.2.5",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|