@abaplint/transpiler-cli 2.14.39 → 2.14.41
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/bundle.js +1433 -187
- package/package.json +3 -3
package/build/bundle.js
CHANGED
|
@@ -5108,7 +5108,7 @@ class Compare extends combi_1.Expression {
|
|
|
5108
5108
|
const predicate = (0, combi_1.ver)(version_1.Release.v740sp08, _1.MethodCallChain, { also: combi_1.AlsoIn.OpenABAP });
|
|
5109
5109
|
const rett = (0, combi_1.seq)(_1.Source, (0, combi_1.altPrio)((0, combi_1.seq)(_1.CompareOperator, _1.Source), inn, between, sopt));
|
|
5110
5110
|
const fsassign = (0, combi_1.seq)(_1.SourceFieldSymbolChain, "IS", (0, combi_1.optPrio)("NOT"), "ASSIGNED");
|
|
5111
|
-
const ret = (0, combi_1.seq)((0, combi_1.
|
|
5111
|
+
const ret = (0, combi_1.seq)((0, combi_1.star)("NOT"), (0, combi_1.altPrio)(rett, predicate, fsassign));
|
|
5112
5112
|
return ret;
|
|
5113
5113
|
}
|
|
5114
5114
|
}
|
|
@@ -5212,7 +5212,7 @@ class ComponentCompare extends combi_1.Expression {
|
|
|
5212
5212
|
const sopt = (0, combi_1.seq)("IS", (0, combi_1.opt)("NOT"), (0, combi_1.altPrio)("SUPPLIED", "BOUND", (0, combi_1.ver)(version_1.Release.v750, (0, combi_1.seq)("INSTANCE OF", _1.Source)), "REQUESTED", "ASSIGNED", "INITIAL"));
|
|
5213
5213
|
const between = (0, combi_1.seq)((0, combi_1.opt)("NOT"), "BETWEEN", _1.Source, "AND", _1.Source);
|
|
5214
5214
|
const rett = (0, combi_1.seq)(_1.ComponentChainSimple, (0, combi_1.altPrio)((0, combi_1.seq)(_1.CompareOperator, _1.Source), inn, between, sopt));
|
|
5215
|
-
const ret = (0, combi_1.seq)((0, combi_1.
|
|
5215
|
+
const ret = (0, combi_1.seq)((0, combi_1.star)("NOT"), rett);
|
|
5216
5216
|
return ret;
|
|
5217
5217
|
}
|
|
5218
5218
|
}
|
|
@@ -5311,7 +5311,7 @@ const tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ "./node_modules
|
|
|
5311
5311
|
const _1 = __webpack_require__(/*! . */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
|
|
5312
5312
|
class ComponentCondSub extends combi_1.Expression {
|
|
5313
5313
|
getRunnable() {
|
|
5314
|
-
const another = (0, combi_1.seq)((0, combi_1.
|
|
5314
|
+
const another = (0, combi_1.seq)((0, combi_1.star)("NOT"), (0, combi_1.tok)(tokens_1.WParenLeftW), _1.ComponentCond, (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WParenRightW), (0, combi_1.tok)(tokens_1.ParenRightW)));
|
|
5315
5315
|
return another;
|
|
5316
5316
|
}
|
|
5317
5317
|
}
|
|
@@ -5431,7 +5431,7 @@ const _1 = __webpack_require__(/*! . */ "./node_modules/@abaplint/core/build/src
|
|
|
5431
5431
|
class CondSub extends combi_1.Expression {
|
|
5432
5432
|
getRunnable() {
|
|
5433
5433
|
// rule ParserMissingSpace makes sure the whitespace is correct
|
|
5434
|
-
const another = (0, combi_1.seq)((0, combi_1.
|
|
5434
|
+
const another = (0, combi_1.seq)((0, combi_1.starPrio)("NOT"), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WParenLeftW), (0, combi_1.tok)(tokens_1.WParenLeft)), _1.Cond, (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WParenRightW), (0, combi_1.tok)(tokens_1.ParenRightW)));
|
|
5435
5435
|
return another;
|
|
5436
5436
|
}
|
|
5437
5437
|
}
|
|
@@ -28226,10 +28226,22 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
28226
28226
|
};
|
|
28227
28227
|
})();
|
|
28228
28228
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
28229
|
+
exports.countLeadingNot = countLeadingNot;
|
|
28229
28230
|
exports.hasKeyCompare = hasKeyCompare;
|
|
28230
28231
|
const Expressions = __importStar(__webpack_require__(/*! ../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
|
|
28231
28232
|
const nodes_1 = __webpack_require__(/*! ../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
28232
|
-
/**
|
|
28233
|
+
/** The number of NOT in front of a relational expression or a parenthesized condition, "NOT NOT a = 1" gives 2 */
|
|
28234
|
+
function countLeadingNot(node) {
|
|
28235
|
+
const children = node.getChildren();
|
|
28236
|
+
let count = 0;
|
|
28237
|
+
while (count < children.length
|
|
28238
|
+
&& children[count] instanceof nodes_1.TokenNode
|
|
28239
|
+
&& children[count].getFirstToken().getStr().toUpperCase() === "NOT") {
|
|
28240
|
+
count++;
|
|
28241
|
+
}
|
|
28242
|
+
return count;
|
|
28243
|
+
}
|
|
28244
|
+
/** True if a conjunct of the WHERE condition reachable through AND only, ie. not under OR or an odd number of NOT,
|
|
28233
28245
|
* compares the key component with = or IS INITIAL. Without such a comparison of its first component,
|
|
28234
28246
|
* a sorted key cannot be used to optimize the WHERE condition */
|
|
28235
28247
|
function hasKeyCompare(cond, component) {
|
|
@@ -28237,17 +28249,19 @@ function hasKeyCompare(cond, component) {
|
|
|
28237
28249
|
return false;
|
|
28238
28250
|
}
|
|
28239
28251
|
for (const child of cond.getChildren()) {
|
|
28240
|
-
if (child
|
|
28241
|
-
|
|
28252
|
+
if (!(child instanceof nodes_1.ExpressionNode) || countLeadingNot(child) % 2 === 1) {
|
|
28253
|
+
continue;
|
|
28254
|
+
}
|
|
28255
|
+
if (child.get() instanceof Expressions.ComponentCompare) {
|
|
28256
|
+
const concat = child.getChildren().slice(countLeadingNot(child))
|
|
28257
|
+
.map(c => c.concatTokens()).join(" ").toUpperCase().replace(/\s+/g, " ");
|
|
28242
28258
|
if (concat.startsWith(component + " = ")
|
|
28243
28259
|
|| concat.startsWith(component + " EQ ")
|
|
28244
28260
|
|| concat === component + " IS INITIAL") {
|
|
28245
28261
|
return true;
|
|
28246
28262
|
}
|
|
28247
28263
|
}
|
|
28248
|
-
else if (child.get() instanceof Expressions.ComponentCondSub
|
|
28249
|
-
&& child instanceof nodes_1.ExpressionNode
|
|
28250
|
-
&& child.findDirectTokenByText("NOT") === undefined) {
|
|
28264
|
+
else if (child.get() instanceof Expressions.ComponentCondSub) {
|
|
28251
28265
|
const sub = child.findDirectExpression(Expressions.ComponentCond);
|
|
28252
28266
|
if (sub !== undefined && hasKeyCompare(sub, component)) {
|
|
28253
28267
|
return true;
|
|
@@ -30238,6 +30252,11 @@ class TypeUtils {
|
|
|
30238
30252
|
}
|
|
30239
30253
|
return false;
|
|
30240
30254
|
}
|
|
30255
|
+
/** a number literal beyond the range of i */
|
|
30256
|
+
isPackedConstant(type) {
|
|
30257
|
+
var _a;
|
|
30258
|
+
return type instanceof basic_1.PackedType && ((_a = type.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) === true;
|
|
30259
|
+
}
|
|
30241
30260
|
isOOAssignable(source, target) {
|
|
30242
30261
|
let sid = source.getIdentifier();
|
|
30243
30262
|
let tid = target.getIdentifier();
|
|
@@ -30356,12 +30375,8 @@ class TypeUtils {
|
|
|
30356
30375
|
if (source2 instanceof basic_1.HexType && this.isCalculated(node2) && source1 instanceof basic_1.IntegerType) {
|
|
30357
30376
|
return false;
|
|
30358
30377
|
}
|
|
30359
|
-
|
|
30360
|
-
|
|
30361
|
-
}
|
|
30362
|
-
if (source2 instanceof basic_1.DateType && this.isCalculated(node1) && source1 instanceof basic_1.IntegerType) {
|
|
30363
|
-
return false;
|
|
30364
|
-
}
|
|
30378
|
+
// a date compared with an arithmetic expression is reported by Compare, a date compared with
|
|
30379
|
+
// a function or method result of type i is compared like a date compared with a data object of type i
|
|
30365
30380
|
return true;
|
|
30366
30381
|
}
|
|
30367
30382
|
structureContainsString(structure) {
|
|
@@ -30577,6 +30592,22 @@ class TypeUtils {
|
|
|
30577
30592
|
if (calculated && strictResult === false) {
|
|
30578
30593
|
return this.isAssignable(source, target);
|
|
30579
30594
|
}
|
|
30595
|
+
// a number literal of type p fits a packed parameter of any length without decimals
|
|
30596
|
+
if (this.isPackedConstant(source)) {
|
|
30597
|
+
if (target instanceof basic_1.PackedType) {
|
|
30598
|
+
return target.getDecimals() === 0;
|
|
30599
|
+
}
|
|
30600
|
+
else if (target instanceof basic_1.StringType
|
|
30601
|
+
|| target instanceof basic_1.DateType
|
|
30602
|
+
|| target instanceof basic_1.CharacterType
|
|
30603
|
+
|| target instanceof cgeneric_type_1.CGenericType
|
|
30604
|
+
|| target instanceof basic_1.CSequenceType
|
|
30605
|
+
|| target instanceof basic_1.XStringType
|
|
30606
|
+
|| target instanceof basic_1.XGenericType
|
|
30607
|
+
|| (target instanceof basic_1.StructureType && target.containsVoid() === false)) {
|
|
30608
|
+
return false;
|
|
30609
|
+
}
|
|
30610
|
+
}
|
|
30580
30611
|
// an elementary text field is not compatible with a structure, also not with a flat character-like one
|
|
30581
30612
|
if (target instanceof basic_1.StructureType
|
|
30582
30613
|
&& target.containsVoid() === false
|
|
@@ -32912,17 +32943,23 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32912
32943
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
32913
32944
|
exports.substringType = substringType;
|
|
32914
32945
|
exports.isFieldSymbolItself = isFieldSymbolItself;
|
|
32946
|
+
const nodes_1 = __webpack_require__(/*! ../../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
32947
|
+
const tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js");
|
|
32915
32948
|
const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
|
|
32916
32949
|
const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
|
|
32950
|
+
const class_attribute_1 = __webpack_require__(/*! ../../types/class_attribute */ "./node_modules/@abaplint/core/build/src/abap/types/class_attribute.js");
|
|
32951
|
+
const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js");
|
|
32917
32952
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
|
|
32918
32953
|
// The type of a substring with a static offset or length, used for reading and writing positions.
|
|
32919
32954
|
// On a character or byte field of fixed length the substring must lie inside the field, else it is
|
|
32920
|
-
// a syntax error
|
|
32921
|
-
//
|
|
32955
|
+
// a syntax error, unless the offset or length is a variable: then the bounds are left to the runtime.
|
|
32956
|
+
// Other types, a dynamic offset or length and "*" (undefined) are left alone, as is length 0.
|
|
32957
|
+
// The offset is applied first, so the length is compared to what remains after the offset.
|
|
32958
|
+
// "chain" holds the nodes of the surrounding chain, including both the offset and the length.
|
|
32922
32959
|
// A substring of a date, time or numeric text field has type n; its bounds are not checked.
|
|
32923
32960
|
// An offset or length on a numeric field (i, int8, p, f, decfloat) is a syntax error, whatever its value,
|
|
32924
32961
|
// except a length without offset covering the full packed field, eg. "lv_p(5)" for "lv_p(5) TYPE p".
|
|
32925
|
-
function substringType(context, offset, length, node, input) {
|
|
32962
|
+
function substringType(context, offset, length, node, chain, input) {
|
|
32926
32963
|
const numericName = numericTypeName(context);
|
|
32927
32964
|
if (context instanceof basic_1.PackedType && offset === undefined && length === context.getLength()) {
|
|
32928
32965
|
// the offset is checked in a separate call before the length, so this is a length without offset
|
|
@@ -32942,6 +32979,9 @@ function substringType(context, offset, length, node, input) {
|
|
|
32942
32979
|
const fieldLength = context.getLength();
|
|
32943
32980
|
if (offset !== undefined && offset > 0) {
|
|
32944
32981
|
if (offset >= fieldLength) {
|
|
32982
|
+
if (hasVariablePart(chain, input)) {
|
|
32983
|
+
return context;
|
|
32984
|
+
}
|
|
32945
32985
|
const message = `Offset ${offset} is outside the field of length ${fieldLength}`;
|
|
32946
32986
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
32947
32987
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
@@ -32950,6 +32990,9 @@ function substringType(context, offset, length, node, input) {
|
|
|
32950
32990
|
}
|
|
32951
32991
|
if (length !== undefined && length > 0) {
|
|
32952
32992
|
if (length > fieldLength) {
|
|
32993
|
+
if (hasVariablePart(chain, input)) {
|
|
32994
|
+
return context;
|
|
32995
|
+
}
|
|
32953
32996
|
const message = `Length ${length} exceeds the remaining length ${fieldLength} of the field`;
|
|
32954
32997
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
32955
32998
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
@@ -32958,6 +33001,37 @@ function substringType(context, offset, length, node, input) {
|
|
|
32958
33001
|
}
|
|
32959
33002
|
return context;
|
|
32960
33003
|
}
|
|
33004
|
+
// true if the offset or the length is given by a variable, a constant counts as static
|
|
33005
|
+
function hasVariablePart(chain, input) {
|
|
33006
|
+
return chain.some(node => {
|
|
33007
|
+
if (!(node instanceof nodes_1.ExpressionNode)
|
|
33008
|
+
|| !(node.get() instanceof Expressions.FieldOffset || node.get() instanceof Expressions.FieldLength)) {
|
|
33009
|
+
return false;
|
|
33010
|
+
}
|
|
33011
|
+
const field = node.findDirectExpression(Expressions.SimpleFieldChain2);
|
|
33012
|
+
return field !== undefined && isConstant(field, input) === false;
|
|
33013
|
+
});
|
|
33014
|
+
}
|
|
33015
|
+
// a constant or a component of one, an attribute behind "->" is not resolved here
|
|
33016
|
+
function isConstant(field, input) {
|
|
33017
|
+
var _a;
|
|
33018
|
+
const children = field.getChildren();
|
|
33019
|
+
if (children.some(c => c.get() instanceof tokens_1.InstanceArrow)) {
|
|
33020
|
+
return false;
|
|
33021
|
+
}
|
|
33022
|
+
const name = children[0].getFirstToken().getStr();
|
|
33023
|
+
if (children[0].get() instanceof Expressions.ClassName) {
|
|
33024
|
+
const def = input.scope.findObjectDefinition(name);
|
|
33025
|
+
const attribute = (_a = children[2]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
|
|
33026
|
+
return new _object_oriented_1.ObjectOriented(input.scope).searchConstantName(def, attribute) !== undefined;
|
|
33027
|
+
}
|
|
33028
|
+
const found = input.scope.findVariable(name);
|
|
33029
|
+
if (found === undefined || found instanceof class_attribute_1.ClassAttribute) {
|
|
33030
|
+
return false;
|
|
33031
|
+
}
|
|
33032
|
+
const meta = found.getMeta();
|
|
33033
|
+
return meta.includes("read_only" /* IdentifierMeta.ReadOnly */) && meta.includes("static" /* IdentifierMeta.Static */);
|
|
33034
|
+
}
|
|
32961
33035
|
// the internal type code the ABAP syntax check names: I, 8, P, F, a (decfloat16), e (decfloat34)
|
|
32962
33036
|
function numericTypeName(context) {
|
|
32963
33037
|
if (context instanceof basic_1.IntegerType) {
|
|
@@ -33152,11 +33226,11 @@ class AttributeChain {
|
|
|
33152
33226
|
}
|
|
33153
33227
|
else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.FieldOffset) {
|
|
33154
33228
|
const offset = field_offset_1.FieldOffset.runSyntax(child, input);
|
|
33155
|
-
contextType = (0, _substring_1.substringType)(contextType, offset, undefined, child, input);
|
|
33229
|
+
contextType = (0, _substring_1.substringType)(contextType, offset, undefined, child, children, input);
|
|
33156
33230
|
}
|
|
33157
33231
|
else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.FieldLength) {
|
|
33158
33232
|
const length = field_length_1.FieldLength.runSyntax(child, input);
|
|
33159
|
-
contextType = (0, _substring_1.substringType)(contextType, undefined, length, child, input);
|
|
33233
|
+
contextType = (0, _substring_1.substringType)(contextType, undefined, length, child, children, input);
|
|
33160
33234
|
}
|
|
33161
33235
|
}
|
|
33162
33236
|
return contextType;
|
|
@@ -33474,16 +33548,7 @@ class Compare {
|
|
|
33474
33548
|
else if (node.findDirectExpression(Expressions.CompareOperator)
|
|
33475
33549
|
&& typeUtils.isCompareable(sourceTypes[0], sourceTypes[1], sources[0], sources[1]) === false
|
|
33476
33550
|
&& sourceTypes.length === 2) {
|
|
33477
|
-
|
|
33478
|
-
if ((sourceTypes[0] instanceof basic_1.DateType
|
|
33479
|
-
&& sourceTypes[1] instanceof basic_1.IntegerType
|
|
33480
|
-
&& sources[1].findFirstExpression(Expressions.ArithOperator))
|
|
33481
|
-
|| (sourceTypes[1] instanceof basic_1.DateType
|
|
33482
|
-
&& sourceTypes[0] instanceof basic_1.IntegerType
|
|
33483
|
-
&& sources[0].findFirstExpression(Expressions.ArithOperator))) {
|
|
33484
|
-
message = "Date cannot be compared with arithmetic result of type Integer";
|
|
33485
|
-
}
|
|
33486
|
-
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
33551
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), "Incompatible types for comparison"));
|
|
33487
33552
|
}
|
|
33488
33553
|
}
|
|
33489
33554
|
// a built-in function with a character-like result cannot be the operand of IS [NOT] INITIAL,
|
|
@@ -34233,8 +34298,9 @@ const expressions_1 = __webpack_require__(/*! ../../2_statements/expressions */
|
|
|
34233
34298
|
class Constant {
|
|
34234
34299
|
static runSyntax(node) {
|
|
34235
34300
|
// todo: ConcatenatedConstant is not used?
|
|
34236
|
-
|
|
34237
|
-
|
|
34301
|
+
const integer = node.findDirectExpression(expressions_1.Integer);
|
|
34302
|
+
if (integer) {
|
|
34303
|
+
return this.numberType(integer.concatTokens());
|
|
34238
34304
|
}
|
|
34239
34305
|
const first = node.getFirstToken().getStr();
|
|
34240
34306
|
if (first.startsWith("'")) {
|
|
@@ -34251,6 +34317,16 @@ class Constant {
|
|
|
34251
34317
|
return basic_1.StringType.get();
|
|
34252
34318
|
}
|
|
34253
34319
|
}
|
|
34320
|
+
// a number literal is of type i if its value is in the range of i, else of type p without decimals,
|
|
34321
|
+
// with length 8 for up to 15 digits and length 16 above, leading zeros not counted
|
|
34322
|
+
static numberType(literal) {
|
|
34323
|
+
const value = Number(literal.replace(/\s/g, ""));
|
|
34324
|
+
if (value >= -2147483648 && value <= 2147483647) {
|
|
34325
|
+
return basic_1.IntegerType.get({ derivedFromConstant: true });
|
|
34326
|
+
}
|
|
34327
|
+
const digits = literal.replace(/\D/g, "").replace(/^0+/, "");
|
|
34328
|
+
return new basic_1.PackedType(digits.length <= 15 ? 8 : 16, 0, { derivedFromConstant: true });
|
|
34329
|
+
}
|
|
34254
34330
|
}
|
|
34255
34331
|
exports.Constant = Constant;
|
|
34256
34332
|
//# sourceMappingURL=constant.js.map
|
|
@@ -34967,13 +35043,13 @@ class FieldChain {
|
|
|
34967
35043
|
else if (current.get() instanceof Expressions.FieldOffset && current instanceof nodes_1.ExpressionNode) {
|
|
34968
35044
|
const offset = field_offset_1.FieldOffset.runSyntax(current, input);
|
|
34969
35045
|
if (!(0, _substring_1.isFieldSymbolItself)(children, i)) {
|
|
34970
|
-
context = (0, _substring_1.substringType)(context, offset, undefined, current, input);
|
|
35046
|
+
context = (0, _substring_1.substringType)(context, offset, undefined, current, children, input);
|
|
34971
35047
|
}
|
|
34972
35048
|
}
|
|
34973
35049
|
else if (current.get() instanceof Expressions.FieldLength && current instanceof nodes_1.ExpressionNode) {
|
|
34974
35050
|
const length = field_length_1.FieldLength.runSyntax(current, input);
|
|
34975
35051
|
if (!(0, _substring_1.isFieldSymbolItself)(children, i)) {
|
|
34976
|
-
context = (0, _substring_1.substringType)(context, undefined, length, current, input);
|
|
35052
|
+
context = (0, _substring_1.substringType)(context, undefined, length, current, children, input);
|
|
34977
35053
|
}
|
|
34978
35054
|
}
|
|
34979
35055
|
prev = current.concatTokens();
|
|
@@ -35777,6 +35853,9 @@ class InlineData {
|
|
|
35777
35853
|
else if (type instanceof basic_1.StringType) {
|
|
35778
35854
|
return basic_1.StringType.get(rest);
|
|
35779
35855
|
}
|
|
35856
|
+
else if (type instanceof basic_1.PackedType) {
|
|
35857
|
+
return new basic_1.PackedType(type.getLength(), type.getDecimals(), rest);
|
|
35858
|
+
}
|
|
35780
35859
|
return type;
|
|
35781
35860
|
}
|
|
35782
35861
|
}
|
|
@@ -40529,7 +40608,7 @@ class Target {
|
|
|
40529
40608
|
}
|
|
40530
40609
|
const value = field_offset_1.FieldOffset.runSyntax(offset, input);
|
|
40531
40610
|
if (!(0, _substring_1.isFieldSymbolItself)(children, children.indexOf(offset))) {
|
|
40532
|
-
substring = (0, _substring_1.substringType)(substring, value, undefined, offset, input);
|
|
40611
|
+
substring = (0, _substring_1.substringType)(substring, value, undefined, offset, children, input);
|
|
40533
40612
|
}
|
|
40534
40613
|
}
|
|
40535
40614
|
const length = node.findDirectExpression(Expressions.FieldLength);
|
|
@@ -40541,7 +40620,7 @@ class Target {
|
|
|
40541
40620
|
}
|
|
40542
40621
|
const value = field_length_1.FieldLength.runSyntax(length, input);
|
|
40543
40622
|
if (!(0, _substring_1.isFieldSymbolItself)(children, children.indexOf(length))) {
|
|
40544
|
-
substring = (0, _substring_1.substringType)(substring, undefined, value, length, input);
|
|
40623
|
+
substring = (0, _substring_1.substringType)(substring, undefined, value, length, children, input);
|
|
40545
40624
|
}
|
|
40546
40625
|
}
|
|
40547
40626
|
if (substring instanceof basic_1.VoidType && !(context instanceof basic_1.VoidType)) {
|
|
@@ -40832,6 +40911,7 @@ const let_1 = __webpack_require__(/*! ./let */ "./node_modules/@abaplint/core/bu
|
|
|
40832
40911
|
const field_assignment_1 = __webpack_require__(/*! ./field_assignment */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_assignment.js");
|
|
40833
40912
|
const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
|
|
40834
40913
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
|
|
40914
|
+
const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
|
|
40835
40915
|
class ValueBody {
|
|
40836
40916
|
static runSyntax(node, input, targetType) {
|
|
40837
40917
|
var _a, _b, _c;
|
|
@@ -40917,16 +40997,17 @@ class ValueBody {
|
|
|
40917
40997
|
}
|
|
40918
40998
|
for (const s of foo.findDirectExpressions(Expressions.Source)) {
|
|
40919
40999
|
const sourceType = source_1.Source.runSyntax(s, input, rowType);
|
|
41000
|
+
const sourceKind = new _type_utils_1.TypeUtils(input.scope).isPackedConstant(sourceType) ? "p" : this.numericKind(sourceType);
|
|
40920
41001
|
if ((rowType instanceof basic_1.StringType || rowType instanceof basic_1.XStringType) && sourceType instanceof basic_1.CharacterType) {
|
|
40921
41002
|
const message = "VALUE, source type CharacterType not compatible with " + rowType.constructor.name;
|
|
40922
41003
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
|
|
40923
41004
|
}
|
|
40924
41005
|
else if (this.isDataObject(s)
|
|
40925
41006
|
&& this.numericKind(rowType) !== undefined
|
|
40926
|
-
&&
|
|
40927
|
-
&& this.numericKind(rowType) !==
|
|
41007
|
+
&& sourceKind !== undefined
|
|
41008
|
+
&& this.numericKind(rowType) !== sourceKind) {
|
|
40928
41009
|
// a data object given as a row must be compatible with the row type, it is not converted
|
|
40929
|
-
const message = `VALUE, source type ${
|
|
41010
|
+
const message = `VALUE, source type ${sourceKind} not compatible with row type ${this.numericKind(rowType)}`;
|
|
40930
41011
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
|
|
40931
41012
|
}
|
|
40932
41013
|
else if (this.insertsUsingTableKey(targetType)) {
|
|
@@ -42783,6 +42864,10 @@ class Catch {
|
|
|
42783
42864
|
const found = input.scope.existsObject(className);
|
|
42784
42865
|
if (found === null || found === void 0 ? void 0 : found.id) {
|
|
42785
42866
|
input.scope.addReference(token, found.id, _reference_1.ReferenceType.ObjectOrientedReference, input.filename);
|
|
42867
|
+
const message = this.checkExceptionClass(className, input);
|
|
42868
|
+
if (message !== undefined) {
|
|
42869
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message));
|
|
42870
|
+
}
|
|
42786
42871
|
}
|
|
42787
42872
|
else if (input.scope.getDDIC().inErrorNamespace(className) === false) {
|
|
42788
42873
|
const extra = { ooName: className, ooType: "Void" };
|
|
@@ -42831,6 +42916,30 @@ class Catch {
|
|
|
42831
42916
|
}
|
|
42832
42917
|
}
|
|
42833
42918
|
}
|
|
42919
|
+
// the classes of a CATCH are exception classes, that is CX_ROOT or a subclass of it. A class is only
|
|
42920
|
+
// reported when its superclasses are known up to the last one, a chain ending in a void class is skipped
|
|
42921
|
+
checkExceptionClass(name, input) {
|
|
42922
|
+
var _a;
|
|
42923
|
+
const visited = new Set();
|
|
42924
|
+
let current = input.scope.findClassDefinition(name);
|
|
42925
|
+
if (current === undefined) {
|
|
42926
|
+
return input.scope.findInterfaceDefinition(name)
|
|
42927
|
+
? `CATCH, ${name} is an interface, not an exception class`
|
|
42928
|
+
: undefined;
|
|
42929
|
+
}
|
|
42930
|
+
while (current !== undefined && visited.has(current.getName().toUpperCase()) === false) {
|
|
42931
|
+
visited.add(current.getName().toUpperCase());
|
|
42932
|
+
const superclass = (_a = current.getSuperClass()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
42933
|
+
if (current.getName().toUpperCase() === "CX_ROOT" || superclass === "CX_ROOT") {
|
|
42934
|
+
return undefined;
|
|
42935
|
+
}
|
|
42936
|
+
else if (superclass === undefined) {
|
|
42937
|
+
return `CATCH, ${name} is not an exception class, it is not derived from CX_ROOT`;
|
|
42938
|
+
}
|
|
42939
|
+
current = input.scope.findClassDefinition(superclass);
|
|
42940
|
+
}
|
|
42941
|
+
return undefined;
|
|
42942
|
+
}
|
|
42834
42943
|
// static type of an inline target: the first class, replaced by each following class that is one of its
|
|
42835
42944
|
// super classes; any other following class makes it CX_ROOT, also when the classes share a closer super class
|
|
42836
42945
|
inlineType(classNames, input) {
|
|
@@ -47021,6 +47130,12 @@ class InsertInternal {
|
|
|
47021
47130
|
if (sourceType instanceof basic_1.IntegerType && targetType instanceof basic_1.Integer8Type) {
|
|
47022
47131
|
error = true;
|
|
47023
47132
|
}
|
|
47133
|
+
else if ((source === null || source === void 0 ? void 0 : source.getChildren().length) === 1
|
|
47134
|
+
&& new _type_utils_1.TypeUtils(input.scope).isPackedConstant(sourceType)
|
|
47135
|
+
&& (targetType instanceof basic_1.IntegerType || targetType instanceof basic_1.Integer8Type)) {
|
|
47136
|
+
// a literal of type p is not converted into an integer row
|
|
47137
|
+
error = true;
|
|
47138
|
+
}
|
|
47024
47139
|
else if (targetType instanceof basic_1.TableType && targetType.isWithHeader() && sourceType instanceof basic_1.TableType) {
|
|
47025
47140
|
// LINES OF into a table with header line, compare the row types
|
|
47026
47141
|
error = new _type_utils_1.TypeUtils(input.scope).isAssignable(sourceType.getRowType(), targetType.getRowType()) === false;
|
|
@@ -51043,8 +51158,11 @@ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/
|
|
|
51043
51158
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
|
|
51044
51159
|
class Split {
|
|
51045
51160
|
runSyntax(node, input) {
|
|
51161
|
+
const byteMode = node.findDirectTokenByText("BYTE") !== undefined;
|
|
51046
51162
|
const intoTable = node.findTokenSequencePosition("INTO", "TABLE") !== undefined;
|
|
51047
|
-
const
|
|
51163
|
+
const segment = byteMode ? basic_1.XStringType.get() : basic_1.StringType.get();
|
|
51164
|
+
const type = intoTable ? new basic_1.TableType(segment, { withHeader: false, keyType: basic_1.TableKeyType.default }) : segment;
|
|
51165
|
+
const utils = new _type_utils_1.TypeUtils(input.scope);
|
|
51048
51166
|
for (const target of node.findAllExpressions(Expressions.Target)) {
|
|
51049
51167
|
const inline = target.findDirectExpression(Expressions.InlineData);
|
|
51050
51168
|
if (inline) {
|
|
@@ -51064,17 +51182,27 @@ class Split {
|
|
|
51064
51182
|
targetType = targetType.getRowType();
|
|
51065
51183
|
}
|
|
51066
51184
|
}
|
|
51067
|
-
|
|
51068
|
-
|
|
51185
|
+
const compatible = byteMode ? this.isByteLike(targetType, utils) : utils.isCharLikeStrict(targetType);
|
|
51186
|
+
if (compatible === false) {
|
|
51187
|
+
const message = "Incompatible, target not " + (byteMode ? "byte" : "character") + " like";
|
|
51069
51188
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
51070
51189
|
return;
|
|
51071
51190
|
}
|
|
51072
51191
|
}
|
|
51073
51192
|
}
|
|
51074
51193
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
51075
|
-
source_1.Source.runSyntax(s, input);
|
|
51194
|
+
const sourceType = source_1.Source.runSyntax(s, input);
|
|
51195
|
+
if (byteMode && sourceType !== undefined && this.isByteLike(sourceType, utils) === false) {
|
|
51196
|
+
const message = "Incompatible, source not byte like";
|
|
51197
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
|
|
51198
|
+
return;
|
|
51199
|
+
}
|
|
51076
51200
|
}
|
|
51077
51201
|
}
|
|
51202
|
+
isByteLike(type, utils) {
|
|
51203
|
+
// the actual type behind "data" and "simple" is only known at runtime
|
|
51204
|
+
return utils.isHexLike(type) || type instanceof basic_1.DataType || type instanceof basic_1.SimpleType;
|
|
51205
|
+
}
|
|
51078
51206
|
}
|
|
51079
51207
|
exports.Split = Split;
|
|
51080
51208
|
//# sourceMappingURL=split.js.map
|
|
@@ -69535,6 +69663,12 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
69535
69663
|
this.parse();
|
|
69536
69664
|
return (_a = this.parsedData) === null || _a === void 0 ? void 0 : _a.description;
|
|
69537
69665
|
}
|
|
69666
|
+
/** SOURCE_TYPE from the abapGit XML, eg. "W" view entity, "P" projection view, "V" DDIC-based view */
|
|
69667
|
+
getSourceType() {
|
|
69668
|
+
var _a;
|
|
69669
|
+
this.parse();
|
|
69670
|
+
return (_a = this.parsedData) === null || _a === void 0 ? void 0 : _a.sourceType;
|
|
69671
|
+
}
|
|
69538
69672
|
parseType(reg) {
|
|
69539
69673
|
this.parse();
|
|
69540
69674
|
if (this.typeCache === undefined || this.typeCacheData !== this.parsedData) {
|
|
@@ -69576,15 +69710,17 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
69576
69710
|
return ret;
|
|
69577
69711
|
}
|
|
69578
69712
|
parse() {
|
|
69579
|
-
var _a, _b;
|
|
69713
|
+
var _a, _b, _c, _d, _e, _f;
|
|
69580
69714
|
if (this.isDirty() === false) {
|
|
69581
69715
|
return { updated: false, runtime: 0 };
|
|
69582
69716
|
}
|
|
69583
69717
|
const start = Date.now();
|
|
69718
|
+
const ddls = (_d = (_c = (_b = (_a = this.parseRaw2()) === null || _a === void 0 ? void 0 : _a.abapGit) === null || _b === void 0 ? void 0 : _b["asx:abap"]) === null || _c === void 0 ? void 0 : _c["asx:values"]) === null || _d === void 0 ? void 0 : _d.DDLS;
|
|
69584
69719
|
this.parsedData = {
|
|
69585
69720
|
sqlViewName: undefined,
|
|
69586
69721
|
definitionName: undefined,
|
|
69587
|
-
|
|
69722
|
+
sourceType: typeof (ddls === null || ddls === void 0 ? void 0 : ddls.SOURCE_TYPE) === "string" ? ddls.SOURCE_TYPE.trim() : undefined,
|
|
69723
|
+
description: undefined,
|
|
69588
69724
|
fields: [],
|
|
69589
69725
|
sources: [],
|
|
69590
69726
|
relations: [],
|
|
@@ -69592,14 +69728,16 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
69592
69728
|
tree: undefined,
|
|
69593
69729
|
};
|
|
69594
69730
|
this.parsedData.tree = new cds_parser_1.CDSParser().parse(this.findSourceFile());
|
|
69595
|
-
this.
|
|
69731
|
+
const leadingAnnotations = this.findLeadingAnnotations(this.parsedData.tree);
|
|
69732
|
+
this.findSQLViewName(leadingAnnotations);
|
|
69733
|
+
this.parsedData.description = this.findDescription(leadingAnnotations, ddls === null || ddls === void 0 ? void 0 : ddls.DDTEXT);
|
|
69596
69734
|
if (this.parsedData.tree) {
|
|
69597
|
-
for (const c of ((
|
|
69735
|
+
for (const c of ((_e = this.parsedData.tree) === null || _e === void 0 ? void 0 : _e.getChildren()) || []) {
|
|
69598
69736
|
if (c.get() instanceof expressions_1.CDSAnnotation) {
|
|
69599
69737
|
continue;
|
|
69600
69738
|
}
|
|
69601
69739
|
if (c instanceof nodes_1.ExpressionNode) {
|
|
69602
|
-
this.parsedData.definitionName = (
|
|
69740
|
+
this.parsedData.definitionName = (_f = c.findFirstExpression(expressions_1.CDSName)) === null || _f === void 0 ? void 0 : _f.concatTokens().replace(/ /g, "");
|
|
69603
69741
|
break;
|
|
69604
69742
|
}
|
|
69605
69743
|
}
|
|
@@ -69617,39 +69755,51 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
69617
69755
|
return (_a = this.parsedData) === null || _a === void 0 ? void 0 : _a.tree;
|
|
69618
69756
|
}
|
|
69619
69757
|
//////////
|
|
69620
|
-
|
|
69758
|
+
/** annotations before the entity definition, ie. not the ones on elements or parameters */
|
|
69759
|
+
findLeadingAnnotations(tree) {
|
|
69621
69760
|
var _a;
|
|
69622
|
-
|
|
69623
|
-
|
|
69624
|
-
|
|
69625
|
-
|
|
69626
|
-
|
|
69627
|
-
|
|
69628
|
-
// Keep SQL view lookup available even when the view body cannot be parsed.
|
|
69629
|
-
const tokens = cds_lexer_1.CDSLexer.run(file).filter(t => !(t instanceof tokens_1.Comment));
|
|
69630
|
-
const leadingAnnotations = (0, combi_1.seq)((0, combi_1.starPrio)(expressions_1.CDSAnnotation), (0, combi_1.starPrio)((0, combi_1.regex)(/.*/)));
|
|
69631
|
-
annotations = (_a = combi_1.Combi.run(leadingAnnotations, tokens, version_1.defaultRelease)) === null || _a === void 0 ? void 0 : _a.filter((n) => n instanceof nodes_1.ExpressionNode && n.get() instanceof expressions_1.CDSAnnotation);
|
|
69761
|
+
if (tree !== undefined) {
|
|
69762
|
+
return tree.findDirectExpressions(expressions_1.CDSAnnotation);
|
|
69763
|
+
}
|
|
69764
|
+
const file = this.findSourceFile();
|
|
69765
|
+
if (file === undefined) {
|
|
69766
|
+
return [];
|
|
69632
69767
|
}
|
|
69633
|
-
|
|
69768
|
+
// Keep header annotations available even when the definition body cannot be parsed.
|
|
69769
|
+
const tokens = cds_lexer_1.CDSLexer.run(file).filter(t => !(t instanceof tokens_1.Comment));
|
|
69770
|
+
const leadingAnnotations = (0, combi_1.seq)((0, combi_1.starPrio)(expressions_1.CDSAnnotation), (0, combi_1.starPrio)((0, combi_1.regex)(/.*/)));
|
|
69771
|
+
return ((_a = combi_1.Combi.run(leadingAnnotations, tokens, version_1.defaultRelease)) === null || _a === void 0 ? void 0 : _a.filter((n) => n instanceof nodes_1.ExpressionNode && n.get() instanceof expressions_1.CDSAnnotation)) || [];
|
|
69772
|
+
}
|
|
69773
|
+
/** values of the leading annotations with the given name, as written in the source */
|
|
69774
|
+
findLeadingAnnotationValues(annotations, name) {
|
|
69775
|
+
const ret = [];
|
|
69776
|
+
for (const annotation of annotations) {
|
|
69634
69777
|
const tokens = annotation.getTokens().map(t => t.getStr());
|
|
69635
69778
|
const colon = tokens.indexOf(":");
|
|
69636
|
-
if (tokens.slice(0, colon).join("")
|
|
69637
|
-
|
|
69779
|
+
if (colon >= 0 && tokens.slice(0, colon).join("") === name) {
|
|
69780
|
+
ret.push(tokens.slice(colon + 1).join(" "));
|
|
69638
69781
|
}
|
|
69639
|
-
|
|
69782
|
+
}
|
|
69783
|
+
return ret;
|
|
69784
|
+
}
|
|
69785
|
+
findSQLViewName(annotations) {
|
|
69786
|
+
for (const value of this.findLeadingAnnotationValues(annotations, "@AbapCatalog.sqlViewName")) {
|
|
69787
|
+
const match = value.match(/^'([\w/]+)'$/);
|
|
69640
69788
|
if (match) {
|
|
69641
69789
|
this.parsedData.sqlViewName = match[1].toUpperCase();
|
|
69642
69790
|
return;
|
|
69643
69791
|
}
|
|
69644
69792
|
}
|
|
69645
69793
|
}
|
|
69646
|
-
|
|
69647
|
-
|
|
69648
|
-
const
|
|
69649
|
-
|
|
69650
|
-
|
|
69794
|
+
/** entity level EndUserText.label annotation, with fallback to DDTEXT from the abapGit XML */
|
|
69795
|
+
findDescription(annotations, ddtext) {
|
|
69796
|
+
for (const value of this.findLeadingAnnotationValues(annotations, "@EndUserText.label")) {
|
|
69797
|
+
const match = value.match(/^'([\s\S]*)'$/);
|
|
69798
|
+
if (match) {
|
|
69799
|
+
return match[1].replace(/\\(['\\])/g, "$1");
|
|
69800
|
+
}
|
|
69651
69801
|
}
|
|
69652
|
-
return undefined;
|
|
69802
|
+
return typeof ddtext === "string" && ddtext !== "" ? ddtext : undefined;
|
|
69653
69803
|
}
|
|
69654
69804
|
findFieldNames(tree) {
|
|
69655
69805
|
var _a, _b, _c;
|
|
@@ -73632,6 +73782,107 @@ exports.QueryUserGroup = QueryUserGroup;
|
|
|
73632
73782
|
|
|
73633
73783
|
/***/ },
|
|
73634
73784
|
|
|
73785
|
+
/***/ "./node_modules/@abaplint/core/build/src/objects/rename/rename_bsp_application.js"
|
|
73786
|
+
/*!****************************************************************************************!*\
|
|
73787
|
+
!*** ./node_modules/@abaplint/core/build/src/objects/rename/rename_bsp_application.js ***!
|
|
73788
|
+
\****************************************************************************************/
|
|
73789
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
73790
|
+
|
|
73791
|
+
"use strict";
|
|
73792
|
+
|
|
73793
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
73794
|
+
exports.RenameBSPApplication = void 0;
|
|
73795
|
+
const vscode_languageserver_types_1 = __webpack_require__(/*! vscode-languageserver-types */ "./node_modules/vscode-languageserver-types/lib/esm/main.js");
|
|
73796
|
+
const __1 = __webpack_require__(/*! .. */ "./node_modules/@abaplint/core/build/src/objects/index.js");
|
|
73797
|
+
const renamer_helper_1 = __webpack_require__(/*! ./renamer_helper */ "./node_modules/@abaplint/core/build/src/objects/rename/renamer_helper.js");
|
|
73798
|
+
/** Renames a BSP application: APPLNAME and APPLEXT in the XML, the name in front of ".wapa." of every
|
|
73799
|
+
* file and the URLs of the MIME objects in its MIME folder. The pages keep their names (PAGEKEY, PAGENAME and the page part of a file name): they are paths
|
|
73800
|
+
* inside the application, which its files refer to, e.g. "thirdparty/zfoo/lib.js" of the application ZFOO.
|
|
73801
|
+
* abapGit finds the file of a page by its page name, a renamed page name has no file */
|
|
73802
|
+
class RenameBSPApplication {
|
|
73803
|
+
constructor(reg) {
|
|
73804
|
+
this.reg = reg;
|
|
73805
|
+
}
|
|
73806
|
+
buildEdits(obj, oldName, newName) {
|
|
73807
|
+
if (!(obj instanceof __1.BSPApplication)) {
|
|
73808
|
+
throw new Error("RenameBSPApplication, not a BSP application");
|
|
73809
|
+
}
|
|
73810
|
+
let changes = [];
|
|
73811
|
+
const helper = new renamer_helper_1.RenamerHelper(this.reg);
|
|
73812
|
+
changes = changes.concat(helper.buildXMLFileEdits(obj, "APPLNAME", oldName, newName));
|
|
73813
|
+
changes = changes.concat(helper.buildXMLFileEdits(obj, "APPLEXT", oldName, newName));
|
|
73814
|
+
changes = changes.concat(this.renameFiles(obj, oldName, newName));
|
|
73815
|
+
changes = changes.concat(this.renameMIMEURLs(oldName, newName));
|
|
73816
|
+
return {
|
|
73817
|
+
documentChanges: changes,
|
|
73818
|
+
};
|
|
73819
|
+
}
|
|
73820
|
+
/** The MIME folder of the application and everything below it (SMIM objects) move with it:
|
|
73821
|
+
* /SAP/BC/BSP/SAP/ZFOO/... for an application ZFOO, /SAP/BC/BSP/NS/BAR/... for /NS/BAR.
|
|
73822
|
+
* abapGit creates MIME objects by their URL, the object and file names are GUIDs and stay */
|
|
73823
|
+
renameMIMEURLs(oldName, newName) {
|
|
73824
|
+
const oldPrefix = mimeFolder(oldName);
|
|
73825
|
+
const newPrefix = mimeFolder(newName);
|
|
73826
|
+
const changes = [];
|
|
73827
|
+
for (const o of this.reg.getObjectsByType("SMIM")) {
|
|
73828
|
+
if (!(o instanceof __1.MIMEObject) || this.reg.isDependency(o)) {
|
|
73829
|
+
continue;
|
|
73830
|
+
}
|
|
73831
|
+
const xml = o.getXMLFile();
|
|
73832
|
+
if (xml === undefined) {
|
|
73833
|
+
continue;
|
|
73834
|
+
}
|
|
73835
|
+
const rows = xml.getRawRows();
|
|
73836
|
+
for (let i = 0; i < rows.length; i++) {
|
|
73837
|
+
const start = rows[i].indexOf("<URL>");
|
|
73838
|
+
const end = rows[i].indexOf("</URL>");
|
|
73839
|
+
if (start < 0 || end < start) {
|
|
73840
|
+
continue;
|
|
73841
|
+
}
|
|
73842
|
+
const url = rows[i].substring(start + 5, end);
|
|
73843
|
+
const upper = url.toUpperCase();
|
|
73844
|
+
if (upper !== oldPrefix && upper.startsWith(oldPrefix + "/") === false) {
|
|
73845
|
+
continue;
|
|
73846
|
+
}
|
|
73847
|
+
const prefix = url.substring(0, oldPrefix.length) === oldPrefix ? newPrefix : newPrefix.toLowerCase();
|
|
73848
|
+
const range = vscode_languageserver_types_1.Range.create(i, start + 5, i, start + 5 + oldPrefix.length);
|
|
73849
|
+
changes.push(vscode_languageserver_types_1.TextDocumentEdit.create({ uri: xml.getFilename(), version: 1 }, [vscode_languageserver_types_1.TextEdit.replace(range, prefix)]));
|
|
73850
|
+
}
|
|
73851
|
+
}
|
|
73852
|
+
return changes;
|
|
73853
|
+
}
|
|
73854
|
+
/** only the name in front of ".wapa.", folders and page parts keep the old name if they contain it */
|
|
73855
|
+
renameFiles(obj, oldName, newName) {
|
|
73856
|
+
const list = [];
|
|
73857
|
+
const oldPrefix = oldName.toLowerCase().replace(/\//g, "#") + ".wapa.";
|
|
73858
|
+
const newPrefix = newName.toLowerCase().replace(/\//g, "#") + ".wapa.";
|
|
73859
|
+
for (const f of obj.getFiles()) {
|
|
73860
|
+
const filename = f.getFilename();
|
|
73861
|
+
const slash = Math.max(filename.lastIndexOf("/"), filename.lastIndexOf("\\"));
|
|
73862
|
+
const base = filename.substring(slash + 1);
|
|
73863
|
+
if (base.toLowerCase().startsWith(oldPrefix) === false) {
|
|
73864
|
+
continue;
|
|
73865
|
+
}
|
|
73866
|
+
list.push(vscode_languageserver_types_1.RenameFile.create(filename, filename.substring(0, slash + 1) + newPrefix + base.substring(oldPrefix.length)));
|
|
73867
|
+
}
|
|
73868
|
+
return list;
|
|
73869
|
+
}
|
|
73870
|
+
}
|
|
73871
|
+
exports.RenameBSPApplication = RenameBSPApplication;
|
|
73872
|
+
/** the URL of the MIME folder of a BSP application, upper case. A namespaced application sits below its
|
|
73873
|
+
* namespace instead of below SAP: ZFOO -> /SAP/BC/BSP/SAP/ZFOO, /NS/BAR -> /SAP/BC/BSP/NS/BAR */
|
|
73874
|
+
function mimeFolder(name) {
|
|
73875
|
+
const upper = name.toUpperCase();
|
|
73876
|
+
const namespaced = upper.match(/^\/([^/]+)\/([^/]+)$/);
|
|
73877
|
+
if (namespaced) {
|
|
73878
|
+
return "/SAP/BC/BSP/" + namespaced[1] + "/" + namespaced[2];
|
|
73879
|
+
}
|
|
73880
|
+
return "/SAP/BC/BSP/SAP/" + upper;
|
|
73881
|
+
}
|
|
73882
|
+
//# sourceMappingURL=rename_bsp_application.js.map
|
|
73883
|
+
|
|
73884
|
+
/***/ },
|
|
73885
|
+
|
|
73635
73886
|
/***/ "./node_modules/@abaplint/core/build/src/objects/rename/rename_data_element.js"
|
|
73636
73887
|
/*!*************************************************************************************!*\
|
|
73637
73888
|
!*** ./node_modules/@abaplint/core/build/src/objects/rename/rename_data_element.js ***!
|
|
@@ -73902,8 +74153,44 @@ exports.RenameGlobalInterface = RenameGlobalInterface;
|
|
|
73902
74153
|
|
|
73903
74154
|
"use strict";
|
|
73904
74155
|
|
|
74156
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
74157
|
+
if (k2 === undefined) k2 = k;
|
|
74158
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
74159
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
74160
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
74161
|
+
}
|
|
74162
|
+
Object.defineProperty(o, k2, desc);
|
|
74163
|
+
}) : (function(o, m, k, k2) {
|
|
74164
|
+
if (k2 === undefined) k2 = k;
|
|
74165
|
+
o[k2] = m[k];
|
|
74166
|
+
}));
|
|
74167
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
74168
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
74169
|
+
}) : function(o, v) {
|
|
74170
|
+
o["default"] = v;
|
|
74171
|
+
});
|
|
74172
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
74173
|
+
var ownKeys = function(o) {
|
|
74174
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
74175
|
+
var ar = [];
|
|
74176
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
74177
|
+
return ar;
|
|
74178
|
+
};
|
|
74179
|
+
return ownKeys(o);
|
|
74180
|
+
};
|
|
74181
|
+
return function (mod) {
|
|
74182
|
+
if (mod && mod.__esModule) return mod;
|
|
74183
|
+
var result = {};
|
|
74184
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
74185
|
+
__setModuleDefault(result, mod);
|
|
74186
|
+
return result;
|
|
74187
|
+
};
|
|
74188
|
+
})();
|
|
73905
74189
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
73906
74190
|
exports.RenameICFService = void 0;
|
|
74191
|
+
exports.namespacedURL = namespacedURL;
|
|
74192
|
+
const crypto = __importStar(__webpack_require__(/*! crypto */ "crypto"));
|
|
74193
|
+
const vscode_languageserver_types_1 = __webpack_require__(/*! vscode-languageserver-types */ "./node_modules/vscode-languageserver-types/lib/esm/main.js");
|
|
73907
74194
|
const __1 = __webpack_require__(/*! .. */ "./node_modules/@abaplint/core/build/src/objects/index.js");
|
|
73908
74195
|
const renamer_helper_1 = __webpack_require__(/*! ./renamer_helper */ "./node_modules/@abaplint/core/build/src/objects/rename/renamer_helper.js");
|
|
73909
74196
|
class RenameICFService {
|
|
@@ -73941,16 +74228,141 @@ class RenameICFService {
|
|
|
73941
74228
|
const cleanNewName = (_d = (_b = newName.match(/^[^ ]+/)) === null || _b === void 0 ? void 0 : _b[0]) !== null && _d !== void 0 ? _d : newName;
|
|
73942
74229
|
let changes = [];
|
|
73943
74230
|
const helper = new renamer_helper_1.RenamerHelper(this.reg);
|
|
73944
|
-
|
|
73945
|
-
|
|
73946
|
-
|
|
73947
|
-
|
|
74231
|
+
const namespaced = cleanNewName.match(/^\/([^/]+)\/([^/]+)$/);
|
|
74232
|
+
if (namespaced) {
|
|
74233
|
+
// ICF node names carry no slashes: "/NS/LEAF" is the node LEAF below a node NS
|
|
74234
|
+
const leaf = namespaced[2];
|
|
74235
|
+
if (leaf.length > ICF_NAME_LENGTH) {
|
|
74236
|
+
throw new Error("RenameICFService, " + leaf + " is longer than " + ICF_NAME_LENGTH + " characters");
|
|
74237
|
+
}
|
|
74238
|
+
const url = obj.getURL();
|
|
74239
|
+
const newURL = url === undefined ? undefined : namespacedURL(url, cleanOldName, namespaced[1], leaf);
|
|
74240
|
+
if (newURL !== undefined) {
|
|
74241
|
+
changes = changes.concat(this.buildURLEdit(obj, newURL));
|
|
74242
|
+
}
|
|
74243
|
+
changes = changes.concat(helper.buildXMLFileEdits(obj, "ICF_NAME", cleanOldName, leaf));
|
|
74244
|
+
changes = changes.concat(helper.buildXMLFileEdits(obj, "ORIG_NAME", cleanOldName, leaf, true));
|
|
74245
|
+
const files = newURL === undefined ? undefined : this.renameAbapGitFiles(obj, leaf, newURL);
|
|
74246
|
+
changes = changes.concat(files !== null && files !== void 0 ? files : helper.renameFiles(obj, cleanOldName, leaf));
|
|
74247
|
+
if (newURL !== undefined && files !== undefined) {
|
|
74248
|
+
changes = changes.concat(this.buildNamespaceNode(obj, namespaced[1], newURL));
|
|
74249
|
+
}
|
|
74250
|
+
}
|
|
74251
|
+
else {
|
|
74252
|
+
changes = changes.concat(helper.buildURLFileEdits(obj, cleanOldName, cleanNewName));
|
|
74253
|
+
changes = changes.concat(helper.buildXMLFileEdits(obj, "ICF_NAME", cleanOldName, cleanNewName));
|
|
74254
|
+
changes = changes.concat(helper.buildXMLFileEdits(obj, "ORIG_NAME", cleanOldName, cleanNewName, true));
|
|
74255
|
+
const url = obj.getURL();
|
|
74256
|
+
const files = url === undefined ? undefined :
|
|
74257
|
+
this.renameAbapGitFiles(obj, cleanNewName, url.replace(cleanOldName.toLowerCase(), cleanNewName.toLowerCase()));
|
|
74258
|
+
changes = changes.concat(files !== null && files !== void 0 ? files : helper.renameFiles(obj, oldName, fileNewName));
|
|
74259
|
+
}
|
|
73948
74260
|
return {
|
|
73949
74261
|
documentChanges: changes,
|
|
73950
74262
|
};
|
|
73951
74263
|
}
|
|
74264
|
+
buildURLEdit(obj, newURL) {
|
|
74265
|
+
const xml = obj.getXMLFile();
|
|
74266
|
+
if (xml === undefined) {
|
|
74267
|
+
return [];
|
|
74268
|
+
}
|
|
74269
|
+
const rows = xml.getRawRows();
|
|
74270
|
+
for (let i = 0; i < rows.length; i++) {
|
|
74271
|
+
const start = rows[i].indexOf("<URL>");
|
|
74272
|
+
const end = rows[i].indexOf("</URL>");
|
|
74273
|
+
if (start >= 0 && end > start) {
|
|
74274
|
+
const range = vscode_languageserver_types_1.Range.create(i, start + 5, i, end);
|
|
74275
|
+
return [vscode_languageserver_types_1.TextDocumentEdit.create({ uri: xml.getFilename(), version: 1 }, [vscode_languageserver_types_1.TextEdit.replace(range, newURL)])];
|
|
74276
|
+
}
|
|
74277
|
+
}
|
|
74278
|
+
return [];
|
|
74279
|
+
}
|
|
74280
|
+
/** The node of the namespace above the renamed one (/sap/bc/ns/ above /sap/bc/ns/leaf/). It does not exist
|
|
74281
|
+
* in a fresh system and abapGit does not create nodes in between, so it is added next to the renamed node,
|
|
74282
|
+
* unless the registry has a node with that URL already */
|
|
74283
|
+
buildNamespaceNode(obj, namespace, newURL) {
|
|
74284
|
+
var _a;
|
|
74285
|
+
const parentURL = newURL.replace(/[^/]+\/?$/, "");
|
|
74286
|
+
for (const o of this.reg.getObjects()) {
|
|
74287
|
+
if (o instanceof __1.ICFService && ((_a = o.getURL()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === parentURL.toLowerCase()) {
|
|
74288
|
+
return [];
|
|
74289
|
+
}
|
|
74290
|
+
}
|
|
74291
|
+
const xml = obj.getXMLFile();
|
|
74292
|
+
if (xml === undefined) {
|
|
74293
|
+
return [];
|
|
74294
|
+
}
|
|
74295
|
+
const filename = xml.getFilename();
|
|
74296
|
+
const slash = Math.max(filename.lastIndexOf("/"), filename.lastIndexOf("\\"));
|
|
74297
|
+
const name = namespace.toLowerCase();
|
|
74298
|
+
const hash = crypto.createHash("sha1").update(parentURL).digest("hex").substring(0, ICF_HASH_LENGTH);
|
|
74299
|
+
const uri = filename.substring(0, slash + 1) + name.padEnd(ICF_NAME_LENGTH, " ") + hash + ".sicf.xml";
|
|
74300
|
+
// abapGit writes every XML file with a UTF-8 byte order mark, xml_bom checks it
|
|
74301
|
+
const content = `\ufeff<?xml version="1.0" encoding="utf-8"?>
|
|
74302
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_SICF" serializer_version="v1.0.0">
|
|
74303
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
74304
|
+
<asx:values>
|
|
74305
|
+
<URL>${parentURL}</URL>
|
|
74306
|
+
<ICFSERVICE>
|
|
74307
|
+
<ICF_NAME>${name.toUpperCase()}</ICF_NAME>
|
|
74308
|
+
<ORIG_NAME>${name}</ORIG_NAME>
|
|
74309
|
+
</ICFSERVICE>
|
|
74310
|
+
<ICFDOCU>
|
|
74311
|
+
<ICF_NAME>${name.toUpperCase()}</ICF_NAME>
|
|
74312
|
+
<ICF_LANGU>E</ICF_LANGU>
|
|
74313
|
+
<ICF_DOCU>Namespace ${name}</ICF_DOCU>
|
|
74314
|
+
</ICFDOCU>
|
|
74315
|
+
</asx:values>
|
|
74316
|
+
</asx:abap>
|
|
74317
|
+
</abapGit>
|
|
74318
|
+
`;
|
|
74319
|
+
return [
|
|
74320
|
+
vscode_languageserver_types_1.CreateFile.create(uri),
|
|
74321
|
+
vscode_languageserver_types_1.TextDocumentEdit.create({ uri, version: 1 }, [vscode_languageserver_types_1.TextEdit.insert({ line: 0, character: 0 }, content)]),
|
|
74322
|
+
];
|
|
74323
|
+
}
|
|
74324
|
+
/** abapGit names a SICF file "<ICF_NAME, lower case, padded to 15><first 25 hex chars of SHA1(URL)>.sicf.xml",
|
|
74325
|
+
* the URL is the one in the XML. Both parts change with the name, keeping the old ones gives an object name
|
|
74326
|
+
* abapGit does not derive from the node. Returns undefined if the files are not in this layout */
|
|
74327
|
+
renameAbapGitFiles(obj, newName, newURL) {
|
|
74328
|
+
if (newName.length > ICF_NAME_LENGTH) {
|
|
74329
|
+
return undefined;
|
|
74330
|
+
}
|
|
74331
|
+
const hash = crypto.createHash("sha1").update(newURL).digest("hex").substring(0, ICF_HASH_LENGTH);
|
|
74332
|
+
const stem = newName.toLowerCase().padEnd(ICF_NAME_LENGTH, " ") + hash;
|
|
74333
|
+
const list = [];
|
|
74334
|
+
for (const f of obj.getFiles()) {
|
|
74335
|
+
const filename = f.getFilename();
|
|
74336
|
+
const slash = Math.max(filename.lastIndexOf("/"), filename.lastIndexOf("\\"));
|
|
74337
|
+
const base = filename.substring(slash + 1);
|
|
74338
|
+
const match = base.match(/^[^ ]+ +[0-9a-f]{25}(\..+)$/i);
|
|
74339
|
+
if (match === null) {
|
|
74340
|
+
return undefined;
|
|
74341
|
+
}
|
|
74342
|
+
list.push(vscode_languageserver_types_1.RenameFile.create(filename, filename.substring(0, slash + 1) + stem + match[1]));
|
|
74343
|
+
}
|
|
74344
|
+
return list;
|
|
74345
|
+
}
|
|
73952
74346
|
}
|
|
73953
74347
|
exports.RenameICFService = RenameICFService;
|
|
74348
|
+
const ICF_NAME_LENGTH = 15;
|
|
74349
|
+
const ICF_HASH_LENGTH = 25;
|
|
74350
|
+
/** The URL of the node moved into a namespace. The node is the last segment of the URL. Below
|
|
74351
|
+
* /sap/bc/bsp/ and /sap/bc/ui5_ui5/ an SAP name sits below a node "sap", and a namespaced one
|
|
74352
|
+
* below the namespace instead: /sap/bc/bsp/sap/old/ -> /sap/bc/bsp/ns/leaf/. Elsewhere the
|
|
74353
|
+
* namespace node is added: /sap/bc/old/ -> /sap/bc/ns/leaf/ */
|
|
74354
|
+
function namespacedURL(url, oldName, namespace, leaf) {
|
|
74355
|
+
const segments = url.split("/");
|
|
74356
|
+
const last = segments.length - (url.endsWith("/") ? 2 : 1);
|
|
74357
|
+
if (last < 1 || segments[last].toLowerCase() !== oldName.toLowerCase()) {
|
|
74358
|
+
return undefined;
|
|
74359
|
+
}
|
|
74360
|
+
const before = segments.slice(0, last).join("/").toLowerCase();
|
|
74361
|
+
const replaceSap = before.endsWith("/sap/bc/bsp/sap") || before.endsWith("/sap/bc/ui5_ui5/sap");
|
|
74362
|
+
const start = replaceSap ? last - 1 : last;
|
|
74363
|
+
segments.splice(start, last - start + 1, namespace.toLowerCase(), leaf.toLowerCase());
|
|
74364
|
+
return segments.join("/");
|
|
74365
|
+
}
|
|
73954
74366
|
//# sourceMappingURL=rename_icf_service.js.map
|
|
73955
74367
|
|
|
73956
74368
|
/***/ },
|
|
@@ -74190,6 +74602,79 @@ exports.RenameTableType = RenameTableType;
|
|
|
74190
74602
|
|
|
74191
74603
|
/***/ },
|
|
74192
74604
|
|
|
74605
|
+
/***/ "./node_modules/@abaplint/core/build/src/objects/rename/rename_urls.js"
|
|
74606
|
+
/*!*****************************************************************************!*\
|
|
74607
|
+
!*** ./node_modules/@abaplint/core/build/src/objects/rename/rename_urls.js ***!
|
|
74608
|
+
\*****************************************************************************/
|
|
74609
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
74610
|
+
|
|
74611
|
+
"use strict";
|
|
74612
|
+
|
|
74613
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
74614
|
+
exports.RenameURLs = void 0;
|
|
74615
|
+
const vscode_languageserver_types_1 = __webpack_require__(/*! vscode-languageserver-types */ "./node_modules/vscode-languageserver-types/lib/esm/main.js");
|
|
74616
|
+
const bsp_application_1 = __webpack_require__(/*! ../bsp_application */ "./node_modules/@abaplint/core/build/src/objects/bsp_application.js");
|
|
74617
|
+
/** Renames the URLs of renamed ICF nodes in the pages of the BSP applications, eg. a data source
|
|
74618
|
+
* in a manifest.json, "/sap/bc/zfoo" -> "/sap/bc/ns/foo". A BSP refers to an ICF node by its URL,
|
|
74619
|
+
* which no reference of the renamer knows. A URL is matched as a whole path, without its trailing
|
|
74620
|
+
* "/" and in any case: "/sap/bc/zfoo", "/sap/bc/zfoo/" and "/sap/bc/zfoo?x=1", not "/sap/bc/zfoo_bar".
|
|
74621
|
+
* The XML of the application, its attributes and the list of its pages, is not changed */
|
|
74622
|
+
class RenameURLs {
|
|
74623
|
+
constructor(reg) {
|
|
74624
|
+
this.reg = reg;
|
|
74625
|
+
}
|
|
74626
|
+
buildEdits(urls) {
|
|
74627
|
+
var _a;
|
|
74628
|
+
const documentChanges = [];
|
|
74629
|
+
const map = new Map();
|
|
74630
|
+
for (const u of urls) {
|
|
74631
|
+
const oldPath = withoutSlash(u.oldURL).toLowerCase();
|
|
74632
|
+
if (oldPath !== "") {
|
|
74633
|
+
map.set(oldPath, withoutSlash(u.newURL).toLowerCase());
|
|
74634
|
+
}
|
|
74635
|
+
}
|
|
74636
|
+
if (map.size === 0) {
|
|
74637
|
+
return { documentChanges };
|
|
74638
|
+
}
|
|
74639
|
+
// longest first, one pass: a replaced URL is not matched again
|
|
74640
|
+
const alternatives = Array.from(map.keys()).sort((a, b) => b.length - a.length).map(escape);
|
|
74641
|
+
const regex = new RegExp("(" + alternatives.join("|") + ")(?![A-Za-z0-9_-])", "gi");
|
|
74642
|
+
for (const obj of this.reg.getObjectsByType("WAPA")) {
|
|
74643
|
+
if (!(obj instanceof bsp_application_1.BSPApplication) || this.reg.isDependency(obj)) {
|
|
74644
|
+
continue;
|
|
74645
|
+
}
|
|
74646
|
+
const descriptor = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename();
|
|
74647
|
+
for (const file of obj.getFiles()) {
|
|
74648
|
+
if (file.getFilename() === descriptor) {
|
|
74649
|
+
continue;
|
|
74650
|
+
}
|
|
74651
|
+
const edits = [];
|
|
74652
|
+
const rows = file.getRawRows();
|
|
74653
|
+
for (let i = 0; i < rows.length; i++) {
|
|
74654
|
+
const replaced = rows[i].replace(regex, found => { var _a; return (_a = map.get(found.toLowerCase())) !== null && _a !== void 0 ? _a : found; });
|
|
74655
|
+
if (replaced !== rows[i]) {
|
|
74656
|
+
edits.push(vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(i, 0, i, rows[i].length), replaced));
|
|
74657
|
+
}
|
|
74658
|
+
}
|
|
74659
|
+
if (edits.length > 0) {
|
|
74660
|
+
documentChanges.push(vscode_languageserver_types_1.TextDocumentEdit.create({ uri: file.getFilename(), version: 1 }, edits));
|
|
74661
|
+
}
|
|
74662
|
+
}
|
|
74663
|
+
}
|
|
74664
|
+
return { documentChanges };
|
|
74665
|
+
}
|
|
74666
|
+
}
|
|
74667
|
+
exports.RenameURLs = RenameURLs;
|
|
74668
|
+
function withoutSlash(url) {
|
|
74669
|
+
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
74670
|
+
}
|
|
74671
|
+
function escape(s) {
|
|
74672
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
74673
|
+
}
|
|
74674
|
+
//# sourceMappingURL=rename_urls.js.map
|
|
74675
|
+
|
|
74676
|
+
/***/ },
|
|
74677
|
+
|
|
74193
74678
|
/***/ "./node_modules/@abaplint/core/build/src/objects/rename/renamer.js"
|
|
74194
74679
|
/*!*************************************************************************!*\
|
|
74195
74680
|
!*** ./node_modules/@abaplint/core/build/src/objects/rename/renamer.js ***!
|
|
@@ -74211,13 +74696,18 @@ const rename_table_1 = __webpack_require__(/*! ./rename_table */ "./node_modules
|
|
|
74211
74696
|
const rename_table_type_1 = __webpack_require__(/*! ./rename_table_type */ "./node_modules/@abaplint/core/build/src/objects/rename/rename_table_type.js");
|
|
74212
74697
|
const rename_message_class_1 = __webpack_require__(/*! ./rename_message_class */ "./node_modules/@abaplint/core/build/src/objects/rename/rename_message_class.js");
|
|
74213
74698
|
const rename_icf_service_1 = __webpack_require__(/*! ./rename_icf_service */ "./node_modules/@abaplint/core/build/src/objects/rename/rename_icf_service.js");
|
|
74699
|
+
const rename_urls_1 = __webpack_require__(/*! ./rename_urls */ "./node_modules/@abaplint/core/build/src/objects/rename/rename_urls.js");
|
|
74700
|
+
const icf_service_1 = __webpack_require__(/*! ../icf_service */ "./node_modules/@abaplint/core/build/src/objects/icf_service.js");
|
|
74701
|
+
const rename_bsp_application_1 = __webpack_require__(/*! ./rename_bsp_application */ "./node_modules/@abaplint/core/build/src/objects/rename/rename_bsp_application.js");
|
|
74214
74702
|
class Renamer {
|
|
74215
74703
|
constructor(reg) {
|
|
74704
|
+
this.renamedURLs = [];
|
|
74216
74705
|
this.reg = reg;
|
|
74217
74706
|
}
|
|
74218
74707
|
/** Applies the renaming to the objects and files in the registry,
|
|
74219
74708
|
* after renaming the registry is not parsed */
|
|
74220
74709
|
rename(type, oldName, newName) {
|
|
74710
|
+
var _a;
|
|
74221
74711
|
const edits = this.buildEdits(type, oldName, newName);
|
|
74222
74712
|
if (edits === undefined) {
|
|
74223
74713
|
throw new Error("no changes could be determined");
|
|
@@ -74225,17 +74715,28 @@ class Renamer {
|
|
|
74225
74715
|
else if (edits.changes) {
|
|
74226
74716
|
throw new Error("only documentChanges expected");
|
|
74227
74717
|
}
|
|
74718
|
+
const before = type === "SICF" ? this.findObject(type, oldName) : undefined;
|
|
74719
|
+
const oldURL = before instanceof icf_service_1.ICFService ? before.getURL() : undefined;
|
|
74720
|
+
const oldXML = (_a = before === null || before === void 0 ? void 0 : before.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename();
|
|
74228
74721
|
const result = this.apply(edits);
|
|
74229
74722
|
this.reg.findIssues(); // hmm, this builds the ddic references
|
|
74723
|
+
if (oldURL !== undefined && oldXML !== undefined) {
|
|
74724
|
+
this.rememberURL(edits, oldURL, oldXML);
|
|
74725
|
+
}
|
|
74726
|
+
return result;
|
|
74727
|
+
}
|
|
74728
|
+
/** Renames the old URLs of the ICF nodes renamed by this renamer in the pages of the BSP
|
|
74729
|
+
* applications, see RenameURLs */
|
|
74730
|
+
renameURLs() {
|
|
74731
|
+
this.reg.parse();
|
|
74732
|
+
const result = this.apply(new rename_urls_1.RenameURLs(this.reg).buildEdits(this.renamedURLs));
|
|
74733
|
+
this.reg.parse();
|
|
74230
74734
|
return result;
|
|
74231
74735
|
}
|
|
74232
74736
|
/** Builds edits, but does not apply to registry, used by LSP */
|
|
74233
74737
|
buildEdits(type, oldName, newName) {
|
|
74234
74738
|
this.reg.parse(); // the registry must be parsed to dermine references
|
|
74235
|
-
|
|
74236
|
-
if (obj === undefined && type === "SICF") {
|
|
74237
|
-
obj = Array.from(this.reg.getObjects()).find(o => o.getType() === "SICF" && o.getName().toUpperCase().startsWith(oldName.toUpperCase() + " "));
|
|
74238
|
-
}
|
|
74739
|
+
const obj = this.findObject(type, oldName);
|
|
74239
74740
|
if (obj === undefined) {
|
|
74240
74741
|
throw new Error("rename, object not found");
|
|
74241
74742
|
}
|
|
@@ -74247,6 +74748,25 @@ class Renamer {
|
|
|
74247
74748
|
return r.buildEdits(obj, oldName.toUpperCase(), newName);
|
|
74248
74749
|
}
|
|
74249
74750
|
//////////////////
|
|
74751
|
+
findObject(type, name) {
|
|
74752
|
+
let obj = this.reg.getObject(type, name);
|
|
74753
|
+
if (obj === undefined && type === "SICF") {
|
|
74754
|
+
obj = Array.from(this.reg.getObjects()).find(o => o.getType() === "SICF" && o.getName().toUpperCase().startsWith(name.toUpperCase() + " "));
|
|
74755
|
+
}
|
|
74756
|
+
return obj;
|
|
74757
|
+
}
|
|
74758
|
+
/** the new URL is the one in the XML file the old XML file was renamed to */
|
|
74759
|
+
rememberURL(edits, oldURL, oldXML) {
|
|
74760
|
+
var _a, _b;
|
|
74761
|
+
for (const dc of edits.documentChanges || []) {
|
|
74762
|
+
if (vscode_languageserver_types_1.RenameFile.is(dc) && dc.oldUri === oldXML) {
|
|
74763
|
+
const newURL = (_b = (_a = this.reg.getFileByName(dc.newUri)) === null || _a === void 0 ? void 0 : _a.getRaw().match(/<URL>([^<]*)<\/URL>/)) === null || _b === void 0 ? void 0 : _b[1];
|
|
74764
|
+
if (newURL !== undefined && newURL.toLowerCase() !== oldURL.toLowerCase()) {
|
|
74765
|
+
this.renamedURLs.push({ oldURL, newURL });
|
|
74766
|
+
}
|
|
74767
|
+
}
|
|
74768
|
+
}
|
|
74769
|
+
}
|
|
74250
74770
|
factory(type) {
|
|
74251
74771
|
switch (type) {
|
|
74252
74772
|
case "CLAS":
|
|
@@ -74267,6 +74787,8 @@ class Renamer {
|
|
|
74267
74787
|
return new rename_message_class_1.RenameMessageClass(this.reg);
|
|
74268
74788
|
case "SICF":
|
|
74269
74789
|
return new rename_icf_service_1.RenameICFService(this.reg);
|
|
74790
|
+
case "WAPA":
|
|
74791
|
+
return new rename_bsp_application_1.RenameBSPApplication(this.reg);
|
|
74270
74792
|
default:
|
|
74271
74793
|
throw new Error("Renaming of " + type + " not yet supported");
|
|
74272
74794
|
}
|
|
@@ -74278,11 +74800,21 @@ class Renamer {
|
|
|
74278
74800
|
deletedFiles: new Set(),
|
|
74279
74801
|
updatedFiles: new Set(),
|
|
74280
74802
|
};
|
|
74281
|
-
// assumption: only renames or text changes, no deletes
|
|
74803
|
+
// assumption: only renames, creates or text changes, no deletes. A created file starts empty,
|
|
74804
|
+
// its content is a text edit after the create
|
|
74282
74805
|
for (const dc of edits.documentChanges || []) {
|
|
74283
74806
|
if (vscode_languageserver_types_1.TextDocumentEdit.is(dc)) {
|
|
74284
74807
|
this.applyEdit(dc);
|
|
74285
|
-
result.
|
|
74808
|
+
if (result.addedFiles.has(dc.textDocument.uri) === false) {
|
|
74809
|
+
result.updatedFiles.add(dc.textDocument.uri);
|
|
74810
|
+
}
|
|
74811
|
+
}
|
|
74812
|
+
else if (vscode_languageserver_types_1.CreateFile.is(dc)) {
|
|
74813
|
+
if (this.reg.getFileByName(dc.uri) !== undefined) {
|
|
74814
|
+
throw new Error("apply, file " + dc.uri + " already exists");
|
|
74815
|
+
}
|
|
74816
|
+
this.reg.addFile(new memory_file_1.MemoryFile(dc.uri, ""));
|
|
74817
|
+
result.addedFiles.add(dc.uri);
|
|
74286
74818
|
}
|
|
74287
74819
|
else if (vscode_languageserver_types_1.RenameFile.is(dc)) {
|
|
74288
74820
|
renames.push(dc);
|
|
@@ -76916,7 +77448,7 @@ class Registry {
|
|
|
76916
77448
|
}
|
|
76917
77449
|
static abaplintVersion() {
|
|
76918
77450
|
// magic, see build script "version.js"
|
|
76919
|
-
return "2.120.
|
|
77451
|
+
return "2.120.121";
|
|
76920
77452
|
}
|
|
76921
77453
|
getDDICReferences() {
|
|
76922
77454
|
return this.ddicReferences;
|
|
@@ -77532,6 +78064,7 @@ const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "./n
|
|
|
77532
78064
|
const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/syntax.js");
|
|
77533
78065
|
const raw_rows_cache_1 = __webpack_require__(/*! ../files/raw_rows_cache */ "./node_modules/@abaplint/core/build/src/files/raw_rows_cache.js");
|
|
77534
78066
|
const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
78067
|
+
const _key_compare_1 = __webpack_require__(/*! ../abap/5_syntax/_key_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_key_compare.js");
|
|
77535
78068
|
const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
|
|
77536
78069
|
const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
|
|
77537
78070
|
const class_definition_1 = __webpack_require__(/*! ../abap/types/class_definition */ "./node_modules/@abaplint/core/build/src/abap/types/class_definition.js");
|
|
@@ -78369,12 +78902,8 @@ function simplePredicate(statement) {
|
|
|
78369
78902
|
return undefined;
|
|
78370
78903
|
}
|
|
78371
78904
|
const children = compare.getChildren();
|
|
78372
|
-
|
|
78373
|
-
|
|
78374
|
-
if (children[0] instanceof nodes_1.TokenNode && children[0].getFirstToken().getStr().toUpperCase() === "NOT") {
|
|
78375
|
-
negated = true;
|
|
78376
|
-
i = 1;
|
|
78377
|
-
}
|
|
78905
|
+
const i = (0, _key_compare_1.countLeadingNot)(compare);
|
|
78906
|
+
const negated = i % 2 === 1;
|
|
78378
78907
|
const left = children[i];
|
|
78379
78908
|
if (!(left instanceof nodes_1.ExpressionNode) || !(left.get() instanceof Expressions.Source)) {
|
|
78380
78909
|
return undefined;
|
|
@@ -82823,6 +83352,8 @@ const RESERVED_ELEMENT_NAMES = ["BEGIN", "NUMBER", "POSITION", "ZONE", "HANDLER"
|
|
|
82823
83352
|
const MAX_LABEL_LENGTH = 40;
|
|
82824
83353
|
// Annotations which are not supported in CDS view entities
|
|
82825
83354
|
const VIEW_ENTITY_FORBIDDEN_ANNOTATIONS = ["Semantics.unitOfMeasure", "Semantics.currencyCode"];
|
|
83355
|
+
// Select list elements which are expressions, ie. not plain fields
|
|
83356
|
+
const CALCULATED_ELEMENT = [expressions_1.CDSCast, expressions_1.CDSCase, expressions_1.CDSArithmetics, expressions_1.CDSArithParen, expressions_1.CDSFunction, expressions_1.CDSAggregate, expressions_1.CDSString, expressions_1.CDSInteger];
|
|
82826
83357
|
class CDSCheckSyntax {
|
|
82827
83358
|
constructor() {
|
|
82828
83359
|
this.conf = new CDSCheckSyntaxConf();
|
|
@@ -82834,7 +83365,9 @@ class CDSCheckSyntax {
|
|
|
82834
83365
|
shortDescription: "Checks CDS source, field, type, and semantic annotation references",
|
|
82835
83366
|
extendedInformation: `Performs semantic checks which require other DDIC objects to be available.
|
|
82836
83367
|
|
|
82837
|
-
Missing objects are only reported when their names match the configured errorNamespace
|
|
83368
|
+
Missing objects are only reported when their names match the configured errorNamespace.
|
|
83369
|
+
|
|
83370
|
+
SOURCE_TYPE in the abapGit XML is checked to match the DDL source, W view entity, P projection view, V DDIC-based view.`,
|
|
82838
83371
|
tags: [_irule_1.RuleTag.Syntax],
|
|
82839
83372
|
};
|
|
82840
83373
|
}
|
|
@@ -82846,6 +83379,7 @@ Missing objects are only reported when their names match the configured errorNam
|
|
|
82846
83379
|
}
|
|
82847
83380
|
initialize(reg) {
|
|
82848
83381
|
this.reg = reg;
|
|
83382
|
+
this.businessObjectTargets = undefined;
|
|
82849
83383
|
return this;
|
|
82850
83384
|
}
|
|
82851
83385
|
run(object) {
|
|
@@ -82862,13 +83396,17 @@ Missing objects are only reported when their names match the configured errorNam
|
|
|
82862
83396
|
const sources = this.findSources(tree, ddic, issues, file);
|
|
82863
83397
|
this.checkRelations(tree, ddic, issues, file);
|
|
82864
83398
|
this.checkTypes(tree, ddic, issues, file);
|
|
82865
|
-
this.checkRootProjection(tree, ddic, issues, file)
|
|
83399
|
+
if (this.checkRootProjection(tree, ddic, issues, file) === false) {
|
|
83400
|
+
this.checkTransactionalProjection(tree, ddic, issues, file);
|
|
83401
|
+
}
|
|
83402
|
+
this.checkCalculatedAssociationPaths(tree, issues, file);
|
|
82866
83403
|
this.checkFieldAnnotations(tree, ddic, issues, file);
|
|
82867
83404
|
this.checkLabels(tree, issues, file);
|
|
82868
83405
|
this.checkViewEntityAnnotations(tree, issues, file);
|
|
82869
83406
|
this.checkSearchable(tree, issues, file);
|
|
82870
83407
|
this.checkReservedNames(tree, issues, file);
|
|
82871
83408
|
this.checkFields(tree, sources, object, issues, file);
|
|
83409
|
+
this.checkSourceType(tree, object, issues);
|
|
82872
83410
|
return issues;
|
|
82873
83411
|
}
|
|
82874
83412
|
findSources(tree, ddic, issues, file) {
|
|
@@ -82923,17 +83461,18 @@ Missing objects are only reported when their names match the configured errorNam
|
|
|
82923
83461
|
}
|
|
82924
83462
|
}
|
|
82925
83463
|
}
|
|
83464
|
+
/** returns true if an issue was reported */
|
|
82926
83465
|
checkRootProjection(tree, ddic, issues, file) {
|
|
82927
83466
|
var _a;
|
|
82928
83467
|
const projection = tree.findFirstExpression(expressions_1.CDSDefineProjection);
|
|
82929
83468
|
const rootToken = projection === null || projection === void 0 ? void 0 : projection.findDirectTokenByText("ROOT");
|
|
82930
83469
|
if (projection === undefined || rootToken === undefined) {
|
|
82931
|
-
return;
|
|
83470
|
+
return false;
|
|
82932
83471
|
}
|
|
82933
83472
|
const names = projection.findDirectExpressions(expressions_1.CDSName);
|
|
82934
83473
|
const projectedEntityNode = names[1];
|
|
82935
83474
|
if (projectedEntityNode === undefined) {
|
|
82936
|
-
return;
|
|
83475
|
+
return false;
|
|
82937
83476
|
}
|
|
82938
83477
|
const projectedEntityName = this.name(projectedEntityNode);
|
|
82939
83478
|
const projectedEntity = ddic.lookupTableOrView(projectedEntityName).object;
|
|
@@ -82941,7 +83480,161 @@ Missing objects are only reported when their names match the configured errorNam
|
|
|
82941
83480
|
&& ((_a = projectedEntity.getTree()) === null || _a === void 0 ? void 0 : _a.findDirectTokenByText("ROOT")) === undefined) {
|
|
82942
83481
|
const message = `ROOT keyword not valid since ${projectedEntityName} is not a root property`;
|
|
82943
83482
|
issues.push(issue_1.Issue.atToken(file, rootToken, message, this.getMetadata().key, this.conf.severity));
|
|
83483
|
+
return true;
|
|
83484
|
+
}
|
|
83485
|
+
return false;
|
|
83486
|
+
}
|
|
83487
|
+
/** a transactional projection(no provider contract or TRANSACTIONAL_QUERY) requires a business object entity */
|
|
83488
|
+
checkTransactionalProjection(tree, ddic, issues, file) {
|
|
83489
|
+
const projection = tree.findFirstExpression(expressions_1.CDSDefineProjection);
|
|
83490
|
+
if (projection === undefined || projection.findDirectTokenByText("TRANSIENT") !== undefined) {
|
|
83491
|
+
return;
|
|
83492
|
+
}
|
|
83493
|
+
const contract = projection.findDirectExpression(expressions_1.CDSProviderContract);
|
|
83494
|
+
if (contract !== undefined && contract.findDirectTokenByText("TRANSACTIONAL_QUERY") === undefined) {
|
|
83495
|
+
return;
|
|
82944
83496
|
}
|
|
83497
|
+
const projectedEntityNode = projection.findDirectExpressions(expressions_1.CDSName)[1];
|
|
83498
|
+
if (projectedEntityNode === undefined) {
|
|
83499
|
+
return;
|
|
83500
|
+
}
|
|
83501
|
+
const projectedEntityName = this.name(projectedEntityNode);
|
|
83502
|
+
const projectedEntity = ddic.lookupTableOrView(projectedEntityName).object;
|
|
83503
|
+
if (!(projectedEntity instanceof objects_1.DataDefinition)) {
|
|
83504
|
+
return;
|
|
83505
|
+
}
|
|
83506
|
+
const projectedTree = projectedEntity.getTree();
|
|
83507
|
+
// only plain select based views are checked, ie. not projections, abstract or custom entities
|
|
83508
|
+
if (projectedTree === undefined || !(projectedTree.get() instanceof expressions_1.CDSDefineView)) {
|
|
83509
|
+
return;
|
|
83510
|
+
}
|
|
83511
|
+
if (projectedTree.findDirectTokenByText("ROOT") !== undefined
|
|
83512
|
+
|| projectedTree.findAllExpressionsRecursive(expressions_1.CDSComposition).length > 0
|
|
83513
|
+
|| projectedTree.findAllExpressionsRecursive(expressions_1.CDSAssociation).some(a => a.findDirectTokenByText("PARENT") !== undefined)) {
|
|
83514
|
+
return;
|
|
83515
|
+
}
|
|
83516
|
+
const candidates = [projectedEntityName.toUpperCase(), projectedEntity.getName().toUpperCase()];
|
|
83517
|
+
const definitionName = projectedEntity.getDefinitionName();
|
|
83518
|
+
if (definitionName !== undefined) {
|
|
83519
|
+
candidates.push(definitionName.toUpperCase());
|
|
83520
|
+
}
|
|
83521
|
+
const targets = this.findBusinessObjectTargets();
|
|
83522
|
+
if (candidates.some(c => targets.has(c))) {
|
|
83523
|
+
return;
|
|
83524
|
+
}
|
|
83525
|
+
const message = `Transactional projection on ${projectedEntityName} not possible, ` +
|
|
83526
|
+
`${projectedEntityName} is not a root entity or part of a composition`;
|
|
83527
|
+
issues.push(issue_1.Issue.atToken(file, projectedEntityNode.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
|
|
83528
|
+
}
|
|
83529
|
+
/** names of entities targeted by a composition or an association to parent in any DDLS in the registry */
|
|
83530
|
+
findBusinessObjectTargets() {
|
|
83531
|
+
if (this.businessObjectTargets !== undefined) {
|
|
83532
|
+
return this.businessObjectTargets;
|
|
83533
|
+
}
|
|
83534
|
+
const targets = new Set();
|
|
83535
|
+
for (const obj of this.reg.getObjectsByType("DDLS")) {
|
|
83536
|
+
const tree = obj.getTree();
|
|
83537
|
+
if (tree === undefined) {
|
|
83538
|
+
continue;
|
|
83539
|
+
}
|
|
83540
|
+
const relations = [];
|
|
83541
|
+
for (const composition of tree.findAllExpressionsRecursive(expressions_1.CDSComposition)) {
|
|
83542
|
+
const relation = composition.findDirectExpression(expressions_1.CDSRelation);
|
|
83543
|
+
if (relation) {
|
|
83544
|
+
relations.push(relation);
|
|
83545
|
+
}
|
|
83546
|
+
}
|
|
83547
|
+
for (const association of tree.findAllExpressionsRecursive(expressions_1.CDSAssociation)) {
|
|
83548
|
+
const relation = association.findDirectExpression(expressions_1.CDSRelation);
|
|
83549
|
+
if (relation && association.findDirectTokenByText("PARENT") !== undefined) {
|
|
83550
|
+
relations.push(relation);
|
|
83551
|
+
}
|
|
83552
|
+
}
|
|
83553
|
+
for (const relation of relations) {
|
|
83554
|
+
const name = relation.getDirectTokens().map(t => t.getStr()).join("");
|
|
83555
|
+
if (name !== "") {
|
|
83556
|
+
targets.add(name.toUpperCase());
|
|
83557
|
+
}
|
|
83558
|
+
}
|
|
83559
|
+
}
|
|
83560
|
+
this.businessObjectTargets = targets;
|
|
83561
|
+
return targets;
|
|
83562
|
+
}
|
|
83563
|
+
/** path expressions are not possible via an association whose ON condition uses a calculated element */
|
|
83564
|
+
checkCalculatedAssociationPaths(tree, issues, file) {
|
|
83565
|
+
var _a, _b;
|
|
83566
|
+
for (const select of tree.findAllExpressionsRecursive(expressions_1.CDSSelect)) {
|
|
83567
|
+
const elements = select.findDirectExpressions(expressions_1.CDSElement);
|
|
83568
|
+
const calculated = new Map();
|
|
83569
|
+
for (const element of elements) {
|
|
83570
|
+
const name = (_a = element.findDirectExpression(expressions_1.CDSAs)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(expressions_1.CDSName);
|
|
83571
|
+
if (name !== undefined && element.findDirectExpressionsMulti(CALCULATED_ELEMENT).length > 0) {
|
|
83572
|
+
calculated.set(this.name(name).toUpperCase(), this.name(name));
|
|
83573
|
+
}
|
|
83574
|
+
}
|
|
83575
|
+
if (calculated.size === 0) {
|
|
83576
|
+
continue;
|
|
83577
|
+
}
|
|
83578
|
+
const marked = new Map();
|
|
83579
|
+
for (const association of select.findDirectExpressions(expressions_1.CDSAssociation)) {
|
|
83580
|
+
const relation = association.findDirectExpression(expressions_1.CDSRelation);
|
|
83581
|
+
const condition = association.findDirectExpression(expressions_1.CDSCondition);
|
|
83582
|
+
if (relation === undefined || condition === undefined) {
|
|
83583
|
+
continue;
|
|
83584
|
+
}
|
|
83585
|
+
const aliasNode = (_b = relation.findDirectExpression(expressions_1.CDSAs)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(expressions_1.CDSName);
|
|
83586
|
+
const alias = aliasNode ? this.name(aliasNode) : relation.getDirectTokens().map(t => t.getStr()).join("");
|
|
83587
|
+
for (const prefixed of condition.findAllExpressionsRecursive(expressions_1.CDSPrefixedName)) {
|
|
83588
|
+
const names = prefixed.findDirectExpressions(expressions_1.CDSName);
|
|
83589
|
+
if (names.length !== 2 || this.name(names[0]).toUpperCase() !== "$PROJECTION") {
|
|
83590
|
+
continue;
|
|
83591
|
+
}
|
|
83592
|
+
const element = calculated.get(this.name(names[1]).toUpperCase());
|
|
83593
|
+
if (element !== undefined && marked.has(alias.toUpperCase()) === false) {
|
|
83594
|
+
marked.set(alias.toUpperCase(), element);
|
|
83595
|
+
}
|
|
83596
|
+
}
|
|
83597
|
+
}
|
|
83598
|
+
if (marked.size === 0) {
|
|
83599
|
+
continue;
|
|
83600
|
+
}
|
|
83601
|
+
const usages = [...elements];
|
|
83602
|
+
for (const clause of select.findDirectExpressionsMulti([expressions_1.CDSWhere, expressions_1.CDSGroupBy, expressions_1.CDSHaving])) {
|
|
83603
|
+
usages.push(clause);
|
|
83604
|
+
}
|
|
83605
|
+
for (const usage of usages) {
|
|
83606
|
+
for (const prefixed of this.findPrefixedNames(usage)) {
|
|
83607
|
+
const names = prefixed.findDirectExpressions(expressions_1.CDSName);
|
|
83608
|
+
if (names.length < 2) {
|
|
83609
|
+
continue;
|
|
83610
|
+
}
|
|
83611
|
+
const alias = this.name(names[0]);
|
|
83612
|
+
const element = marked.get(alias.toUpperCase());
|
|
83613
|
+
if (element === undefined) {
|
|
83614
|
+
continue;
|
|
83615
|
+
}
|
|
83616
|
+
const message = `Path expression via ${alias} not possible, ` +
|
|
83617
|
+
`its ON condition uses calculated element ${element}`;
|
|
83618
|
+
issues.push(issue_1.Issue.atToken(file, names[0].getFirstToken(), message, this.getMetadata().key, this.conf.severity));
|
|
83619
|
+
}
|
|
83620
|
+
}
|
|
83621
|
+
}
|
|
83622
|
+
}
|
|
83623
|
+
/** outermost prefixed names, skipping annotations */
|
|
83624
|
+
findPrefixedNames(node) {
|
|
83625
|
+
const ret = [];
|
|
83626
|
+
for (const child of node.getChildren()) {
|
|
83627
|
+
if (!(child instanceof nodes_1.ExpressionNode) || child.get() instanceof expressions_1.CDSAnnotation) {
|
|
83628
|
+
continue;
|
|
83629
|
+
}
|
|
83630
|
+
else if (child.get() instanceof expressions_1.CDSPrefixedName) {
|
|
83631
|
+
ret.push(child);
|
|
83632
|
+
}
|
|
83633
|
+
else {
|
|
83634
|
+
ret.push(...this.findPrefixedNames(child));
|
|
83635
|
+
}
|
|
83636
|
+
}
|
|
83637
|
+
return ret;
|
|
82945
83638
|
}
|
|
82946
83639
|
checkFieldAnnotations(tree, ddic, issues, file) {
|
|
82947
83640
|
const definition = tree.findFirstExpression(expressions_1.CDSDefineAbstract);
|
|
@@ -83131,8 +83824,37 @@ Missing objects are only reported when their names match the configured errorNam
|
|
|
83131
83824
|
}
|
|
83132
83825
|
}
|
|
83133
83826
|
}
|
|
83827
|
+
/** SOURCE_TYPE in the XML must match the DDL source, only the confirmed W/P/V mappings are checked */
|
|
83828
|
+
checkSourceType(tree, object, issues) {
|
|
83829
|
+
const sourceType = object.getSourceType();
|
|
83830
|
+
const xmlFile = object.getXMLFile();
|
|
83831
|
+
if (sourceType === undefined || xmlFile === undefined || ["W", "P", "V"].includes(sourceType) === false) {
|
|
83832
|
+
return;
|
|
83833
|
+
}
|
|
83834
|
+
// other definitions(abstract, custom, table functions, etc.) are skipped
|
|
83835
|
+
let expected = undefined;
|
|
83836
|
+
if (tree.get() instanceof expressions_1.CDSDefineView && tree.findDirectTokenByText("WRITABLE") === undefined) {
|
|
83837
|
+
if (tree.findDirectTokenByText("ENTITY") !== undefined) {
|
|
83838
|
+
expected = "W";
|
|
83839
|
+
}
|
|
83840
|
+
else if (object.getSQLViewName() !== undefined) {
|
|
83841
|
+
expected = "V";
|
|
83842
|
+
}
|
|
83843
|
+
}
|
|
83844
|
+
else if (tree.get() instanceof expressions_1.CDSDefineProjection && tree.findDirectTokenByText("ENTITY") !== undefined) {
|
|
83845
|
+
expected = "P";
|
|
83846
|
+
}
|
|
83847
|
+
if (expected === undefined || expected === sourceType) {
|
|
83848
|
+
return;
|
|
83849
|
+
}
|
|
83850
|
+
const xml = xmlFile.getRaw();
|
|
83851
|
+
const index = xml.indexOf("<SOURCE_TYPE>");
|
|
83852
|
+
const row = index < 0 ? 1 : xml.substring(0, index).split("\n").length;
|
|
83853
|
+
const message = `SOURCE_TYPE "${sourceType}" does not match DDL source, expected "${expected}"`;
|
|
83854
|
+
issues.push(issue_1.Issue.atRow(xmlFile, row, message, this.getMetadata().key, this.conf.severity));
|
|
83855
|
+
}
|
|
83134
83856
|
checkFields(tree, sources, object, issues, file) {
|
|
83135
|
-
var _a;
|
|
83857
|
+
var _a, _b;
|
|
83136
83858
|
const associationNames = new Set();
|
|
83137
83859
|
for (const association of ((_a = object.getParsedData()) === null || _a === void 0 ? void 0 : _a.associations) || []) {
|
|
83138
83860
|
associationNames.add(association.name.toUpperCase());
|
|
@@ -83140,6 +83862,21 @@ Missing objects are only reported when their names match the configured errorNam
|
|
|
83140
83862
|
associationNames.add(association.as.toUpperCase());
|
|
83141
83863
|
}
|
|
83142
83864
|
}
|
|
83865
|
+
for (const composition of tree.findAllExpressionsRecursive(expressions_1.CDSComposition)) {
|
|
83866
|
+
const relation = composition.findDirectExpression(expressions_1.CDSRelation);
|
|
83867
|
+
if (relation === undefined) {
|
|
83868
|
+
continue;
|
|
83869
|
+
}
|
|
83870
|
+
// direct tokens exclude the alias and parameters, and include a namespace like /ABC/
|
|
83871
|
+
const name = relation.getDirectTokens().map(t => t.getStr()).join("");
|
|
83872
|
+
if (name !== "") {
|
|
83873
|
+
associationNames.add(name.toUpperCase());
|
|
83874
|
+
}
|
|
83875
|
+
const alias = (_b = relation.findDirectExpression(expressions_1.CDSAs)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(expressions_1.CDSName);
|
|
83876
|
+
if (alias) {
|
|
83877
|
+
associationNames.add(this.name(alias).toUpperCase());
|
|
83878
|
+
}
|
|
83879
|
+
}
|
|
83143
83880
|
for (const element of tree.findAllExpressionsRecursive(expressions_1.CDSElement)) {
|
|
83144
83881
|
const prefixed = element.findDirectExpression(expressions_1.CDSPrefixedName);
|
|
83145
83882
|
if (prefixed === undefined) {
|
|
@@ -86950,6 +87687,7 @@ exports.ConstantCondition = exports.ConstantConditionConf = void 0;
|
|
|
86950
87687
|
const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
|
|
86951
87688
|
const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js"));
|
|
86952
87689
|
const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
87690
|
+
const _key_compare_1 = __webpack_require__(/*! ../abap/5_syntax/_key_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_key_compare.js");
|
|
86953
87691
|
const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
|
|
86954
87692
|
const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
|
|
86955
87693
|
const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
|
|
@@ -87182,8 +87920,9 @@ ENDIF.`,
|
|
|
87182
87920
|
/** x = a, x <> a, a = x, NOT x = a etc, x character-like and a a known character value */
|
|
87183
87921
|
valueComparison(procedure, compare) {
|
|
87184
87922
|
const children = compare.getChildren();
|
|
87185
|
-
const
|
|
87186
|
-
const
|
|
87923
|
+
const nots = (0, _key_compare_1.countLeadingNot)(compare);
|
|
87924
|
+
const negated = nots % 2 === 1;
|
|
87925
|
+
const rest = children.slice(nots);
|
|
87187
87926
|
if (rest.length !== 3 || !(rest[0] instanceof nodes_1.ExpressionNode) || !(rest[2] instanceof nodes_1.ExpressionNode)
|
|
87188
87927
|
|| !(rest[1].get() instanceof Expressions.CompareOperator)) {
|
|
87189
87928
|
return undefined;
|
|
@@ -89274,6 +90013,7 @@ Current rules:
|
|
|
89274
90013
|
* Some occurrences of string template formatting option ALPHA changed to function module call
|
|
89275
90014
|
* SELECT/INSERT/MODIFY/DELETE/UPDATE "," in field list removed, "@" in source/targets removed
|
|
89276
90015
|
* OPEN CURSOR/FETCH NEXT CURSOR/CLOSE CURSOR "@" in source/targets removed
|
|
90016
|
+
* the ABAP language version of an object, ABAP for Cloud Development or ABAP for Key Users, set to standard ABAP
|
|
89277
90017
|
* PARTIALLY IMPLEMENTED removed, it can be quick fixed via rule implement_methods
|
|
89278
90018
|
* RAISE EXCEPTION ... MESSAGE
|
|
89279
90019
|
* Moving with +=, -=, /=, *=, &&= is expanded
|
|
@@ -89301,6 +90041,29 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
89301
90041
|
}
|
|
89302
90042
|
return this;
|
|
89303
90043
|
}
|
|
90044
|
+
/** the ABAP language version of the object, which abapGit keeps in UNICODE (classes, interfaces) or
|
|
90045
|
+
* ABAP_LANGU_VERSION: 5 is ABAP for Cloud Development, 2 ABAP for Key Users. 7.02 has neither, and a
|
|
90046
|
+
* system that has them checks the downported code by their rules, eg. the downport's restore of
|
|
90047
|
+
* SY-TABIX is a write to a system field ABAP Cloud refuses. The downport is standard ABAP, X */
|
|
90048
|
+
downportLanguageVersion(obj) {
|
|
90049
|
+
const xml = obj.getXMLFile();
|
|
90050
|
+
if (xml === undefined) {
|
|
90051
|
+
return undefined;
|
|
90052
|
+
}
|
|
90053
|
+
const rows = xml.getRawRows();
|
|
90054
|
+
for (let i = 0; i < rows.length; i++) {
|
|
90055
|
+
const match = rows[i].match(/<(UNICODE|ABAP_LANGU_VERSION)>([25])<\/\1>/);
|
|
90056
|
+
if (match === null || match.index === undefined) {
|
|
90057
|
+
continue;
|
|
90058
|
+
}
|
|
90059
|
+
const start = new position_1.Position(i + 1, match.index + match[1].length + 3);
|
|
90060
|
+
const end = new position_1.Position(i + 1, start.getCol() + 1);
|
|
90061
|
+
const fix = edit_helper_1.EditHelper.replaceRange(xml, start, end, "X");
|
|
90062
|
+
const name = match[2] === "5" ? "ABAP for Cloud Development" : "ABAP for Key Users";
|
|
90063
|
+
return issue_1.Issue.atRowRange(xml, i + 1, start.getCol(), end.getCol(), "Language version " + name + ", standard ABAP", this.getMetadata().key, this.conf.severity, fix);
|
|
90064
|
+
}
|
|
90065
|
+
return undefined;
|
|
90066
|
+
}
|
|
89304
90067
|
listMainForInclude(filename) {
|
|
89305
90068
|
if (filename === undefined) {
|
|
89306
90069
|
return [];
|
|
@@ -89335,6 +90098,12 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
89335
90098
|
else if (!(lowObj instanceof _abap_object_1.ABAPObject)) {
|
|
89336
90099
|
return ret;
|
|
89337
90100
|
}
|
|
90101
|
+
if (config.getRelease() === version_1.Release.v702) {
|
|
90102
|
+
const languageVersion = this.downportLanguageVersion(lowObj);
|
|
90103
|
+
if (languageVersion !== undefined) {
|
|
90104
|
+
return [languageVersion];
|
|
90105
|
+
}
|
|
90106
|
+
}
|
|
89338
90107
|
const highObj = this.highReg.getObject(lowObj.getType(), lowObj.getName());
|
|
89339
90108
|
if (highObj === undefined || !(highObj instanceof _abap_object_1.ABAPObject)) {
|
|
89340
90109
|
return ret;
|
|
@@ -89811,11 +90580,18 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
89811
90580
|
&& !(high.get() instanceof Statements.SelectLoop)) {
|
|
89812
90581
|
return undefined;
|
|
89813
90582
|
}
|
|
89814
|
-
// note: SQLCond is also used in JOIN(FROM) conditions
|
|
89815
|
-
|
|
89816
|
-
|
|
90583
|
+
// note: SQLCond is also used in JOIN(FROM) conditions. INTO after any of WHERE, GROUP BY,
|
|
90584
|
+
// HAVING or ORDER BY is strict syntax, the first of them is where INTO has to be in front of
|
|
90585
|
+
const clauses = [
|
|
90586
|
+
(_a = high.findFirstExpression(Expressions.Select)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.SQLCond),
|
|
90587
|
+
high.findFirstExpression(Expressions.SQLGroupBy),
|
|
90588
|
+
high.findFirstExpression(Expressions.SQLHaving),
|
|
90589
|
+
high.findFirstExpression(Expressions.SQLOrderBy),
|
|
90590
|
+
].filter(c => c !== undefined);
|
|
90591
|
+
if (clauses.length === 0) {
|
|
89817
90592
|
return undefined;
|
|
89818
90593
|
}
|
|
90594
|
+
const first = clauses.reduce((a, b) => b.getFirstToken().getStart().isBefore(a.getFirstToken().getStart()) ? b : a);
|
|
89819
90595
|
// the FIELDS list sits between FROM and WHERE, wait for it to be removed first
|
|
89820
90596
|
if (high.findFirstExpression(Expressions.SQLFields) !== undefined) {
|
|
89821
90597
|
return undefined;
|
|
@@ -89830,21 +90606,26 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
89830
90606
|
if (into === undefined) {
|
|
89831
90607
|
return undefined;
|
|
89832
90608
|
}
|
|
89833
|
-
if (
|
|
90609
|
+
if (first.getFirstToken().getStart().isBefore(into.getFirstToken().getStart()) === false) {
|
|
89834
90610
|
return undefined;
|
|
89835
90611
|
}
|
|
89836
90612
|
const from = high.findFirstExpression(Expressions.SQLFrom);
|
|
89837
90613
|
if (from === undefined) {
|
|
89838
90614
|
return undefined;
|
|
89839
90615
|
}
|
|
89840
|
-
// UP TO after INTO
|
|
90616
|
+
// UP TO and BYPASSING BUFFER after INTO are not valid behind WHERE or ORDER BY, they belong to
|
|
90617
|
+
// FROM in the old syntax: move them along in front of INTO, FROM ... BYPASSING BUFFER UP TO n ROWS INTO
|
|
89841
90618
|
let move = into.concatTokens();
|
|
89842
90619
|
const fixes = [];
|
|
89843
|
-
const
|
|
89844
|
-
|
|
89845
|
-
|
|
89846
|
-
move =
|
|
89847
|
-
|
|
90620
|
+
const along = [high.findFirstExpression(Expressions.SQLUpTo), high.findFirstExpression(Expressions.SQLBypassingBuffer)]
|
|
90621
|
+
.filter(e => e !== undefined && into.getLastToken().getEnd().isBefore(e.getFirstToken().getStart()));
|
|
90622
|
+
for (const e of along) {
|
|
90623
|
+
move = e.concatTokens() + ` ` + move;
|
|
90624
|
+
}
|
|
90625
|
+
// edits are applied in sequence, so delete the later one first
|
|
90626
|
+
along.sort((a, b) => b.getFirstToken().getStart().isBefore(a.getFirstToken().getStart()) ? -1 : 1);
|
|
90627
|
+
for (const e of along) {
|
|
90628
|
+
fixes.push(edit_helper_1.EditHelper.deleteRange(lowFile, e.getFirstToken().getStart(), e.getLastToken().getEnd()));
|
|
89848
90629
|
}
|
|
89849
90630
|
// edits are applied in sequence, so work from the end of the statement towards the start
|
|
89850
90631
|
fixes.push(edit_helper_1.EditHelper.deleteRange(lowFile, into.getFirstToken().getStart(), into.getLastToken().getEnd()));
|
|
@@ -89891,15 +90672,11 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
89891
90672
|
&& !(high.get() instanceof Statements.CloseCursor)) {
|
|
89892
90673
|
return undefined;
|
|
89893
90674
|
}
|
|
89894
|
-
|
|
90675
|
+
// the edits of a fix are applied one after the other, a deletion moves what follows it in the
|
|
90676
|
+
// same row: collect the tokens and delete from the end of the statement towards its start
|
|
90677
|
+
const toDelete = [];
|
|
89895
90678
|
const addFix = (token) => {
|
|
89896
|
-
|
|
89897
|
-
if (fix === undefined) {
|
|
89898
|
-
fix = add;
|
|
89899
|
-
}
|
|
89900
|
-
else {
|
|
89901
|
-
fix = edit_helper_1.EditHelper.merge(fix, add);
|
|
89902
|
-
}
|
|
90679
|
+
toDelete.push(token);
|
|
89903
90680
|
};
|
|
89904
90681
|
const candidates = [high.findAllExpressionsRecursive(Expressions.SQLTarget),
|
|
89905
90682
|
high.findAllExpressionsRecursive(Expressions.SQLSource),
|
|
@@ -89938,14 +90715,17 @@ ${indentation}${uniqueName} = ${source === null || source === void 0 ? void 0 :
|
|
|
89938
90715
|
}
|
|
89939
90716
|
}
|
|
89940
90717
|
}
|
|
89941
|
-
for (const fieldList of high.findAllExpressionsMulti([Expressions.SQLFieldList, Expressions.SQLFieldListLoop, Expressions.SQLOrderBy
|
|
90718
|
+
for (const fieldList of high.findAllExpressionsMulti([Expressions.SQLFieldList, Expressions.SQLFieldListLoop, Expressions.SQLOrderBy,
|
|
90719
|
+
Expressions.SQLGroupBy], true)) {
|
|
89942
90720
|
for (const token of fieldList.getDirectTokens()) {
|
|
89943
90721
|
if (token.getStr() === ",") {
|
|
89944
90722
|
addFix(token);
|
|
89945
90723
|
}
|
|
89946
90724
|
}
|
|
89947
90725
|
}
|
|
89948
|
-
if (
|
|
90726
|
+
if (toDelete.length > 0) {
|
|
90727
|
+
toDelete.sort((a, b) => b.getStart().isBefore(a.getStart()) ? -1 : 1);
|
|
90728
|
+
const fix = edit_helper_1.EditHelper.mergeList(toDelete.map(t => edit_helper_1.EditHelper.deleteToken(lowFile, t)));
|
|
89949
90729
|
return issue_1.Issue.atToken(lowFile, low.getFirstToken(), "SQL, remove @ and ,", this.getMetadata().key, this.conf.severity, fix);
|
|
89950
90730
|
}
|
|
89951
90731
|
for (const c of high.findAllExpressionsRecursive(Expressions.SQLIn)) {
|
|
@@ -89962,7 +90742,7 @@ ${indentation}${uniqueName} = ${source === null || source === void 0 ? void 0 :
|
|
|
89962
90742
|
const lastStart = last.getFirstToken().getStart();
|
|
89963
90743
|
const startDelete = new position_1.Position(lastStart.getRow(), lastStart.getCol() - 1);
|
|
89964
90744
|
const fix2 = edit_helper_1.EditHelper.deleteRange(lowFile, startDelete, lastStart);
|
|
89965
|
-
fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
90745
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
89966
90746
|
return issue_1.Issue.atToken(lowFile, low.getFirstToken(), "SQL, remove spaces", this.getMetadata().key, this.conf.severity, fix);
|
|
89967
90747
|
}
|
|
89968
90748
|
}
|
|
@@ -90256,7 +91036,7 @@ ${indentation}`);
|
|
|
90256
91036
|
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
90257
91037
|
const firstToken = high.getFirstToken();
|
|
90258
91038
|
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, firstToken.getStart(), `DATA ${uniqueName} LIKE LINE OF ${target === null || target === void 0 ? void 0 : target.concatTokens()}.
|
|
90259
|
-
${indentation}${uniqueName} = ${source.
|
|
91039
|
+
${indentation}${uniqueName} = ${source.concatTokensWithLinebreaks()}.\n${indentation}`);
|
|
90260
91040
|
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, source.getFirstToken().getStart(), source.getLastToken().getEnd(), uniqueName);
|
|
90261
91041
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
90262
91042
|
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Outline APPEND source expression", this.getMetadata().key, this.conf.severity, fix);
|
|
@@ -90312,7 +91092,7 @@ ${indentation}${uniqueName} = ${source.concatTokens()}.\n${indentation}`);
|
|
|
90312
91092
|
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
90313
91093
|
const firstToken = high.getFirstToken();
|
|
90314
91094
|
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, firstToken.getStart(), `DATA ${uniqueName} LIKE LINE OF ${target === null || target === void 0 ? void 0 : target.concatTokens()}.
|
|
90315
|
-
${indentation}${uniqueName} = ${source.
|
|
91095
|
+
${indentation}${uniqueName} = ${source.concatTokensWithLinebreaks()}.\n${indentation}`);
|
|
90316
91096
|
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, source.getFirstToken().getStart(), source.getLastToken().getEnd(), uniqueName);
|
|
90317
91097
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
90318
91098
|
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Outline INSERT source expression", this.getMetadata().key, this.conf.severity, fix);
|
|
@@ -90378,7 +91158,7 @@ ENDIF.`;
|
|
|
90378
91158
|
${read.replace(/^/gm, " ")}
|
|
90379
91159
|
ENDIF.`;
|
|
90380
91160
|
}
|
|
90381
|
-
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, firstToken.getStart(), `FIELD-SYMBOLS ${uniqueName}
|
|
91161
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, firstToken.getStart(), `FIELD-SYMBOLS ${uniqueName} ${this.rowOf(pre, high, lowFile, highSyntax)}.
|
|
90382
91162
|
${indentation}DATA ${tabixBackup} LIKE sy-tabix.
|
|
90383
91163
|
${read.replace(/\n/g, "\n" + indentation).replace(/^/, indentation)}
|
|
90384
91164
|
${indentation}`);
|
|
@@ -91298,6 +92078,17 @@ CONSTANTS: BEGIN OF ${structureName},\n`;
|
|
|
91298
92078
|
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
|
|
91299
92079
|
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport ENUM", this.getMetadata().key, this.conf.severity, fix);
|
|
91300
92080
|
}
|
|
92081
|
+
/** the type of a field symbol for a row of the table, LIKE LINE OF a generically typed table is
|
|
92082
|
+
* refused by the system, "<TAB> is a generic type" - the field symbol is then TYPE any */
|
|
92083
|
+
rowOf(table, high, lowFile, highSyntax) {
|
|
92084
|
+
var _a;
|
|
92085
|
+
const spag = highSyntax.spaghetti.lookupPosition(high.getFirstToken().getStart(), lowFile.getFilename());
|
|
92086
|
+
const type = (_a = spag === null || spag === void 0 ? void 0 : spag.findVariable(table)) === null || _a === void 0 ? void 0 : _a.getType();
|
|
92087
|
+
if (type instanceof basic_1.TableType && type.isGeneric() === true) {
|
|
92088
|
+
return "TYPE any";
|
|
92089
|
+
}
|
|
92090
|
+
return "LIKE LINE OF " + table;
|
|
92091
|
+
}
|
|
91301
92092
|
moveWithTableTarget(low, high, lowFile, highSyntax) {
|
|
91302
92093
|
var _a;
|
|
91303
92094
|
if (!(low.get() instanceof _statement_1.Unknown)) {
|
|
@@ -91332,7 +92123,7 @@ CONSTANTS: BEGIN OF ${structureName},\n`;
|
|
|
91332
92123
|
const tabixBackup = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
91333
92124
|
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
91334
92125
|
// restore tabix before exeption
|
|
91335
|
-
const code = `FIELD-SYMBOLS ${uniqueName}
|
|
92126
|
+
const code = `FIELD-SYMBOLS ${uniqueName} ${this.rowOf(tName, high, lowFile, highSyntax)}.
|
|
91336
92127
|
${indentation}DATA ${tabixBackup} LIKE sy-tabix.
|
|
91337
92128
|
${indentation}${tabixBackup} = sy-tabix.
|
|
91338
92129
|
${indentation}READ TABLE ${tName} ${condition}ASSIGNING ${uniqueName}.
|
|
@@ -91994,11 +92785,11 @@ ${indentation} output = ${uniqueName}.\n`;
|
|
|
91994
92785
|
}
|
|
91995
92786
|
else if (b.get() instanceof Expressions.Source) {
|
|
91996
92787
|
// note: it wont work with APPEND for Hashed/Sorted Tables, so use INSERT,
|
|
91997
|
-
body += indentation + "INSERT " + b.
|
|
92788
|
+
body += indentation + "INSERT " + b.concatTokensWithLinebreaks() + ` INTO TABLE ${uniqueName}.\n`;
|
|
91998
92789
|
skip = true;
|
|
91999
92790
|
}
|
|
92000
92791
|
else if (b.get() instanceof Expressions.ValueBodyLines) {
|
|
92001
|
-
body += indentation + "INSERT " + b.
|
|
92792
|
+
body += indentation + "INSERT " + b.concatTokensWithLinebreaks() + ` INTO TABLE ${uniqueName}.\n`;
|
|
92002
92793
|
skip = true;
|
|
92003
92794
|
}
|
|
92004
92795
|
else if (b.concatTokens() === ")") {
|
|
@@ -96392,6 +97183,7 @@ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./
|
|
|
96392
97183
|
const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
|
|
96393
97184
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
|
|
96394
97185
|
const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
97186
|
+
const _key_compare_1 = __webpack_require__(/*! ../abap/5_syntax/_key_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_key_compare.js");
|
|
96395
97187
|
class Conditions {
|
|
96396
97188
|
constructor() {
|
|
96397
97189
|
this.arr = [];
|
|
@@ -96485,8 +97277,9 @@ ENDIF.`,
|
|
|
96485
97277
|
}
|
|
96486
97278
|
for (const compare of statement.findAllExpressionsRecursive(Expressions.Compare)) {
|
|
96487
97279
|
const children = compare.getChildren();
|
|
96488
|
-
const
|
|
96489
|
-
const
|
|
97280
|
+
const nots = (0, _key_compare_1.countLeadingNot)(compare);
|
|
97281
|
+
const negated = nots % 2 === 1;
|
|
97282
|
+
const rest = children.slice(nots);
|
|
96490
97283
|
if (rest.length !== 3
|
|
96491
97284
|
|| !(rest[0] instanceof nodes_1.ExpressionNode) || !(rest[0].get() instanceof Expressions.Source)
|
|
96492
97285
|
|| !(rest[1] instanceof nodes_1.ExpressionNode) || !(rest[1].get() instanceof Expressions.CompareOperator)
|
|
@@ -101618,6 +102411,7 @@ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./
|
|
|
101618
102411
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
|
|
101619
102412
|
const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
101620
102413
|
const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
|
|
102414
|
+
const _key_compare_1 = __webpack_require__(/*! ../abap/5_syntax/_key_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_key_compare.js");
|
|
101621
102415
|
class ManyParenthesesConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
101622
102416
|
}
|
|
101623
102417
|
exports.ManyParenthesesConf = ManyParenthesesConf;
|
|
@@ -101671,12 +102465,9 @@ ENDIF.`,
|
|
|
101671
102465
|
if (cond[0].getChildren().length === 1) {
|
|
101672
102466
|
const message = "Too many parentheses, simple";
|
|
101673
102467
|
const children = sub.getChildren();
|
|
101674
|
-
|
|
101675
|
-
|
|
101676
|
-
|
|
101677
|
-
startToken = children[1].getFirstToken();
|
|
101678
|
-
fixText = sub.getChildren()[2].concatTokens();
|
|
101679
|
-
}
|
|
102468
|
+
const nots = (0, _key_compare_1.countLeadingNot)(sub);
|
|
102469
|
+
const startToken = children[nots].getFirstToken();
|
|
102470
|
+
const fixText = children[nots + 1].concatTokens();
|
|
101680
102471
|
const fix = edit_helper_1.EditHelper.replaceRange(file, startToken.getStart(), sub.getLastToken().getEnd(), fixText);
|
|
101681
102472
|
const issue = issue_1.Issue.atToken(file, startToken, message, this.getMetadata().key, this.conf.severity, fix);
|
|
101682
102473
|
issues.push(issue);
|
|
@@ -101738,7 +102529,7 @@ ENDIF.`,
|
|
|
101738
102529
|
}
|
|
101739
102530
|
else if (c instanceof nodes_1.ExpressionNode
|
|
101740
102531
|
&& (c.get() instanceof Expressions.CondSub || c.get() instanceof Expressions.ComponentCondSub)) {
|
|
101741
|
-
if (
|
|
102532
|
+
if ((0, _key_compare_1.countLeadingNot)(c) > 0) {
|
|
101742
102533
|
return [];
|
|
101743
102534
|
}
|
|
101744
102535
|
let i = c.findDirectExpression(Expressions.Cond);
|
|
@@ -123193,6 +123984,9 @@ class CDSMetadata {
|
|
|
123193
123984
|
}
|
|
123194
123985
|
}
|
|
123195
123986
|
}
|
|
123987
|
+
else if (def instanceof cds.CDSDefineHierarchy) {
|
|
123988
|
+
this.hierarchy(root, result);
|
|
123989
|
+
}
|
|
123196
123990
|
else {
|
|
123197
123991
|
this.signature(root, result);
|
|
123198
123992
|
}
|
|
@@ -123233,7 +124027,7 @@ class CDSMetadata {
|
|
|
123233
124027
|
// the first name is the projection's own, the second the projected entity
|
|
123234
124028
|
const name = root.findDirectExpressions(cds.CDSName)[1];
|
|
123235
124029
|
if (name) {
|
|
123236
|
-
ret.push(name.concatTokens().toUpperCase());
|
|
124030
|
+
ret.push(name.concatTokens().replace(/ /g, "").toUpperCase());
|
|
123237
124031
|
}
|
|
123238
124032
|
}
|
|
123239
124033
|
for (const s of root.findAllExpressions(cds.CDSSource)) {
|
|
@@ -123322,7 +124116,7 @@ class CDSMetadata {
|
|
|
123322
124116
|
return undefined;
|
|
123323
124117
|
}
|
|
123324
124118
|
const rest = children.slice(to + 1).map(c => c.concatTokens().toUpperCase());
|
|
123325
|
-
const target = children.slice(to + 1).find(c => c.get() instanceof cds.CDSName)?.concatTokens();
|
|
124119
|
+
const target = children.slice(to + 1).find(c => c.get() instanceof cds.CDSName)?.concatTokens().replace(/ /g, "");
|
|
123326
124120
|
if (target === undefined) {
|
|
123327
124121
|
return undefined;
|
|
123328
124122
|
}
|
|
@@ -123335,6 +124129,52 @@ class CDSMetadata {
|
|
|
123335
124129
|
}
|
|
123336
124130
|
return { target, type };
|
|
123337
124131
|
}
|
|
124132
|
+
/** hierarchies list their elements directly under the root, after the "{" and separated by ",":
|
|
124133
|
+
* [annotations] [KEY] path [AS alias]. Associations of the SOURCE entity can be exposed. */
|
|
124134
|
+
hierarchy(root, result) {
|
|
124135
|
+
const children = root.getChildren();
|
|
124136
|
+
const token = (c) => c instanceof abaplint.Nodes.TokenNode ? c.getFirstToken().getStr().toUpperCase() : "";
|
|
124137
|
+
const source = children[children.findIndex(c => token(c) === "SOURCE") + 1];
|
|
124138
|
+
const sources = source?.get() instanceof cds.CDSName ? [source.concatTokens().toUpperCase()] : [];
|
|
124139
|
+
let annotations = [];
|
|
124140
|
+
let key = false;
|
|
124141
|
+
let path = [];
|
|
124142
|
+
let as;
|
|
124143
|
+
for (const child of children.slice(children.findIndex(c => token(c) === "{") + 1)) {
|
|
124144
|
+
const text = token(child);
|
|
124145
|
+
if (child.get() instanceof cds.CDSAnnotation) {
|
|
124146
|
+
annotations.push(CDSMetadata.annotation(child));
|
|
124147
|
+
}
|
|
124148
|
+
else if (text === "KEY") {
|
|
124149
|
+
key = true;
|
|
124150
|
+
}
|
|
124151
|
+
else if (child.get() instanceof cds.CDSPrefixedName) {
|
|
124152
|
+
path = child.findAllExpressions(cds.CDSName).map(n => n.concatTokens());
|
|
124153
|
+
}
|
|
124154
|
+
else if (child.get() instanceof cds.CDSAs) {
|
|
124155
|
+
as = this.alias(child);
|
|
124156
|
+
}
|
|
124157
|
+
else if (text === "," || text === "}") {
|
|
124158
|
+
if (path.length > 0) {
|
|
124159
|
+
const name = as ?? path[path.length - 1];
|
|
124160
|
+
const inherited = this.sourceAssociation(sources, path[path.length - 1]);
|
|
124161
|
+
if (inherited) {
|
|
124162
|
+
result.associations.push({ ...inherited, name, exposed: true, annotations });
|
|
124163
|
+
}
|
|
124164
|
+
else {
|
|
124165
|
+
result.fields.push({ name, key, virtual: false, annotations });
|
|
124166
|
+
}
|
|
124167
|
+
}
|
|
124168
|
+
annotations = [];
|
|
124169
|
+
key = false;
|
|
124170
|
+
path = [];
|
|
124171
|
+
as = undefined;
|
|
124172
|
+
if (text === "}") {
|
|
124173
|
+
return;
|
|
124174
|
+
}
|
|
124175
|
+
}
|
|
124176
|
+
}
|
|
124177
|
+
}
|
|
123338
124178
|
/** abstract and custom entities and table functions list their elements inline: name : type ; */
|
|
123339
124179
|
signature(root, result) {
|
|
123340
124180
|
let inBody = false;
|
|
@@ -123869,6 +124709,137 @@ exports.Chunk = Chunk;
|
|
|
123869
124709
|
|
|
123870
124710
|
/***/ },
|
|
123871
124711
|
|
|
124712
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/constant_value.js"
|
|
124713
|
+
/*!***********************************************************************!*\
|
|
124714
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/constant_value.js ***!
|
|
124715
|
+
\***********************************************************************/
|
|
124716
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
124717
|
+
|
|
124718
|
+
"use strict";
|
|
124719
|
+
|
|
124720
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
124721
|
+
if (k2 === undefined) k2 = k;
|
|
124722
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
124723
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
124724
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
124725
|
+
}
|
|
124726
|
+
Object.defineProperty(o, k2, desc);
|
|
124727
|
+
}) : (function(o, m, k, k2) {
|
|
124728
|
+
if (k2 === undefined) k2 = k;
|
|
124729
|
+
o[k2] = m[k];
|
|
124730
|
+
}));
|
|
124731
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
124732
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
124733
|
+
}) : function(o, v) {
|
|
124734
|
+
o["default"] = v;
|
|
124735
|
+
});
|
|
124736
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
124737
|
+
var ownKeys = function(o) {
|
|
124738
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
124739
|
+
var ar = [];
|
|
124740
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
124741
|
+
return ar;
|
|
124742
|
+
};
|
|
124743
|
+
return ownKeys(o);
|
|
124744
|
+
};
|
|
124745
|
+
return function (mod) {
|
|
124746
|
+
if (mod && mod.__esModule) return mod;
|
|
124747
|
+
var result = {};
|
|
124748
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
124749
|
+
__setModuleDefault(result, mod);
|
|
124750
|
+
return result;
|
|
124751
|
+
};
|
|
124752
|
+
})();
|
|
124753
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
124754
|
+
exports.constantSource = constantSource;
|
|
124755
|
+
exports.memberRead = memberRead;
|
|
124756
|
+
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
124757
|
+
function constantSource(reg, chain, path = []) {
|
|
124758
|
+
const match = /^([^\s=]+)\s*=>\s*([^\s-]+)(?:\s*-\s*(.+))?$/.exec(chain.concatTokens());
|
|
124759
|
+
if (match === null) {
|
|
124760
|
+
return { kind: "void" };
|
|
124761
|
+
}
|
|
124762
|
+
let objectName = match[1];
|
|
124763
|
+
let attribute = match[2];
|
|
124764
|
+
if (attribute.includes("~")) {
|
|
124765
|
+
[objectName, attribute] = attribute.split("~");
|
|
124766
|
+
}
|
|
124767
|
+
const components = match[3]?.split(/\s*-\s*/).map(c => c.toLowerCase()) ?? [];
|
|
124768
|
+
const obj = reg.getObject("INTF", objectName) || reg.getObject("CLAS", objectName);
|
|
124769
|
+
if (!(obj instanceof abaplint.ABAPObject)) {
|
|
124770
|
+
return { kind: "void" };
|
|
124771
|
+
}
|
|
124772
|
+
const key = (objectName + "=>" + attribute).toUpperCase();
|
|
124773
|
+
if (path.includes(key)) {
|
|
124774
|
+
throw new Error((obj.getMainABAPFile()?.getFilename() ?? obj.getName()) + ": constant chain "
|
|
124775
|
+
+ [...path, key].join(" -> ") + " never reaches a value");
|
|
124776
|
+
}
|
|
124777
|
+
const member = { kind: "member", object: obj, attribute: attribute, components: components };
|
|
124778
|
+
if (obj.getType() === "CLAS") {
|
|
124779
|
+
// a class's constant may change at run time
|
|
124780
|
+
return member;
|
|
124781
|
+
}
|
|
124782
|
+
const identifier = findConstant(reg, obj, attribute);
|
|
124783
|
+
if (identifier === undefined) {
|
|
124784
|
+
return member;
|
|
124785
|
+
}
|
|
124786
|
+
if (components.length > 0) {
|
|
124787
|
+
let value = identifier.getValue();
|
|
124788
|
+
for (const component of components) {
|
|
124789
|
+
const name = typeof value === "object" && value !== null
|
|
124790
|
+
? Object.keys(value).find(k => k.toLowerCase() === component) : undefined;
|
|
124791
|
+
value = name === undefined ? undefined : value[name];
|
|
124792
|
+
}
|
|
124793
|
+
return typeof value === "string" ? { kind: "literal", value: value } : member;
|
|
124794
|
+
}
|
|
124795
|
+
const declared = findStatement(obj, identifier)?.findDirectExpression(abaplint.Expressions.Value);
|
|
124796
|
+
const next = declared?.getChildren()[1];
|
|
124797
|
+
if (next instanceof abaplint.Nodes.ExpressionNode && next.get() instanceof abaplint.Expressions.SimpleFieldChain) {
|
|
124798
|
+
const further = constantSource(reg, next, [...path, key]);
|
|
124799
|
+
return further.kind === "void" ? member : further;
|
|
124800
|
+
}
|
|
124801
|
+
if (next instanceof abaplint.Nodes.TokenNode && next.concatTokens().toUpperCase() === "IS") {
|
|
124802
|
+
// VALUE IS INITIAL has no expression of its own: it is the one alternative of Value made of words
|
|
124803
|
+
return { kind: "initial", type: identifier.getType() };
|
|
124804
|
+
}
|
|
124805
|
+
const value = identifier.getValue();
|
|
124806
|
+
return typeof value === "string" ? { kind: "literal", value: value } : member;
|
|
124807
|
+
}
|
|
124808
|
+
function findConstant(reg, obj, attribute) {
|
|
124809
|
+
const found = [];
|
|
124810
|
+
const walk = (n) => {
|
|
124811
|
+
const id = n.getIdentifier();
|
|
124812
|
+
if (id.stype === abaplint.ScopeType.Interface && id.sname.toUpperCase() === obj.getName().toUpperCase()) {
|
|
124813
|
+
const v = n.findVariable(attribute);
|
|
124814
|
+
if (v !== undefined) {
|
|
124815
|
+
found.push(v);
|
|
124816
|
+
}
|
|
124817
|
+
}
|
|
124818
|
+
n.getChildren().forEach(walk);
|
|
124819
|
+
};
|
|
124820
|
+
walk(new abaplint.SyntaxLogic(reg, obj).run().spaghetti.getTop());
|
|
124821
|
+
return found[0];
|
|
124822
|
+
}
|
|
124823
|
+
function findStatement(obj, identifier) {
|
|
124824
|
+
const file = obj.getABAPFiles().find(f => f.getFilename() === identifier.getFilename());
|
|
124825
|
+
const start = identifier.getStart();
|
|
124826
|
+
return file?.getStatements().find(s => s.get() instanceof abaplint.Statements.Constant
|
|
124827
|
+
&& s.findDirectExpression(abaplint.Expressions.DefinitionName)?.getFirstToken().getStart().equals(start) === true);
|
|
124828
|
+
}
|
|
124829
|
+
/** the JS expression reading a member source at load */
|
|
124830
|
+
function memberRead(source) {
|
|
124831
|
+
const name = source.object.getName();
|
|
124832
|
+
const attribute = source.attribute.toLowerCase();
|
|
124833
|
+
const property = source.object.getType() === "INTF"
|
|
124834
|
+
? name.toLowerCase().replace(/\//g, "$") + "$" + attribute
|
|
124835
|
+
: attribute;
|
|
124836
|
+
return "abap.Classes['" + name.toUpperCase() + "']." + property.replace(/\//g, "$")
|
|
124837
|
+
+ source.components.map(c => c.includes("/") ? ".get()[\"" + c + "\"]" : ".get()." + c).join("");
|
|
124838
|
+
}
|
|
124839
|
+
//# sourceMappingURL=constant_value.js.map
|
|
124840
|
+
|
|
124841
|
+
/***/ },
|
|
124842
|
+
|
|
123872
124843
|
/***/ "./node_modules/@abaplint/transpiler/build/src/db/cds_database_view.js"
|
|
123873
124844
|
/*!*****************************************************************************!*\
|
|
123874
124845
|
!*** ./node_modules/@abaplint/transpiler/build/src/db/cds_database_view.js ***!
|
|
@@ -125420,7 +126391,8 @@ const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abapli
|
|
|
125420
126391
|
class CallTransformationParametersTranspiler {
|
|
125421
126392
|
transpile(node, traversal) {
|
|
125422
126393
|
if (node.getFirstChild()?.get() instanceof abaplint.Expressions.Dynamic) {
|
|
125423
|
-
|
|
126394
|
+
// a dynamic parameter table named with its body suffix: (lt_x[])
|
|
126395
|
+
return new chunk_1.Chunk().append(node.concatTokens().replace(/\[\]\s*\)$/, ")"), node, traversal);
|
|
125424
126396
|
}
|
|
125425
126397
|
else {
|
|
125426
126398
|
const res = new chunk_1.Chunk().appendString("{");
|
|
@@ -125539,6 +126511,11 @@ class CompareTranspiler {
|
|
|
125539
126511
|
else if (concat.endsWith("IS ASSIGNED")) {
|
|
125540
126512
|
return new chunk_1.Chunk().appendString("abap.compare.assigned(").appendChunk(s0).appendString(")");
|
|
125541
126513
|
}
|
|
126514
|
+
// a table parameter is often named with its body suffix (it_x[] IS
|
|
126515
|
+
// SUPPLIED): the parameter is it_x, "[]" is no part of a JS name
|
|
126516
|
+
if (/ IS (NOT )?(SUPPLIED|REQUESTED)$/.test(concat)) {
|
|
126517
|
+
concat = concat.replace(/\[\](?= IS )/, "");
|
|
126518
|
+
}
|
|
125542
126519
|
if (concat.endsWith(" IS SUPPLIED")) {
|
|
125543
126520
|
if (concat.startsWith("NOT ")) {
|
|
125544
126521
|
concat = concat.replace("NOT ", "");
|
|
@@ -128739,11 +129716,22 @@ const let_1 = __webpack_require__(/*! ./let */ "./node_modules/@abaplint/transpi
|
|
|
128739
129716
|
const value_body_1 = __webpack_require__(/*! ./value_body */ "./node_modules/@abaplint/transpiler/build/src/expressions/value_body.js");
|
|
128740
129717
|
class SourceTranspiler {
|
|
128741
129718
|
addGet;
|
|
128742
|
-
|
|
128743
|
-
/**
|
|
128744
|
-
|
|
129719
|
+
calculation;
|
|
129720
|
+
/** calculation: the calculation type the target gives integer operands, each operation
|
|
129721
|
+
* gets its left operand as an int8, or as a decfloat34 when the target is p, f or decfloat34;
|
|
129722
|
+
* with "i" the operands stay as they are and "+", "-" and "*" are the operators that check
|
|
129723
|
+
* the range of i */
|
|
129724
|
+
constructor(addGet = false, calculation) {
|
|
128745
129725
|
this.addGet = addGet;
|
|
128746
|
-
this.
|
|
129726
|
+
this.calculation = calculation;
|
|
129727
|
+
}
|
|
129728
|
+
static INTEGER_OPERATORS = {
|
|
129729
|
+
"+": "abap.operators.addInt",
|
|
129730
|
+
"-": "abap.operators.minusInt",
|
|
129731
|
+
"*": "abap.operators.multiplyInt",
|
|
129732
|
+
};
|
|
129733
|
+
negation() {
|
|
129734
|
+
return this.calculation === "i" ? "abap.operators.minusInt(0, " : "abap.operators.minus(0, ";
|
|
128747
129735
|
}
|
|
128748
129736
|
// the operands of a chain of & / && (the rearranger leaves them as a binary
|
|
128749
129737
|
// tree of Source nodes); an empty list when the node is not such a chain
|
|
@@ -128811,8 +129799,8 @@ class SourceTranspiler {
|
|
|
128811
129799
|
break;
|
|
128812
129800
|
}
|
|
128813
129801
|
}
|
|
128814
|
-
//
|
|
128815
|
-
let
|
|
129802
|
+
// whether the operand left of the next operator already has the calculation type
|
|
129803
|
+
let leftIsCalculation = false;
|
|
128816
129804
|
for (let i = startIdx; i < children.length; i++) {
|
|
128817
129805
|
const c = children[i];
|
|
128818
129806
|
const isLast = i === children.length - 1;
|
|
@@ -128834,21 +129822,27 @@ class SourceTranspiler {
|
|
|
128834
129822
|
// same for -, *, /, DIV and MOD. It binds weaker than **, - a ** 2 is - ( a ** 2 ),
|
|
128835
129823
|
// so there the whole expression stays negated, below
|
|
128836
129824
|
if (prefixNegated === true && c.concatTokens().trim() !== "**") {
|
|
128837
|
-
ret = new chunk_1.Chunk().appendString(
|
|
129825
|
+
ret = new chunk_1.Chunk().appendString(this.negation()).appendChunk(ret).appendString(")");
|
|
128838
129826
|
prefixNegated = false;
|
|
128839
129827
|
}
|
|
128840
129828
|
// "/" rounds in calculation type int8, the runtime's divide() does not know the target
|
|
128841
|
-
|
|
129829
|
+
let operator = this.calculation === "int8" && c.concatTokens().trim() === "/"
|
|
128842
129830
|
? new chunk_1.Chunk().append("abap.operators.divideInt8", c, traversal)
|
|
128843
129831
|
: traversal.traverse(c);
|
|
128844
|
-
|
|
128845
|
-
|
|
129832
|
+
// calculation type i: the operator checks the range of i
|
|
129833
|
+
const checked = this.calculation === "i" ? SourceTranspiler.INTEGER_OPERATORS[c.concatTokens().trim()] : undefined;
|
|
129834
|
+
if (checked !== undefined) {
|
|
129835
|
+
operator = new chunk_1.Chunk().append(checked, c, traversal);
|
|
129836
|
+
}
|
|
129837
|
+
if (this.calculation !== undefined && this.calculation !== "i" && leftIsCalculation === false) {
|
|
129838
|
+
const type = this.calculation === "int8" ? "Integer8" : "DecFloat34";
|
|
129839
|
+
ret = new chunk_1.Chunk().appendChunk(operator).appendString(`(new abap.types.${type}().set(`).appendChunk(ret).appendString("),");
|
|
128846
129840
|
}
|
|
128847
129841
|
else {
|
|
128848
129842
|
ret = new chunk_1.Chunk().appendChunk(operator).appendString("(").appendChunk(ret).appendString(",");
|
|
128849
129843
|
}
|
|
128850
|
-
// the result of an operation with an int8 operand
|
|
128851
|
-
|
|
129844
|
+
// the result of an operation with an int8 or decfloat34 operand has that type
|
|
129845
|
+
leftIsCalculation = true;
|
|
128852
129846
|
post.appendString(")");
|
|
128853
129847
|
if (this.addGet) {
|
|
128854
129848
|
post.append(".get()", c, traversal);
|
|
@@ -128865,8 +129859,8 @@ class SourceTranspiler {
|
|
|
128865
129859
|
}
|
|
128866
129860
|
}
|
|
128867
129861
|
else if (c.get() instanceof core_1.Expressions.Source) {
|
|
128868
|
-
ret.appendChunk(new SourceTranspiler(this.addGet, this.
|
|
128869
|
-
|
|
129862
|
+
ret.appendChunk(new SourceTranspiler(this.addGet, this.calculation).transpile(c, traversal));
|
|
129863
|
+
leftIsCalculation = c.findDirectExpression(core_1.Expressions.ArithOperator) !== undefined;
|
|
128870
129864
|
}
|
|
128871
129865
|
else if (c.get() instanceof core_1.Expressions.Arrow) {
|
|
128872
129866
|
ret = new chunk_1.Chunk().appendString("(").appendChunk(ret).appendString(").get().");
|
|
@@ -129046,7 +130040,7 @@ class SourceTranspiler {
|
|
|
129046
130040
|
}
|
|
129047
130041
|
ret.appendChunk(post);
|
|
129048
130042
|
if (prefixNegated) {
|
|
129049
|
-
ret = new chunk_1.Chunk().appendString(
|
|
130043
|
+
ret = new chunk_1.Chunk().appendString(this.negation()).appendChunk(ret).appendString(")");
|
|
129050
130044
|
}
|
|
129051
130045
|
// console.dir("return: " + ret.getCode());
|
|
129052
130046
|
return ret;
|
|
@@ -129498,7 +130492,9 @@ class SQLCondTranspiler {
|
|
|
129498
130492
|
const operator = children[1];
|
|
129499
130493
|
const source = children[2];
|
|
129500
130494
|
if (!(fieldName instanceof abaplint.Nodes.ExpressionNode)
|
|
129501
|
-
|
|
130495
|
+
// field = structure-component, and tab~field = structure-component
|
|
130496
|
+
|| !(fieldName.get() instanceof abaplint.Expressions.SQLFieldName
|
|
130497
|
+
|| fieldName.get() instanceof abaplint.Expressions.SQLAliasField)
|
|
129502
130498
|
|| !(operator instanceof abaplint.Nodes.ExpressionNode)
|
|
129503
130499
|
|| !(operator.get() instanceof abaplint.Expressions.SQLCompareOperator)
|
|
129504
130500
|
|| !(source instanceof abaplint.Nodes.ExpressionNode)
|
|
@@ -129511,8 +130507,10 @@ class SQLCondTranspiler {
|
|
|
129511
130507
|
for (let i = 3; i < children.length; i += 2) {
|
|
129512
130508
|
const dash = children[i];
|
|
129513
130509
|
const component = children[i + 1];
|
|
130510
|
+
// the component selector is the token Dash; a minus sign is arithmetic
|
|
129514
130511
|
if (!(dash instanceof abaplint.Nodes.TokenNode)
|
|
129515
130512
|
|| dash.getFirstToken().getStr() !== "-"
|
|
130513
|
+
|| !(dash.getFirstToken() instanceof abaplint.Tokens.Dash)
|
|
129516
130514
|
|| !(component instanceof abaplint.Nodes.ExpressionNode)
|
|
129517
130515
|
|| !(component.get() instanceof abaplint.Expressions.SQLFieldName)) {
|
|
129518
130516
|
return undefined;
|
|
@@ -129777,11 +130775,24 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
|
|
|
129777
130775
|
const sql_field_1 = __webpack_require__(/*! ./sql_field */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field.js");
|
|
129778
130776
|
const sql_field_name_1 = __webpack_require__(/*! ./sql_field_name */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field_name.js");
|
|
129779
130777
|
class SQLFieldListTranspiler {
|
|
129780
|
-
|
|
130778
|
+
/**
|
|
130779
|
+
* byPosition: the rows are filled by position, but the database clients return
|
|
130780
|
+
* them keyed by column name, so two columns of one name (a~id b~id) come back as
|
|
130781
|
+
* one. Where a plain column repeats the name of another in the list, the entries
|
|
130782
|
+
* without an alias of their own get one, "#0", "#1", ... by position in the
|
|
130783
|
+
* list: a name no column or alias can have. A list without such a clash is
|
|
130784
|
+
* left exactly as it is.
|
|
130785
|
+
*/
|
|
130786
|
+
transpile(node, traversal, byPosition = false) {
|
|
130787
|
+
const clashing = byPosition ? this.clashingNames(node) : new Set();
|
|
129781
130788
|
const fields = [];
|
|
129782
130789
|
for (const f of node.getChildren() || []) {
|
|
129783
130790
|
if (f instanceof abaplint.Nodes.ExpressionNode && f.get() instanceof abaplint.Expressions.SQLField) {
|
|
129784
|
-
|
|
130791
|
+
let code = new sql_field_1.SQLFieldTranspiler().transpile(f, traversal).getCode();
|
|
130792
|
+
const column = this.plainColumn(f);
|
|
130793
|
+
if (column !== undefined && column.alias === false && clashing.has(column.name)) {
|
|
130794
|
+
code = code.trimEnd() + ` AS \\"#${fields.length}\\"`;
|
|
130795
|
+
}
|
|
129785
130796
|
fields.push(code);
|
|
129786
130797
|
}
|
|
129787
130798
|
else if (f instanceof abaplint.Nodes.ExpressionNode && f.get() instanceof abaplint.Expressions.SQLFieldName) {
|
|
@@ -129790,7 +130801,7 @@ class SQLFieldListTranspiler {
|
|
|
129790
130801
|
}
|
|
129791
130802
|
else if (f instanceof abaplint.Nodes.ExpressionNode && f.get() instanceof abaplint.Expressions.SQLFieldList) {
|
|
129792
130803
|
// todo, I have no idea why its nested like this when there is just one field
|
|
129793
|
-
return new SQLFieldListTranspiler().transpile(f, traversal);
|
|
130804
|
+
return new SQLFieldListTranspiler().transpile(f, traversal, byPosition);
|
|
129794
130805
|
}
|
|
129795
130806
|
else {
|
|
129796
130807
|
const concat = f.concatTokens();
|
|
@@ -129801,6 +130812,39 @@ class SQLFieldListTranspiler {
|
|
|
129801
130812
|
}
|
|
129802
130813
|
return new chunk_1.Chunk().append(fields.join(", "), node, traversal);
|
|
129803
130814
|
}
|
|
130815
|
+
// "col", "tab~col" or one of them with "AS name": the name its column has in the row
|
|
130816
|
+
plainColumn(field) {
|
|
130817
|
+
const children = field.getChildren();
|
|
130818
|
+
const first = children[0];
|
|
130819
|
+
if (!(first instanceof abaplint.Nodes.ExpressionNode) || !(first.get() instanceof abaplint.Expressions.SQLFieldName)) {
|
|
130820
|
+
return undefined;
|
|
130821
|
+
}
|
|
130822
|
+
const as = field.findDirectExpression(abaplint.Expressions.SQLAsName);
|
|
130823
|
+
if (children.length === 1) {
|
|
130824
|
+
return { name: first.concatTokens().split("~").pop().toLowerCase(), alias: false };
|
|
130825
|
+
}
|
|
130826
|
+
else if (children.length === 3 && as !== undefined && children[2] === as) {
|
|
130827
|
+
return { name: as.concatTokens().toLowerCase(), alias: true };
|
|
130828
|
+
}
|
|
130829
|
+
return undefined;
|
|
130830
|
+
}
|
|
130831
|
+
clashingNames(node) {
|
|
130832
|
+
const seen = new Set();
|
|
130833
|
+
const clashing = new Set();
|
|
130834
|
+
for (const f of node.getChildren() || []) {
|
|
130835
|
+
if (f instanceof abaplint.Nodes.ExpressionNode && f.get() instanceof abaplint.Expressions.SQLField) {
|
|
130836
|
+
const column = this.plainColumn(f);
|
|
130837
|
+
if (column === undefined) {
|
|
130838
|
+
continue;
|
|
130839
|
+
}
|
|
130840
|
+
else if (seen.has(column.name)) {
|
|
130841
|
+
clashing.add(column.name);
|
|
130842
|
+
}
|
|
130843
|
+
seen.add(column.name);
|
|
130844
|
+
}
|
|
130845
|
+
}
|
|
130846
|
+
return clashing;
|
|
130847
|
+
}
|
|
129804
130848
|
}
|
|
129805
130849
|
exports.SQLFieldListTranspiler = SQLFieldListTranspiler;
|
|
129806
130850
|
//# sourceMappingURL=sql_field_list.js.map
|
|
@@ -131790,7 +132834,8 @@ class HandleABAP {
|
|
|
131790
132834
|
output.chunk.runIndentationLogic(this.options?.ignoreSourceMap);
|
|
131791
132835
|
}
|
|
131792
132836
|
if (this.options?.addCommonJS === true) {
|
|
131793
|
-
|
|
132837
|
+
const owner = this.findOwnerRequiredByLocals(obj, ret);
|
|
132838
|
+
ret.map(output => output.chunk = this.addImportsAndExports(output, owner));
|
|
131794
132839
|
}
|
|
131795
132840
|
return ret;
|
|
131796
132841
|
}
|
|
@@ -131844,8 +132889,33 @@ class HandleABAP {
|
|
|
131844
132889
|
}
|
|
131845
132890
|
return ret;
|
|
131846
132891
|
}
|
|
131847
|
-
|
|
132892
|
+
/** A local class inheriting from its own global class: the locals module needs the owner
|
|
132893
|
+
* defined, and the owner module awaits the locals before it is defined. Under top-level await
|
|
132894
|
+
* that import cycle never settles. When the locals require the owner, the locals take it from
|
|
132895
|
+
* abap.Classes and the owner imports its locals right after registering itself, still before its
|
|
132896
|
+
* static values and class constructors, which may use the locals */
|
|
132897
|
+
findOwnerRequiredByLocals(obj, output) {
|
|
132898
|
+
if (!(obj instanceof abaplint.Objects.Class)) {
|
|
132899
|
+
return undefined;
|
|
132900
|
+
}
|
|
132901
|
+
const main = obj.getMainABAPFile()?.getFilename().replace(".abap", ".mjs").toLowerCase();
|
|
132902
|
+
const locals = output.find(o => o.filename.endsWith(".clas.locals.mjs"));
|
|
132903
|
+
if (main === undefined || locals === undefined
|
|
132904
|
+
|| locals.requires.some(r => r.filename.replace(".abap", ".mjs").toLowerCase() === main) === false) {
|
|
132905
|
+
return undefined;
|
|
132906
|
+
}
|
|
132907
|
+
const name = obj.getName();
|
|
132908
|
+
return {
|
|
132909
|
+
main: main,
|
|
132910
|
+
locals: locals.filename,
|
|
132911
|
+
registration: "abap.Classes['" + name.toUpperCase() + "'] = " + traversal_1.Traversal.escapeNamespace(name.toLowerCase()) + ";",
|
|
132912
|
+
lookup: "abap.Classes['" + name.toUpperCase() + "']",
|
|
132913
|
+
};
|
|
132914
|
+
}
|
|
132915
|
+
addImportsAndExports(output, deferred) {
|
|
131848
132916
|
const contents = new chunk_1.Chunk();
|
|
132917
|
+
const isMain = deferred !== undefined && output.filename === deferred.main;
|
|
132918
|
+
const isLocals = deferred !== undefined && output.filename === deferred.locals;
|
|
131849
132919
|
for (const r of output.requires) {
|
|
131850
132920
|
const name = r.name?.toLowerCase();
|
|
131851
132921
|
const filename = r.filename.replace(".abap", ".mjs");
|
|
@@ -131853,6 +132923,18 @@ class HandleABAP {
|
|
|
131853
132923
|
continue;
|
|
131854
132924
|
}
|
|
131855
132925
|
const specifier = (0, output_layout_1.importPath)(this.layout.file(output.object, output.filename), this.layout.sourceModule(r.filename));
|
|
132926
|
+
if (isMain && filename.toLowerCase() === deferred.locals) {
|
|
132927
|
+
const occurrences = output.chunk.getCode().split(deferred.registration).length - 1;
|
|
132928
|
+
if (occurrences !== 1) {
|
|
132929
|
+
throw new Error("HandleABAP, class registration not found once in " + output.filename + ", cannot defer its locals");
|
|
132930
|
+
}
|
|
132931
|
+
output.chunk.replaceAll(deferred.registration, deferred.registration + "\nawait import(\"" + specifier + "\");");
|
|
132932
|
+
continue;
|
|
132933
|
+
}
|
|
132934
|
+
else if (isLocals && filename.toLowerCase() === deferred.main && name) {
|
|
132935
|
+
contents.appendString("const " + traversal_1.Traversal.escapeNamespace(name) + " = " + deferred.lookup + ";\n");
|
|
132936
|
+
continue;
|
|
132937
|
+
}
|
|
131856
132938
|
if (name) {
|
|
131857
132939
|
contents.appendString("const {" + traversal_1.Traversal.escapeNamespace(name) + "} = await import(\"" + specifier + "\");\n");
|
|
131858
132940
|
}
|
|
@@ -133672,6 +134754,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
133672
134754
|
exports.Requires = void 0;
|
|
133673
134755
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
133674
134756
|
const program_includes_1 = __webpack_require__(/*! ./program_includes */ "./node_modules/@abaplint/transpiler/build/src/program_includes.js");
|
|
134757
|
+
const constant_value_1 = __webpack_require__(/*! ./constant_value */ "./node_modules/@abaplint/transpiler/build/src/constant_value.js");
|
|
133675
134758
|
class Requires {
|
|
133676
134759
|
reg;
|
|
133677
134760
|
constructor(reg) {
|
|
@@ -133681,7 +134764,7 @@ class Requires {
|
|
|
133681
134764
|
find(obj, _node, filename) {
|
|
133682
134765
|
const ret = [];
|
|
133683
134766
|
if (obj.getType() === "INTF") {
|
|
133684
|
-
return
|
|
134767
|
+
return this.constantSources(obj, filename);
|
|
133685
134768
|
}
|
|
133686
134769
|
const add = function (req) {
|
|
133687
134770
|
if (req === undefined || req.filename === filename) {
|
|
@@ -133774,6 +134857,31 @@ class Requires {
|
|
|
133774
134857
|
}
|
|
133775
134858
|
return ret;
|
|
133776
134859
|
}
|
|
134860
|
+
/** the global objects whose constants an interface reads at load: a constant whose VALUE
|
|
134861
|
+
* leads to a class constant, or to an object no analysis knows (constant_value.ts) */
|
|
134862
|
+
constantSources(obj, filename) {
|
|
134863
|
+
const ret = [];
|
|
134864
|
+
for (const file of obj.getABAPFiles()) {
|
|
134865
|
+
for (const statement of file.getStatements()) {
|
|
134866
|
+
if (!(statement.get() instanceof abaplint.Statements.Constant)) {
|
|
134867
|
+
continue;
|
|
134868
|
+
}
|
|
134869
|
+
const chain = statement.findDirectExpression(abaplint.Expressions.Value)?.getChildren()[1];
|
|
134870
|
+
if (!(chain instanceof abaplint.Nodes.ExpressionNode) || !(chain.get() instanceof abaplint.Expressions.SimpleFieldChain)) {
|
|
134871
|
+
continue;
|
|
134872
|
+
}
|
|
134873
|
+
const source = (0, constant_value_1.constantSource)(this.reg, chain);
|
|
134874
|
+
if (source.kind !== "member" || source.object.getName().toUpperCase() === obj.getName().toUpperCase()) {
|
|
134875
|
+
continue;
|
|
134876
|
+
}
|
|
134877
|
+
const main = source.object.getMainABAPFile()?.getFilename();
|
|
134878
|
+
if (main && main !== filename && ret.some(r => r.filename === main) === false) {
|
|
134879
|
+
ret.push({ filename: main, name: undefined });
|
|
134880
|
+
}
|
|
134881
|
+
}
|
|
134882
|
+
}
|
|
134883
|
+
return ret;
|
|
134884
|
+
}
|
|
133777
134885
|
}
|
|
133778
134886
|
exports.Requires = Requires;
|
|
133779
134887
|
//# sourceMappingURL=requires.js.map
|
|
@@ -140239,6 +141347,7 @@ __exportStar(__webpack_require__(/*! ./replace */ "./node_modules/@abaplint/tran
|
|
|
140239
141347
|
__exportStar(__webpack_require__(/*! ./report */ "./node_modules/@abaplint/transpiler/build/src/statements/report.js"), exports);
|
|
140240
141348
|
__exportStar(__webpack_require__(/*! ./reserve */ "./node_modules/@abaplint/transpiler/build/src/statements/reserve.js"), exports);
|
|
140241
141349
|
__exportStar(__webpack_require__(/*! ./retry */ "./node_modules/@abaplint/transpiler/build/src/statements/retry.js"), exports);
|
|
141350
|
+
__exportStar(__webpack_require__(/*! ./resume */ "./node_modules/@abaplint/transpiler/build/src/statements/resume.js"), exports);
|
|
140242
141351
|
__exportStar(__webpack_require__(/*! ./return */ "./node_modules/@abaplint/transpiler/build/src/statements/return.js"), exports);
|
|
140243
141352
|
__exportStar(__webpack_require__(/*! ./rollback */ "./node_modules/@abaplint/transpiler/build/src/statements/rollback.js"), exports);
|
|
140244
141353
|
__exportStar(__webpack_require__(/*! ./rollback_entities */ "./node_modules/@abaplint/transpiler/build/src/statements/rollback_entities.js"), exports);
|
|
@@ -142025,8 +143134,12 @@ class MoveTranspiler {
|
|
|
142025
143134
|
? this.correspondingGeneric(sourceExpression, targets[0], traversal)
|
|
142026
143135
|
: undefined;
|
|
142027
143136
|
if (source === undefined) {
|
|
142028
|
-
|
|
142029
|
-
|
|
143137
|
+
let calculation = this.integerCalculation(node, sourceExpression, targetExpressions.length, traversal);
|
|
143138
|
+
if (calculation === "i" && second !== "=") {
|
|
143139
|
+
calculation = undefined;
|
|
143140
|
+
}
|
|
143141
|
+
source = calculation !== undefined
|
|
143142
|
+
? new source_1.SourceTranspiler(false, calculation).transpile(sourceExpression, traversal)
|
|
142030
143143
|
: traversal.traverse(sourceExpression);
|
|
142031
143144
|
}
|
|
142032
143145
|
switch (second) {
|
|
@@ -142111,20 +143224,43 @@ class MoveTranspiler {
|
|
|
142111
143224
|
// when the target or an operand is int8: i * i into int8 is exact up to 2^62, and "/"
|
|
142112
143225
|
// rounds. The runtime decides by the operands alone and does not know the target, so here
|
|
142113
143226
|
// the operands are converted to int8 before the calculation. Only for an i or int8 target
|
|
142114
|
-
// and operands whose type is known to be i or int8, and not for **, which counts as f
|
|
142115
|
-
|
|
143227
|
+
// and operands whose type is known to be i or int8, and not for **, which counts as f.
|
|
143228
|
+
// With a p, f or decfloat34 target the calculation type is that of the target, and an int8
|
|
143229
|
+
// result outside the int8 range is no overflow: the operands are converted to decfloat34,
|
|
143230
|
+
// exact for sums, differences and products of int8, so the runtime does not raise for them.
|
|
143231
|
+
// With an i target and operands of type i only it is i, and then "+", "-" and "*" raise
|
|
143232
|
+
// CX_SY_ARITHMETIC_OVERFLOW outside the range of i: SourceTranspiler picks the operators that
|
|
143233
|
+
// check it. An expression with "/", DIV or MOD keeps the unchecked operators for now
|
|
143234
|
+
integerCalculation(node, source, targets, traversal) {
|
|
142116
143235
|
if (source === undefined
|
|
142117
143236
|
|| targets !== 1
|
|
142118
143237
|
|| source.findFirstExpression(abaplint.Expressions.ArithOperator) === undefined) {
|
|
142119
|
-
return
|
|
143238
|
+
return undefined;
|
|
142120
143239
|
}
|
|
142121
143240
|
const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
|
|
142122
143241
|
const target = traversal.determineType(node, scope);
|
|
143242
|
+
const wide = target instanceof abaplint.BasicTypes.PackedType
|
|
143243
|
+
|| target instanceof abaplint.BasicTypes.FloatType
|
|
143244
|
+
|| target instanceof abaplint.BasicTypes.DecFloat34Type;
|
|
142123
143245
|
const found = { int8: target instanceof abaplint.BasicTypes.Integer8Type };
|
|
142124
|
-
if (found.int8 === false && !(target instanceof abaplint.BasicTypes.IntegerType)) {
|
|
142125
|
-
return
|
|
143246
|
+
if (found.int8 === false && wide === false && !(target instanceof abaplint.BasicTypes.IntegerType)) {
|
|
143247
|
+
return undefined;
|
|
143248
|
+
}
|
|
143249
|
+
else if (this.integerOperands(source, scope, found) === false) {
|
|
143250
|
+
return undefined;
|
|
143251
|
+
}
|
|
143252
|
+
else if (found.int8 === false) {
|
|
143253
|
+
const division = source.findAllExpressions(abaplint.Expressions.ArithOperator)
|
|
143254
|
+
.some(o => ["/", "DIV", "MOD"].includes(o.concatTokens().toUpperCase()));
|
|
143255
|
+
return wide === false && division === false ? "i" : undefined;
|
|
142126
143256
|
}
|
|
142127
|
-
|
|
143257
|
+
else if (wide === true) {
|
|
143258
|
+
// DIV and MOD of a decfloat34 go through a double in the runtime, they stay int8
|
|
143259
|
+
const divMod = source.findAllExpressions(abaplint.Expressions.ArithOperator)
|
|
143260
|
+
.some(o => ["DIV", "MOD"].includes(o.concatTokens().toUpperCase()));
|
|
143261
|
+
return divMod ? undefined : "decfloat34";
|
|
143262
|
+
}
|
|
143263
|
+
return "int8";
|
|
142128
143264
|
}
|
|
142129
143265
|
integerOperands(node, scope, found) {
|
|
142130
143266
|
for (const c of node.getChildren()) {
|
|
@@ -142987,9 +144123,7 @@ const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/
|
|
|
142987
144123
|
const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
|
|
142988
144124
|
class RaiseTranspiler {
|
|
142989
144125
|
transpile(node, traversal) {
|
|
142990
|
-
|
|
142991
|
-
throw new Error("RaiseTranspiler, RESUMABLE not implemented");
|
|
142992
|
-
}
|
|
144126
|
+
// RESUMABLE: the exception is raised as any other, a handler that does not RESUME sees no difference
|
|
142993
144127
|
const classNameToken = node.findFirstExpression(abaplint.Expressions.ClassName)?.getFirstToken();
|
|
142994
144128
|
const className = classNameToken?.getStr();
|
|
142995
144129
|
if (className === undefined) {
|
|
@@ -143938,6 +145072,27 @@ exports.ReserveTranspiler = ReserveTranspiler;
|
|
|
143938
145072
|
|
|
143939
145073
|
/***/ },
|
|
143940
145074
|
|
|
145075
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/statements/resume.js"
|
|
145076
|
+
/*!**************************************************************************!*\
|
|
145077
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/statements/resume.js ***!
|
|
145078
|
+
\**************************************************************************/
|
|
145079
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
145080
|
+
|
|
145081
|
+
"use strict";
|
|
145082
|
+
|
|
145083
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
145084
|
+
exports.ResumeTranspiler = void 0;
|
|
145085
|
+
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
145086
|
+
class ResumeTranspiler {
|
|
145087
|
+
transpile(_node, _traversal) {
|
|
145088
|
+
return new chunk_1.Chunk(`throw new Error("RESUME, not supported, transpiler");`);
|
|
145089
|
+
}
|
|
145090
|
+
}
|
|
145091
|
+
exports.ResumeTranspiler = ResumeTranspiler;
|
|
145092
|
+
//# sourceMappingURL=resume.js.map
|
|
145093
|
+
|
|
145094
|
+
/***/ },
|
|
145095
|
+
|
|
143941
145096
|
/***/ "./node_modules/@abaplint/transpiler/build/src/statements/retry.js"
|
|
143942
145097
|
/*!*************************************************************************!*\
|
|
143943
145098
|
!*** ./node_modules/@abaplint/transpiler/build/src/statements/retry.js ***!
|
|
@@ -144298,7 +145453,7 @@ function escapeRegExp(string) {
|
|
|
144298
145453
|
}
|
|
144299
145454
|
// TODO: currently SELECT into are always handled as CORRESPONDING
|
|
144300
145455
|
class SelectTranspiler {
|
|
144301
|
-
transpile(node, traversal, targetOverride) {
|
|
145456
|
+
transpile(node, traversal, targetOverride, overrideOptions = [], columnsByPosition = false) {
|
|
144302
145457
|
if (node.findDirectTokenByText("UNION") !== undefined) {
|
|
144303
145458
|
return new chunk_1.Chunk(`throw new Error("SELECT UNION, not supported, transpiler, todo");`);
|
|
144304
145459
|
}
|
|
@@ -144337,7 +145492,7 @@ class SelectTranspiler {
|
|
|
144337
145492
|
if (fieldList === undefined) {
|
|
144338
145493
|
throw new Error("SelectTranspiler, field list not found");
|
|
144339
145494
|
}
|
|
144340
|
-
select += new expressions_1.SQLFieldListTranspiler().transpile(fieldList, traversal).getCode() + " ";
|
|
145495
|
+
select += new expressions_1.SQLFieldListTranspiler().transpile(fieldList, traversal, columnsByPosition).getCode() + " ";
|
|
144341
145496
|
const from = node.findFirstExpression(abaplint.Expressions.SQLFrom);
|
|
144342
145497
|
if (from) {
|
|
144343
145498
|
select += new sql_from_1.SQLFromTranspiler().transpile(from, traversal).getCode();
|
|
@@ -144422,7 +145577,10 @@ class SelectTranspiler {
|
|
|
144422
145577
|
select += "UP TO 1 ROWS";
|
|
144423
145578
|
}
|
|
144424
145579
|
let runtimeOptions = "";
|
|
144425
|
-
|
|
145580
|
+
// the SelectLoop structure passes its options for its buffer table
|
|
145581
|
+
const runtimeOptionsList = [...overrideOptions];
|
|
145582
|
+
const appendingOptions = ["appending: true", ...overrideOptions].join(", ");
|
|
145583
|
+
const loopOptions = overrideOptions.length > 0 ? `, {${overrideOptions.join(", ")}}` : "";
|
|
144426
145584
|
if (concat.includes(" APPENDING TABLE ") || concat.includes(" APPENDING CORRESPONDING FIELDS OF TABLE ")) {
|
|
144427
145585
|
runtimeOptionsList.push(`appending: true`);
|
|
144428
145586
|
}
|
|
@@ -144464,12 +145622,12 @@ await abap.statements.deleteInternal(${target}, {adjacent: true, allFields: true
|
|
|
144464
145622
|
// trim after the de-duplicating sort, so that pair stays row by row
|
|
144465
145623
|
if (concat.startsWith("SELECT SINGLE ") || at < 0 || (upTo && orderBy)) {
|
|
144466
145624
|
const code = `if (${faeTranspiled}.array().length === 0) {
|
|
144467
|
-
await abap.statements.select(${target}, {select: "${selectEmpty.trim()}"${extra}});
|
|
145625
|
+
await abap.statements.select(${target}, {select: "${selectEmpty.trim()}"${extra}}${loopOptions});
|
|
144468
145626
|
} else {
|
|
144469
145627
|
const ${unique2} = ${faeTranspiled}.array();
|
|
144470
145628
|
${target}.clear();
|
|
144471
145629
|
for await (const ${unique} of ${unique2}) {
|
|
144472
|
-
await abap.statements.select(${target}, {select: "${select.trim()}"${extra}}, {
|
|
145630
|
+
await abap.statements.select(${target}, {select: "${select.trim()}"${extra}}, {${appendingOptions}});
|
|
144473
145631
|
}
|
|
144474
145632
|
${dedup}
|
|
144475
145633
|
abap.builtin.sy.get().dbcnt.set(${target}.getArrayLength());
|
|
@@ -144500,14 +145658,14 @@ abap.builtin.sy.get().dbcnt.set(${target}.getArrayLength());
|
|
|
144500
145658
|
const unique3 = unique_identifier_1.UniqueIdentifier.get();
|
|
144501
145659
|
const unique4 = unique_identifier_1.UniqueIdentifier.get();
|
|
144502
145660
|
const code = `if (${faeTranspiled}.array().length === 0) {
|
|
144503
|
-
await abap.statements.select(${target}, {select: "${selectEmpty.trim()}"${extra}});
|
|
145661
|
+
await abap.statements.select(${target}, {select: "${selectEmpty.trim()}"${extra}}${loopOptions});
|
|
144504
145662
|
} else {
|
|
144505
145663
|
const ${unique2} = ${faeTranspiled}.array();
|
|
144506
145664
|
${target}.clear();
|
|
144507
145665
|
const ${unique3} = (${unique}) => "(${condition})";
|
|
144508
145666
|
for (let ${unique4} = 0; ${unique4} < ${unique2}.length; ${unique4} += 50) {
|
|
144509
145667
|
const ${unique4}where = ${unique2}.slice(${unique4}, ${unique4} + 50).map(${unique3}).join(" OR ");
|
|
144510
|
-
await abap.statements.select(${target}, {select: "${head}WHERE " + ${unique4}where + " ${tail.trim()}"${extra}}, {
|
|
145668
|
+
await abap.statements.select(${target}, {select: "${head}WHERE " + ${unique4}where + " ${tail.trim()}"${extra}}, {${appendingOptions}});
|
|
144511
145669
|
}
|
|
144512
145670
|
${dedup}
|
|
144513
145671
|
const ${unique4}max = ${upToCode};
|
|
@@ -144548,9 +145706,12 @@ abap.builtin.sy.get().dbcnt.set(${target}.getArrayLength());
|
|
|
144548
145706
|
+ ` : ${code}.get())`;
|
|
144549
145707
|
}
|
|
144550
145708
|
dynamicSQLClause(keyword, code) {
|
|
145709
|
+
// a dynamic ORDER BY may separate its columns with blanks, as Open SQL
|
|
145710
|
+
// allows; abap.dynamicOrderBy puts the commas SQL needs between them
|
|
145711
|
+
const list = (text) => keyword === "ORDER BY" ? `abap.dynamicOrderBy(${text})` : text;
|
|
144551
145712
|
return `(${code} instanceof abap.types.Table || ${code} instanceof abap.types.HashedTable`
|
|
144552
|
-
+ ` ? (${code}.array().length === 0 ? "" : "${keyword} " + ${code}.array().map(row => row.get()).join(", "))`
|
|
144553
|
-
+ ` : (("" + ${code}.get()).trim() === "" ? "" : "${keyword} " + ${code}.get()))`;
|
|
145713
|
+
+ ` ? (${code}.array().length === 0 ? "" : "${keyword} " + ${list(`${code}.array().map(row => row.get()).join(", ")`)})`
|
|
145714
|
+
+ ` : (("" + ${code}.get()).trim() === "" ? "" : "${keyword} " + ${list(`${code}.get()`)}))`;
|
|
144554
145715
|
}
|
|
144555
145716
|
dynamicHavingClause(code) {
|
|
144556
145717
|
return `((value) => {
|
|
@@ -148379,6 +149540,7 @@ const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_
|
|
|
148379
149540
|
const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
|
|
148380
149541
|
const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
|
|
148381
149542
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
149543
|
+
const constant_value_1 = __webpack_require__(/*! ../constant_value */ "./node_modules/@abaplint/transpiler/build/src/constant_value.js");
|
|
148382
149544
|
class InterfaceTranspiler {
|
|
148383
149545
|
transpile(node, traversal) {
|
|
148384
149546
|
let ret = "";
|
|
@@ -148450,10 +149612,26 @@ class InterfaceTranspiler {
|
|
|
148450
149612
|
}
|
|
148451
149613
|
const constantStatement = traversal.findStatementInFile(identifier.getStart());
|
|
148452
149614
|
const valExpression = constantStatement?.findFirstExpression(abaplint.Expressions.Value);
|
|
148453
|
-
|
|
148454
|
-
|
|
148455
|
-
|
|
148456
|
-
|
|
149615
|
+
// VALUE other=>constant: followed to the constant that declares the value
|
|
149616
|
+
// (constant_value.ts). An interface literal is written as the literal, so interfaces
|
|
149617
|
+
// naming each other's constants have no load-time edge; a class constant, which the class
|
|
149618
|
+
// may set at run time, is read at load from that class, which requires.ts loads first
|
|
149619
|
+
const chain = valExpression?.getChildren()[1];
|
|
149620
|
+
if (chain instanceof abaplint.Nodes.ExpressionNode && chain.get() instanceof abaplint.Expressions.SimpleFieldChain) {
|
|
149621
|
+
const source = (0, constant_value_1.constantSource)(traversal.reg, chain);
|
|
149622
|
+
if (source.kind === "literal") {
|
|
149623
|
+
ret += name + ".set(" + expressions_1.ConstantTranspiler.escape(expressions_1.ConstantTranspiler.trimTextFieldLiteral(source.value)) + ");\n";
|
|
149624
|
+
}
|
|
149625
|
+
else if (source.kind === "member") {
|
|
149626
|
+
ret += name + ".set(" + (0, constant_value_1.memberRead)(source) + ");\n";
|
|
149627
|
+
}
|
|
149628
|
+
else if (source.kind === "initial") {
|
|
149629
|
+
ret += name + ".set(" + traversal.toType(source.type) + ");\n";
|
|
149630
|
+
}
|
|
149631
|
+
else {
|
|
149632
|
+
const s = new expressions_1.FieldChainTranspiler().transpile(chain, traversal, false).getCode();
|
|
149633
|
+
ret += name + ".set(" + expressions_1.ConstantTranspiler.escape(s) + ");\n";
|
|
149634
|
+
}
|
|
148457
149635
|
continue;
|
|
148458
149636
|
}
|
|
148459
149637
|
ret += traversal.setValues(identifier, name);
|
|
@@ -149005,8 +150183,60 @@ class SelectTranspiler {
|
|
|
149005
150183
|
// note: this implementation SELECTs everything into memory, which might be bad, and sometimes not correct
|
|
149006
150184
|
const targetName = unique_identifier_1.UniqueIdentifier.get();
|
|
149007
150185
|
const loopName = unique_identifier_1.UniqueIdentifier.get();
|
|
149008
|
-
|
|
149009
|
-
const
|
|
150186
|
+
// the sources of the loop's own FROM, not those of a subquery in its WHERE
|
|
150187
|
+
const sources = selectStatement.findFirstExpression(abaplint.Expressions.SQLFrom)
|
|
150188
|
+
?.findAllExpressions(abaplint.Expressions.SQLFromSource) ?? [];
|
|
150189
|
+
const aliased = sources[0]?.findDirectExpression(abaplint.Expressions.SQLAsName) !== undefined;
|
|
150190
|
+
const table = sources[0]?.findDirectExpression(abaplint.Expressions.DatabaseTable)?.concatTokens().toUpperCase();
|
|
150191
|
+
const intoList = selectStatement.findFirstExpression(abaplint.Expressions.SQLIntoList);
|
|
150192
|
+
const loopOptions = [];
|
|
150193
|
+
let assign;
|
|
150194
|
+
if (intoList) {
|
|
150195
|
+
// INTO (a, b, c): the buffer row has one component per target, filled
|
|
150196
|
+
// from the columns left to right, and every target is assigned per row
|
|
150197
|
+
const targets = intoList.findDirectExpressions(abaplint.Expressions.SQLTarget)
|
|
150198
|
+
.map(t => new expressions_1.SQLTargetTranspiler().transpile(t, traversal).getCode());
|
|
150199
|
+
const components = targets.map((t, i) => `"c${i}": ${this.cloneOf(t)}`);
|
|
150200
|
+
ret.appendString(`let ${targetName} = new abap.types.Table(new abap.types.Structure({${components.join(", ")}}));\n`);
|
|
150201
|
+
loopOptions.push("positional: true");
|
|
150202
|
+
assign = targets.map((t, i) => `${t}.set(${loopName}.get().c${i});\n`).join("");
|
|
150203
|
+
}
|
|
150204
|
+
else {
|
|
150205
|
+
if (aliased && sources.length === 1 && table !== undefined) {
|
|
150206
|
+
// "tab AS a" is no DDIC name, the row type is that of the table
|
|
150207
|
+
ret.appendString(`let ${targetName} = new abap.types.Table(abap.DDIC["${table}"].type());\n`);
|
|
150208
|
+
}
|
|
150209
|
+
else if (aliased && sTarget !== undefined) {
|
|
150210
|
+
const intoTable = selectStatement.findFirstExpression(abaplint.Expressions.SQLIntoTable);
|
|
150211
|
+
if (intoTable) {
|
|
150212
|
+
// PACKAGE SIZE ... INTO TABLE over a join that starts with "tab AS a": the
|
|
150213
|
+
// buffer holds rows of the target table's row type, filled as below
|
|
150214
|
+
ret.appendString(`let ${targetName} = new abap.types.Table(${this.pointerOf(intoName)}.getRowType());\n`);
|
|
150215
|
+
if (intoTable.findDirectTokenByText("CORRESPONDING") === undefined) {
|
|
150216
|
+
loopOptions.push("positional: true");
|
|
150217
|
+
}
|
|
150218
|
+
}
|
|
150219
|
+
else {
|
|
150220
|
+
// a join that starts with "tab AS a" has no row type to look up, the buffer
|
|
150221
|
+
// takes the work area's; without CORRESPONDING it is filled left to right
|
|
150222
|
+
ret.appendString(`let ${targetName} = new abap.types.Table(${this.cloneOf(intoName)});\n`);
|
|
150223
|
+
if (concat.includes(" INTO CORRESPONDING FIELDS OF ") === false) {
|
|
150224
|
+
loopOptions.push("positional: true");
|
|
150225
|
+
}
|
|
150226
|
+
}
|
|
150227
|
+
}
|
|
150228
|
+
else {
|
|
150229
|
+
ret.appendString(`let ${targetName} = new abap.types.Table(abap.DDIC["${from}"].type());\n`);
|
|
150230
|
+
}
|
|
150231
|
+
if (concat.includes(" INTO CORRESPONDING FIELDS OF ")) {
|
|
150232
|
+
assign = `abap.statements.moveCorresponding(${loopName}, ${intoName});\n`;
|
|
150233
|
+
}
|
|
150234
|
+
else {
|
|
150235
|
+
assign = `${intoName}.set(${loopName});\n`;
|
|
150236
|
+
}
|
|
150237
|
+
}
|
|
150238
|
+
// INTO (a, b, c) is filled by position: two columns of one name get an alias
|
|
150239
|
+
const selectHead = new select_1.SelectTranspiler().transpile(selectStatement, traversal, targetName, loopOptions, intoList !== undefined);
|
|
149010
150240
|
ret.appendChunk(selectHead.ensureStartMapping(selectStatement, traversal));
|
|
149011
150241
|
// todo: optimize, it should do real streaming?
|
|
149012
150242
|
const packageSize = selectStatement.findFirstExpression(abaplint.Expressions.SQLPackageSize)
|
|
@@ -149019,13 +150249,22 @@ class SelectTranspiler {
|
|
|
149019
150249
|
abap.statements.append({source: ${targetName}, target: ${intoName}, lines: true});
|
|
149020
150250
|
{\n`);
|
|
149021
150251
|
}
|
|
149022
|
-
else if (concat.includes(" INTO CORRESPONDING FIELDS OF ")) {
|
|
149023
|
-
ret.appendString(`\nfor (const ${loopName} of ${targetName}.array()) {\n`);
|
|
149024
|
-
ret.appendString(`abap.statements.moveCorresponding(${loopName}, ${intoName});\n`);
|
|
149025
|
-
}
|
|
149026
150252
|
else {
|
|
149027
|
-
|
|
149028
|
-
|
|
150253
|
+
// every pass sets sy-dbcnt to the number of rows passed so far and sy-subrc
|
|
150254
|
+
// to 0; ENDSELECT sets both once more when the rows run out, which an EXIT
|
|
150255
|
+
// does not reach
|
|
150256
|
+
const countName = unique_identifier_1.UniqueIdentifier.get();
|
|
150257
|
+
ret.appendString(`\nlet ${countName} = 0;
|
|
150258
|
+
for (;;) {
|
|
150259
|
+
const ${loopName} = ${targetName}.array()[${countName}];
|
|
150260
|
+
if (${loopName} === undefined) {
|
|
150261
|
+
abap.builtin.sy.get().dbcnt.set(${countName});
|
|
150262
|
+
abap.builtin.sy.get().subrc.set(${countName} > 0 ? 0 : 4);
|
|
150263
|
+
break;
|
|
150264
|
+
}
|
|
150265
|
+
abap.builtin.sy.get().dbcnt.set(++${countName});
|
|
150266
|
+
abap.builtin.sy.get().subrc.set(0);\n`);
|
|
150267
|
+
ret.appendString(assign);
|
|
149029
150268
|
}
|
|
149030
150269
|
const body = node.findDirectStructure(abaplint.Structures.Body);
|
|
149031
150270
|
if (body) {
|
|
@@ -149034,6 +150273,13 @@ abap.statements.append({source: ${targetName}, target: ${intoName}, lines: true}
|
|
|
149034
150273
|
ret.appendString("}\n");
|
|
149035
150274
|
return ret;
|
|
149036
150275
|
}
|
|
150276
|
+
// a fresh value of the target's type, also when the target is a field symbol
|
|
150277
|
+
cloneOf(code) {
|
|
150278
|
+
return `${this.pointerOf(code)}.clone()`;
|
|
150279
|
+
}
|
|
150280
|
+
pointerOf(code) {
|
|
150281
|
+
return `(${code} instanceof abap.types.FieldSymbol ? ${code}.getPointer() : ${code})`;
|
|
150282
|
+
}
|
|
149037
150283
|
}
|
|
149038
150284
|
exports.SelectTranspiler = SelectTranspiler;
|
|
149039
150285
|
//# sourceMappingURL=select.js.map
|