@abaplint/cli 2.120.75 → 2.120.77
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 +549 -52
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -24995,6 +24995,12 @@ class BuiltIn {
|
|
|
24995
24995
|
}
|
|
24996
24996
|
return BuiltIn.unnamedArgument.has(name.toUpperCase());
|
|
24997
24997
|
}
|
|
24998
|
+
static returnsArgumentType(name) {
|
|
24999
|
+
if (name === undefined) {
|
|
25000
|
+
return false;
|
|
25001
|
+
}
|
|
25002
|
+
return BuiltIn.argumentTypedReturn.has(name.toUpperCase());
|
|
25003
|
+
}
|
|
24998
25004
|
static isPredicate(name) {
|
|
24999
25005
|
if (name === undefined) {
|
|
25000
25006
|
return undefined;
|
|
@@ -26102,6 +26108,8 @@ BuiltIn.unnamedArgument = new Set([
|
|
|
26102
26108
|
"FRAC", "LINES", "LOG", "LOG10", "NUMOFCHAR", "SIGN", "SIN", "SINH", "SQRT", "STRLEN", "TAN", "TANH",
|
|
26103
26109
|
"TRUNC", "XSTRLEN"
|
|
26104
26110
|
]);
|
|
26111
|
+
// numeric functions returning a value of the type of the argument
|
|
26112
|
+
BuiltIn.argumentTypedReturn = new Set(["ABS", "CEIL", "FLOOR", "FRAC", "SIGN", "TRUNC"]);
|
|
26105
26113
|
//# sourceMappingURL=_builtin.js.map
|
|
26106
26114
|
|
|
26107
26115
|
/***/ },
|
|
@@ -26683,6 +26691,142 @@ exports.CurrentScope = CurrentScope;
|
|
|
26683
26691
|
|
|
26684
26692
|
/***/ },
|
|
26685
26693
|
|
|
26694
|
+
/***/ "../core/build/src/abap/5_syntax/_loop_table_change.js"
|
|
26695
|
+
/*!*************************************************************!*\
|
|
26696
|
+
!*** ../core/build/src/abap/5_syntax/_loop_table_change.js ***!
|
|
26697
|
+
\*************************************************************/
|
|
26698
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
26699
|
+
|
|
26700
|
+
"use strict";
|
|
26701
|
+
|
|
26702
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
26703
|
+
if (k2 === undefined) k2 = k;
|
|
26704
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26705
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26706
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
26707
|
+
}
|
|
26708
|
+
Object.defineProperty(o, k2, desc);
|
|
26709
|
+
}) : (function(o, m, k, k2) {
|
|
26710
|
+
if (k2 === undefined) k2 = k;
|
|
26711
|
+
o[k2] = m[k];
|
|
26712
|
+
}));
|
|
26713
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26714
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26715
|
+
}) : function(o, v) {
|
|
26716
|
+
o["default"] = v;
|
|
26717
|
+
});
|
|
26718
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26719
|
+
var ownKeys = function(o) {
|
|
26720
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26721
|
+
var ar = [];
|
|
26722
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26723
|
+
return ar;
|
|
26724
|
+
};
|
|
26725
|
+
return ownKeys(o);
|
|
26726
|
+
};
|
|
26727
|
+
return function (mod) {
|
|
26728
|
+
if (mod && mod.__esModule) return mod;
|
|
26729
|
+
var result = {};
|
|
26730
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
26731
|
+
__setModuleDefault(result, mod);
|
|
26732
|
+
return result;
|
|
26733
|
+
};
|
|
26734
|
+
})();
|
|
26735
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
26736
|
+
exports.LoopTableChange = void 0;
|
|
26737
|
+
const Expressions = __importStar(__webpack_require__(/*! ../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
26738
|
+
const Statements = __importStar(__webpack_require__(/*! ../2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
|
|
26739
|
+
const nodes_1 = __webpack_require__(/*! ../nodes */ "../core/build/src/abap/nodes/index.js");
|
|
26740
|
+
const basic_1 = __webpack_require__(/*! ../types/basic */ "../core/build/src/abap/types/basic/index.js");
|
|
26741
|
+
const _scope_type_1 = __webpack_require__(/*! ./_scope_type */ "../core/build/src/abap/5_syntax/_scope_type.js");
|
|
26742
|
+
const _syntax_input_1 = __webpack_require__(/*! ./_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
26743
|
+
/** In a method, the body of the table an enclosing LOOP AT walks cannot be replaced or freed,
|
|
26744
|
+
* "you cannot access the entire table body in change mode in a loop. If this is known statically,
|
|
26745
|
+
* a syntax error occurs in classes", see the ABAP keyword documentation for LOOP AT itab.
|
|
26746
|
+
* Only tables named directly are handled, a field symbol or a reference is a runtime matter. */
|
|
26747
|
+
class LoopTableChange {
|
|
26748
|
+
constructor() {
|
|
26749
|
+
this.tables = [];
|
|
26750
|
+
}
|
|
26751
|
+
/** returns true if the LOOP structure was pushed, then pop() must be called after it */
|
|
26752
|
+
push(node, scope) {
|
|
26753
|
+
var _a, _b;
|
|
26754
|
+
if (scope.getType() !== _scope_type_1.ScopeType.Method) {
|
|
26755
|
+
return false;
|
|
26756
|
+
}
|
|
26757
|
+
const loop = node.findDirectStatement(Statements.Loop);
|
|
26758
|
+
if (loop === undefined || loop.findDirectExpression(Expressions.LoopGroupBy) !== undefined) {
|
|
26759
|
+
return false;
|
|
26760
|
+
}
|
|
26761
|
+
const chain = (_b = (_a = loop.findDirectExpression(Expressions.LoopSource)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.SimpleSource2)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.FieldChain);
|
|
26762
|
+
const children = (chain === null || chain === void 0 ? void 0 : chain.getChildren()) || [];
|
|
26763
|
+
if (children.length !== 1 && !(children.length === 2 && children[1].get() instanceof Expressions.TableBody)) {
|
|
26764
|
+
return false;
|
|
26765
|
+
}
|
|
26766
|
+
const found = LoopTableChange.findTable(children[0], scope);
|
|
26767
|
+
if (found === undefined) {
|
|
26768
|
+
return false;
|
|
26769
|
+
}
|
|
26770
|
+
this.tables.push(found);
|
|
26771
|
+
return true;
|
|
26772
|
+
}
|
|
26773
|
+
pop() {
|
|
26774
|
+
this.tables.pop();
|
|
26775
|
+
}
|
|
26776
|
+
check(node, input) {
|
|
26777
|
+
if (this.tables.length === 0 || input.scope.getType() !== _scope_type_1.ScopeType.Method) {
|
|
26778
|
+
return;
|
|
26779
|
+
}
|
|
26780
|
+
// DELETE itab WHERE is not refused, abapGit does it in zcl_abapgit_syntax_xml->order_matches,
|
|
26781
|
+
// SORT is left out, it is not certain that it is checked statically
|
|
26782
|
+
const s = node.get();
|
|
26783
|
+
if (!(s instanceof Statements.Clear)
|
|
26784
|
+
&& !(s instanceof Statements.Free)
|
|
26785
|
+
&& !(s instanceof Statements.Refresh)
|
|
26786
|
+
&& !(s instanceof Statements.Move)) {
|
|
26787
|
+
return;
|
|
26788
|
+
}
|
|
26789
|
+
for (const target of node.findDirectExpressions(Expressions.Target)) {
|
|
26790
|
+
const children = target.getChildren();
|
|
26791
|
+
const body = children.length === 2 && children[1].get() instanceof Expressions.TableBody;
|
|
26792
|
+
if (children.length !== 1 && body === false) {
|
|
26793
|
+
continue;
|
|
26794
|
+
}
|
|
26795
|
+
else if (!(children[0].get() instanceof Expressions.TargetField)) {
|
|
26796
|
+
continue;
|
|
26797
|
+
}
|
|
26798
|
+
const found = LoopTableChange.findTable(children[0], input.scope);
|
|
26799
|
+
if (found === undefined || this.tables.includes(found) === false) {
|
|
26800
|
+
continue;
|
|
26801
|
+
}
|
|
26802
|
+
else if (found.getType().isWithHeader() === true && body === false) {
|
|
26803
|
+
// without [] the statement works on the header line
|
|
26804
|
+
continue;
|
|
26805
|
+
}
|
|
26806
|
+
const message = `"${found.getName()}" cannot be changed as a whole inside a LOOP over it`;
|
|
26807
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
26808
|
+
return;
|
|
26809
|
+
}
|
|
26810
|
+
}
|
|
26811
|
+
static findTable(node, scope) {
|
|
26812
|
+
var _a;
|
|
26813
|
+
if (!(node instanceof nodes_1.ExpressionNode)
|
|
26814
|
+
|| node.getChildren().length !== 1
|
|
26815
|
+
|| !(((_a = node.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.Field)) {
|
|
26816
|
+
return undefined;
|
|
26817
|
+
}
|
|
26818
|
+
const found = scope.findVariable(node.concatTokens());
|
|
26819
|
+
if (found === undefined || !(found.getType() instanceof basic_1.TableType)) {
|
|
26820
|
+
return undefined;
|
|
26821
|
+
}
|
|
26822
|
+
return found;
|
|
26823
|
+
}
|
|
26824
|
+
}
|
|
26825
|
+
exports.LoopTableChange = LoopTableChange;
|
|
26826
|
+
//# sourceMappingURL=_loop_table_change.js.map
|
|
26827
|
+
|
|
26828
|
+
/***/ },
|
|
26829
|
+
|
|
26686
26830
|
/***/ "../core/build/src/abap/5_syntax/_object_oriented.js"
|
|
26687
26831
|
/*!***********************************************************!*\
|
|
26688
26832
|
!*** ../core/build/src/abap/5_syntax/_object_oriented.js ***!
|
|
@@ -29936,6 +30080,99 @@ function checkTextSymbol(source, parameterType, input) {
|
|
|
29936
30080
|
|
|
29937
30081
|
/***/ },
|
|
29938
30082
|
|
|
30083
|
+
/***/ "../core/build/src/abap/5_syntax/expressions/_substring.js"
|
|
30084
|
+
/*!*****************************************************************!*\
|
|
30085
|
+
!*** ../core/build/src/abap/5_syntax/expressions/_substring.js ***!
|
|
30086
|
+
\*****************************************************************/
|
|
30087
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
30088
|
+
|
|
30089
|
+
"use strict";
|
|
30090
|
+
|
|
30091
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30092
|
+
if (k2 === undefined) k2 = k;
|
|
30093
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
30094
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
30095
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
30096
|
+
}
|
|
30097
|
+
Object.defineProperty(o, k2, desc);
|
|
30098
|
+
}) : (function(o, m, k, k2) {
|
|
30099
|
+
if (k2 === undefined) k2 = k;
|
|
30100
|
+
o[k2] = m[k];
|
|
30101
|
+
}));
|
|
30102
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
30103
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30104
|
+
}) : function(o, v) {
|
|
30105
|
+
o["default"] = v;
|
|
30106
|
+
});
|
|
30107
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30108
|
+
var ownKeys = function(o) {
|
|
30109
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30110
|
+
var ar = [];
|
|
30111
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30112
|
+
return ar;
|
|
30113
|
+
};
|
|
30114
|
+
return ownKeys(o);
|
|
30115
|
+
};
|
|
30116
|
+
return function (mod) {
|
|
30117
|
+
if (mod && mod.__esModule) return mod;
|
|
30118
|
+
var result = {};
|
|
30119
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
30120
|
+
__setModuleDefault(result, mod);
|
|
30121
|
+
return result;
|
|
30122
|
+
};
|
|
30123
|
+
})();
|
|
30124
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
30125
|
+
exports.substringType = substringType;
|
|
30126
|
+
exports.isFieldSymbolItself = isFieldSymbolItself;
|
|
30127
|
+
const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
30128
|
+
const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
|
|
30129
|
+
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
30130
|
+
// The type of a substring with a static offset or length, used for reading and writing positions.
|
|
30131
|
+
// On a character or byte field of fixed length the substring must lie inside the field, else it is
|
|
30132
|
+
// a syntax error. Other types, a dynamic offset or length and "*" (undefined) are left alone, as is
|
|
30133
|
+
// length 0. The offset is applied first, so the length is compared to what remains after the offset.
|
|
30134
|
+
function substringType(context, offset, length, node, input) {
|
|
30135
|
+
if (!(context instanceof basic_1.CharacterType) && !(context instanceof basic_1.HexType)) {
|
|
30136
|
+
return context;
|
|
30137
|
+
}
|
|
30138
|
+
const fieldLength = context.getLength();
|
|
30139
|
+
if (offset !== undefined && offset > 0) {
|
|
30140
|
+
if (offset >= fieldLength) {
|
|
30141
|
+
const message = `Offset ${offset} is outside the field of length ${fieldLength}`;
|
|
30142
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
30143
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
30144
|
+
}
|
|
30145
|
+
return context instanceof basic_1.CharacterType ? new basic_1.CharacterType(fieldLength - offset) : new basic_1.HexType(fieldLength - offset);
|
|
30146
|
+
}
|
|
30147
|
+
if (length !== undefined && length > 0) {
|
|
30148
|
+
if (length > fieldLength) {
|
|
30149
|
+
const message = `Length ${length} exceeds the remaining length ${fieldLength} of the field`;
|
|
30150
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
30151
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
30152
|
+
}
|
|
30153
|
+
return context instanceof basic_1.CharacterType ? new basic_1.CharacterType(length) : new basic_1.HexType(length);
|
|
30154
|
+
}
|
|
30155
|
+
return context;
|
|
30156
|
+
}
|
|
30157
|
+
// A field symbol typed "c" or "x" is generic, but its type is represented with length 1, so the
|
|
30158
|
+
// offset or length at "index" is not checked when it directly follows the field symbol
|
|
30159
|
+
function isFieldSymbolItself(children, index) {
|
|
30160
|
+
var _a;
|
|
30161
|
+
const first = (_a = children[0]) === null || _a === void 0 ? void 0 : _a.get();
|
|
30162
|
+
if (!(first instanceof Expressions.SourceFieldSymbol) && !(first instanceof Expressions.TargetFieldSymbol)) {
|
|
30163
|
+
return false;
|
|
30164
|
+
}
|
|
30165
|
+
for (let i = 1; i < index; i++) {
|
|
30166
|
+
if (!(children[i].get() instanceof Expressions.FieldOffset)) {
|
|
30167
|
+
return false;
|
|
30168
|
+
}
|
|
30169
|
+
}
|
|
30170
|
+
return true;
|
|
30171
|
+
}
|
|
30172
|
+
//# sourceMappingURL=_substring.js.map
|
|
30173
|
+
|
|
30174
|
+
/***/ },
|
|
30175
|
+
|
|
29939
30176
|
/***/ "../core/build/src/abap/5_syntax/expressions/attribute_chain.js"
|
|
29940
30177
|
/*!**********************************************************************!*\
|
|
29941
30178
|
!*** ../core/build/src/abap/5_syntax/expressions/attribute_chain.js ***!
|
|
@@ -29991,6 +30228,7 @@ const attribute_name_1 = __webpack_require__(/*! ./attribute_name */ "../core/bu
|
|
|
29991
30228
|
const table_expression_1 = __webpack_require__(/*! ./table_expression */ "../core/build/src/abap/5_syntax/expressions/table_expression.js");
|
|
29992
30229
|
const field_offset_1 = __webpack_require__(/*! ./field_offset */ "../core/build/src/abap/5_syntax/expressions/field_offset.js");
|
|
29993
30230
|
const field_length_1 = __webpack_require__(/*! ./field_length */ "../core/build/src/abap/5_syntax/expressions/field_length.js");
|
|
30231
|
+
const _substring_1 = __webpack_require__(/*! ./_substring */ "../core/build/src/abap/5_syntax/expressions/_substring.js");
|
|
29994
30232
|
class AttributeChain {
|
|
29995
30233
|
static runSyntax(inputContext, node, input, type) {
|
|
29996
30234
|
if (inputContext instanceof void_type_1.VoidType) {
|
|
@@ -30067,25 +30305,11 @@ class AttributeChain {
|
|
|
30067
30305
|
}
|
|
30068
30306
|
else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.FieldOffset) {
|
|
30069
30307
|
const offset = field_offset_1.FieldOffset.runSyntax(child, input);
|
|
30070
|
-
|
|
30071
|
-
if (contextType instanceof basic_1.CharacterType) {
|
|
30072
|
-
contextType = new basic_1.CharacterType(contextType.getLength() - offset);
|
|
30073
|
-
}
|
|
30074
|
-
else if (contextType instanceof basic_1.HexType) {
|
|
30075
|
-
contextType = new basic_1.HexType(contextType.getLength() - offset);
|
|
30076
|
-
}
|
|
30077
|
-
}
|
|
30308
|
+
contextType = (0, _substring_1.substringType)(contextType, offset, undefined, child, input);
|
|
30078
30309
|
}
|
|
30079
30310
|
else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.FieldLength) {
|
|
30080
30311
|
const length = field_length_1.FieldLength.runSyntax(child, input);
|
|
30081
|
-
|
|
30082
|
-
if (contextType instanceof basic_1.CharacterType) {
|
|
30083
|
-
contextType = new basic_1.CharacterType(length);
|
|
30084
|
-
}
|
|
30085
|
-
else if (contextType instanceof basic_1.HexType) {
|
|
30086
|
-
contextType = new basic_1.HexType(length);
|
|
30087
|
-
}
|
|
30088
|
-
}
|
|
30312
|
+
contextType = (0, _substring_1.substringType)(contextType, undefined, length, child, input);
|
|
30089
30313
|
}
|
|
30090
30314
|
}
|
|
30091
30315
|
return contextType;
|
|
@@ -30381,6 +30605,11 @@ class Compare {
|
|
|
30381
30605
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), initialMessage));
|
|
30382
30606
|
return;
|
|
30383
30607
|
}
|
|
30608
|
+
const predicateMessage = this.checkPredicateOperand(sources, input);
|
|
30609
|
+
if (predicateMessage !== undefined) {
|
|
30610
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), predicateMessage));
|
|
30611
|
+
return;
|
|
30612
|
+
}
|
|
30384
30613
|
const typeUtils = new _type_utils_1.TypeUtils(input.scope);
|
|
30385
30614
|
const compareOperator = (_a = node.findDirectExpression(Expressions.CompareOperator)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
30386
30615
|
if (compareOperator === "CS"
|
|
@@ -30421,6 +30650,31 @@ class Compare {
|
|
|
30421
30650
|
if ((chain === null || chain === void 0 ? void 0 : chain.length) === 4 && chain[0] instanceof nodes_1.TokenNode && (first === "XSDBOOL" || first === "BOOLC")) {
|
|
30422
30651
|
return `Built-in function "${chain[0].getFirstToken().getStr()}" cannot be the operand of IS INITIAL`;
|
|
30423
30652
|
}
|
|
30653
|
+
const name = this.builtinCallName(node.findDirectExpression(Expressions.Source), input);
|
|
30654
|
+
const returning = (_d = (_c = _builtin_1.BuiltIn.searchBuiltin(name)) === null || _c === void 0 ? void 0 : _c.getParameters().getReturning()) === null || _d === void 0 ? void 0 : _d.getType();
|
|
30655
|
+
if (returning instanceof basic_1.StringType || returning instanceof basic_1.CharacterType) {
|
|
30656
|
+
return `Built-in function "${name}" cannot be the operand of IS INITIAL`;
|
|
30657
|
+
}
|
|
30658
|
+
return undefined;
|
|
30659
|
+
}
|
|
30660
|
+
// a predicate function, contains( ) or line_exists( ), is a relational expression and not a value,
|
|
30661
|
+
// it can stand alone as a condition or inside boolc( ) or xsdbool( ), but cannot be an operand of a comparison
|
|
30662
|
+
static checkPredicateOperand(sources, input) {
|
|
30663
|
+
if (input.scope.getOpenABAP()) {
|
|
30664
|
+
return undefined;
|
|
30665
|
+
}
|
|
30666
|
+
for (const source of sources) {
|
|
30667
|
+
const name = this.builtinCallName(source, input);
|
|
30668
|
+
if (_builtin_1.BuiltIn.isPredicate(name) === true) {
|
|
30669
|
+
return `Predicate function "${name}" cannot be the operand of a comparison`;
|
|
30670
|
+
}
|
|
30671
|
+
}
|
|
30672
|
+
return undefined;
|
|
30673
|
+
}
|
|
30674
|
+
// 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
|
|
30675
|
+
static builtinCallName(source, input) {
|
|
30676
|
+
var _a;
|
|
30677
|
+
const chain = source === null || source === void 0 ? void 0 : source.getChildren();
|
|
30424
30678
|
if ((chain === null || chain === void 0 ? void 0 : chain.length) !== 1 || !(chain[0] instanceof nodes_1.ExpressionNode) || !(chain[0].get() instanceof Expressions.MethodCallChain)) {
|
|
30425
30679
|
return undefined;
|
|
30426
30680
|
}
|
|
@@ -30428,9 +30682,8 @@ class Compare {
|
|
|
30428
30682
|
if (calls.length !== 1 || !(calls[0] instanceof nodes_1.ExpressionNode) || !(calls[0].get() instanceof Expressions.MethodCall)) {
|
|
30429
30683
|
return undefined;
|
|
30430
30684
|
}
|
|
30431
|
-
const name = (
|
|
30432
|
-
|
|
30433
|
-
if (name === undefined || builtin === undefined) {
|
|
30685
|
+
const name = (_a = calls[0].findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
30686
|
+
if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name) === undefined) {
|
|
30434
30687
|
return undefined;
|
|
30435
30688
|
}
|
|
30436
30689
|
// a method of the same name hides the built-in function
|
|
@@ -30438,11 +30691,7 @@ class Compare {
|
|
|
30438
30691
|
if (enclosing !== undefined && new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(enclosing, name).method !== undefined) {
|
|
30439
30692
|
return undefined;
|
|
30440
30693
|
}
|
|
30441
|
-
|
|
30442
|
-
if (returning instanceof basic_1.StringType || returning instanceof basic_1.CharacterType) {
|
|
30443
|
-
return `Built-in function "${name}" cannot be the operand of IS INITIAL`;
|
|
30444
|
-
}
|
|
30445
|
-
return undefined;
|
|
30694
|
+
return name;
|
|
30446
30695
|
}
|
|
30447
30696
|
}
|
|
30448
30697
|
exports.Compare = Compare;
|
|
@@ -31672,6 +31921,7 @@ const expressions_1 = __webpack_require__(/*! ../../2_statements/expressions */
|
|
|
31672
31921
|
const dereference_1 = __webpack_require__(/*! ./dereference */ "../core/build/src/abap/5_syntax/expressions/dereference.js");
|
|
31673
31922
|
const source_field_symbol_1 = __webpack_require__(/*! ./source_field_symbol */ "../core/build/src/abap/5_syntax/expressions/source_field_symbol.js");
|
|
31674
31923
|
const source_field_1 = __webpack_require__(/*! ./source_field */ "../core/build/src/abap/5_syntax/expressions/source_field.js");
|
|
31924
|
+
const _substring_1 = __webpack_require__(/*! ./_substring */ "../core/build/src/abap/5_syntax/expressions/_substring.js");
|
|
31675
31925
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
31676
31926
|
const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
|
|
31677
31927
|
class FieldChain {
|
|
@@ -31784,24 +32034,14 @@ class FieldChain {
|
|
|
31784
32034
|
}
|
|
31785
32035
|
else if (current.get() instanceof Expressions.FieldOffset && current instanceof nodes_1.ExpressionNode) {
|
|
31786
32036
|
const offset = field_offset_1.FieldOffset.runSyntax(current, input);
|
|
31787
|
-
if (
|
|
31788
|
-
|
|
31789
|
-
context = new basic_1.CharacterType(context.getLength() - offset);
|
|
31790
|
-
}
|
|
31791
|
-
else if (context instanceof basic_1.HexType) {
|
|
31792
|
-
context = new basic_1.HexType(context.getLength() - offset);
|
|
31793
|
-
}
|
|
32037
|
+
if (!(0, _substring_1.isFieldSymbolItself)(children, i)) {
|
|
32038
|
+
context = (0, _substring_1.substringType)(context, offset, undefined, current, input);
|
|
31794
32039
|
}
|
|
31795
32040
|
}
|
|
31796
32041
|
else if (current.get() instanceof Expressions.FieldLength && current instanceof nodes_1.ExpressionNode) {
|
|
31797
32042
|
const length = field_length_1.FieldLength.runSyntax(current, input);
|
|
31798
|
-
if (
|
|
31799
|
-
|
|
31800
|
-
context = new basic_1.CharacterType(length);
|
|
31801
|
-
}
|
|
31802
|
-
else if (context instanceof basic_1.HexType) {
|
|
31803
|
-
context = new basic_1.HexType(length);
|
|
31804
|
-
}
|
|
32043
|
+
if (!(0, _substring_1.isFieldSymbolItself)(children, i)) {
|
|
32044
|
+
context = (0, _substring_1.substringType)(context, undefined, length, current, input);
|
|
31805
32045
|
}
|
|
31806
32046
|
}
|
|
31807
32047
|
prev = current.concatTokens();
|
|
@@ -33235,7 +33475,12 @@ class MethodCallChain {
|
|
|
33235
33475
|
}
|
|
33236
33476
|
const param = current.findDirectExpression(Expressions.MethodCallParam);
|
|
33237
33477
|
if (param && method) {
|
|
33238
|
-
method_call_param_1.MethodCallParam.runSyntax(param, input, method);
|
|
33478
|
+
const argumentType = method_call_param_1.MethodCallParam.runSyntax(param, input, method);
|
|
33479
|
+
if (method instanceof _builtin_1.BuiltInMethod
|
|
33480
|
+
&& _builtin_1.BuiltIn.returnsArgumentType(methodName)
|
|
33481
|
+
&& this.isNumeric(argumentType)) {
|
|
33482
|
+
context = argumentType;
|
|
33483
|
+
}
|
|
33239
33484
|
}
|
|
33240
33485
|
else if (param && context instanceof basic_1.VoidType) {
|
|
33241
33486
|
method_call_param_1.MethodCallParam.runSyntax(param, input, context);
|
|
@@ -33252,6 +33497,16 @@ class MethodCallChain {
|
|
|
33252
33497
|
return context;
|
|
33253
33498
|
}
|
|
33254
33499
|
//////////////////////////////////////
|
|
33500
|
+
static isNumeric(type) {
|
|
33501
|
+
return type instanceof basic_1.IntegerType
|
|
33502
|
+
|| type instanceof basic_1.Integer8Type
|
|
33503
|
+
|| type instanceof basic_1.PackedType
|
|
33504
|
+
|| type instanceof basic_1.FloatType
|
|
33505
|
+
|| type instanceof basic_1.FloatingPointType
|
|
33506
|
+
|| type instanceof basic_1.DecFloatType
|
|
33507
|
+
|| type instanceof basic_1.DecFloat16Type
|
|
33508
|
+
|| type instanceof basic_1.DecFloat34Type;
|
|
33509
|
+
}
|
|
33255
33510
|
static findTop(first, input, targetType) {
|
|
33256
33511
|
var _a;
|
|
33257
33512
|
if (first.get() instanceof Expressions.ClassName) {
|
|
@@ -33349,6 +33604,7 @@ const constant_1 = __webpack_require__(/*! ./constant */ "../core/build/src/abap
|
|
|
33349
33604
|
const _check_offset_length_1 = __webpack_require__(/*! ./_check_offset_length */ "../core/build/src/abap/5_syntax/expressions/_check_offset_length.js");
|
|
33350
33605
|
const _check_text_symbol_1 = __webpack_require__(/*! ./_check_text_symbol */ "../core/build/src/abap/5_syntax/expressions/_check_text_symbol.js");
|
|
33351
33606
|
class MethodCallParam {
|
|
33607
|
+
/** returns the type of the unnamed argument, if any */
|
|
33352
33608
|
static runSyntax(node, input, method) {
|
|
33353
33609
|
if (!(node.get() instanceof Expressions.MethodCallParam)) {
|
|
33354
33610
|
const message = "MethodCallParam, unexpected input";
|
|
@@ -33428,6 +33684,7 @@ class MethodCallParam {
|
|
|
33428
33684
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
33429
33685
|
return;
|
|
33430
33686
|
}
|
|
33687
|
+
return sourceType;
|
|
33431
33688
|
}
|
|
33432
33689
|
else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.ParameterListS) {
|
|
33433
33690
|
new method_parameters_1.MethodParameters().checkExporting(child, input, method);
|
|
@@ -33440,6 +33697,7 @@ class MethodCallParam {
|
|
|
33440
33697
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
33441
33698
|
return;
|
|
33442
33699
|
}
|
|
33700
|
+
return undefined;
|
|
33443
33701
|
}
|
|
33444
33702
|
}
|
|
33445
33703
|
exports.MethodCallParam = MethodCallParam;
|
|
@@ -35220,7 +35478,7 @@ const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src
|
|
|
35220
35478
|
// TODO: refactor all these method parameters to objects, this is getting messy
|
|
35221
35479
|
class Source {
|
|
35222
35480
|
static runSyntax(node, input, targetType, writeReference = false, allowGenericDeference = false, readReference = true) {
|
|
35223
|
-
var _a, _b
|
|
35481
|
+
var _a, _b;
|
|
35224
35482
|
if (node === undefined) {
|
|
35225
35483
|
return undefined;
|
|
35226
35484
|
}
|
|
@@ -35315,13 +35573,7 @@ class Source {
|
|
|
35315
35573
|
this.traverseRemainingChildren(children, input);
|
|
35316
35574
|
return bodyType;
|
|
35317
35575
|
}
|
|
35318
|
-
|
|
35319
|
-
const nestedType = (_c = bodySource === null || bodySource === void 0 ? void 0 : bodySource.findDirectExpression(Expressions.TypeNameOrInfer)) === null || _c === void 0 ? void 0 : _c.concatTokens();
|
|
35320
|
-
// CONV # passes its target type into a nested inferred constructor, so
|
|
35321
|
-
// showing both inferred types would produce duplicate inlay hints.
|
|
35322
|
-
if (!(inferred === "#" && nestedType === "#")) {
|
|
35323
|
-
this.addIfInferred(node, input, foundType);
|
|
35324
|
-
}
|
|
35576
|
+
this.addIfInferred(node, input, foundType);
|
|
35325
35577
|
this.traverseRemainingChildren(children, input);
|
|
35326
35578
|
return foundType;
|
|
35327
35579
|
}
|
|
@@ -35379,7 +35631,7 @@ class Source {
|
|
|
35379
35631
|
{
|
|
35380
35632
|
const foundType = this.determineType(node, input, targetType);
|
|
35381
35633
|
if ((foundType === null || foundType === void 0 ? void 0 : foundType.isGeneric()) === true
|
|
35382
|
-
&& ((
|
|
35634
|
+
&& ((_b = node.findDirectExpression(Expressions.TypeNameOrInfer)) === null || _b === void 0 ? void 0 : _b.concatTokens()) === "#"
|
|
35383
35635
|
&& !(0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v756)
|
|
35384
35636
|
&& input.scope.getLanguageVersion() !== version_1.LanguageVersion.Cloud
|
|
35385
35637
|
&& !input.scope.getOpenABAP()) {
|
|
@@ -36630,6 +36882,7 @@ const table_expression_1 = __webpack_require__(/*! ./table_expression */ "../cor
|
|
|
36630
36882
|
const expressions_1 = __webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js");
|
|
36631
36883
|
const field_length_1 = __webpack_require__(/*! ./field_length */ "../core/build/src/abap/5_syntax/expressions/field_length.js");
|
|
36632
36884
|
const cast_1 = __webpack_require__(/*! ./cast */ "../core/build/src/abap/5_syntax/expressions/cast.js");
|
|
36885
|
+
const _substring_1 = __webpack_require__(/*! ./_substring */ "../core/build/src/abap/5_syntax/expressions/_substring.js");
|
|
36633
36886
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
36634
36887
|
const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
|
|
36635
36888
|
class Target {
|
|
@@ -36737,6 +36990,8 @@ class Target {
|
|
|
36737
36990
|
context = attribute_name_1.AttributeName.runSyntax(context, current, input, type);
|
|
36738
36991
|
}
|
|
36739
36992
|
}
|
|
36993
|
+
// the substring is checked, but the type of the whole field is returned
|
|
36994
|
+
let substring = context;
|
|
36740
36995
|
const offset = node.findDirectExpression(Expressions.FieldOffset);
|
|
36741
36996
|
if (offset) {
|
|
36742
36997
|
if (context instanceof basic_1.XStringType || context instanceof basic_1.StringType) {
|
|
@@ -36744,7 +36999,10 @@ class Target {
|
|
|
36744
36999
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
36745
37000
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
36746
37001
|
}
|
|
36747
|
-
field_offset_1.FieldOffset.runSyntax(offset, input);
|
|
37002
|
+
const value = field_offset_1.FieldOffset.runSyntax(offset, input);
|
|
37003
|
+
if (!(0, _substring_1.isFieldSymbolItself)(children, children.indexOf(offset))) {
|
|
37004
|
+
substring = (0, _substring_1.substringType)(substring, value, undefined, offset, input);
|
|
37005
|
+
}
|
|
36748
37006
|
}
|
|
36749
37007
|
const length = node.findDirectExpression(Expressions.FieldLength);
|
|
36750
37008
|
if (length) {
|
|
@@ -36753,7 +37011,13 @@ class Target {
|
|
|
36753
37011
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
36754
37012
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
36755
37013
|
}
|
|
36756
|
-
field_length_1.FieldLength.runSyntax(length, input);
|
|
37014
|
+
const value = field_length_1.FieldLength.runSyntax(length, input);
|
|
37015
|
+
if (!(0, _substring_1.isFieldSymbolItself)(children, children.indexOf(length))) {
|
|
37016
|
+
substring = (0, _substring_1.substringType)(substring, undefined, value, length, input);
|
|
37017
|
+
}
|
|
37018
|
+
}
|
|
37019
|
+
if (substring instanceof basic_1.VoidType && !(context instanceof basic_1.VoidType)) {
|
|
37020
|
+
return substring;
|
|
36757
37021
|
}
|
|
36758
37022
|
return context;
|
|
36759
37023
|
}
|
|
@@ -45282,6 +45546,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
45282
45546
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
45283
45547
|
exports.ReadTable = void 0;
|
|
45284
45548
|
const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
45549
|
+
const nodes_1 = __webpack_require__(/*! ../../nodes */ "../core/build/src/abap/nodes/index.js");
|
|
45285
45550
|
const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
|
|
45286
45551
|
const source_1 = __webpack_require__(/*! ../expressions/source */ "../core/build/src/abap/5_syntax/expressions/source.js");
|
|
45287
45552
|
const inline_data_1 = __webpack_require__(/*! ../expressions/inline_data */ "../core/build/src/abap/5_syntax/expressions/inline_data.js");
|
|
@@ -45290,6 +45555,9 @@ const fstarget_1 = __webpack_require__(/*! ../expressions/fstarget */ "../core/b
|
|
|
45290
45555
|
const component_compare_simple_1 = __webpack_require__(/*! ../expressions/component_compare_simple */ "../core/build/src/abap/5_syntax/expressions/component_compare_simple.js");
|
|
45291
45556
|
const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "../core/build/src/abap/5_syntax/_type_utils.js");
|
|
45292
45557
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
45558
|
+
const _builtin_1 = __webpack_require__(/*! ../_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
|
|
45559
|
+
const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
|
|
45560
|
+
const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
|
|
45293
45561
|
class ReadTable {
|
|
45294
45562
|
runSyntax(node, input) {
|
|
45295
45563
|
const concat = node.concatTokens().toUpperCase();
|
|
@@ -45316,6 +45584,11 @@ class ReadTable {
|
|
|
45316
45584
|
const components = node.findDirectExpression(Expressions.ComponentCompareSimple);
|
|
45317
45585
|
if (components !== undefined) {
|
|
45318
45586
|
component_compare_simple_1.ComponentCompareSimple.runSyntax(components, input, rowType);
|
|
45587
|
+
const keyMessage = this.checkKeyOperands(components, input);
|
|
45588
|
+
if (keyMessage !== undefined) {
|
|
45589
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), keyMessage));
|
|
45590
|
+
return;
|
|
45591
|
+
}
|
|
45319
45592
|
}
|
|
45320
45593
|
const indexSource = node.findExpressionAfterToken("INDEX");
|
|
45321
45594
|
if (indexSource) {
|
|
@@ -45411,6 +45684,36 @@ class ReadTable {
|
|
|
45411
45684
|
}
|
|
45412
45685
|
}
|
|
45413
45686
|
}
|
|
45687
|
+
// before 7.40 a WITH [TABLE] KEY operand is not an expression position, a built-in function from 7.02 on
|
|
45688
|
+
// is read as a functional method call there, "method TO_UPPER is unknown" on a system, while
|
|
45689
|
+
// functional methods and the older built-in functions like lines( ) are accepted
|
|
45690
|
+
checkKeyOperands(node, input) {
|
|
45691
|
+
var _a, _b;
|
|
45692
|
+
if (input.scope.getOpenABAP() || (0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v740sp02)) {
|
|
45693
|
+
return undefined;
|
|
45694
|
+
}
|
|
45695
|
+
for (const operand of node.findDirectExpressionsMulti([Expressions.Source, Expressions.SimpleSource4])) {
|
|
45696
|
+
const chain = operand.getChildren();
|
|
45697
|
+
if (chain.length !== 1 || !(chain[0] instanceof nodes_1.ExpressionNode) || !(chain[0].get() instanceof Expressions.MethodCallChain)) {
|
|
45698
|
+
continue;
|
|
45699
|
+
}
|
|
45700
|
+
const calls = chain[0].getChildren();
|
|
45701
|
+
if (calls.length !== 1 || !(calls[0] instanceof nodes_1.ExpressionNode) || !(calls[0].get() instanceof Expressions.MethodCall)) {
|
|
45702
|
+
continue;
|
|
45703
|
+
}
|
|
45704
|
+
const name = (_a = calls[0].findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
45705
|
+
if (name === undefined || ((_b = _builtin_1.BuiltIn.methods[name.toUpperCase()]) === null || _b === void 0 ? void 0 : _b.release) === undefined) {
|
|
45706
|
+
continue;
|
|
45707
|
+
}
|
|
45708
|
+
// a method of the same name hides the built-in function
|
|
45709
|
+
const enclosing = input.scope.findClassDefinition(input.scope.getEnclosingClassName());
|
|
45710
|
+
if (enclosing !== undefined && new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(enclosing, name).method !== undefined) {
|
|
45711
|
+
continue;
|
|
45712
|
+
}
|
|
45713
|
+
return `Built-in function "${name}" cannot be a READ TABLE key operand before 7.40`;
|
|
45714
|
+
}
|
|
45715
|
+
return undefined;
|
|
45716
|
+
}
|
|
45414
45717
|
}
|
|
45415
45718
|
exports.ReadTable = ReadTable;
|
|
45416
45719
|
//# sourceMappingURL=read_table.js.map
|
|
@@ -48298,6 +48601,121 @@ exports.ClassData = ClassData;
|
|
|
48298
48601
|
|
|
48299
48602
|
/***/ },
|
|
48300
48603
|
|
|
48604
|
+
/***/ "../core/build/src/abap/5_syntax/structures/cleanup.js"
|
|
48605
|
+
/*!*************************************************************!*\
|
|
48606
|
+
!*** ../core/build/src/abap/5_syntax/structures/cleanup.js ***!
|
|
48607
|
+
\*************************************************************/
|
|
48608
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
48609
|
+
|
|
48610
|
+
"use strict";
|
|
48611
|
+
|
|
48612
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
48613
|
+
if (k2 === undefined) k2 = k;
|
|
48614
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
48615
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
48616
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
48617
|
+
}
|
|
48618
|
+
Object.defineProperty(o, k2, desc);
|
|
48619
|
+
}) : (function(o, m, k, k2) {
|
|
48620
|
+
if (k2 === undefined) k2 = k;
|
|
48621
|
+
o[k2] = m[k];
|
|
48622
|
+
}));
|
|
48623
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
48624
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
48625
|
+
}) : function(o, v) {
|
|
48626
|
+
o["default"] = v;
|
|
48627
|
+
});
|
|
48628
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
48629
|
+
var ownKeys = function(o) {
|
|
48630
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
48631
|
+
var ar = [];
|
|
48632
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
48633
|
+
return ar;
|
|
48634
|
+
};
|
|
48635
|
+
return ownKeys(o);
|
|
48636
|
+
};
|
|
48637
|
+
return function (mod) {
|
|
48638
|
+
if (mod && mod.__esModule) return mod;
|
|
48639
|
+
var result = {};
|
|
48640
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
48641
|
+
__setModuleDefault(result, mod);
|
|
48642
|
+
return result;
|
|
48643
|
+
};
|
|
48644
|
+
})();
|
|
48645
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
48646
|
+
exports.Cleanup = void 0;
|
|
48647
|
+
const Statements = __importStar(__webpack_require__(/*! ../../2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
|
|
48648
|
+
const Structures = __importStar(__webpack_require__(/*! ../../3_structures/structures */ "../core/build/src/abap/3_structures/structures/index.js"));
|
|
48649
|
+
const nodes_1 = __webpack_require__(/*! ../../nodes */ "../core/build/src/abap/nodes/index.js");
|
|
48650
|
+
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
|
|
48651
|
+
const LOOPS = [
|
|
48652
|
+
Structures.Loop,
|
|
48653
|
+
Structures.LoopAtScreen,
|
|
48654
|
+
Structures.LoopExtract,
|
|
48655
|
+
Structures.Do,
|
|
48656
|
+
Structures.While,
|
|
48657
|
+
Structures.Select,
|
|
48658
|
+
Structures.With,
|
|
48659
|
+
Structures.Provide,
|
|
48660
|
+
];
|
|
48661
|
+
// a CLEANUP block cannot contain statements that statically leave it: RETURN, and EXIT, CONTINUE or CHECK
|
|
48662
|
+
// that do not belong to a loop inside the block, these end a loop outside the TRY or the processing block
|
|
48663
|
+
class Cleanup {
|
|
48664
|
+
static runSyntax(node, input) {
|
|
48665
|
+
if (input.scope.getOpenABAP()) {
|
|
48666
|
+
return;
|
|
48667
|
+
}
|
|
48668
|
+
const body = node.findDirectStructure(Structures.Body);
|
|
48669
|
+
if (body !== undefined) {
|
|
48670
|
+
this.walk(body, false, input);
|
|
48671
|
+
}
|
|
48672
|
+
}
|
|
48673
|
+
static walk(node, inLoop, input) {
|
|
48674
|
+
for (const child of node.getChildren()) {
|
|
48675
|
+
if (child instanceof nodes_1.StructureNode) {
|
|
48676
|
+
const stru = child.get();
|
|
48677
|
+
// a nested CLEANUP block is checked on its own, macro definitions and test injections do not run here
|
|
48678
|
+
if (stru instanceof Structures.Cleanup
|
|
48679
|
+
|| stru instanceof Structures.Define
|
|
48680
|
+
|| stru instanceof Structures.TestInjection) {
|
|
48681
|
+
continue;
|
|
48682
|
+
}
|
|
48683
|
+
this.walk(child, inLoop || LOOPS.some(l => stru instanceof l), input);
|
|
48684
|
+
}
|
|
48685
|
+
else if (child instanceof nodes_1.StatementNode) {
|
|
48686
|
+
const name = this.leavingStatement(child, inLoop);
|
|
48687
|
+
if (name !== undefined) {
|
|
48688
|
+
const message = `${name} cannot leave a CLEANUP block`;
|
|
48689
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), message));
|
|
48690
|
+
}
|
|
48691
|
+
}
|
|
48692
|
+
}
|
|
48693
|
+
}
|
|
48694
|
+
static leavingStatement(node, inLoop) {
|
|
48695
|
+
const s = node.get();
|
|
48696
|
+
if (s instanceof Statements.Return) {
|
|
48697
|
+
return "RETURN";
|
|
48698
|
+
}
|
|
48699
|
+
else if (inLoop === true) {
|
|
48700
|
+
return undefined;
|
|
48701
|
+
}
|
|
48702
|
+
else if (s instanceof Statements.Exit && node.findDirectTokenByText("FROM") === undefined) {
|
|
48703
|
+
return "EXIT";
|
|
48704
|
+
}
|
|
48705
|
+
else if (s instanceof Statements.Continue) {
|
|
48706
|
+
return "CONTINUE";
|
|
48707
|
+
}
|
|
48708
|
+
else if (s instanceof Statements.Check) {
|
|
48709
|
+
return "CHECK";
|
|
48710
|
+
}
|
|
48711
|
+
return undefined;
|
|
48712
|
+
}
|
|
48713
|
+
}
|
|
48714
|
+
exports.Cleanup = Cleanup;
|
|
48715
|
+
//# sourceMappingURL=cleanup.js.map
|
|
48716
|
+
|
|
48717
|
+
/***/ },
|
|
48718
|
+
|
|
48301
48719
|
/***/ "../core/build/src/abap/5_syntax/structures/constants.js"
|
|
48302
48720
|
/*!***************************************************************!*\
|
|
48303
48721
|
!*** ../core/build/src/abap/5_syntax/structures/constants.js ***!
|
|
@@ -49101,6 +49519,7 @@ const type_mesh_1 = __webpack_require__(/*! ./structures/type_mesh */ "../core/b
|
|
|
49101
49519
|
const types_1 = __webpack_require__(/*! ./structures/types */ "../core/build/src/abap/5_syntax/structures/types.js");
|
|
49102
49520
|
const statics_1 = __webpack_require__(/*! ./structures/statics */ "../core/build/src/abap/5_syntax/structures/statics.js");
|
|
49103
49521
|
const constants_1 = __webpack_require__(/*! ./structures/constants */ "../core/build/src/abap/5_syntax/structures/constants.js");
|
|
49522
|
+
const cleanup_1 = __webpack_require__(/*! ./structures/cleanup */ "../core/build/src/abap/5_syntax/structures/cleanup.js");
|
|
49104
49523
|
const class_definition_1 = __webpack_require__(/*! ../types/class_definition */ "../core/build/src/abap/types/class_definition.js");
|
|
49105
49524
|
const interface_definition_1 = __webpack_require__(/*! ../types/interface_definition */ "../core/build/src/abap/types/interface_definition.js");
|
|
49106
49525
|
const delete_memory_1 = __webpack_require__(/*! ./statements/delete_memory */ "../core/build/src/abap/5_syntax/statements/delete_memory.js");
|
|
@@ -49242,6 +49661,7 @@ const _syntax_input_1 = __webpack_require__(/*! ./_syntax_input */ "../core/buil
|
|
|
49242
49661
|
const assert_error_1 = __webpack_require__(/*! ./assert_error */ "../core/build/src/abap/5_syntax/assert_error.js");
|
|
49243
49662
|
const field_group_1 = __webpack_require__(/*! ./statements/field_group */ "../core/build/src/abap/5_syntax/statements/field_group.js");
|
|
49244
49663
|
const stuff_1 = __webpack_require__(/*! ../../stuff */ "../core/build/src/stuff.js");
|
|
49664
|
+
const _loop_table_change_1 = __webpack_require__(/*! ./_loop_table_change */ "../core/build/src/abap/5_syntax/_loop_table_change.js");
|
|
49245
49665
|
// -----------------------------------
|
|
49246
49666
|
const map = {};
|
|
49247
49667
|
function addToMap(handler) {
|
|
@@ -49403,6 +49823,7 @@ class SyntaxLogic {
|
|
|
49403
49823
|
};
|
|
49404
49824
|
this.issues = [];
|
|
49405
49825
|
this.deferred = [];
|
|
49826
|
+
this.loopTables = new _loop_table_change_1.LoopTableChange();
|
|
49406
49827
|
this.reg.getDDICReferences().clear(this.object);
|
|
49407
49828
|
this.reg.getMSAGReferences().clear(this.object);
|
|
49408
49829
|
if (this.object instanceof objects_1.Program && this.object.isInclude()) {
|
|
@@ -49468,6 +49889,9 @@ class SyntaxLogic {
|
|
|
49468
49889
|
this.issues.push(issue);
|
|
49469
49890
|
}
|
|
49470
49891
|
traverse(node) {
|
|
49892
|
+
const loop = node instanceof nodes_1.StructureNode
|
|
49893
|
+
&& node.get() instanceof Structures.Loop
|
|
49894
|
+
&& this.loopTables.push(node, this.scope);
|
|
49471
49895
|
for (const child of node.getChildren()) {
|
|
49472
49896
|
const isStructure = child instanceof nodes_1.StructureNode;
|
|
49473
49897
|
const isStatement = child instanceof nodes_1.StatementNode;
|
|
@@ -49500,6 +49924,9 @@ class SyntaxLogic {
|
|
|
49500
49924
|
this.traverse(child);
|
|
49501
49925
|
}
|
|
49502
49926
|
}
|
|
49927
|
+
if (loop === true) {
|
|
49928
|
+
this.loopTables.pop();
|
|
49929
|
+
}
|
|
49503
49930
|
}
|
|
49504
49931
|
/**
|
|
49505
49932
|
* if this returns true, then the traversal should continue with next child
|
|
@@ -49556,6 +49983,9 @@ class SyntaxLogic {
|
|
|
49556
49983
|
// todo: skipped for now
|
|
49557
49984
|
return true;
|
|
49558
49985
|
}
|
|
49986
|
+
else if (stru instanceof Structures.Cleanup) {
|
|
49987
|
+
cleanup_1.Cleanup.runSyntax(node, input);
|
|
49988
|
+
}
|
|
49559
49989
|
return false;
|
|
49560
49990
|
}
|
|
49561
49991
|
updateScopeStatement(node) {
|
|
@@ -49585,6 +50015,7 @@ class SyntaxLogic {
|
|
|
49585
50015
|
this.scope.addIdentifier(new data_2.Data().runSyntax(node, input));
|
|
49586
50016
|
return;
|
|
49587
50017
|
}
|
|
50018
|
+
this.loopTables.check(node, input);
|
|
49588
50019
|
const name = s.constructor.name;
|
|
49589
50020
|
if (map[name]) {
|
|
49590
50021
|
map[name].runSyntax(node, input);
|
|
@@ -70942,7 +71373,7 @@ class Registry {
|
|
|
70942
71373
|
}
|
|
70943
71374
|
static abaplintVersion() {
|
|
70944
71375
|
// magic, see build script "version.js"
|
|
70945
|
-
return "2.120.
|
|
71376
|
+
return "2.120.77";
|
|
70946
71377
|
}
|
|
70947
71378
|
getDDICReferences() {
|
|
70948
71379
|
return this.ddicReferences;
|
|
@@ -97440,6 +97871,9 @@ text = text.`,
|
|
|
97440
97871
|
else if (child.get() instanceof Expressions.Constant) {
|
|
97441
97872
|
context = this.infer(context, constant_1.Constant.runSyntax(child));
|
|
97442
97873
|
}
|
|
97874
|
+
else if (child.get() instanceof Expressions.StringTemplate) {
|
|
97875
|
+
context = basic_1.StringType.get();
|
|
97876
|
+
}
|
|
97443
97877
|
else if (child.get() instanceof Expressions.Source) {
|
|
97444
97878
|
context = this.infer(context, this.sourceType(child, scope));
|
|
97445
97879
|
}
|
|
@@ -104278,7 +104712,16 @@ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/ex
|
|
|
104278
104712
|
const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
|
|
104279
104713
|
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
|
|
104280
104714
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
104715
|
+
const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
|
|
104716
|
+
const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
|
|
104717
|
+
const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
|
|
104718
|
+
const tokens_1 = __webpack_require__(/*! ../abap/1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
|
|
104281
104719
|
class UseMessageClassConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
104720
|
+
constructor() {
|
|
104721
|
+
super(...arguments);
|
|
104722
|
+
/** Allow MESSAGE with an object reference, eg. an exception, like MESSAGE lx_error TYPE 'E' */
|
|
104723
|
+
this.allowExceptions = true;
|
|
104724
|
+
}
|
|
104282
104725
|
}
|
|
104283
104726
|
exports.UseMessageClassConf = UseMessageClassConf;
|
|
104284
104727
|
class UseMessageClass extends _abap_rule_1.ABAPRule {
|
|
@@ -104291,6 +104734,9 @@ class UseMessageClass extends _abap_rule_1.ABAPRule {
|
|
|
104291
104734
|
key: "use_message_class",
|
|
104292
104735
|
title: "Use message class",
|
|
104293
104736
|
shortDescription: `Define messages in SE91 instead of using inline text or variables`,
|
|
104737
|
+
extendedInformation: `If allowExceptions is enabled, MESSAGE with an object reference is allowed, eg. MESSAGE lx_error TYPE 'E'.
|
|
104738
|
+
|
|
104739
|
+
Void types are only allowed if the type name contains "CX_", as void class references cannot be distinguished from other void types.`,
|
|
104294
104740
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
|
|
104295
104741
|
badExample: `MESSAGE 'Something went wrong' TYPE 'E'.`,
|
|
104296
104742
|
goodExample: `MESSAGE e001(bc_msg).`,
|
|
@@ -104302,13 +104748,14 @@ class UseMessageClass extends _abap_rule_1.ABAPRule {
|
|
|
104302
104748
|
setConfig(conf) {
|
|
104303
104749
|
this.conf = conf;
|
|
104304
104750
|
}
|
|
104305
|
-
runParsed(file,
|
|
104751
|
+
runParsed(file, obj) {
|
|
104306
104752
|
const structure = file.getStructure();
|
|
104307
104753
|
if (structure === undefined) {
|
|
104308
104754
|
return [];
|
|
104309
104755
|
}
|
|
104310
104756
|
const issues = [];
|
|
104311
104757
|
const key = this.getMetadata().key;
|
|
104758
|
+
let syntax = undefined;
|
|
104312
104759
|
for (const statement of structure.findAllStatements(Statements.Message)) {
|
|
104313
104760
|
// The parser populates MessageSource only for the class-based forms (e001(bc_msg) or ID/TYPE/NUMBER).
|
|
104314
104761
|
// The text form (MESSAGE <source> TYPE <source>) uses MessageSourceSource directly with no MessageSource child.
|
|
@@ -104316,10 +104763,60 @@ class UseMessageClass extends _abap_rule_1.ABAPRule {
|
|
|
104316
104763
|
if (statement.findDirectExpression(Expressions.MessageSource) !== undefined) {
|
|
104317
104764
|
continue;
|
|
104318
104765
|
}
|
|
104766
|
+
if (this.conf.allowExceptions === true) {
|
|
104767
|
+
syntax !== null && syntax !== void 0 ? syntax : (syntax = new syntax_1.SyntaxLogic(this.reg, obj).run());
|
|
104768
|
+
if (this.isObjectReference(statement, file, syntax)) {
|
|
104769
|
+
continue;
|
|
104770
|
+
}
|
|
104771
|
+
}
|
|
104319
104772
|
issues.push(issue_1.Issue.atStatement(file, statement, "Use a message class (SE91) instead of inline text or variable", key, this.conf.severity));
|
|
104320
104773
|
}
|
|
104321
104774
|
return issues;
|
|
104322
104775
|
}
|
|
104776
|
+
isObjectReference(statement, file, syntax) {
|
|
104777
|
+
var _a, _b;
|
|
104778
|
+
const chain = (_b = (_a = statement.findDirectExpression(Expressions.MessageSourceSource)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Source)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.FieldChain);
|
|
104779
|
+
if (chain === undefined) {
|
|
104780
|
+
return false;
|
|
104781
|
+
}
|
|
104782
|
+
let type = undefined;
|
|
104783
|
+
for (const child of chain.getChildren()) {
|
|
104784
|
+
const c = child.get();
|
|
104785
|
+
if (c instanceof Expressions.ComponentName) {
|
|
104786
|
+
type = type instanceof basic_1.StructureType ? type.getComponentByName(child.concatTokens()) : undefined;
|
|
104787
|
+
}
|
|
104788
|
+
else if (c instanceof Expressions.SourceField
|
|
104789
|
+
|| c instanceof Expressions.SourceFieldSymbol
|
|
104790
|
+
|| c instanceof Expressions.AttributeName) {
|
|
104791
|
+
type = this.findType(child.getFirstToken().getStart(), file, syntax);
|
|
104792
|
+
}
|
|
104793
|
+
else if (c instanceof Expressions.ClassName
|
|
104794
|
+
|| c instanceof tokens_1.InstanceArrow
|
|
104795
|
+
|| c instanceof tokens_1.StaticArrow
|
|
104796
|
+
|| c instanceof tokens_1.Dash) {
|
|
104797
|
+
continue;
|
|
104798
|
+
}
|
|
104799
|
+
else {
|
|
104800
|
+
return false;
|
|
104801
|
+
}
|
|
104802
|
+
if (type === undefined) {
|
|
104803
|
+
return false;
|
|
104804
|
+
}
|
|
104805
|
+
}
|
|
104806
|
+
// void class references cannot be distinguished from other void types, guess based on the name
|
|
104807
|
+
return type instanceof basic_1.ObjectReferenceType
|
|
104808
|
+
|| type instanceof basic_1.GenericObjectReferenceType
|
|
104809
|
+
|| (type instanceof basic_1.VoidType && /CX_/i.test(type.getVoided() || ""));
|
|
104810
|
+
}
|
|
104811
|
+
findType(start, file, syntax) {
|
|
104812
|
+
const scope = syntax.spaghetti.lookupPosition(start, file.getFilename());
|
|
104813
|
+
for (const r of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
|
|
104814
|
+
if (r.position.getStart().equals(start) && r.resolved instanceof _typed_identifier_1.TypedIdentifier) {
|
|
104815
|
+
return r.resolved.getType();
|
|
104816
|
+
}
|
|
104817
|
+
}
|
|
104818
|
+
return undefined;
|
|
104819
|
+
}
|
|
104323
104820
|
}
|
|
104324
104821
|
exports.UseMessageClass = UseMessageClass;
|
|
104325
104822
|
//# sourceMappingURL=use_message_class.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.120.
|
|
3
|
+
"version": "2.120.77",
|
|
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.77",
|
|
43
43
|
"@types/chai": "^4.3.20",
|
|
44
44
|
"@types/minimist": "^1.2.5",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|