@abaplint/cli 2.120.111 → 2.120.112
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 +634 -61
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -6091,7 +6091,7 @@ const loop_group_by_component_1 = __webpack_require__(/*! ./loop_group_by_compon
|
|
|
6091
6091
|
class LoopGroupBy extends combi_1.Expression {
|
|
6092
6092
|
getRunnable() {
|
|
6093
6093
|
const components = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), (0, combi_1.plus)(loop_group_by_component_1.LoopGroupByComponent), (0, combi_1.tok)(tokens_1.WParenRightW));
|
|
6094
|
-
const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)("ASCENDING"), (0, combi_1.optPrio)("WITHOUT MEMBERS"), loop_group_by_target_1.LoopGroupByTarget);
|
|
6094
|
+
const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)((0, combi_1.seq)((0, combi_1.alt)("ASCENDING", "DESCENDING"), (0, combi_1.optPrio)("AS TEXT"))), (0, combi_1.optPrio)("WITHOUT MEMBERS"), loop_group_by_target_1.LoopGroupByTarget);
|
|
6095
6095
|
return ret;
|
|
6096
6096
|
}
|
|
6097
6097
|
}
|
|
@@ -26194,6 +26194,114 @@ BuiltIn.argumentTypedReturn = new Set(["ABS", "CEIL", "FLOOR", "FRAC", "SIGN", "
|
|
|
26194
26194
|
|
|
26195
26195
|
/***/ },
|
|
26196
26196
|
|
|
26197
|
+
/***/ "../core/build/src/abap/5_syntax/_builtin_call.js"
|
|
26198
|
+
/*!********************************************************!*\
|
|
26199
|
+
!*** ../core/build/src/abap/5_syntax/_builtin_call.js ***!
|
|
26200
|
+
\********************************************************/
|
|
26201
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
26202
|
+
|
|
26203
|
+
"use strict";
|
|
26204
|
+
|
|
26205
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
26206
|
+
if (k2 === undefined) k2 = k;
|
|
26207
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26208
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26209
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
26210
|
+
}
|
|
26211
|
+
Object.defineProperty(o, k2, desc);
|
|
26212
|
+
}) : (function(o, m, k, k2) {
|
|
26213
|
+
if (k2 === undefined) k2 = k;
|
|
26214
|
+
o[k2] = m[k];
|
|
26215
|
+
}));
|
|
26216
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26217
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26218
|
+
}) : function(o, v) {
|
|
26219
|
+
o["default"] = v;
|
|
26220
|
+
});
|
|
26221
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26222
|
+
var ownKeys = function(o) {
|
|
26223
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26224
|
+
var ar = [];
|
|
26225
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26226
|
+
return ar;
|
|
26227
|
+
};
|
|
26228
|
+
return ownKeys(o);
|
|
26229
|
+
};
|
|
26230
|
+
return function (mod) {
|
|
26231
|
+
if (mod && mod.__esModule) return mod;
|
|
26232
|
+
var result = {};
|
|
26233
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
26234
|
+
__setModuleDefault(result, mod);
|
|
26235
|
+
return result;
|
|
26236
|
+
};
|
|
26237
|
+
})();
|
|
26238
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
26239
|
+
exports.BuiltInCall = void 0;
|
|
26240
|
+
const Expressions = __importStar(__webpack_require__(/*! ../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
26241
|
+
const nodes_1 = __webpack_require__(/*! ../nodes */ "../core/build/src/abap/nodes/index.js");
|
|
26242
|
+
const _builtin_1 = __webpack_require__(/*! ./_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
|
|
26243
|
+
const _object_oriented_1 = __webpack_require__(/*! ./_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
|
|
26244
|
+
const basic_1 = __webpack_require__(/*! ../types/basic */ "../core/build/src/abap/types/basic/index.js");
|
|
26245
|
+
class BuiltInCall {
|
|
26246
|
+
// the call of a built-in function that starts a method call chain, not hidden by a method of the same name
|
|
26247
|
+
static fromChain(chain, input) {
|
|
26248
|
+
if (chain === undefined || !(chain.get() instanceof Expressions.MethodCallChain)) {
|
|
26249
|
+
return undefined;
|
|
26250
|
+
}
|
|
26251
|
+
const call = chain.getChildren()[0];
|
|
26252
|
+
if (!(call instanceof nodes_1.ExpressionNode) || !(call.get() instanceof Expressions.MethodCall)) {
|
|
26253
|
+
return undefined;
|
|
26254
|
+
}
|
|
26255
|
+
const name = this.callName(call);
|
|
26256
|
+
// upper case, the definition is cached with the name it is first searched with
|
|
26257
|
+
if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name.toUpperCase()) === undefined) {
|
|
26258
|
+
return undefined;
|
|
26259
|
+
}
|
|
26260
|
+
const enclosing = input.scope.findClassDefinition(input.scope.getEnclosingClassName());
|
|
26261
|
+
if (enclosing !== undefined && new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(enclosing, name).method !== undefined) {
|
|
26262
|
+
return undefined;
|
|
26263
|
+
}
|
|
26264
|
+
return call;
|
|
26265
|
+
}
|
|
26266
|
+
// the call of a built-in function when the source is exactly that one call
|
|
26267
|
+
static fromSource(source, input) {
|
|
26268
|
+
const chain = source === null || source === void 0 ? void 0 : source.getChildren();
|
|
26269
|
+
if ((chain === null || chain === void 0 ? void 0 : chain.length) !== 1 || !(chain[0] instanceof nodes_1.ExpressionNode) || chain[0].getChildren().length !== 1) {
|
|
26270
|
+
return undefined;
|
|
26271
|
+
}
|
|
26272
|
+
return this.fromChain(chain[0], input);
|
|
26273
|
+
}
|
|
26274
|
+
static callName(call) {
|
|
26275
|
+
var _a;
|
|
26276
|
+
return (_a = call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
26277
|
+
}
|
|
26278
|
+
static isNumeric(call) {
|
|
26279
|
+
var _a, _b, _c;
|
|
26280
|
+
const returning = (_c = (_b = _builtin_1.BuiltIn.searchBuiltin((_a = this.callName(call)) === null || _a === void 0 ? void 0 : _a.toUpperCase())) === null || _b === void 0 ? void 0 : _b.getParameters().getReturning()) === null || _c === void 0 ? void 0 : _c.getType();
|
|
26281
|
+
return returning instanceof basic_1.IntegerType || returning instanceof basic_1.FloatType || returning instanceof basic_1.DecFloat34Type;
|
|
26282
|
+
}
|
|
26283
|
+
// the call has a single argument, without a parameter name, that is a data object and not an expression
|
|
26284
|
+
static hasDataObjectArgument(call) {
|
|
26285
|
+
var _a;
|
|
26286
|
+
const argument = (_a = call.findDirectExpression(Expressions.MethodCallParam)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Source);
|
|
26287
|
+
const children = (argument === null || argument === void 0 ? void 0 : argument.getChildren()) || [];
|
|
26288
|
+
// a literal or a text symbol, text-001
|
|
26289
|
+
if (children.length === 1
|
|
26290
|
+
&& (children[0].get() instanceof Expressions.Constant || children[0].get() instanceof Expressions.TextElement)) {
|
|
26291
|
+
return true;
|
|
26292
|
+
}
|
|
26293
|
+
// a field, a component, an offset/length or a dereference, r->*
|
|
26294
|
+
return children.length > 0
|
|
26295
|
+
&& children[0].get() instanceof Expressions.FieldChain
|
|
26296
|
+
&& children.every(c => c.get() instanceof Expressions.FieldChain || c.get() instanceof Expressions.Dereference)
|
|
26297
|
+
&& (argument === null || argument === void 0 ? void 0 : argument.findFirstExpression(Expressions.TableExpression)) === undefined;
|
|
26298
|
+
}
|
|
26299
|
+
}
|
|
26300
|
+
exports.BuiltInCall = BuiltInCall;
|
|
26301
|
+
//# sourceMappingURL=_builtin_call.js.map
|
|
26302
|
+
|
|
26303
|
+
/***/ },
|
|
26304
|
+
|
|
26197
26305
|
/***/ "../core/build/src/abap/5_syntax/_current_scope.js"
|
|
26198
26306
|
/*!*********************************************************!*\
|
|
26199
26307
|
!*** ../core/build/src/abap/5_syntax/_current_scope.js ***!
|
|
@@ -27378,6 +27486,17 @@ class ObjectOriented {
|
|
|
27378
27486
|
}
|
|
27379
27487
|
return undefined;
|
|
27380
27488
|
}
|
|
27489
|
+
// RAISE EXCEPTION and THROW are not allowed in a method whose interface declares classic EXCEPTIONS,
|
|
27490
|
+
// not even for a CX_NO_CHECK class
|
|
27491
|
+
checkClassBasedException() {
|
|
27492
|
+
var _a;
|
|
27493
|
+
const methodName = this.scope.getEnclosingMethodName();
|
|
27494
|
+
const classDef = this.scope.findClassDefinition(this.scope.getEnclosingClassName());
|
|
27495
|
+
if (methodName && classDef && ((_a = this.searchMethodName(classDef, methodName).method) === null || _a === void 0 ? void 0 : _a.getExceptions().length)) {
|
|
27496
|
+
return "Old exceptions and class-based exceptions cannot be used at the same time";
|
|
27497
|
+
}
|
|
27498
|
+
return undefined;
|
|
27499
|
+
}
|
|
27381
27500
|
// SUPER-> can only call the previous implementation of the method it is used in, returns the message otherwise
|
|
27382
27501
|
// both names are resolved in the super class, so an alias and the method it stands for are the same
|
|
27383
27502
|
checkSuperCall(superDef, methodName) {
|
|
@@ -30147,6 +30266,11 @@ class BasicTypes {
|
|
|
30147
30266
|
if (text === undefined) {
|
|
30148
30267
|
text = "TYPE";
|
|
30149
30268
|
}
|
|
30269
|
+
const additionIssue = this.checkLengthDecimals(node, text);
|
|
30270
|
+
if (additionIssue !== undefined) {
|
|
30271
|
+
this.input.issues.push(additionIssue);
|
|
30272
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
30273
|
+
}
|
|
30150
30274
|
let found = undefined;
|
|
30151
30275
|
if (this.isRAPTypeStructure(text)) {
|
|
30152
30276
|
return Types.VoidType.get((_f = node.findFirstExpression(Expressions.TypeStructure)) === null || _f === void 0 ? void 0 : _f.concatTokens());
|
|
@@ -30690,6 +30814,31 @@ class BasicTypes {
|
|
|
30690
30814
|
}
|
|
30691
30815
|
throw new Error("findValue, unexpected");
|
|
30692
30816
|
}
|
|
30817
|
+
// the LENGTH and DECIMALS additions of DATA, TYPES, CONSTANTS and STATICS, as a system checks them:
|
|
30818
|
+
// LENGTH only with TYPE c, n, x or p, DECIMALS only with TYPE p, also not without a TYPE addition,
|
|
30819
|
+
// a named type cannot be given a length either. With LIKE, a system ignores LENGTH and rejects DECIMALS
|
|
30820
|
+
checkLengthDecimals(node, text) {
|
|
30821
|
+
const length = node.findDirectExpression(Expressions.Length);
|
|
30822
|
+
const decimals = node.findDirectExpression(Expressions.Decimals);
|
|
30823
|
+
if (length === undefined && decimals === undefined) {
|
|
30824
|
+
return undefined;
|
|
30825
|
+
}
|
|
30826
|
+
else if (text.startsWith("LIKE")) {
|
|
30827
|
+
if (decimals === undefined) {
|
|
30828
|
+
return undefined;
|
|
30829
|
+
}
|
|
30830
|
+
const message = "When referencing another field (with LIKE), type and length cannot be changed";
|
|
30831
|
+
return (0, _syntax_input_1.syntaxIssue)(this.input, decimals.getFirstToken(), message);
|
|
30832
|
+
}
|
|
30833
|
+
const builtin = text.startsWith("TYPE") ? text.substring(4).trim() : "";
|
|
30834
|
+
if (length !== undefined && ["C", "N", "X", "P"].includes(builtin) === false) {
|
|
30835
|
+
return (0, _syntax_input_1.syntaxIssue)(this.input, length.getFirstToken(), "\"LENGTH\" can only be specified for types C, N, X, or P");
|
|
30836
|
+
}
|
|
30837
|
+
else if (decimals !== undefined && builtin !== "P") {
|
|
30838
|
+
return (0, _syntax_input_1.syntaxIssue)(this.input, decimals.getFirstToken(), "\"DECIMALS\" can be specified only for type P");
|
|
30839
|
+
}
|
|
30840
|
+
return undefined;
|
|
30841
|
+
}
|
|
30693
30842
|
findDecimals(node) {
|
|
30694
30843
|
var _a, _b, _c;
|
|
30695
30844
|
const dec = (_b = (_a = node.findDirectExpression(Expressions.Decimals)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Integer)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
@@ -31164,7 +31313,7 @@ function substringType(context, offset, length, node, input) {
|
|
|
31164
31313
|
return context;
|
|
31165
31314
|
}
|
|
31166
31315
|
else if (numericName !== undefined) {
|
|
31167
|
-
const message = `
|
|
31316
|
+
const message = `Field type "${numericName}" does not permit substrings to be accessed`;
|
|
31168
31317
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
31169
31318
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
31170
31319
|
}
|
|
@@ -31193,12 +31342,13 @@ function substringType(context, offset, length, node, input) {
|
|
|
31193
31342
|
}
|
|
31194
31343
|
return context;
|
|
31195
31344
|
}
|
|
31345
|
+
// the internal type code the ABAP syntax check names: I, 8, P, F, a (decfloat16), e (decfloat34)
|
|
31196
31346
|
function numericTypeName(context) {
|
|
31197
31347
|
if (context instanceof basic_1.IntegerType) {
|
|
31198
31348
|
return "I";
|
|
31199
31349
|
}
|
|
31200
31350
|
else if (context instanceof basic_1.Integer8Type) {
|
|
31201
|
-
return "
|
|
31351
|
+
return "8";
|
|
31202
31352
|
}
|
|
31203
31353
|
else if (context instanceof basic_1.PackedType) {
|
|
31204
31354
|
return "P";
|
|
@@ -31207,10 +31357,10 @@ function numericTypeName(context) {
|
|
|
31207
31357
|
return "F";
|
|
31208
31358
|
}
|
|
31209
31359
|
else if (context instanceof basic_1.DecFloat16Type) {
|
|
31210
|
-
return "
|
|
31360
|
+
return "a";
|
|
31211
31361
|
}
|
|
31212
31362
|
else if (context instanceof basic_1.DecFloat34Type) {
|
|
31213
|
-
return "
|
|
31363
|
+
return "e";
|
|
31214
31364
|
}
|
|
31215
31365
|
else if (context instanceof basic_1.DecFloatType) {
|
|
31216
31366
|
return "DECFLOAT";
|
|
@@ -31666,12 +31816,20 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/bui
|
|
|
31666
31816
|
const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
|
|
31667
31817
|
const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "../core/build/src/abap/5_syntax/_type_utils.js");
|
|
31668
31818
|
const _builtin_1 = __webpack_require__(/*! ../_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
|
|
31669
|
-
const
|
|
31819
|
+
const _builtin_call_1 = __webpack_require__(/*! ../_builtin_call */ "../core/build/src/abap/5_syntax/_builtin_call.js");
|
|
31670
31820
|
class Compare {
|
|
31671
31821
|
static runSyntax(node, input) {
|
|
31672
31822
|
var _a;
|
|
31673
|
-
const sourceTypes = [];
|
|
31674
31823
|
const sources = node.findDirectExpressions(Expressions.Source);
|
|
31824
|
+
// reported before the operands are checked, which then skip the more general predicate function message
|
|
31825
|
+
const initialMessage = this.checkInitialOperand(node, input);
|
|
31826
|
+
const predicateMessage = this.checkPredicateOperand(sources, input);
|
|
31827
|
+
const operandMessage = initialMessage !== null && initialMessage !== void 0 ? initialMessage : predicateMessage;
|
|
31828
|
+
if (operandMessage !== undefined) {
|
|
31829
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), operandMessage));
|
|
31830
|
+
}
|
|
31831
|
+
// the operands are always checked, for their own errors and references
|
|
31832
|
+
const sourceTypes = [];
|
|
31675
31833
|
for (const t of sources) {
|
|
31676
31834
|
sourceTypes.push(source_1.Source.runSyntax(t, input));
|
|
31677
31835
|
}
|
|
@@ -31681,14 +31839,7 @@ class Compare {
|
|
|
31681
31839
|
for (const t of node.findDirectExpressions(Expressions.MethodCallChain)) {
|
|
31682
31840
|
method_call_chain_1.MethodCallChain.runSyntax(t, input);
|
|
31683
31841
|
}
|
|
31684
|
-
|
|
31685
|
-
if (initialMessage !== undefined) {
|
|
31686
|
-
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), initialMessage));
|
|
31687
|
-
return;
|
|
31688
|
-
}
|
|
31689
|
-
const predicateMessage = this.checkPredicateOperand(sources, input);
|
|
31690
|
-
if (predicateMessage !== undefined) {
|
|
31691
|
-
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), predicateMessage));
|
|
31842
|
+
if (operandMessage !== undefined) {
|
|
31692
31843
|
return;
|
|
31693
31844
|
}
|
|
31694
31845
|
const typeUtils = new _type_utils_1.TypeUtils(input.scope);
|
|
@@ -31744,35 +31895,20 @@ class Compare {
|
|
|
31744
31895
|
if (input.scope.getOpenABAP()) {
|
|
31745
31896
|
return undefined;
|
|
31746
31897
|
}
|
|
31898
|
+
let message = undefined;
|
|
31747
31899
|
for (const source of sources) {
|
|
31748
31900
|
const name = this.builtinCallName(source, input);
|
|
31749
31901
|
if (_builtin_1.BuiltIn.isPredicate(name) === true) {
|
|
31750
|
-
|
|
31902
|
+
source_1.Source.predicateReported(source);
|
|
31903
|
+
message = message !== null && message !== void 0 ? message : `Predicate function "${name}" cannot be the operand of a comparison`;
|
|
31751
31904
|
}
|
|
31752
31905
|
}
|
|
31753
|
-
return
|
|
31906
|
+
return message;
|
|
31754
31907
|
}
|
|
31755
31908
|
// the name of the built-in function when the source is exactly one call of it, not hidden by a method of the same name
|
|
31756
31909
|
static builtinCallName(source, input) {
|
|
31757
|
-
|
|
31758
|
-
|
|
31759
|
-
if ((chain === null || chain === void 0 ? void 0 : chain.length) !== 1 || !(chain[0] instanceof nodes_1.ExpressionNode) || !(chain[0].get() instanceof Expressions.MethodCallChain)) {
|
|
31760
|
-
return undefined;
|
|
31761
|
-
}
|
|
31762
|
-
const calls = chain[0].getChildren();
|
|
31763
|
-
if (calls.length !== 1 || !(calls[0] instanceof nodes_1.ExpressionNode) || !(calls[0].get() instanceof Expressions.MethodCall)) {
|
|
31764
|
-
return undefined;
|
|
31765
|
-
}
|
|
31766
|
-
const name = (_a = calls[0].findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
31767
|
-
if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name) === undefined) {
|
|
31768
|
-
return undefined;
|
|
31769
|
-
}
|
|
31770
|
-
// a method of the same name hides the built-in function
|
|
31771
|
-
const enclosing = input.scope.findClassDefinition(input.scope.getEnclosingClassName());
|
|
31772
|
-
if (enclosing !== undefined && new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(enclosing, name).method !== undefined) {
|
|
31773
|
-
return undefined;
|
|
31774
|
-
}
|
|
31775
|
-
return name;
|
|
31910
|
+
const call = _builtin_call_1.BuiltInCall.fromSource(source, input);
|
|
31911
|
+
return call === undefined ? undefined : _builtin_call_1.BuiltInCall.callName(call);
|
|
31776
31912
|
}
|
|
31777
31913
|
}
|
|
31778
31914
|
exports.Compare = Compare;
|
|
@@ -32353,15 +32489,22 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32353
32489
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
32354
32490
|
exports.CondBody = void 0;
|
|
32355
32491
|
const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
32492
|
+
const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
|
|
32356
32493
|
const source_1 = __webpack_require__(/*! ./source */ "../core/build/src/abap/5_syntax/expressions/source.js");
|
|
32357
32494
|
const let_1 = __webpack_require__(/*! ./let */ "../core/build/src/abap/5_syntax/expressions/let.js");
|
|
32358
32495
|
const cond_1 = __webpack_require__(/*! ./cond */ "../core/build/src/abap/5_syntax/expressions/cond.js");
|
|
32359
32496
|
const _raise_message_1 = __webpack_require__(/*! ../_raise_message */ "../core/build/src/abap/5_syntax/_raise_message.js");
|
|
32497
|
+
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
32360
32498
|
class CondBody {
|
|
32361
32499
|
static runSyntax(node, input, targetType) {
|
|
32362
32500
|
if (node === undefined) {
|
|
32363
32501
|
return undefined;
|
|
32364
32502
|
}
|
|
32503
|
+
const throwNode = node.findDirectExpression(Expressions.Throw);
|
|
32504
|
+
const throwMessage = throwNode ? new _object_oriented_1.ObjectOriented(input.scope).checkClassBasedException() : undefined;
|
|
32505
|
+
if (throwNode && throwMessage) {
|
|
32506
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, throwNode.getFirstToken(), throwMessage));
|
|
32507
|
+
}
|
|
32365
32508
|
let scoped = false;
|
|
32366
32509
|
const l = node.findDirectExpression(Expressions.Let);
|
|
32367
32510
|
if (l) {
|
|
@@ -36863,6 +37006,7 @@ const conv_body_1 = __webpack_require__(/*! ./conv_body */ "../core/build/src/ab
|
|
|
36863
37006
|
const filter_body_1 = __webpack_require__(/*! ./filter_body */ "../core/build/src/abap/5_syntax/expressions/filter_body.js");
|
|
36864
37007
|
const corresponding_body_1 = __webpack_require__(/*! ./corresponding_body */ "../core/build/src/abap/5_syntax/expressions/corresponding_body.js");
|
|
36865
37008
|
const _builtin_1 = __webpack_require__(/*! ../_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
|
|
37009
|
+
const _builtin_call_1 = __webpack_require__(/*! ../_builtin_call */ "../core/build/src/abap/5_syntax/_builtin_call.js");
|
|
36866
37010
|
const attribute_chain_1 = __webpack_require__(/*! ./attribute_chain */ "../core/build/src/abap/5_syntax/expressions/attribute_chain.js");
|
|
36867
37011
|
const dereference_1 = __webpack_require__(/*! ./dereference */ "../core/build/src/abap/5_syntax/expressions/dereference.js");
|
|
36868
37012
|
const cast_1 = __webpack_require__(/*! ./cast */ "../core/build/src/abap/5_syntax/expressions/cast.js");
|
|
@@ -36882,6 +37026,10 @@ const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src
|
|
|
36882
37026
|
*/
|
|
36883
37027
|
// TODO: refactor all these method parameters to objects, this is getting messy
|
|
36884
37028
|
class Source {
|
|
37029
|
+
// the predicate function in this source is already reported by the caller, Source only checks its arguments
|
|
37030
|
+
static predicateReported(source) {
|
|
37031
|
+
this.logicalArguments.add(source);
|
|
37032
|
+
}
|
|
36885
37033
|
static runSyntax(node, input, targetType, writeReference = false, allowGenericDeference = false, readReference = true) {
|
|
36886
37034
|
var _a, _b;
|
|
36887
37035
|
if (node === undefined) {
|
|
@@ -37092,6 +37240,14 @@ class Source {
|
|
|
37092
37240
|
if (first instanceof nodes_1.ExpressionNode) {
|
|
37093
37241
|
const get = first.get();
|
|
37094
37242
|
if (get instanceof Expressions.MethodCallChain) {
|
|
37243
|
+
const predicate = this.predicateCall(node, first, input);
|
|
37244
|
+
if (predicate !== undefined) {
|
|
37245
|
+
const message = `Predicate function "${predicate}" can only be used in a logical expression`;
|
|
37246
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, first.getFirstToken(), message));
|
|
37247
|
+
// the arguments are still checked, for their own errors and references
|
|
37248
|
+
method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
|
|
37249
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
37250
|
+
}
|
|
37095
37251
|
const found = method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
|
|
37096
37252
|
context = arithmetic === true ? this.infer(context, found, true) : found;
|
|
37097
37253
|
if (context === undefined) {
|
|
@@ -37344,6 +37500,36 @@ class Source {
|
|
|
37344
37500
|
}
|
|
37345
37501
|
return targetType;
|
|
37346
37502
|
}
|
|
37503
|
+
// a predicate function, line_exists( ) or contains( ), is a logical expression and not a value,
|
|
37504
|
+
// a system reports it as an unknown method in any operand position other than the argument of boolc( ) or xsdbool( ),
|
|
37505
|
+
// which parse as method calls in releases before xsdbool( ) was added, or the bool parameter of boolx( )
|
|
37506
|
+
static predicateCall(source, chain, input) {
|
|
37507
|
+
var _a, _b;
|
|
37508
|
+
if (input.scope.getOpenABAP()) {
|
|
37509
|
+
return undefined;
|
|
37510
|
+
}
|
|
37511
|
+
const call = _builtin_call_1.BuiltInCall.fromChain(chain, input);
|
|
37512
|
+
const name = call === undefined ? undefined : _builtin_call_1.BuiltInCall.callName(call);
|
|
37513
|
+
const upper = name === null || name === void 0 ? void 0 : name.toUpperCase();
|
|
37514
|
+
const param = call === null || call === void 0 ? void 0 : call.findDirectExpression(Expressions.MethodCallParam);
|
|
37515
|
+
if (upper === "BOOLC" || upper === "XSDBOOL") {
|
|
37516
|
+
const argument = param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.Source);
|
|
37517
|
+
if (argument !== undefined) {
|
|
37518
|
+
this.logicalArguments.add(argument);
|
|
37519
|
+
}
|
|
37520
|
+
return undefined;
|
|
37521
|
+
}
|
|
37522
|
+
else if (upper === "BOOLX") {
|
|
37523
|
+
for (const p of ((_a = param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.ParameterListS)) === null || _a === void 0 ? void 0 : _a.findDirectExpressions(Expressions.ParameterS)) || []) {
|
|
37524
|
+
const argument = p.findDirectExpression(Expressions.Source);
|
|
37525
|
+
if (((_b = p.findDirectExpression(Expressions.ParameterName)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase()) === "BOOL" && argument !== undefined) {
|
|
37526
|
+
this.logicalArguments.add(argument);
|
|
37527
|
+
}
|
|
37528
|
+
}
|
|
37529
|
+
return undefined;
|
|
37530
|
+
}
|
|
37531
|
+
return _builtin_1.BuiltIn.isPredicate(name) === true && this.logicalArguments.has(source) === false ? name : undefined;
|
|
37532
|
+
}
|
|
37347
37533
|
// "NEW ty( )->*" is a syntax error, also in releases where a method call can be dereferenced
|
|
37348
37534
|
static isNewObjectDereference(node, deref) {
|
|
37349
37535
|
var _a;
|
|
@@ -37356,6 +37542,9 @@ class Source {
|
|
|
37356
37542
|
}
|
|
37357
37543
|
}
|
|
37358
37544
|
exports.Source = Source;
|
|
37545
|
+
// arguments of boolc( ), xsdbool( ) and the bool parameter of boolx( ) parsed as method calls, where a predicate function is allowed,
|
|
37546
|
+
// and operands where the caller has already reported the predicate function in more specific terms
|
|
37547
|
+
Source.logicalArguments = new WeakSet();
|
|
37359
37548
|
//# sourceMappingURL=source.js.map
|
|
37360
37549
|
|
|
37361
37550
|
/***/ },
|
|
@@ -38152,6 +38341,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38152
38341
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
38153
38342
|
exports.SwitchBody = void 0;
|
|
38154
38343
|
const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
38344
|
+
const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
|
|
38155
38345
|
const source_1 = __webpack_require__(/*! ./source */ "../core/build/src/abap/5_syntax/expressions/source.js");
|
|
38156
38346
|
const _raise_message_1 = __webpack_require__(/*! ../_raise_message */ "../core/build/src/abap/5_syntax/_raise_message.js");
|
|
38157
38347
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
@@ -38161,6 +38351,11 @@ class SwitchBody {
|
|
|
38161
38351
|
if (node === undefined) {
|
|
38162
38352
|
return;
|
|
38163
38353
|
}
|
|
38354
|
+
const throwNode = node.findDirectExpression(Expressions.Throw);
|
|
38355
|
+
const throwMessage = throwNode ? new _object_oriented_1.ObjectOriented(input.scope).checkClassBasedException() : undefined;
|
|
38356
|
+
if (throwNode && throwMessage) {
|
|
38357
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, throwNode.getFirstToken(), throwMessage));
|
|
38358
|
+
}
|
|
38164
38359
|
for (const t of node.findDirectExpressions(Expressions.Throw)) {
|
|
38165
38360
|
_raise_message_1.RaiseMessage.checkThrow(t, input);
|
|
38166
38361
|
}
|
|
@@ -45413,6 +45608,7 @@ const target_1 = __webpack_require__(/*! ../expressions/target */ "../core/build
|
|
|
45413
45608
|
const message_source_1 = __webpack_require__(/*! ../expressions/message_source */ "../core/build/src/abap/5_syntax/expressions/message_source.js");
|
|
45414
45609
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
45415
45610
|
const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
|
|
45611
|
+
const _builtin_call_1 = __webpack_require__(/*! ../_builtin_call */ "../core/build/src/abap/5_syntax/_builtin_call.js");
|
|
45416
45612
|
class Message {
|
|
45417
45613
|
runSyntax(node, input) {
|
|
45418
45614
|
const exceptionName = node.findDirectExpression(Expressions.ExceptionName);
|
|
@@ -45431,7 +45627,16 @@ class Message {
|
|
|
45431
45627
|
}
|
|
45432
45628
|
for (const mss of node.findDirectExpressions(Expressions.MessageSourceSource)) {
|
|
45433
45629
|
for (const s of mss.findDirectExpressions(Expressions.Source)) {
|
|
45630
|
+
const issueCount = input.issues.length;
|
|
45434
45631
|
source_1.Source.runSyntax(s, input);
|
|
45632
|
+
// "Arithmetic calculation not permitted here" on a system, whatever the argument
|
|
45633
|
+
const call = issueCount === input.issues.length && input.scope.getOpenABAP() === false
|
|
45634
|
+
? _builtin_call_1.BuiltInCall.fromSource(s, input) : undefined;
|
|
45635
|
+
if (call !== undefined && _builtin_call_1.BuiltInCall.isNumeric(call)) {
|
|
45636
|
+
const message = `Numeric function "${_builtin_call_1.BuiltInCall.callName(call)}" cannot be used in MESSAGE WITH`;
|
|
45637
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
|
|
45638
|
+
return;
|
|
45639
|
+
}
|
|
45435
45640
|
}
|
|
45436
45641
|
for (const s of mss.findDirectExpressions(Expressions.SimpleSource3)) {
|
|
45437
45642
|
source_1.Source.runSyntax(s, input);
|
|
@@ -46688,6 +46893,11 @@ class Raise {
|
|
|
46688
46893
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, exceptionName.getFirstToken(), classicMessage));
|
|
46689
46894
|
return;
|
|
46690
46895
|
}
|
|
46896
|
+
const classBasedMessage = exceptionName === undefined && node.findDirectTokenByText("EXCEPTION")
|
|
46897
|
+
? helper.checkClassBasedException() : undefined;
|
|
46898
|
+
if (classBasedMessage) {
|
|
46899
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), classBasedMessage));
|
|
46900
|
+
}
|
|
46691
46901
|
const classTok = (_a = node.findDirectExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
46692
46902
|
const className = classTok === null || classTok === void 0 ? void 0 : classTok.getStr();
|
|
46693
46903
|
if (classTok && className) {
|
|
@@ -50091,6 +50301,7 @@ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "../core/build/s
|
|
|
50091
50301
|
const field_chain_1 = __webpack_require__(/*! ../expressions/field_chain */ "../core/build/src/abap/5_syntax/expressions/field_chain.js");
|
|
50092
50302
|
const _reference_1 = __webpack_require__(/*! ../_reference */ "../core/build/src/abap/5_syntax/_reference.js");
|
|
50093
50303
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
50304
|
+
const _builtin_call_1 = __webpack_require__(/*! ../_builtin_call */ "../core/build/src/abap/5_syntax/_builtin_call.js");
|
|
50094
50305
|
class Write {
|
|
50095
50306
|
runSyntax(node, input) {
|
|
50096
50307
|
// todo, more
|
|
@@ -50100,7 +50311,16 @@ class Write {
|
|
|
50100
50311
|
second = node.getChildren()[2];
|
|
50101
50312
|
}
|
|
50102
50313
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
50314
|
+
const issueCount = input.issues.length;
|
|
50103
50315
|
const type = source_1.Source.runSyntax(s, input);
|
|
50316
|
+
// "Arithmetic calculation not permitted here" on a system, while abs( x ) or lines( itab ) is fine
|
|
50317
|
+
const call = s === second && issueCount === input.issues.length && input.scope.getOpenABAP() === false
|
|
50318
|
+
? _builtin_call_1.BuiltInCall.fromSource(s, input) : undefined;
|
|
50319
|
+
if (call !== undefined && _builtin_call_1.BuiltInCall.isNumeric(call) && _builtin_call_1.BuiltInCall.hasDataObjectArgument(call) === false) {
|
|
50320
|
+
const message = `Numeric function "${_builtin_call_1.BuiltInCall.callName(call)}" in WRITE takes only a single data object as argument`;
|
|
50321
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
|
|
50322
|
+
return;
|
|
50323
|
+
}
|
|
50104
50324
|
if (s === second
|
|
50105
50325
|
&& new _type_utils_1.TypeUtils(input.scope).isCharLike(type) === false
|
|
50106
50326
|
&& new _type_utils_1.TypeUtils(input.scope).isHexLike(type) === false) {
|
|
@@ -74310,7 +74530,7 @@ class Registry {
|
|
|
74310
74530
|
}
|
|
74311
74531
|
static abaplintVersion() {
|
|
74312
74532
|
// magic, see build script "version.js"
|
|
74313
|
-
return "2.120.
|
|
74533
|
+
return "2.120.112";
|
|
74314
74534
|
}
|
|
74315
74535
|
getDDICReferences() {
|
|
74316
74536
|
return this.ddicReferences;
|
|
@@ -97911,6 +98131,7 @@ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js"
|
|
|
97911
98131
|
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
|
|
97912
98132
|
const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
|
|
97913
98133
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
98134
|
+
const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
|
|
97914
98135
|
class LoopTargetMisuseConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
97915
98136
|
constructor() {
|
|
97916
98137
|
super(...arguments);
|
|
@@ -97919,6 +98140,9 @@ class LoopTargetMisuseConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
|
97919
98140
|
/** Report LOOP AT ... INTO <fs> and READ TABLE ... INTO <fs> when the local field symbol is only bound by ASSIGNING,
|
|
97920
98141
|
* so the statement overwrites a table row */
|
|
97921
98142
|
this.intoFieldSymbol = true;
|
|
98143
|
+
/** Report a field symbol of LOOP AT ... ASSIGNING used after ENDLOOP, and a field symbol of READ TABLE ... ASSIGNING
|
|
98144
|
+
* used after the check of sy-subrc, outside the branch that found the row */
|
|
98145
|
+
this.usedAfterLoop = true;
|
|
97922
98146
|
}
|
|
97923
98147
|
}
|
|
97924
98148
|
exports.LoopTargetMisuseConf = LoopTargetMisuseConf;
|
|
@@ -97944,7 +98168,21 @@ Option intoFieldSymbol: LOOP AT ... INTO <fs> or READ TABLE ... INTO <fs>. INTO
|
|
|
97944
98168
|
into the data object the field symbol points to. When <fs> was bound by ASSIGNING, that data
|
|
97945
98169
|
object is a row of a table, and the statement overwrites it. ASSIGNING was meant.
|
|
97946
98170
|
Reported only for a field symbol declared in the method, form or function module, and only when
|
|
97947
|
-
no ASSIGN and no STRUCTURE ... DEFAULT binds it there, so it can only point to a table row
|
|
98171
|
+
no ASSIGN and no STRUCTURE ... DEFAULT binds it there, so it can only point to a table row.
|
|
98172
|
+
|
|
98173
|
+
Option usedAfterLoop: a field symbol of LOOP AT ... ASSIGNING used after ENDLOOP. It points to
|
|
98174
|
+
the last row the loop processed. When the loop processed no row, it is not assigned, and the use
|
|
98175
|
+
raises GETWA_NOT_ASSIGNED, or it still points to what it was bound to before the loop.
|
|
98176
|
+
Also a field symbol of READ TABLE ... ASSIGNING used after sy-subrc was checked, outside the
|
|
98177
|
+
branch of that check. When the READ fails, the field symbol keeps its previous binding.
|
|
98178
|
+
Reported at the first such use in the method, form or function module.
|
|
98179
|
+
Not reported: a use inside IF, ELSEIF, CASE or WHILE whose condition reads sy-subrc, the table of
|
|
98180
|
+
the loop or a variable the loop body sets (a flag), a use after such a check that leaves with
|
|
98181
|
+
RETURN, EXIT, CONTINUE, CHECK, RAISE or MESSAGE or that does not use the field symbol, a use after
|
|
98182
|
+
CHECK or ASSERT of such a condition, and any use after IS ASSIGNED, UNASSIGN or another binding of
|
|
98183
|
+
the field symbol, or after a macro call. Work areas of INTO are not checked, they keep a value.
|
|
98184
|
+
A READ TABLE whose sy-subrc is not checked at all is left to check_subrc, a LOOP inside a LOOP
|
|
98185
|
+
with the same field symbol to the option nestedLoop.`,
|
|
97948
98186
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
97949
98187
|
badExample: `LOOP AT lt_header INTO ls_row.
|
|
97950
98188
|
LOOP AT lt_items INTO ls_row WHERE parent = ls_row-id.
|
|
@@ -97956,7 +98194,12 @@ ENDLOOP.
|
|
|
97956
98194
|
|
|
97957
98195
|
LOOP AT lt_a ASSIGNING <ls_a>.
|
|
97958
98196
|
ENDLOOP.
|
|
97959
|
-
READ TABLE lt_a INTO <ls_a> INDEX 1
|
|
98197
|
+
READ TABLE lt_a INTO <ls_a> INDEX 1.
|
|
98198
|
+
|
|
98199
|
+
LOOP AT lt_a ASSIGNING <ls_a> WHERE id = lv_id.
|
|
98200
|
+
EXIT.
|
|
98201
|
+
ENDLOOP.
|
|
98202
|
+
<ls_a>-flag = abap_true.`,
|
|
97960
98203
|
goodExample: `LOOP AT lt_header INTO ls_row.
|
|
97961
98204
|
LOOP AT lt_items INTO ls_item WHERE parent = ls_row-id.
|
|
97962
98205
|
lv_sum = lv_sum + ls_item-amount.
|
|
@@ -97967,7 +98210,14 @@ ENDLOOP.
|
|
|
97967
98210
|
|
|
97968
98211
|
LOOP AT lt_a ASSIGNING <ls_a>.
|
|
97969
98212
|
ENDLOOP.
|
|
97970
|
-
READ TABLE lt_a ASSIGNING <ls_a> INDEX 1
|
|
98213
|
+
READ TABLE lt_a ASSIGNING <ls_a> INDEX 1.
|
|
98214
|
+
|
|
98215
|
+
LOOP AT lt_a ASSIGNING <ls_a> WHERE id = lv_id.
|
|
98216
|
+
EXIT.
|
|
98217
|
+
ENDLOOP.
|
|
98218
|
+
IF sy-subrc = 0.
|
|
98219
|
+
<ls_a>-flag = abap_true.
|
|
98220
|
+
ENDIF.`,
|
|
97971
98221
|
};
|
|
97972
98222
|
}
|
|
97973
98223
|
getConfig() {
|
|
@@ -97985,6 +98235,14 @@ READ TABLE lt_a ASSIGNING <ls_a> INDEX 1.`,
|
|
|
97985
98235
|
if (this.conf.intoFieldSymbol !== false) {
|
|
97986
98236
|
issues.push(...this.checkIntoFieldSymbol(file, statements));
|
|
97987
98237
|
}
|
|
98238
|
+
if (this.conf.usedAfterLoop !== false) {
|
|
98239
|
+
for (const issue of this.checkUsedAfterLoop(file, statements)) {
|
|
98240
|
+
// a READ TABLE ... INTO <fs> after the loop is already reported by the option intoFieldSymbol
|
|
98241
|
+
if (issues.some(i => i.getStart().equals(issue.getStart())) === false) {
|
|
98242
|
+
issues.push(issue);
|
|
98243
|
+
}
|
|
98244
|
+
}
|
|
98245
|
+
}
|
|
97988
98246
|
return issues;
|
|
97989
98247
|
}
|
|
97990
98248
|
////////////////
|
|
@@ -98041,7 +98299,7 @@ READ TABLE lt_a ASSIGNING <ls_a> INDEX 1.`,
|
|
|
98041
98299
|
let depth = 0;
|
|
98042
98300
|
for (let i = index + 1; i < statements.length && this.isBlockBoundary(statements[i]) === false; i++) {
|
|
98043
98301
|
const s = statements[i].get();
|
|
98044
|
-
if (s instanceof Statements.Loop) {
|
|
98302
|
+
if (s instanceof Statements.Loop || s instanceof Statements.LoopAtScreen || s instanceof Statements.LoopExtract) {
|
|
98045
98303
|
depth++;
|
|
98046
98304
|
}
|
|
98047
98305
|
else if (s instanceof Statements.EndLoop) {
|
|
@@ -98150,6 +98408,232 @@ READ TABLE lt_a ASSIGNING <ls_a> INDEX 1.`,
|
|
|
98150
98408
|
var _a;
|
|
98151
98409
|
return (_a = fsTarget.findFirstExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
98152
98410
|
}
|
|
98411
|
+
checkUsedAfterLoop(file, statements) {
|
|
98412
|
+
var _a;
|
|
98413
|
+
const issues = [];
|
|
98414
|
+
// the field symbols of the open LOOPs, undefined for a LOOP without field symbol
|
|
98415
|
+
let open = [];
|
|
98416
|
+
for (let i = 0; i < statements.length; i++) {
|
|
98417
|
+
const statement = statements[i];
|
|
98418
|
+
const s = statement.get();
|
|
98419
|
+
if (this.isBlockBoundary(statement)) {
|
|
98420
|
+
open = [];
|
|
98421
|
+
continue;
|
|
98422
|
+
}
|
|
98423
|
+
else if (s instanceof Statements.EndLoop) {
|
|
98424
|
+
open.pop();
|
|
98425
|
+
continue;
|
|
98426
|
+
}
|
|
98427
|
+
let use = undefined;
|
|
98428
|
+
let name = undefined;
|
|
98429
|
+
let what = "";
|
|
98430
|
+
if (s instanceof Statements.Loop) {
|
|
98431
|
+
const node = this.loopTarget(statement);
|
|
98432
|
+
name = (node === null || node === void 0 ? void 0 : node.get()) instanceof Expressions.FSTarget ? this.targetName(node) : undefined;
|
|
98433
|
+
const end = this.findEndLoop(statements, i);
|
|
98434
|
+
// a LOOP inside a LOOP with the same field symbol is left to the option nestedLoop
|
|
98435
|
+
if (name !== undefined && end !== undefined && open.includes(name) === false) {
|
|
98436
|
+
const guards = this.loopGuards(statements, i, end, name);
|
|
98437
|
+
use = this.findUncheckedUse(statements, end + 1, name, guards, false);
|
|
98438
|
+
what = `after ENDLOOP, it points to the last row, or is not assigned when the loop processed no row`;
|
|
98439
|
+
}
|
|
98440
|
+
open.push(name);
|
|
98441
|
+
}
|
|
98442
|
+
else if (s instanceof Statements.LoopAtScreen || s instanceof Statements.LoopExtract) {
|
|
98443
|
+
open.push(undefined);
|
|
98444
|
+
}
|
|
98445
|
+
else if (s instanceof Statements.ReadTable) {
|
|
98446
|
+
const fs = (_a = statement.findDirectExpression(Expressions.ReadTableTarget)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.FSTarget);
|
|
98447
|
+
name = fs ? this.targetName(fs) : undefined;
|
|
98448
|
+
if (name !== undefined) {
|
|
98449
|
+
use = this.findUncheckedUse(statements, i + 1, name, new Set(), true);
|
|
98450
|
+
what = `outside the check of sy-subrc, when the READ TABLE fails it is not assigned or points to an earlier row`;
|
|
98451
|
+
}
|
|
98452
|
+
}
|
|
98453
|
+
if (use !== undefined && name !== undefined) {
|
|
98454
|
+
const token = statements[use].getTokens().find(t => t.getStr().toUpperCase() === name);
|
|
98455
|
+
const message = `${token === null || token === void 0 ? void 0 : token.getStr()} is used ${what}`;
|
|
98456
|
+
issues.push(issue_1.Issue.atStatement(file, statements[use], message, this.getMetadata().key, this.conf.severity));
|
|
98457
|
+
}
|
|
98458
|
+
}
|
|
98459
|
+
return issues;
|
|
98460
|
+
}
|
|
98461
|
+
/** upper case names of the variables whose check counts as a check that the LOOP processed a row:
|
|
98462
|
+
* the table and the variables the loop body writes */
|
|
98463
|
+
loopGuards(statements, loop, end, name) {
|
|
98464
|
+
var _a;
|
|
98465
|
+
const guards = new Set();
|
|
98466
|
+
const first = (_a = statements[loop].findDirectExpression(Expressions.LoopSource)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr().toUpperCase();
|
|
98467
|
+
if (first !== undefined) {
|
|
98468
|
+
guards.add(first);
|
|
98469
|
+
}
|
|
98470
|
+
for (let i = loop + 1; i < end; i++) {
|
|
98471
|
+
for (const target of statements[i].findAllExpressions(Expressions.Target)) {
|
|
98472
|
+
guards.add(this.firstName(target));
|
|
98473
|
+
}
|
|
98474
|
+
}
|
|
98475
|
+
guards.delete(name);
|
|
98476
|
+
return guards;
|
|
98477
|
+
}
|
|
98478
|
+
/** upper case name of the variable a Target writes, also declared inline */
|
|
98479
|
+
firstName(target) {
|
|
98480
|
+
const inline = target.findFirstExpression(Expressions.TargetField);
|
|
98481
|
+
return (inline ? inline.getFirstToken() : target.getFirstToken()).getStr().toUpperCase();
|
|
98482
|
+
}
|
|
98483
|
+
/** index of the first statement from the index on that uses the field symbol without a check before it,
|
|
98484
|
+
* looking until the end of the method, form or function module or until the field symbol is bound again.
|
|
98485
|
+
* With checkFirst, only a use after a check is returned, an unchecked READ TABLE is left to check_subrc */
|
|
98486
|
+
findUncheckedUse(statements, from, name, guards, checkFirst) {
|
|
98487
|
+
const frames = [];
|
|
98488
|
+
let checked = false;
|
|
98489
|
+
let sawCheck = false;
|
|
98490
|
+
for (let i = from; i < statements.length && this.isBlockBoundary(statements[i]) === false; i++) {
|
|
98491
|
+
const statement = statements[i];
|
|
98492
|
+
const s = statement.get();
|
|
98493
|
+
if (s instanceof _statement_1.MacroCall || s instanceof _statement_1.Unknown || this.bindsOrTests(statement, name)) {
|
|
98494
|
+
return undefined;
|
|
98495
|
+
}
|
|
98496
|
+
const isCondition = s instanceof Statements.If || s instanceof Statements.ElseIf || s instanceof Statements.Case
|
|
98497
|
+
|| s instanceof Statements.When || s instanceof Statements.While
|
|
98498
|
+
|| s instanceof Statements.Check || s instanceof Statements.Assert;
|
|
98499
|
+
const guard = isCondition && this.isGuard(statement, guards);
|
|
98500
|
+
sawCheck = sawCheck || guard;
|
|
98501
|
+
if ((s instanceof Statements.Check || s instanceof Statements.Assert) && guard) {
|
|
98502
|
+
checked = true;
|
|
98503
|
+
}
|
|
98504
|
+
if (s instanceof Statements.FieldSymbol === false && this.mentions(statement, name)) {
|
|
98505
|
+
if (guard || checked || frames.some(f => f.guard)) {
|
|
98506
|
+
frames.forEach(f => f.uses = true);
|
|
98507
|
+
}
|
|
98508
|
+
else if (checkFirst === false || sawCheck === true) {
|
|
98509
|
+
return i;
|
|
98510
|
+
}
|
|
98511
|
+
}
|
|
98512
|
+
if (guard || frames.some(f => f.guard)) {
|
|
98513
|
+
// a flag set where the check holds, like lv_found = abap_true, checks it as well
|
|
98514
|
+
for (const target of statement.findAllExpressions(Expressions.Target)) {
|
|
98515
|
+
guards.add(this.firstName(target));
|
|
98516
|
+
}
|
|
98517
|
+
guards.delete(name);
|
|
98518
|
+
}
|
|
98519
|
+
if (this.leaves(statement)) {
|
|
98520
|
+
frames.forEach(f => f.leaves = true);
|
|
98521
|
+
}
|
|
98522
|
+
if (this.opensBlock(statement)) {
|
|
98523
|
+
frames.push({ guard, uses: false, leaves: false });
|
|
98524
|
+
}
|
|
98525
|
+
else if (this.isBranch(statement)) {
|
|
98526
|
+
if (frames.length === 0) {
|
|
98527
|
+
// another branch of a block around the binding, it does not run after it
|
|
98528
|
+
return undefined;
|
|
98529
|
+
}
|
|
98530
|
+
frames[frames.length - 1].guard = frames[frames.length - 1].guard || guard;
|
|
98531
|
+
}
|
|
98532
|
+
else if (this.closesBlock(statement)) {
|
|
98533
|
+
const frame = frames.pop();
|
|
98534
|
+
// IF sy-subrc <> 0. RETURN. ENDIF., or a check that sets a flag
|
|
98535
|
+
if (frame && frame.guard && (frame.leaves || frame.uses === false)) {
|
|
98536
|
+
checked = true;
|
|
98537
|
+
}
|
|
98538
|
+
}
|
|
98539
|
+
}
|
|
98540
|
+
return undefined;
|
|
98541
|
+
}
|
|
98542
|
+
/** true when the statement binds the field symbol again, unassigns it, or checks IS ASSIGNED */
|
|
98543
|
+
bindsOrTests(statement, name) {
|
|
98544
|
+
if (statement.get() instanceof Statements.Unassign && this.mentions(statement, name)) {
|
|
98545
|
+
return true;
|
|
98546
|
+
}
|
|
98547
|
+
for (const fsTarget of statement.findAllExpressions(Expressions.FSTarget)) {
|
|
98548
|
+
if (this.targetName(fsTarget) === name) {
|
|
98549
|
+
return true;
|
|
98550
|
+
}
|
|
98551
|
+
}
|
|
98552
|
+
const tokens = statement.getTokens().map(t => t.getStr().toUpperCase());
|
|
98553
|
+
for (let i = 0; i < tokens.length - 2; i++) {
|
|
98554
|
+
if (tokens[i] === name && tokens[i + 1] === "IS"
|
|
98555
|
+
&& (tokens[i + 2] === "ASSIGNED" || (tokens[i + 2] === "NOT" && tokens[i + 3] === "ASSIGNED"))) {
|
|
98556
|
+
return true;
|
|
98557
|
+
}
|
|
98558
|
+
}
|
|
98559
|
+
return false;
|
|
98560
|
+
}
|
|
98561
|
+
/** true when the condition reads sy-subrc or one of the variables */
|
|
98562
|
+
isGuard(statement, guards) {
|
|
98563
|
+
var _a, _b;
|
|
98564
|
+
const tokens = statement.getTokens();
|
|
98565
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
98566
|
+
const str = tokens[i].getStr().toUpperCase();
|
|
98567
|
+
const previous = i > 0 ? tokens[i - 1].getStr() : "";
|
|
98568
|
+
if (["-", "->", "=>", "~"].includes(previous)) {
|
|
98569
|
+
continue;
|
|
98570
|
+
}
|
|
98571
|
+
if ((str === "SY" && ((_a = tokens[i + 1]) === null || _a === void 0 ? void 0 : _a.getStr()) === "-" && ((_b = tokens[i + 2]) === null || _b === void 0 ? void 0 : _b.getStr().toUpperCase()) === "SUBRC")
|
|
98572
|
+
|| guards.has(str)) {
|
|
98573
|
+
return true;
|
|
98574
|
+
}
|
|
98575
|
+
}
|
|
98576
|
+
return false;
|
|
98577
|
+
}
|
|
98578
|
+
mentions(statement, name) {
|
|
98579
|
+
return statement.getTokens().some(t => t.getStr().toUpperCase() === name);
|
|
98580
|
+
}
|
|
98581
|
+
/** true for a statement that can leave the current block, a call of a method named like RAISE counts */
|
|
98582
|
+
leaves(statement) {
|
|
98583
|
+
const s = statement.get();
|
|
98584
|
+
return s instanceof Statements.Return
|
|
98585
|
+
|| s instanceof Statements.Exit
|
|
98586
|
+
|| s instanceof Statements.Continue
|
|
98587
|
+
|| s instanceof Statements.Check
|
|
98588
|
+
|| s instanceof Statements.Raise
|
|
98589
|
+
|| s instanceof Statements.Leave
|
|
98590
|
+
|| s instanceof Statements.Message
|
|
98591
|
+
|| s instanceof Statements.Assert
|
|
98592
|
+
|| (s instanceof Statements.Call && statement.getTokens().some(t => /raise/i.test(t.getStr())));
|
|
98593
|
+
}
|
|
98594
|
+
opensBlock(statement) {
|
|
98595
|
+
const s = statement.get();
|
|
98596
|
+
return s instanceof Statements.If
|
|
98597
|
+
|| s instanceof Statements.Case
|
|
98598
|
+
|| s instanceof Statements.CaseType
|
|
98599
|
+
|| s instanceof Statements.Loop
|
|
98600
|
+
|| s instanceof Statements.LoopAtScreen
|
|
98601
|
+
|| s instanceof Statements.LoopExtract
|
|
98602
|
+
|| s instanceof Statements.Do
|
|
98603
|
+
|| s instanceof Statements.While
|
|
98604
|
+
|| s instanceof Statements.Try
|
|
98605
|
+
|| s instanceof Statements.SelectLoop
|
|
98606
|
+
|| s instanceof Statements.At
|
|
98607
|
+
|| s instanceof Statements.AtFirst
|
|
98608
|
+
|| s instanceof Statements.AtLast
|
|
98609
|
+
|| s instanceof Statements.OnChange
|
|
98610
|
+
|| s instanceof Statements.Provide
|
|
98611
|
+
|| s instanceof Statements.CatchSystemExceptions;
|
|
98612
|
+
}
|
|
98613
|
+
isBranch(statement) {
|
|
98614
|
+
const s = statement.get();
|
|
98615
|
+
return s instanceof Statements.ElseIf
|
|
98616
|
+
|| s instanceof Statements.Else
|
|
98617
|
+
|| s instanceof Statements.When
|
|
98618
|
+
|| s instanceof Statements.WhenOthers
|
|
98619
|
+
|| s instanceof Statements.WhenType
|
|
98620
|
+
|| s instanceof Statements.Catch
|
|
98621
|
+
|| s instanceof Statements.Cleanup;
|
|
98622
|
+
}
|
|
98623
|
+
closesBlock(statement) {
|
|
98624
|
+
const s = statement.get();
|
|
98625
|
+
return s instanceof Statements.EndIf
|
|
98626
|
+
|| s instanceof Statements.EndCase
|
|
98627
|
+
|| s instanceof Statements.EndLoop
|
|
98628
|
+
|| s instanceof Statements.EndDo
|
|
98629
|
+
|| s instanceof Statements.EndWhile
|
|
98630
|
+
|| s instanceof Statements.EndTry
|
|
98631
|
+
|| s instanceof Statements.EndSelect
|
|
98632
|
+
|| s instanceof Statements.EndAt
|
|
98633
|
+
|| s instanceof Statements.EndOn
|
|
98634
|
+
|| s instanceof Statements.EndProvide
|
|
98635
|
+
|| s instanceof Statements.EndCatch;
|
|
98636
|
+
}
|
|
98153
98637
|
isBlockBoundary(statement) {
|
|
98154
98638
|
return this.startsBlock(statement) || this.endsBlock(statement);
|
|
98155
98639
|
}
|
|
@@ -107168,8 +107652,16 @@ text = text.`,
|
|
|
107168
107652
|
if (structure === undefined) {
|
|
107169
107653
|
continue;
|
|
107170
107654
|
}
|
|
107655
|
+
const sources = structure.findAllExpressionsRecursive(Expressions.Source);
|
|
107656
|
+
// Sources that are an operand of an enclosing Source, e.g. "2 * CONV i( a + b )" or "- CONV i( a + b )"
|
|
107657
|
+
const operands = new Set();
|
|
107658
|
+
for (const source of sources) {
|
|
107659
|
+
if (source.getChildren().length > 1) {
|
|
107660
|
+
source.findDirectExpressions(Expressions.Source).forEach(operand => operands.add(operand));
|
|
107661
|
+
}
|
|
107662
|
+
}
|
|
107171
107663
|
// recursive, a CONV can be the argument of a built-in function, which is itself a Source
|
|
107172
|
-
for (const source of
|
|
107664
|
+
for (const source of sources) {
|
|
107173
107665
|
if (source.getFirstToken().getStr().toUpperCase() !== "CONV") {
|
|
107174
107666
|
continue;
|
|
107175
107667
|
}
|
|
@@ -107202,8 +107694,12 @@ text = text.`,
|
|
|
107202
107694
|
if (closingParen === undefined) {
|
|
107203
107695
|
continue;
|
|
107204
107696
|
}
|
|
107205
|
-
|
|
107206
|
-
|
|
107697
|
+
// parentheses are only needed when the CONV takes part in a surrounding operation,
|
|
107698
|
+
// "CONV type ( body )" alone has 5 children, more means a trailing operator
|
|
107699
|
+
const partOfOperation = source.getChildren().length !== 5 || operands.has(source);
|
|
107700
|
+
const preserveParentheses = partOfOperation
|
|
107701
|
+
&& (bodySource.findDirectExpression(Expressions.ArithOperator) !== undefined
|
|
107702
|
+
|| bodySource.findDirectTokenByText("&&") !== undefined);
|
|
107207
107703
|
// Apply the later edit first so the original positions remain valid when
|
|
107208
107704
|
// both parts of the CONV wrapper are changed on the same line.
|
|
107209
107705
|
const fix = edit_helper_1.EditHelper.merge(edit_helper_1.EditHelper.replaceRange(file, bodySource.getLastToken().getEnd(), closingParen.getEnd(), preserveParentheses ? ")" : ""), edit_helper_1.EditHelper.replaceRange(file, source.getFirstToken().getStart(), bodySource.getFirstToken().getStart(), preserveParentheses ? "(" : ""));
|
|
@@ -107793,6 +108289,15 @@ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/sta
|
|
|
107793
108289
|
const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
107794
108290
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
107795
108291
|
class RFCErrorHandlingConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
108292
|
+
constructor() {
|
|
108293
|
+
super(...arguments);
|
|
108294
|
+
/** Also check CALL FUNCTION ... STARTING NEW TASK without DESTINATION, an asynchronous RFC to the destination NONE */
|
|
108295
|
+
this.startingNewTask = true;
|
|
108296
|
+
/** Report error_message in the EXCEPTIONS of an RFC call, it is ignored in RFC */
|
|
108297
|
+
this.errorMessage = true;
|
|
108298
|
+
/** Report SYSTEM_FAILURE and COMMUNICATION_FAILURE without the addition MESSAGE, the error text is lost */
|
|
108299
|
+
this.requireMessage = false;
|
|
108300
|
+
}
|
|
107796
108301
|
}
|
|
107797
108302
|
exports.RFCErrorHandlingConf = RFCErrorHandlingConf;
|
|
107798
108303
|
class RFCErrorHandling extends _abap_rule_1.ABAPRule {
|
|
@@ -107808,11 +108313,35 @@ class RFCErrorHandling extends _abap_rule_1.ABAPRule {
|
|
|
107808
108313
|
shortDescription: `Checks that exceptions 'system_failure' and 'communication_failure' are handled in RFC calls`,
|
|
107809
108314
|
extendedInformation: `RESOURCE_FAILURE is also required for asynchronous calls with DESTINATION IN GROUP.
|
|
107810
108315
|
|
|
107811
|
-
|
|
108316
|
+
Checked are CALL FUNCTION ... DESTINATION and, with startingNewTask, CALL FUNCTION ... STARTING NEW TASK
|
|
108317
|
+
without DESTINATION, which is an asynchronous RFC to the destination NONE.
|
|
108318
|
+
CALL FUNCTION ... IN BACKGROUND TASK is not checked, it cannot have EXCEPTIONS.
|
|
108319
|
+
|
|
108320
|
+
errorMessage: reports error_message in the EXCEPTIONS of an RFC call. It is ignored in RFC, a message of
|
|
108321
|
+
type A, E or X ends the called function module and raises SYSTEM_FAILURE, use system_failure = n MESSAGE msg
|
|
108322
|
+
to get the message text. Exception: with a DESTINATION that is blank at runtime, the call is local.
|
|
108323
|
+
|
|
108324
|
+
requireMessage: reports SYSTEM_FAILURE and COMMUNICATION_FAILURE without the addition MESSAGE.
|
|
108325
|
+
|
|
108326
|
+
https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenrfc_exception.html
|
|
108327
|
+
https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapcall_function_destination_para.html`,
|
|
107812
108328
|
badExample: `CALL FUNCTION 'ZRFC'
|
|
107813
|
-
DESTINATION lv_rfc
|
|
108329
|
+
DESTINATION lv_rfc.
|
|
108330
|
+
|
|
108331
|
+
CALL FUNCTION 'ZRFC'
|
|
108332
|
+
STARTING NEW TASK 'TASK'
|
|
108333
|
+
EXCEPTIONS
|
|
108334
|
+
error_message = 1
|
|
108335
|
+
OTHERS = 2.`,
|
|
107814
108336
|
goodExample: `CALL FUNCTION 'ZRFC'
|
|
107815
108337
|
DESTINATION lv_rfc
|
|
108338
|
+
EXCEPTIONS
|
|
108339
|
+
system_failure = 1 MESSAGE msg
|
|
108340
|
+
communication_failure = 2 MESSAGE msg
|
|
108341
|
+
OTHERS = 3.
|
|
108342
|
+
|
|
108343
|
+
CALL FUNCTION 'ZRFC'
|
|
108344
|
+
STARTING NEW TASK 'TASK'
|
|
107816
108345
|
EXCEPTIONS
|
|
107817
108346
|
system_failure = 1 MESSAGE msg
|
|
107818
108347
|
communication_failure = 2 MESSAGE msg
|
|
@@ -107837,28 +108366,45 @@ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenrfc_exceptio
|
|
|
107837
108366
|
continue;
|
|
107838
108367
|
}
|
|
107839
108368
|
const destination = stat.findFirstExpression(Expressions.Destination);
|
|
107840
|
-
|
|
108369
|
+
const starting = stat.findDirectTokenByText("STARTING") !== undefined;
|
|
108370
|
+
if (destination === undefined && (starting === false || this.conf.startingNewTask === false)) {
|
|
108371
|
+
continue;
|
|
108372
|
+
}
|
|
108373
|
+
if (stat.findDirectTokenByText("BACKGROUND") !== undefined) {
|
|
108374
|
+
// transactional RFC, it has no EXCEPTIONS
|
|
107841
108375
|
continue;
|
|
107842
108376
|
}
|
|
107843
|
-
const requireResourceFailure =
|
|
107844
|
-
&& destination.findDirectTokenByText("GROUP") !== undefined;
|
|
108377
|
+
const requireResourceFailure = starting === true
|
|
108378
|
+
&& (destination === null || destination === void 0 ? void 0 : destination.findDirectTokenByText("GROUP")) !== undefined;
|
|
107845
108379
|
const list = stat.findFirstExpression(Expressions.ParameterListExceptions);
|
|
107846
108380
|
if (list === undefined) {
|
|
107847
108381
|
const issue = issue_1.Issue.atToken(file, token, this.getMessage(requireResourceFailure), this.getMetadata().key, this.conf.severity);
|
|
107848
108382
|
output.push(issue);
|
|
107849
108383
|
continue;
|
|
107850
108384
|
}
|
|
107851
|
-
const
|
|
107852
|
-
const
|
|
107853
|
-
|
|
107854
|
-
names.push(par.getFirstToken().getStr().toUpperCase());
|
|
108385
|
+
const exceptions = new Map();
|
|
108386
|
+
for (const exception of list.findDirectExpressions(Expressions.ParameterException)) {
|
|
108387
|
+
exceptions.set(exception.getFirstToken().getStr().toUpperCase(), exception);
|
|
107855
108388
|
}
|
|
107856
|
-
if (
|
|
107857
|
-
||
|
|
107858
|
-
|| (requireResourceFailure &&
|
|
108389
|
+
if (exceptions.has("SYSTEM_FAILURE") === false
|
|
108390
|
+
|| exceptions.has("COMMUNICATION_FAILURE") === false
|
|
108391
|
+
|| (requireResourceFailure && exceptions.has("RESOURCE_FAILURE") === false)) {
|
|
107859
108392
|
const issue = issue_1.Issue.atToken(file, token, this.getMessage(requireResourceFailure), this.getMetadata().key, this.conf.severity);
|
|
107860
108393
|
output.push(issue);
|
|
107861
|
-
|
|
108394
|
+
}
|
|
108395
|
+
const errorMessage = exceptions.get("ERROR_MESSAGE");
|
|
108396
|
+
if (this.conf.errorMessage !== false && errorMessage !== undefined) {
|
|
108397
|
+
const message = "error_message is ignored in RFC, messages of type A, E and X raise SYSTEM_FAILURE, use system_failure = n MESSAGE msg";
|
|
108398
|
+
output.push(issue_1.Issue.atToken(file, errorMessage.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
|
|
108399
|
+
}
|
|
108400
|
+
if (this.conf.requireMessage === true) {
|
|
108401
|
+
for (const name of ["SYSTEM_FAILURE", "COMMUNICATION_FAILURE"]) {
|
|
108402
|
+
const exception = exceptions.get(name);
|
|
108403
|
+
if (exception !== undefined && exception.findDirectTokenByText("MESSAGE") === undefined) {
|
|
108404
|
+
const message = `${name} without MESSAGE, the error text is lost, use ${name.toLowerCase()} = n MESSAGE msg`;
|
|
108405
|
+
output.push(issue_1.Issue.atToken(file, exception.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
|
|
108406
|
+
}
|
|
108407
|
+
}
|
|
107862
108408
|
}
|
|
107863
108409
|
}
|
|
107864
108410
|
return output;
|
|
@@ -113932,6 +114478,8 @@ class UnhandledClassicExceptionConf extends _basic_rule_config_1.BasicRuleConfig
|
|
|
113932
114478
|
this.missingExceptions = true;
|
|
113933
114479
|
/** missingExceptions: do not report a method call whose arguments are all literals or me, like describe_by_name( 'T100' ) */
|
|
113934
114480
|
this.allowLiteralArguments = true;
|
|
114481
|
+
/** Report CALL FUNCTION without error_message, the policy "always list error_message", for code that runs outside dialog */
|
|
114482
|
+
this.missingErrorMessage = false;
|
|
113935
114483
|
}
|
|
113936
114484
|
}
|
|
113937
114485
|
exports.UnhandledClassicExceptionConf = UnhandledClassicExceptionConf;
|
|
@@ -113957,6 +114505,13 @@ missingExceptions: reports calls without EXCEPTIONS of a method or function modu
|
|
|
113957
114505
|
this includes functional calls, which cannot have EXCEPTIONS.
|
|
113958
114506
|
With allowLiteralArguments, a method call whose arguments are all literals or me is not reported.
|
|
113959
114507
|
|
|
114508
|
+
missingErrorMessage, off by default: reports every CALL FUNCTION that does not list the predefined exception error_message,
|
|
114509
|
+
the policy "always list error_message". Any function module can send a MESSAGE without RAISING, directly or from a
|
|
114510
|
+
function module it calls, and OTHERS does not catch it. Outside dialog, in HTTP handlers, RFC and background jobs,
|
|
114511
|
+
a message of type E or A ends the processing. Use it together with check_subrc, otherwise error_message turns a
|
|
114512
|
+
visible abort into a silent failure. Not reported: DESTINATION, STARTING NEW TASK, IN UPDATE TASK, IN BACKGROUND,
|
|
114513
|
+
EXCEPTION-TABLE, and function modules in the registry with class-based exceptions.
|
|
114514
|
+
|
|
113960
114515
|
Signatures are taken from the registry, including dependencies. Methods and function modules that are not
|
|
113961
114516
|
found (void) are only checked by missingOthers.
|
|
113962
114517
|
|
|
@@ -114017,7 +114572,7 @@ cl_abap_typedescr=>describe_by_name(
|
|
|
114017
114572
|
if (nameNode) {
|
|
114018
114573
|
const token = nameNode.getFirstToken();
|
|
114019
114574
|
const callee = nameNode.get() instanceof Expressions.Dynamic ? undefined : this.findMethod(methods, token);
|
|
114020
|
-
const issue = this.checkCall(file, token, callee, body === null || body === void 0 ? void 0 : body.findDirectExpression(Expressions.MethodParameters), (body === null || body === void 0 ? void 0 : body.findDirectTokenByText("EXCEPTION
|
|
114575
|
+
const issue = this.checkCall(file, token, callee, body === null || body === void 0 ? void 0 : body.findDirectExpression(Expressions.MethodParameters), (body === null || body === void 0 ? void 0 : body.findDirectTokenByText("EXCEPTION")) !== undefined, false, this.onlyLiterals(body));
|
|
114021
114576
|
if (issue) {
|
|
114022
114577
|
issues.push(issue);
|
|
114023
114578
|
}
|
|
@@ -114039,6 +114594,7 @@ cl_abap_typedescr=>describe_by_name(
|
|
|
114039
114594
|
return issues;
|
|
114040
114595
|
}
|
|
114041
114596
|
checkCallFunction(statement, file) {
|
|
114597
|
+
var _a;
|
|
114042
114598
|
if (statement.findDirectTokenByText("STARTING")
|
|
114043
114599
|
|| statement.findDirectTokenByText("UPDATE")
|
|
114044
114600
|
|| statement.findDirectTokenByText("BACKGROUND")) {
|
|
@@ -114049,18 +114605,35 @@ cl_abap_typedescr=>describe_by_name(
|
|
|
114049
114605
|
return [];
|
|
114050
114606
|
}
|
|
114051
114607
|
let callee = undefined;
|
|
114608
|
+
let classBased = false;
|
|
114052
114609
|
if (nameNode.findFirstExpression(Expressions.FieldChain) === undefined) {
|
|
114053
114610
|
const name = nameNode.concatTokens().replace(/'/g, "").replace(/`/g, "");
|
|
114054
114611
|
const module = this.findFunctionModule(name);
|
|
114055
114612
|
if (module) {
|
|
114613
|
+
classBased = module.isClassBasedExceptions();
|
|
114056
114614
|
callee = {
|
|
114057
114615
|
name: module.getName(),
|
|
114058
|
-
exceptions:
|
|
114616
|
+
exceptions: classBased ? [] : module.getExceptions().map(e => e.toUpperCase()),
|
|
114059
114617
|
};
|
|
114060
114618
|
}
|
|
114061
114619
|
}
|
|
114062
|
-
const
|
|
114063
|
-
|
|
114620
|
+
const issues = [];
|
|
114621
|
+
const parameters = statement.findDirectExpression(Expressions.FunctionParameters);
|
|
114622
|
+
const exceptionTable = statement.findDirectTokenByText("EXCEPTION") !== undefined;
|
|
114623
|
+
const destination = statement.findDirectExpression(Expressions.Destination) !== undefined;
|
|
114624
|
+
const issue = this.checkCall(file, nameNode.getFirstToken(), callee, parameters, exceptionTable, destination, false);
|
|
114625
|
+
if (issue) {
|
|
114626
|
+
issues.push(issue);
|
|
114627
|
+
}
|
|
114628
|
+
if (this.conf.missingErrorMessage === true && exceptionTable === false && destination === false && classBased === false) {
|
|
114629
|
+
const listed = (_a = parameters === null || parameters === void 0 ? void 0 : parameters.findDirectExpression(Expressions.ParameterListExceptions)) === null || _a === void 0 ? void 0 : _a.findDirectExpressions(Expressions.ParameterException).some(e => e.getFirstChild().concatTokens().toUpperCase() === "ERROR_MESSAGE");
|
|
114630
|
+
if (listed !== true) {
|
|
114631
|
+
const position = (parameters === null || parameters === void 0 ? void 0 : parameters.findDirectTokenByText("EXCEPTIONS")) || nameNode.getFirstToken();
|
|
114632
|
+
const message = "No error_message, OTHERS does not catch a message that the function module sends without RAISING";
|
|
114633
|
+
issues.push(issue_1.Issue.atToken(file, position, message, this.getMetadata().key, this.conf.severity));
|
|
114634
|
+
}
|
|
114635
|
+
}
|
|
114636
|
+
return issues;
|
|
114064
114637
|
}
|
|
114065
114638
|
checkCall(file, token, callee, parameters, exceptionTable, destination, onlyLiterals) {
|
|
114066
114639
|
if (exceptionTable === true) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.120.
|
|
3
|
+
"version": "2.120.112",
|
|
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.112",
|
|
43
43
|
"@types/chai": "^4.3.20",
|
|
44
44
|
"@types/minimist": "^1.2.5",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|