@abaplint/transpiler-cli 2.14.36 → 2.14.38
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 +1606 -463
- package/package.json +3 -3
package/build/bundle.js
CHANGED
|
@@ -4613,19 +4613,18 @@ function buildSelectCore(allowInto = false, allowOrderBy = true) {
|
|
|
4613
4613
|
const fae = (0, combi_1.optPrio)(_1.SQLForAllEntries);
|
|
4614
4614
|
const whereClause = (0, combi_1.optPrio)(where);
|
|
4615
4615
|
const groupHaving = (0, combi_1.seq)((0, combi_1.optPrio)(sql_group_by_1.SQLGroupBy), (0, combi_1.optPrio)(_1.SQLHaving));
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
: [];
|
|
4616
|
+
// UP TO and OFFSET are not allowed directly after ORDER BY, they go before it or after a trailing INTO
|
|
4617
|
+
const orderBy = allowOrderBy ? [(0, combi_1.optPrio)(_1.SQLOrderBy)] : [];
|
|
4619
4618
|
const trailingOpts = (0, combi_1.seq)(conn, (0, combi_1.optPrio)(_1.SQLHints), (0, combi_1.optPrio)(privileged), (0, combi_1.optPrio)(_1.SQLOptions));
|
|
4620
4619
|
const intoSingle = (0, combi_1.seq)((0, combi_1.altPrio)(sql_into_structure_1.SQLIntoStructure, _1.SQLIntoList), extResult, creating);
|
|
4621
4620
|
const intoForPackSize = (0, combi_1.seq)(_1.SQLIntoTable, extResult, creating);
|
|
4622
4621
|
if (!allowInto) {
|
|
4623
|
-
const afterFromNoInto = (0, combi_1.seq)(_1.SQLFrom, client, byp, (0, combi_1.seq)((0, combi_1.optPrio)(sqlFields), fae, whereClause, groupHaving, ...
|
|
4622
|
+
const afterFromNoInto = (0, combi_1.seq)(_1.SQLFrom, client, byp, (0, combi_1.seq)((0, combi_1.optPrio)(sqlFields), fae, whereClause, groupHaving, ...orderBy, trailingOpts));
|
|
4624
4623
|
return (0, combi_1.altPrio)((0, combi_1.seq)("SINGLE", buildSelectSingleCore(false)), (0, combi_1.seq)((0, combi_1.optPrio)("DISTINCT"), fieldList, byp, afterFromNoInto));
|
|
4625
4624
|
}
|
|
4626
4625
|
const fromPackSize = (0, combi_1.seq)((0, combi_1.optPrio)(_1.SQLPackageSize), (0, combi_1.optPrio)(sql_up_to_1.SQLUpTo), byp, conn, byp, (0, combi_1.optPrio)(sql_up_to_1.SQLUpTo));
|
|
4627
4626
|
const trailingInto = (0, combi_1.seq)((0, combi_1.optPrio)((0, combi_1.altPrio)((0, combi_1.seq)(intoForPackSize, (0, combi_1.optPrio)(_1.SQLPackageSize), byp, (0, combi_1.optPrio)(sql_up_to_1.SQLUpTo), byp, (0, combi_1.optPrio)(offset), (0, combi_1.optPrio)(_1.SQLOrderBy)), (0, combi_1.seq)(intoSingle, byp, (0, combi_1.optPrio)(sql_up_to_1.SQLUpTo), byp, (0, combi_1.optPrio)(offset)))), (0, combi_1.optPrio)(_1.SQLOptions));
|
|
4628
|
-
const afterFromWithInto = (0, combi_1.seq)((0, combi_1.optPrio)(_1.SQLFrom), client, byp, fromPackSize, (0, combi_1.altPrio)((0, combi_1.seq)(intoForPackSize, (0, combi_1.optPrio)(_1.SQLPackageSize), byp, conn, (0, combi_1.optPrio)(sql_up_to_1.SQLUpTo), byp, (0, combi_1.optPrio)(offset), fae, whereClause, groupHaving, ...
|
|
4627
|
+
const afterFromWithInto = (0, combi_1.seq)((0, combi_1.optPrio)(_1.SQLFrom), client, byp, fromPackSize, (0, combi_1.altPrio)((0, combi_1.seq)(intoForPackSize, (0, combi_1.optPrio)(_1.SQLPackageSize), byp, conn, (0, combi_1.optPrio)(sql_up_to_1.SQLUpTo), byp, (0, combi_1.optPrio)(offset), fae, whereClause, groupHaving, ...orderBy, trailingOpts), (0, combi_1.seq)(intoSingle, byp, (0, combi_1.optPrio)(sql_up_to_1.SQLUpTo), byp, fae, (0, combi_1.optPrio)(sql_up_to_1.SQLUpTo), byp, (0, combi_1.optPrio)(offset), whereClause, groupHaving, ...orderBy, trailingOpts), (0, combi_1.seq)((0, combi_1.optPrio)(sqlFields), fae, whereClause, groupHaving, ...orderBy, trailingOpts, trailingInto)));
|
|
4629
4628
|
const selectTableIntoThenFrom = (0, combi_1.seq)(intoForPackSize, (0, combi_1.optPrio)(_1.SQLPackageSize));
|
|
4630
4629
|
const selectOtherIntoThenFrom = intoSingle;
|
|
4631
4630
|
const nonSingleBody = (0, combi_1.seq)((0, combi_1.optPrio)("DISTINCT"), fieldList, (0, combi_1.optPrio)(sql_up_to_1.SQLUpTo), byp, (0, combi_1.optPrio)((0, combi_1.altPrio)(selectTableIntoThenFrom, selectOtherIntoThenFrom)), (0, combi_1.optPrio)(sql_up_to_1.SQLUpTo), byp, conn, afterFromWithInto);
|
|
@@ -5589,10 +5588,14 @@ exports.CorrespondingBodyBase = CorrespondingBodyBase;
|
|
|
5589
5588
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5590
5589
|
exports.CorrespondingBodyMapping = void 0;
|
|
5591
5590
|
const combi_1 = __webpack_require__(/*! ../combi */ "./node_modules/@abaplint/core/build/src/abap/2_statements/combi.js");
|
|
5591
|
+
const tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js");
|
|
5592
5592
|
const _1 = __webpack_require__(/*! . */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
|
|
5593
5593
|
class CorrespondingBodyMapping extends combi_1.Expression {
|
|
5594
5594
|
getRunnable() {
|
|
5595
|
-
const
|
|
5595
|
+
const single = (0, combi_1.seq)(_1.ComponentName, "=", _1.ComponentChain);
|
|
5596
|
+
// mapping rule for a sub structure or tabular component, with its own MAPPING and EXCEPT
|
|
5597
|
+
const nested = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), single, (0, combi_1.optPrio)(CorrespondingBodyMapping), (0, combi_1.optPrio)((0, combi_1.seq)("EXCEPT", (0, combi_1.alt)((0, combi_1.plus)(_1.Field), "*"))), (0, combi_1.tok)(tokens_1.WParenRightW));
|
|
5598
|
+
const mapping = (0, combi_1.seq)("MAPPING", (0, combi_1.plus)((0, combi_1.alt)(single, nested)));
|
|
5596
5599
|
return mapping;
|
|
5597
5600
|
}
|
|
5598
5601
|
}
|
|
@@ -9275,10 +9278,14 @@ class SQLCompare extends combi_1.Expression {
|
|
|
9275
9278
|
const nul = (0, combi_1.seq)("IS", (0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)("NULL", (0, combi_1.ver)(version_1.Release.v753, "INITIAL")));
|
|
9276
9279
|
const sub = (0, combi_1.seq)((0, combi_1.optPrio)((0, combi_1.altPrio)("ALL", "ANY", "SOME")), (0, combi_1.altPrio)(subSelect, simpleScalarSubSelect));
|
|
9277
9280
|
const source = new _1.SQLSource();
|
|
9278
|
-
const arith = (0, combi_1.ver)(version_1.Release.v750, (0, combi_1.plusPrio)((0, combi_1.seq)((0, combi_1.altPrio)("+", "-", "*", "/"), _1.SQLFieldName)), { also: combi_1.AlsoIn.OpenABAP });
|
|
9279
9281
|
const paren = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.ParenLeftW), _1.Source, (0, combi_1.tok)(tokens_1.WParenRightW));
|
|
9280
9282
|
const at = (0, combi_1.ver)(version_1.Release.v740sp05, (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WAt), (0, combi_1.altPrio)(_1.SimpleSource3, paren)), { also: combi_1.AlsoIn.OpenABAP });
|
|
9281
|
-
const
|
|
9283
|
+
const arithmetic = (0, combi_1.seq)((0, combi_1.altPrio)("+", "-", "*", "/"), _1.SQLFieldName);
|
|
9284
|
+
const arith = (0, combi_1.ver)(version_1.Release.v750, (0, combi_1.plusPrio)(arithmetic), { also: combi_1.AlsoIn.OpenABAP });
|
|
9285
|
+
// the left hand side can also concatenate with &&, the right hand side can not
|
|
9286
|
+
const concat = (0, combi_1.seq)("&&", (0, combi_1.altPrio)(_1.SQLFieldName, _1.ConstantString, at));
|
|
9287
|
+
const arithLeft = (0, combi_1.ver)(version_1.Release.v750, (0, combi_1.plusPrio)((0, combi_1.altPrio)(arithmetic, concat)), { also: combi_1.AlsoIn.OpenABAP });
|
|
9288
|
+
const lhs = (0, combi_1.altPrio)(_1.SQLCase, _1.SQLAggregation, _1.SQLFunction, (0, combi_1.seq)(_1.ConstantString, (0, combi_1.optPrio)(arithLeft)), (0, combi_1.seq)((0, combi_1.altPrio)(_1.SQLPathForColumn, _1.SQLAliasField, _1.SQLFieldName), (0, combi_1.optPrio)(arithLeft)), (0, combi_1.seq)(at, (0, combi_1.optPrio)(arithLeft)));
|
|
9282
9289
|
const rhs = (0, combi_1.altPrio)((0, combi_1.seq)(_1.SQLCompareOperator, (0, combi_1.altPrio)(sub, _1.SQLCase, _1.SQLAggregation, _1.SQLFunction, (0, combi_1.seq)(source, (0, combi_1.optPrio)(arith)))), (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)(_1.SQLIn, like, between)), sql_like_regexpr_1.SQLLikeRegexpr, nul);
|
|
9283
9290
|
const rett = (0, combi_1.seq)(lhs, rhs);
|
|
9284
9291
|
const exists = (0, combi_1.seq)("EXISTS", (0, combi_1.altPrio)(subSelect, simpleSubSelect));
|
|
@@ -10940,7 +10947,12 @@ class SQLOrderBy extends combi_1.Expression {
|
|
|
10940
10947
|
const ding = (0, combi_1.alt)("ASCENDING", "DESCENDING");
|
|
10941
10948
|
const nulls = (0, combi_1.ver)(version_1.Release.v778, (0, combi_1.seq)("NULLS", (0, combi_1.alt)("FIRST", "LAST")));
|
|
10942
10949
|
const item = (0, combi_1.altPrio)((0, combi_1.ver)(version_1.Release.v789, sql_field_1.SQLField), sql_field_name_1.SQLFieldName);
|
|
10943
|
-
const
|
|
10950
|
+
const entry = (0, combi_1.seq)(item, (0, combi_1.opt)(ding), (0, combi_1.opt)(nulls));
|
|
10951
|
+
// without commas only column names, SQL expressions need the comma separated list.
|
|
10952
|
+
// UP TO and OFFSET are not taken as column names, they are not allowed after ORDER BY, #2555
|
|
10953
|
+
const commaList = (0, combi_1.seq)(entry, (0, combi_1.star)((0, combi_1.seq)(",", entry)));
|
|
10954
|
+
const blankList = (0, combi_1.plus)((0, combi_1.seq)((0, combi_1.stopBefore)("UP", "TO"), (0, combi_1.stopBefore1)("OFFSET"), sql_field_name_1.SQLFieldName, (0, combi_1.opt)(ding), (0, combi_1.opt)(nulls)));
|
|
10955
|
+
const ofields = (0, combi_1.alt)(commaList, blankList);
|
|
10944
10956
|
const order = (0, combi_1.seq)("ORDER BY", (0, combi_1.altPrio)("PRIMARY KEY", dynamic_1.Dynamic, ofields));
|
|
10945
10957
|
return order;
|
|
10946
10958
|
}
|
|
@@ -30081,6 +30093,8 @@ const enum_type_1 = __webpack_require__(/*! ../types/basic/enum_type */ "./node_
|
|
|
30081
30093
|
const cgeneric_type_1 = __webpack_require__(/*! ../types/basic/cgeneric_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/cgeneric_type.js");
|
|
30082
30094
|
const Expressions = __importStar(__webpack_require__(/*! ../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
|
|
30083
30095
|
const nodes_1 = __webpack_require__(/*! ../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
30096
|
+
const ngeneric_type_1 = __webpack_require__(/*! ../types/basic/ngeneric_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/ngeneric_type.js");
|
|
30097
|
+
const _builtin_1 = __webpack_require__(/*! ./_builtin */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js");
|
|
30084
30098
|
// todo: refactor to static? for performance
|
|
30085
30099
|
class TypeUtils {
|
|
30086
30100
|
constructor(scope) {
|
|
@@ -30378,6 +30392,117 @@ class TypeUtils {
|
|
|
30378
30392
|
|| node.findFirstExpression(Expressions.ArithOperator) !== undefined;
|
|
30379
30393
|
return calculated;
|
|
30380
30394
|
}
|
|
30395
|
+
/** the source is only a call of a functional method, not a built-in function */
|
|
30396
|
+
isFunctionalMethodResult(node) {
|
|
30397
|
+
var _a;
|
|
30398
|
+
if (!(node.get() instanceof Expressions.Source) || node.getChildren().length !== 1) {
|
|
30399
|
+
return false;
|
|
30400
|
+
}
|
|
30401
|
+
const chain = node.getFirstChild();
|
|
30402
|
+
if (!(chain instanceof nodes_1.ExpressionNode) || !(chain.get() instanceof Expressions.MethodCallChain)) {
|
|
30403
|
+
return false;
|
|
30404
|
+
}
|
|
30405
|
+
const children = chain.getChildren();
|
|
30406
|
+
const last = children[children.length - 1];
|
|
30407
|
+
if (!(last instanceof nodes_1.ExpressionNode) || !(last.get() instanceof Expressions.MethodCall)) {
|
|
30408
|
+
return false;
|
|
30409
|
+
}
|
|
30410
|
+
if (children.length === 1) {
|
|
30411
|
+
const name = (_a = last.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
30412
|
+
if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name) !== undefined) {
|
|
30413
|
+
return false;
|
|
30414
|
+
}
|
|
30415
|
+
}
|
|
30416
|
+
return true;
|
|
30417
|
+
}
|
|
30418
|
+
/** the result of a functional method passed to a formal parameter: the result is expected to be of
|
|
30419
|
+
* the same kind as the parameter, numeric types mix, c, n and x only into the same or a longer length.
|
|
30420
|
+
* Returns false for a known mismatch of elementary types, true otherwise */
|
|
30421
|
+
isFunctionalResultAssignable(source, target) {
|
|
30422
|
+
const isNumber = (t) => t instanceof basic_1.IntegerType
|
|
30423
|
+
|| t instanceof basic_1.Integer8Type
|
|
30424
|
+
|| t instanceof basic_1.PackedType
|
|
30425
|
+
|| t instanceof basic_1.FloatType
|
|
30426
|
+
|| t instanceof basic_1.DecFloat16Type
|
|
30427
|
+
|| t instanceof basic_1.DecFloat34Type;
|
|
30428
|
+
let kind;
|
|
30429
|
+
if (isNumber(source)) {
|
|
30430
|
+
kind = "number";
|
|
30431
|
+
}
|
|
30432
|
+
else if (source instanceof basic_1.CharacterType) {
|
|
30433
|
+
kind = "c";
|
|
30434
|
+
}
|
|
30435
|
+
else if (source instanceof basic_1.NumericType && !(source instanceof ngeneric_type_1.NGenericType)) {
|
|
30436
|
+
kind = "n";
|
|
30437
|
+
}
|
|
30438
|
+
else if (source instanceof basic_1.HexType) {
|
|
30439
|
+
kind = "x";
|
|
30440
|
+
}
|
|
30441
|
+
else if (source instanceof basic_1.StringType) {
|
|
30442
|
+
kind = "string";
|
|
30443
|
+
}
|
|
30444
|
+
else if (source instanceof basic_1.XStringType) {
|
|
30445
|
+
kind = "xstring";
|
|
30446
|
+
}
|
|
30447
|
+
else if (source instanceof basic_1.DateType) {
|
|
30448
|
+
kind = "d";
|
|
30449
|
+
}
|
|
30450
|
+
else if (source instanceof basic_1.TimeType) {
|
|
30451
|
+
kind = "t";
|
|
30452
|
+
}
|
|
30453
|
+
else if (source instanceof basic_1.UTCLongType) {
|
|
30454
|
+
kind = "utclong";
|
|
30455
|
+
}
|
|
30456
|
+
else {
|
|
30457
|
+
return true;
|
|
30458
|
+
}
|
|
30459
|
+
if (isNumber(target) || target instanceof basic_1.NumericGenericType || target instanceof basic_1.PGenericType) {
|
|
30460
|
+
return kind === "number";
|
|
30461
|
+
}
|
|
30462
|
+
else if (target instanceof basic_1.CharacterType) {
|
|
30463
|
+
return source instanceof basic_1.CharacterType && source.getLength() <= target.getLength();
|
|
30464
|
+
}
|
|
30465
|
+
else if (target instanceof ngeneric_type_1.NGenericType) {
|
|
30466
|
+
return kind === "n";
|
|
30467
|
+
}
|
|
30468
|
+
else if (target instanceof basic_1.NumericType) {
|
|
30469
|
+
return source instanceof basic_1.NumericType && source.getLength() <= target.getLength();
|
|
30470
|
+
}
|
|
30471
|
+
else if (target instanceof basic_1.HexType) {
|
|
30472
|
+
return source instanceof basic_1.HexType && source.getLength() <= target.getLength();
|
|
30473
|
+
}
|
|
30474
|
+
else if (target instanceof basic_1.StringType) {
|
|
30475
|
+
return kind === "c" || kind === "string";
|
|
30476
|
+
}
|
|
30477
|
+
else if (target instanceof basic_1.XStringType) {
|
|
30478
|
+
return kind === "x" || kind === "xstring";
|
|
30479
|
+
}
|
|
30480
|
+
else if (target instanceof basic_1.DateType) {
|
|
30481
|
+
return kind === "d";
|
|
30482
|
+
}
|
|
30483
|
+
else if (target instanceof basic_1.TimeType) {
|
|
30484
|
+
return kind === "t";
|
|
30485
|
+
}
|
|
30486
|
+
else if (target instanceof basic_1.UTCLongType) {
|
|
30487
|
+
return kind === "utclong";
|
|
30488
|
+
}
|
|
30489
|
+
else if (target instanceof cgeneric_type_1.CGenericType) {
|
|
30490
|
+
return kind === "c";
|
|
30491
|
+
}
|
|
30492
|
+
else if (target instanceof basic_1.XGenericType) {
|
|
30493
|
+
return kind === "x";
|
|
30494
|
+
}
|
|
30495
|
+
else if (target instanceof basic_1.CSequenceType) {
|
|
30496
|
+
return kind === "c" || kind === "string";
|
|
30497
|
+
}
|
|
30498
|
+
else if (target instanceof basic_1.XSequenceType) {
|
|
30499
|
+
return kind === "x" || kind === "xstring";
|
|
30500
|
+
}
|
|
30501
|
+
else if (target instanceof basic_1.CLikeType) {
|
|
30502
|
+
return kind !== "number" && kind !== "x" && kind !== "xstring" && kind !== "utclong";
|
|
30503
|
+
}
|
|
30504
|
+
return true;
|
|
30505
|
+
}
|
|
30381
30506
|
// a text or string literal is only assignable to an xstring or xsequence parameter if its
|
|
30382
30507
|
// content is hexadecimal: one or more of 0-9 and A-F, upper case, nothing else, or ``
|
|
30383
30508
|
isHexConstant(node) {
|
|
@@ -30400,7 +30525,7 @@ class TypeUtils {
|
|
|
30400
30525
|
}
|
|
30401
30526
|
return this.isAssignable(source, target);
|
|
30402
30527
|
}
|
|
30403
|
-
isAssignableStrict(source, target, node) {
|
|
30528
|
+
isAssignableStrict(source, target, node, builtin = false) {
|
|
30404
30529
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
30405
30530
|
const calculated = node ? this.isCalculated(node) : false;
|
|
30406
30531
|
/*
|
|
@@ -30426,9 +30551,25 @@ class TypeUtils {
|
|
|
30426
30551
|
return false;
|
|
30427
30552
|
}
|
|
30428
30553
|
}
|
|
30429
|
-
|
|
30554
|
+
const functionalResult = node !== undefined && builtin === false && this.isFunctionalMethodResult(node);
|
|
30555
|
+
if (functionalResult && this.isFunctionalResultAssignable(source, target) === false) {
|
|
30556
|
+
return false;
|
|
30557
|
+
}
|
|
30558
|
+
// a structure, table or reference returned by a functional method follows the same rule as a variable
|
|
30559
|
+
const strictResult = functionalResult && (source instanceof basic_1.StructureType
|
|
30560
|
+
|| source instanceof basic_1.TableType
|
|
30561
|
+
|| source instanceof basic_1.DataReference
|
|
30562
|
+
|| source instanceof basic_1.ObjectReferenceType
|
|
30563
|
+
|| source instanceof basic_1.GenericObjectReferenceType);
|
|
30564
|
+
if (calculated && strictResult === false) {
|
|
30430
30565
|
return this.isAssignable(source, target);
|
|
30431
30566
|
}
|
|
30567
|
+
// an elementary text field is not compatible with a structure, also not with a flat character-like one
|
|
30568
|
+
if (target instanceof basic_1.StructureType
|
|
30569
|
+
&& target.containsVoid() === false
|
|
30570
|
+
&& (source instanceof basic_1.CharacterType || source instanceof basic_1.StringType || source instanceof basic_1.NumericType)) {
|
|
30571
|
+
return false;
|
|
30572
|
+
}
|
|
30432
30573
|
if (target instanceof basic_1.CLikeType) {
|
|
30433
30574
|
return this.isCharLikeStrict(source);
|
|
30434
30575
|
}
|
|
@@ -30615,8 +30756,14 @@ class TypeUtils {
|
|
|
30615
30756
|
return false;
|
|
30616
30757
|
}
|
|
30617
30758
|
}
|
|
30759
|
+
else if (source instanceof basic_1.DataReference && target instanceof basic_1.DataReference) {
|
|
30760
|
+
return this.isDataReferenceCompatible(source, target);
|
|
30761
|
+
}
|
|
30618
30762
|
else if (source instanceof basic_1.TableType) {
|
|
30619
|
-
if (
|
|
30763
|
+
if (target instanceof basic_1.TableType && this.isTableKindCompatible(source, target) === false) {
|
|
30764
|
+
return false;
|
|
30765
|
+
}
|
|
30766
|
+
else if (source.getRowType() instanceof basic_1.AnyType) {
|
|
30620
30767
|
// then its a generic table, todo: add top level generic table type?
|
|
30621
30768
|
return true;
|
|
30622
30769
|
}
|
|
@@ -30646,6 +30793,81 @@ class TypeUtils {
|
|
|
30646
30793
|
}
|
|
30647
30794
|
return this.isAssignable(source, target);
|
|
30648
30795
|
}
|
|
30796
|
+
// a standard, sorted or hashed table only fits a table type of the same kind, generic or not,
|
|
30797
|
+
// INDEX TABLE takes standard and sorted tables, ANY TABLE takes all
|
|
30798
|
+
isTableKindCompatible(source, target) {
|
|
30799
|
+
const sourceAccess = source.getAccessType();
|
|
30800
|
+
const targetAccess = target.getAccessType();
|
|
30801
|
+
if (sourceAccess === undefined
|
|
30802
|
+
|| targetAccess === undefined
|
|
30803
|
+
|| sourceAccess === table_type_1.TableAccessType.index
|
|
30804
|
+
|| sourceAccess === table_type_1.TableAccessType.any
|
|
30805
|
+
|| source.isWithHeader()
|
|
30806
|
+
|| target.isWithHeader()) {
|
|
30807
|
+
return true;
|
|
30808
|
+
}
|
|
30809
|
+
else if (targetAccess === table_type_1.TableAccessType.any) {
|
|
30810
|
+
return true;
|
|
30811
|
+
}
|
|
30812
|
+
else if (targetAccess === table_type_1.TableAccessType.index) {
|
|
30813
|
+
return sourceAccess !== table_type_1.TableAccessType.hashed;
|
|
30814
|
+
}
|
|
30815
|
+
return sourceAccess === targetAccess;
|
|
30816
|
+
}
|
|
30817
|
+
// a data reference fits REF TO data, or a reference to the same type, no down cast
|
|
30818
|
+
isDataReferenceCompatible(source, target) {
|
|
30819
|
+
const targetType = target.getType();
|
|
30820
|
+
const sourceType = source.getType();
|
|
30821
|
+
if (targetType instanceof basic_1.DataType || targetType instanceof basic_1.AnyType || target.isGeneric()) {
|
|
30822
|
+
return true;
|
|
30823
|
+
}
|
|
30824
|
+
else if (sourceType instanceof basic_1.DataType || sourceType instanceof basic_1.AnyType) {
|
|
30825
|
+
return false;
|
|
30826
|
+
}
|
|
30827
|
+
return this.isSameType(sourceType, targetType);
|
|
30828
|
+
}
|
|
30829
|
+
// types of the same kind and technical attributes, structures also with the same component names;
|
|
30830
|
+
// returns true whenever this cannot be decided
|
|
30831
|
+
isSameType(source, target) {
|
|
30832
|
+
if (source instanceof basic_1.VoidType || target instanceof basic_1.VoidType
|
|
30833
|
+
|| source instanceof basic_1.UnknownType || target instanceof basic_1.UnknownType
|
|
30834
|
+
|| source instanceof basic_1.AnyType || target instanceof basic_1.AnyType
|
|
30835
|
+
|| source.containsVoid() || target.containsVoid()) {
|
|
30836
|
+
return true;
|
|
30837
|
+
}
|
|
30838
|
+
else if (source.constructor !== target.constructor) {
|
|
30839
|
+
return false;
|
|
30840
|
+
}
|
|
30841
|
+
if ((source instanceof basic_1.CharacterType && target instanceof basic_1.CharacterType)
|
|
30842
|
+
|| (source instanceof basic_1.HexType && target instanceof basic_1.HexType)
|
|
30843
|
+
|| (source instanceof basic_1.NumericType && target instanceof basic_1.NumericType)) {
|
|
30844
|
+
return source.getLength() === target.getLength();
|
|
30845
|
+
}
|
|
30846
|
+
else if (source instanceof basic_1.PackedType && target instanceof basic_1.PackedType) {
|
|
30847
|
+
return source.getLength() === target.getLength() && source.getDecimals() === target.getDecimals();
|
|
30848
|
+
}
|
|
30849
|
+
else if (source instanceof basic_1.StructureType && target instanceof basic_1.StructureType) {
|
|
30850
|
+
const sourceComponents = source.getComponents();
|
|
30851
|
+
const targetComponents = target.getComponents();
|
|
30852
|
+
if (sourceComponents.length !== targetComponents.length) {
|
|
30853
|
+
return false;
|
|
30854
|
+
}
|
|
30855
|
+
for (let i = 0; i < sourceComponents.length; i++) {
|
|
30856
|
+
if (sourceComponents[i].name.toUpperCase() !== targetComponents[i].name.toUpperCase()
|
|
30857
|
+
|| this.isSameType(sourceComponents[i].type, targetComponents[i].type) === false) {
|
|
30858
|
+
return false;
|
|
30859
|
+
}
|
|
30860
|
+
}
|
|
30861
|
+
}
|
|
30862
|
+
else if (source instanceof basic_1.TableType && target instanceof basic_1.TableType) {
|
|
30863
|
+
return source.getAccessType() === target.getAccessType()
|
|
30864
|
+
&& this.isSameType(source.getRowType(), target.getRowType());
|
|
30865
|
+
}
|
|
30866
|
+
else if (source instanceof basic_1.DataReference && target instanceof basic_1.DataReference) {
|
|
30867
|
+
return this.isSameType(source.getType(), target.getType());
|
|
30868
|
+
}
|
|
30869
|
+
return true;
|
|
30870
|
+
}
|
|
30649
30871
|
// character-like arguments of built-in functions must be elementary, flat character-like structures are not allowed
|
|
30650
30872
|
isAssignableBuiltin(source, target, node) {
|
|
30651
30873
|
if (target instanceof basic_1.CLikeType
|
|
@@ -30653,7 +30875,7 @@ class TypeUtils {
|
|
|
30653
30875
|
|| (source instanceof basic_1.TableType && source.isWithHeader() && source.getRowType() instanceof basic_1.StructureType))) {
|
|
30654
30876
|
return false;
|
|
30655
30877
|
}
|
|
30656
|
-
return this.isAssignableStrict(source, target, node);
|
|
30878
|
+
return this.isAssignableStrict(source, target, node, true);
|
|
30657
30879
|
}
|
|
30658
30880
|
// Typing with the classic STRUCTURE addition, ie. "FORM foo USING bar STRUCTURE zkey",
|
|
30659
30881
|
// is not a compatibility check: ABAP only checks the fragment view up to the end of the
|
|
@@ -30676,8 +30898,40 @@ class TypeUtils {
|
|
|
30676
30898
|
else if (source instanceof basic_1.TableType && target instanceof basic_1.TableType) {
|
|
30677
30899
|
return this.isAssignableStructureTyping(source.getRowType(), target.getRowType());
|
|
30678
30900
|
}
|
|
30901
|
+
else if (source instanceof basic_1.CharacterType && target instanceof basic_1.StructureType) {
|
|
30902
|
+
// an elementary actual must be character-like, the formal structure purely character-like
|
|
30903
|
+
const length = this.characterLikeStructureLength(target);
|
|
30904
|
+
return length !== undefined && source.getLength() >= length;
|
|
30905
|
+
}
|
|
30679
30906
|
return this.isAssignableStrict(source, target, node);
|
|
30680
30907
|
}
|
|
30908
|
+
// returns the total length if the structure is flat and purely character-like, otherwise undefined
|
|
30909
|
+
characterLikeStructureLength(type) {
|
|
30910
|
+
let length = 0;
|
|
30911
|
+
for (const component of type.getComponents()) {
|
|
30912
|
+
const t = component.type;
|
|
30913
|
+
if (t instanceof basic_1.CharacterType || t instanceof basic_1.NumericType) {
|
|
30914
|
+
length += t.getLength();
|
|
30915
|
+
}
|
|
30916
|
+
else if (t instanceof basic_1.DateType) {
|
|
30917
|
+
length += 8;
|
|
30918
|
+
}
|
|
30919
|
+
else if (t instanceof basic_1.TimeType) {
|
|
30920
|
+
length += 6;
|
|
30921
|
+
}
|
|
30922
|
+
else if (t instanceof basic_1.StructureType) {
|
|
30923
|
+
const sub = this.characterLikeStructureLength(t);
|
|
30924
|
+
if (sub === undefined) {
|
|
30925
|
+
return undefined;
|
|
30926
|
+
}
|
|
30927
|
+
length += sub;
|
|
30928
|
+
}
|
|
30929
|
+
else {
|
|
30930
|
+
return undefined;
|
|
30931
|
+
}
|
|
30932
|
+
}
|
|
30933
|
+
return length;
|
|
30934
|
+
}
|
|
30681
30935
|
isAssignable(source, target) {
|
|
30682
30936
|
if (source === undefined || target === undefined) {
|
|
30683
30937
|
return true;
|
|
@@ -31553,7 +31807,13 @@ class BasicTypes {
|
|
|
31553
31807
|
|| text === "TYPE HASHED TABLE"
|
|
31554
31808
|
|| text === "TYPE INDEX TABLE"
|
|
31555
31809
|
|| text === "TYPE ANY TABLE") {
|
|
31556
|
-
|
|
31810
|
+
// the table kind is kept, the key is left open
|
|
31811
|
+
const access = text.split(" ")[1];
|
|
31812
|
+
return new Types.TableType(Types.AnyType.get(), {
|
|
31813
|
+
withHeader: node.concatTokens().toUpperCase().includes("WITH HEADER LINE"),
|
|
31814
|
+
keyType: Types.TableKeyType.user,
|
|
31815
|
+
primaryKey: { name: "primary_key", type: access, isUnique: false, keyFields: [] },
|
|
31816
|
+
});
|
|
31557
31817
|
}
|
|
31558
31818
|
else if (text.startsWith("LIKE ")) {
|
|
31559
31819
|
let sub = node.findFirstExpression(Expressions.Type);
|
|
@@ -31732,6 +31992,10 @@ class BasicTypes {
|
|
|
31732
31992
|
this.input.scope.addReference(token, foundId, _reference_1.ReferenceType.TypeReference, this.input.filename);
|
|
31733
31993
|
}
|
|
31734
31994
|
}
|
|
31995
|
+
else if (className === "ME") {
|
|
31996
|
+
// me is the reference to the instance, not a class or interface; "me->ty" names the type through it
|
|
31997
|
+
return new Types.UnknownType("\"me\" is not a class or interface, \"" + chainText + "\" cannot be resolved");
|
|
31998
|
+
}
|
|
31735
31999
|
else {
|
|
31736
32000
|
// lookup in local and global scope
|
|
31737
32001
|
const obj = this.input.scope.findObjectDefinition(className);
|
|
@@ -31989,6 +32253,10 @@ class BasicTypes {
|
|
|
31989
32253
|
else if (chain.concatTokens().toUpperCase() === "DATA") {
|
|
31990
32254
|
return new Types.DataReference(new Types.DataType());
|
|
31991
32255
|
}
|
|
32256
|
+
else if (found instanceof Types.UnknownType && name.toUpperCase() === "ME") {
|
|
32257
|
+
// "REF TO me=>ty", me is not a class or interface whatever the error namespace
|
|
32258
|
+
return found;
|
|
32259
|
+
}
|
|
31992
32260
|
if (this.input.scope.isBadiDef(name) === true) {
|
|
31993
32261
|
return Types.VoidType.get(name);
|
|
31994
32262
|
}
|
|
@@ -33177,6 +33445,11 @@ class Compare {
|
|
|
33177
33445
|
if (operandMessage !== undefined) {
|
|
33178
33446
|
return;
|
|
33179
33447
|
}
|
|
33448
|
+
const arithmeticMessage = this.checkArithmeticOperands(node, sources, sourceTypes);
|
|
33449
|
+
if (arithmeticMessage !== undefined) {
|
|
33450
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), arithmeticMessage));
|
|
33451
|
+
return;
|
|
33452
|
+
}
|
|
33180
33453
|
const typeUtils = new _type_utils_1.TypeUtils(input.scope);
|
|
33181
33454
|
const compareOperator = (_a = node.findDirectExpression(Expressions.CompareOperator)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
33182
33455
|
if (compareOperator === "CS"
|
|
@@ -33245,6 +33518,67 @@ class Compare {
|
|
|
33245
33518
|
const call = _builtin_call_1.BuiltInCall.fromSource(source, input);
|
|
33246
33519
|
return call === undefined ? undefined : _builtin_call_1.BuiltInCall.callName(call);
|
|
33247
33520
|
}
|
|
33521
|
+
// an arithmetic expression can only be compared with a numeric operand or another arithmetic expression,
|
|
33522
|
+
// a character-like, byte-like, date, time or structured operand is expected to be a syntax error,
|
|
33523
|
+
// the operand can be made an arithmetic expression with a "+" in front, "+ lv_c"
|
|
33524
|
+
static checkArithmeticOperands(node, sources, types) {
|
|
33525
|
+
let pairs = [];
|
|
33526
|
+
if (node.findDirectExpression(Expressions.CompareOperator) !== undefined && sources.length === 2) {
|
|
33527
|
+
pairs = [[0, 1]];
|
|
33528
|
+
}
|
|
33529
|
+
else if (node.findDirectTokenByText("BETWEEN") !== undefined && sources.length === 3) {
|
|
33530
|
+
pairs = [[0, 1], [0, 2]];
|
|
33531
|
+
}
|
|
33532
|
+
for (const [a, b] of pairs) {
|
|
33533
|
+
for (const [arith, other] of [[a, b], [b, a]]) {
|
|
33534
|
+
if (this.isArithmetic(sources[arith]) === true
|
|
33535
|
+
&& this.isArithmetic(sources[other]) === false
|
|
33536
|
+
&& this.isNonNumeric(types[other]) === true) {
|
|
33537
|
+
const operand = sources[other].concatTokens();
|
|
33538
|
+
return `Arithmetic expression cannot be compared with non-numeric operand "${operand}", use "+ ${operand}"`;
|
|
33539
|
+
}
|
|
33540
|
+
}
|
|
33541
|
+
}
|
|
33542
|
+
return undefined;
|
|
33543
|
+
}
|
|
33544
|
+
// "a + b", "- a", "( a * b )", but not "( a )", "a && b" or "a BIT-AND b"
|
|
33545
|
+
static isArithmetic(source) {
|
|
33546
|
+
const children = source.getChildren();
|
|
33547
|
+
const first = children[0];
|
|
33548
|
+
if (first instanceof nodes_1.TokenNode) {
|
|
33549
|
+
const str = first.getFirstToken().getStr();
|
|
33550
|
+
if (str === "+" || str === "-") {
|
|
33551
|
+
return true;
|
|
33552
|
+
}
|
|
33553
|
+
else if (str === "(" && children.length === 3 && children[1] instanceof nodes_1.ExpressionNode) {
|
|
33554
|
+
return this.isArithmetic(children[1]);
|
|
33555
|
+
}
|
|
33556
|
+
}
|
|
33557
|
+
for (const child of children) {
|
|
33558
|
+
if (child instanceof nodes_1.ExpressionNode
|
|
33559
|
+
&& child.get() instanceof Expressions.ArithOperator
|
|
33560
|
+
&& child.concatTokens().toUpperCase().startsWith("BIT-") === false) {
|
|
33561
|
+
return true;
|
|
33562
|
+
}
|
|
33563
|
+
}
|
|
33564
|
+
return false;
|
|
33565
|
+
}
|
|
33566
|
+
static isNonNumeric(type) {
|
|
33567
|
+
return type instanceof basic_1.CharacterType
|
|
33568
|
+
|| type instanceof basic_1.StringType
|
|
33569
|
+
|| type instanceof basic_1.NumericType
|
|
33570
|
+
|| type instanceof basic_1.DateType
|
|
33571
|
+
|| type instanceof basic_1.TimeType
|
|
33572
|
+
|| type instanceof basic_1.HexType
|
|
33573
|
+
|| type instanceof basic_1.XStringType
|
|
33574
|
+
|| type instanceof basic_1.StructureType
|
|
33575
|
+
|| type instanceof basic_1.CLikeType
|
|
33576
|
+
|| type instanceof basic_1.CSequenceType
|
|
33577
|
+
|| type instanceof basic_1.CGenericType
|
|
33578
|
+
|| type instanceof basic_1.NGenericType
|
|
33579
|
+
|| type instanceof basic_1.XSequenceType
|
|
33580
|
+
|| type instanceof basic_1.XGenericType;
|
|
33581
|
+
}
|
|
33248
33582
|
}
|
|
33249
33583
|
exports.Compare = Compare;
|
|
33250
33584
|
//# sourceMappingURL=compare.js.map
|
|
@@ -34386,6 +34720,7 @@ const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expr
|
|
|
34386
34720
|
const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
|
|
34387
34721
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
|
|
34388
34722
|
const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
|
|
34723
|
+
const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
|
|
34389
34724
|
class FieldAssignment {
|
|
34390
34725
|
static runSyntax(node, input, targetType) {
|
|
34391
34726
|
const fieldSub = node.findDirectExpression(Expressions.FieldSub);
|
|
@@ -34419,7 +34754,19 @@ class FieldAssignment {
|
|
|
34419
34754
|
else if (targetType instanceof basic_1.VoidType) {
|
|
34420
34755
|
type = targetType;
|
|
34421
34756
|
}
|
|
34422
|
-
source_1.Source.runSyntax(s, input, type);
|
|
34757
|
+
const sourceType = source_1.Source.runSyntax(s, input, type);
|
|
34758
|
+
if (this.isReference(type)
|
|
34759
|
+
&& !(type instanceof basic_1.ObjectReferenceType && sourceType instanceof basic_1.ObjectReferenceType)
|
|
34760
|
+
&& new _type_utils_1.TypeUtils(input.scope).isAssignable(sourceType, type) === false) {
|
|
34761
|
+
// a reference component only takes a reference, values like '' or 1 are not converted
|
|
34762
|
+
const message = `Type of source cannot be converted to the type of ${fieldSub.concatTokens()}`;
|
|
34763
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
|
|
34764
|
+
}
|
|
34765
|
+
}
|
|
34766
|
+
static isReference(type) {
|
|
34767
|
+
return type instanceof basic_1.ObjectReferenceType
|
|
34768
|
+
|| type instanceof basic_1.GenericObjectReferenceType
|
|
34769
|
+
|| type instanceof basic_1.DataReference;
|
|
34423
34770
|
}
|
|
34424
34771
|
}
|
|
34425
34772
|
exports.FieldAssignment = FieldAssignment;
|
|
@@ -35015,7 +35362,7 @@ const assert_error_1 = __webpack_require__(/*! ../assert_error */ "./node_module
|
|
|
35015
35362
|
const tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js");
|
|
35016
35363
|
class FormParam {
|
|
35017
35364
|
static runSyntax(node, input) {
|
|
35018
|
-
var _a, _b, _c;
|
|
35365
|
+
var _a, _b, _c, _d;
|
|
35019
35366
|
const formParamName = node.findFirstExpression(expressions_1.FormParamName);
|
|
35020
35367
|
if (formParamName === undefined) {
|
|
35021
35368
|
throw new assert_error_1.AssertError("FormParam, could not find FormParamName");
|
|
@@ -35030,6 +35377,14 @@ class FormParam {
|
|
|
35030
35377
|
let type;
|
|
35031
35378
|
if (typeName) {
|
|
35032
35379
|
type = (_b = input.scope.findType(typeName)) === null || _b === void 0 ? void 0 : _b.getType();
|
|
35380
|
+
if (type === undefined) {
|
|
35381
|
+
// STRUCTURE can also refer to a program-local data object
|
|
35382
|
+
type = (_c = input.scope.findVariable(typeName)) === null || _c === void 0 ? void 0 : _c.getType();
|
|
35383
|
+
if (type instanceof basic_1.TableType && type.isWithHeader()) {
|
|
35384
|
+
// a table with header line refers to its header line
|
|
35385
|
+
type = type.getRowType();
|
|
35386
|
+
}
|
|
35387
|
+
}
|
|
35033
35388
|
if (type === undefined) {
|
|
35034
35389
|
type = input.scope.getDDIC().lookupTableOrView(typeName).type;
|
|
35035
35390
|
}
|
|
@@ -35044,7 +35399,7 @@ class FormParam {
|
|
|
35044
35399
|
return new _typed_identifier_1.TypedIdentifier(nameToken, input.filename, basic_1.AnyType.get(), ["form_parameter" /* IdentifierMeta.FormParameter */]);
|
|
35045
35400
|
}
|
|
35046
35401
|
let bfound = new basic_types_1.BasicTypes(input).parseType(node);
|
|
35047
|
-
const typeName = (
|
|
35402
|
+
const typeName = (_d = node.findFirstExpression(expressions_1.TypeName)) === null || _d === void 0 ? void 0 : _d.concatTokens().toUpperCase();
|
|
35048
35403
|
const hasExplicitLength = node.findFirstExpression(expressions_1.Length) !== undefined
|
|
35049
35404
|
|| node.findFirstExpression(expressions_1.ConstantFieldLength) !== undefined;
|
|
35050
35405
|
// the length cannot be specified for FORM parameters, so these types are generic
|
|
@@ -36861,7 +37216,11 @@ class MethodParameters {
|
|
|
36861
37216
|
}
|
|
36862
37217
|
// the parameter is supplied, even if its type is wrong
|
|
36863
37218
|
(_a = this.requiredParameters) === null || _a === void 0 ? void 0 : _a.delete(item.name);
|
|
36864
|
-
|
|
37219
|
+
const typeUtils = new _type_utils_1.TypeUtils(input.scope);
|
|
37220
|
+
if (item.targetType && (typeUtils.isAssignableStrict(parameterType, item.targetType) === false
|
|
37221
|
+
// a CHANGING parameter is read and written, so a data reference is checked in both directions
|
|
37222
|
+
|| (parameterType instanceof basic_1.DataReference && item.targetType instanceof basic_1.DataReference
|
|
37223
|
+
&& typeUtils.isAssignableStrict(item.targetType, parameterType) === false))) {
|
|
36865
37224
|
const message = "Method parameter type not compatible, " + item.name;
|
|
36866
37225
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
36867
37226
|
return;
|
|
@@ -37929,17 +38288,19 @@ class Select {
|
|
|
37929
38288
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
37930
38289
|
}
|
|
37931
38290
|
}
|
|
38291
|
+
/** an inline declaration cannot be the target of INTO or APPENDING CORRESPONDING FIELDS OF,
|
|
38292
|
+
* the declaration is still made, so later reads give no follow-up errors */
|
|
38293
|
+
static checkCorrespondingInline(into, inline, node, input) {
|
|
38294
|
+
if (inline !== undefined && into.findDirectTokenByText("CORRESPONDING") !== undefined) {
|
|
38295
|
+
const message = "Inline declarations cannot be used together with INTO CORRESPONDING FIELDS OF";
|
|
38296
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
38297
|
+
}
|
|
38298
|
+
}
|
|
37932
38299
|
static handleInto(node, input, fields, dbSources, from) {
|
|
37933
38300
|
const intoTable = node.findDirectExpression(Expressions.SQLIntoTable);
|
|
37934
38301
|
if (intoTable) {
|
|
37935
38302
|
const inline = intoTable.findFirstExpression(Expressions.InlineData);
|
|
37936
|
-
|
|
37937
|
-
&& intoTable.findDirectTokenByText("INTO") !== undefined
|
|
37938
|
-
&& intoTable.findDirectTokenByText("CORRESPONDING") !== undefined
|
|
37939
|
-
&& !(0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v755)) {
|
|
37940
|
-
const message = "INTO CORRESPONDING FIELDS OF TABLE with an inline declaration requires 7.55";
|
|
37941
|
-
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
37942
|
-
}
|
|
38303
|
+
this.checkCorrespondingInline(intoTable, inline, node, input);
|
|
37943
38304
|
if (inline) {
|
|
37944
38305
|
inline_data_1.InlineData.runSyntax(inline, input, this.buildTableType(fields, dbSources, input.scope, from));
|
|
37945
38306
|
}
|
|
@@ -37948,6 +38309,7 @@ class Select {
|
|
|
37948
38309
|
const intoStructure = node.findDirectExpression(Expressions.SQLIntoStructure);
|
|
37949
38310
|
if (intoStructure) {
|
|
37950
38311
|
const inlineList = intoStructure.findAllExpressions(Expressions.InlineData);
|
|
38312
|
+
this.checkCorrespondingInline(intoStructure, inlineList[0], node, input);
|
|
37951
38313
|
if (inlineList.length === 1) {
|
|
37952
38314
|
inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input, from));
|
|
37953
38315
|
}
|
|
@@ -38425,13 +38787,17 @@ class Source {
|
|
|
38425
38787
|
}
|
|
38426
38788
|
const children = node.getChildren().slice();
|
|
38427
38789
|
let first = children.shift();
|
|
38790
|
+
// a leading sign makes the operand part of a calculation, "- foo"
|
|
38791
|
+
let signed = false;
|
|
38428
38792
|
if (first instanceof nodes_1.TokenNode) {
|
|
38429
38793
|
const token = first.getFirstToken();
|
|
38430
38794
|
const tok = token.getStr().toUpperCase();
|
|
38431
38795
|
switch (tok) {
|
|
38432
|
-
case "(":
|
|
38433
38796
|
case "-":
|
|
38434
38797
|
case "+":
|
|
38798
|
+
signed = true;
|
|
38799
|
+
break;
|
|
38800
|
+
case "(":
|
|
38435
38801
|
case "BIT":
|
|
38436
38802
|
break;
|
|
38437
38803
|
case "BOOLC":
|
|
@@ -38573,6 +38939,7 @@ class Source {
|
|
|
38573
38939
|
{
|
|
38574
38940
|
const foundType = this.determineType(node, input, targetType);
|
|
38575
38941
|
if ((foundType === null || foundType === void 0 ? void 0 : foundType.isGeneric()) === true
|
|
38942
|
+
&& !(foundType instanceof basic_1.DataType)
|
|
38576
38943
|
&& ((_b = node.findDirectExpression(Expressions.TypeNameOrInfer)) === null || _b === void 0 ? void 0 : _b.concatTokens()) === "#"
|
|
38577
38944
|
&& !(0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v756)
|
|
38578
38945
|
&& input.scope.getLanguageVersion() !== version_1.LanguageVersion.Cloud
|
|
@@ -38624,9 +38991,14 @@ class Source {
|
|
|
38624
38991
|
// an arithmetic operator has been seen, so the operands that follow
|
|
38625
38992
|
// determine a calculation type rather than simply replacing the context
|
|
38626
38993
|
let arithmetic = false;
|
|
38994
|
+
// the expressions of the operand in front of the next arithmetic operator
|
|
38995
|
+
let operand = [];
|
|
38627
38996
|
while (children.length >= 0) {
|
|
38628
38997
|
if (first instanceof nodes_1.ExpressionNode) {
|
|
38629
38998
|
const get = first.get();
|
|
38999
|
+
if (!(get instanceof Expressions.ArithOperator) && !(get instanceof Expressions.Source && arithmetic === true)) {
|
|
39000
|
+
operand.push(first);
|
|
39001
|
+
}
|
|
38630
39002
|
if (get instanceof Expressions.MethodCallChain) {
|
|
38631
39003
|
const predicate = this.predicateCall(node, first, input);
|
|
38632
39004
|
if (predicate !== undefined) {
|
|
@@ -38657,6 +39029,9 @@ class Source {
|
|
|
38657
39029
|
}
|
|
38658
39030
|
else if (get instanceof Expressions.Source) {
|
|
38659
39031
|
const found = Source.runSyntax(first, input);
|
|
39032
|
+
if (arithmetic === true && this.reportReferenceOperand(found, first, input)) {
|
|
39033
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
39034
|
+
}
|
|
38660
39035
|
context = this.infer(context, found, arithmetic);
|
|
38661
39036
|
}
|
|
38662
39037
|
else if (get instanceof Expressions.Constant) {
|
|
@@ -38675,11 +39050,15 @@ class Source {
|
|
|
38675
39050
|
context = component_chain_1.ComponentChain.runSyntax(context, first, input);
|
|
38676
39051
|
}
|
|
38677
39052
|
else if (get instanceof Expressions.ArithOperator) {
|
|
39053
|
+
const operator = first.concatTokens().toUpperCase();
|
|
39054
|
+
if (!operator.startsWith("BIT-") && this.reportReferenceOperand(context, operand, input)) {
|
|
39055
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
39056
|
+
}
|
|
39057
|
+
operand = [];
|
|
38678
39058
|
arithmetic = true;
|
|
38679
|
-
if (
|
|
39059
|
+
if (operator === "**") {
|
|
38680
39060
|
context = new basic_1.FloatType();
|
|
38681
39061
|
}
|
|
38682
|
-
const operator = first.concatTokens().toUpperCase();
|
|
38683
39062
|
if (operator === "BIT-OR" || operator === "BIT-AND" || operator === "BIT-XOR") {
|
|
38684
39063
|
hexExpected = true;
|
|
38685
39064
|
hexNext = true;
|
|
@@ -38713,8 +39092,28 @@ class Source {
|
|
|
38713
39092
|
if (node.findDirectTokenByText("&&")) {
|
|
38714
39093
|
return basic_1.StringType.get();
|
|
38715
39094
|
}
|
|
39095
|
+
if (signed === true && arithmetic === false && this.reportReferenceOperand(context, operand, input)) {
|
|
39096
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
39097
|
+
}
|
|
38716
39098
|
return context;
|
|
38717
39099
|
}
|
|
39100
|
+
static isReference(type) {
|
|
39101
|
+
return type instanceof basic_1.ObjectReferenceType
|
|
39102
|
+
|| type instanceof basic_1.GenericObjectReferenceType
|
|
39103
|
+
|| type instanceof basic_1.DataReference;
|
|
39104
|
+
}
|
|
39105
|
+
/** an operand of an arithmetic calculation is converted into a number, which is not possible for a
|
|
39106
|
+
* data or object reference, "foo - 1"; a dereferenced "foo->* - 1" is fine. Returns true if reported */
|
|
39107
|
+
static reportReferenceOperand(type, operand, input) {
|
|
39108
|
+
const nodes = Array.isArray(operand) ? operand : [operand];
|
|
39109
|
+
if (nodes.length === 0 || this.isReference(type) === false) {
|
|
39110
|
+
return false;
|
|
39111
|
+
}
|
|
39112
|
+
const name = nodes.map(n => n.concatTokens()).join("");
|
|
39113
|
+
const message = `"${name}" is a reference, it cannot be used in a calculation`;
|
|
39114
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, nodes[0].getFirstToken(), message));
|
|
39115
|
+
return true;
|
|
39116
|
+
}
|
|
38718
39117
|
////////////////////////////////
|
|
38719
39118
|
static traverseRemainingChildren(children, input) {
|
|
38720
39119
|
const last = children[children.length - 1];
|
|
@@ -41187,11 +41586,18 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
|
|
|
41187
41586
|
const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
41188
41587
|
class Add {
|
|
41189
41588
|
runSyntax(node, input) {
|
|
41589
|
+
// both operands are converted into numbers, a reference cannot be
|
|
41190
41590
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
41191
|
-
source_1.Source.runSyntax(s, input);
|
|
41591
|
+
const type = source_1.Source.runSyntax(s, input);
|
|
41592
|
+
if (source_1.Source.reportReferenceOperand(type, s, input)) {
|
|
41593
|
+
return;
|
|
41594
|
+
}
|
|
41192
41595
|
}
|
|
41193
41596
|
for (const t of node.findDirectExpressions(Expressions.Target)) {
|
|
41194
|
-
target_1.Target.runSyntax(t, input);
|
|
41597
|
+
const type = target_1.Target.runSyntax(t, input);
|
|
41598
|
+
if (source_1.Source.reportReferenceOperand(type, t, input)) {
|
|
41599
|
+
return;
|
|
41600
|
+
}
|
|
41195
41601
|
}
|
|
41196
41602
|
}
|
|
41197
41603
|
}
|
|
@@ -42355,12 +42761,9 @@ class Catch {
|
|
|
42355
42761
|
if (token) {
|
|
42356
42762
|
const classNames = Array.from(names);
|
|
42357
42763
|
const unknownClass = classNames.find(name => input.scope.findClassDefinition(name) === undefined);
|
|
42358
|
-
const
|
|
42359
|
-
? this.
|
|
42360
|
-
:
|
|
42361
|
-
const type = commonSuperclass
|
|
42362
|
-
? new basic_1.ObjectReferenceType(commonSuperclass)
|
|
42363
|
-
: basic_1.VoidType.get(unknownClass || classNames.join(" "));
|
|
42764
|
+
const type = unknownClass === undefined
|
|
42765
|
+
? this.inlineType(classNames, input)
|
|
42766
|
+
: basic_1.VoidType.get(unknownClass);
|
|
42364
42767
|
const identifier = new _typed_identifier_1.TypedIdentifier(token, input.filename, type, ["inline" /* IdentifierMeta.InlineDefinition */]);
|
|
42365
42768
|
input.scope.addIdentifier(identifier);
|
|
42366
42769
|
input.scope.addReference(token, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename);
|
|
@@ -42385,21 +42788,35 @@ class Catch {
|
|
|
42385
42788
|
}
|
|
42386
42789
|
}
|
|
42387
42790
|
}
|
|
42388
|
-
|
|
42389
|
-
|
|
42390
|
-
|
|
42391
|
-
|
|
42392
|
-
|
|
42393
|
-
|
|
42394
|
-
|
|
42395
|
-
while (current && visited.has(current.getName().toUpperCase()) === false) {
|
|
42396
|
-
lineage.push(current);
|
|
42397
|
-
visited.add(current.getName().toUpperCase());
|
|
42398
|
-
current = input.scope.findClassDefinition(current.getSuperClass());
|
|
42791
|
+
// static type of an inline target: the first class, replaced by each following class that is one of its
|
|
42792
|
+
// super classes; any other following class makes it CX_ROOT, also when the classes share a closer super class
|
|
42793
|
+
inlineType(classNames, input) {
|
|
42794
|
+
let current = input.scope.findClassDefinition(classNames[0]);
|
|
42795
|
+
for (const name of classNames.slice(1)) {
|
|
42796
|
+
if (current === undefined) {
|
|
42797
|
+
break;
|
|
42399
42798
|
}
|
|
42400
|
-
|
|
42799
|
+
const next = input.scope.findClassDefinition(name);
|
|
42800
|
+
current = next && this.isSuperClass(next, current, input) ? next : undefined;
|
|
42401
42801
|
}
|
|
42402
|
-
|
|
42802
|
+
if (current !== undefined) {
|
|
42803
|
+
return new basic_1.ObjectReferenceType(current);
|
|
42804
|
+
}
|
|
42805
|
+
const root = input.scope.findClassDefinition("CX_ROOT");
|
|
42806
|
+
return root ? new basic_1.ObjectReferenceType(root) : basic_1.VoidType.get("CX_ROOT");
|
|
42807
|
+
}
|
|
42808
|
+
isSuperClass(candidate, cls, input) {
|
|
42809
|
+
const name = candidate.getName().toUpperCase();
|
|
42810
|
+
const visited = new Set();
|
|
42811
|
+
let current = cls;
|
|
42812
|
+
while (current && visited.has(current.getName().toUpperCase()) === false) {
|
|
42813
|
+
if (current.getName().toUpperCase() === name) {
|
|
42814
|
+
return true;
|
|
42815
|
+
}
|
|
42816
|
+
visited.add(current.getName().toUpperCase());
|
|
42817
|
+
current = input.scope.findClassDefinition(current.getSuperClass());
|
|
42818
|
+
}
|
|
42819
|
+
return false;
|
|
42403
42820
|
}
|
|
42404
42821
|
}
|
|
42405
42822
|
exports.Catch = Catch;
|
|
@@ -44214,8 +44631,12 @@ class DeleteInternal {
|
|
|
44214
44631
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
44215
44632
|
return;
|
|
44216
44633
|
}
|
|
44217
|
-
if (targetType instanceof basic_1.TableType
|
|
44634
|
+
if (targetType instanceof basic_1.TableType
|
|
44635
|
+
&& targetType.isWithHeader() === false
|
|
44636
|
+
&& targetType.isGeneric() === false
|
|
44637
|
+
&& this.isBodyOfTableWithHeader(target, input) === false) {
|
|
44218
44638
|
// short forms, "DELETE itab." deletes the current line inside a LOOP, otherwise both use the header line
|
|
44639
|
+
// generically typed tables are not checked statically
|
|
44219
44640
|
const children = node.getChildren().length;
|
|
44220
44641
|
const short = children === 3 && input.inLoop !== true;
|
|
44221
44642
|
const shortTable = children === 4 && node.findDirectTokenByText("TABLE") !== undefined;
|
|
@@ -44237,6 +44658,16 @@ class DeleteInternal {
|
|
|
44237
44658
|
component_cond_1.ComponentCond.runSyntax(t, input, targetType);
|
|
44238
44659
|
}
|
|
44239
44660
|
}
|
|
44661
|
+
// "DELETE itab[]." where itab has a header line, eg. a FORM TABLES parameter
|
|
44662
|
+
isBodyOfTableWithHeader(target, input) {
|
|
44663
|
+
var _a;
|
|
44664
|
+
const children = target.getChildren();
|
|
44665
|
+
if (children.length !== 2 || !(children[1].get() instanceof Expressions.TableBody)) {
|
|
44666
|
+
return false;
|
|
44667
|
+
}
|
|
44668
|
+
const type = (_a = input.scope.findVariable(children[0].concatTokens())) === null || _a === void 0 ? void 0 : _a.getType();
|
|
44669
|
+
return type instanceof basic_1.TableType && type.isWithHeader();
|
|
44670
|
+
}
|
|
44240
44671
|
}
|
|
44241
44672
|
exports.DeleteInternal = DeleteInternal;
|
|
44242
44673
|
//# sourceMappingURL=delete_internal.js.map
|
|
@@ -44415,14 +44846,16 @@ class Describe {
|
|
|
44415
44846
|
for (const s of node.findDirectExpressions(Expressions.FieldChain)) {
|
|
44416
44847
|
field_chain_1.FieldChain.runSyntax(s, input, _reference_1.ReferenceType.DataReadReference);
|
|
44417
44848
|
}
|
|
44418
|
-
const
|
|
44419
|
-
|
|
44420
|
-
|
|
44421
|
-
|
|
44422
|
-
|
|
44423
|
-
|
|
44424
|
-
|
|
44425
|
-
|
|
44849
|
+
for (const addition of ["LINES", "KIND", "OCCURS"]) {
|
|
44850
|
+
const target = node.findExpressionAfterToken(addition);
|
|
44851
|
+
if ((target === null || target === void 0 ? void 0 : target.get()) instanceof Expressions.Target) {
|
|
44852
|
+
const inline = target.findDirectExpression(Expressions.InlineData);
|
|
44853
|
+
if (inline) {
|
|
44854
|
+
inline_data_1.InlineData.runSyntax(inline, input, addition === "KIND" ? new basic_1.CharacterType(1) : basic_1.IntegerType.get());
|
|
44855
|
+
}
|
|
44856
|
+
else {
|
|
44857
|
+
target_1.Target.runSyntax(target, input);
|
|
44858
|
+
}
|
|
44426
44859
|
}
|
|
44427
44860
|
}
|
|
44428
44861
|
const typeTarget = node.findExpressionAfterToken("TYPE");
|
|
@@ -44510,11 +44943,18 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
|
|
|
44510
44943
|
const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
44511
44944
|
class Divide {
|
|
44512
44945
|
runSyntax(node, input) {
|
|
44946
|
+
// both operands are converted into numbers, a reference cannot be
|
|
44513
44947
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
44514
|
-
source_1.Source.runSyntax(s, input);
|
|
44948
|
+
const type = source_1.Source.runSyntax(s, input);
|
|
44949
|
+
if (source_1.Source.reportReferenceOperand(type, s, input)) {
|
|
44950
|
+
return;
|
|
44951
|
+
}
|
|
44515
44952
|
}
|
|
44516
44953
|
for (const t of node.findDirectExpressions(Expressions.Target)) {
|
|
44517
|
-
target_1.Target.runSyntax(t, input);
|
|
44954
|
+
const type = target_1.Target.runSyntax(t, input);
|
|
44955
|
+
if (source_1.Source.reportReferenceOperand(type, t, input)) {
|
|
44956
|
+
return;
|
|
44957
|
+
}
|
|
44518
44958
|
}
|
|
44519
44959
|
}
|
|
44520
44960
|
}
|
|
@@ -47987,11 +48427,18 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
|
|
|
47987
48427
|
const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
47988
48428
|
class Multiply {
|
|
47989
48429
|
runSyntax(node, input) {
|
|
48430
|
+
// both operands are converted into numbers, a reference cannot be
|
|
47990
48431
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
47991
|
-
source_1.Source.runSyntax(s, input);
|
|
48432
|
+
const type = source_1.Source.runSyntax(s, input);
|
|
48433
|
+
if (source_1.Source.reportReferenceOperand(type, s, input)) {
|
|
48434
|
+
return;
|
|
48435
|
+
}
|
|
47992
48436
|
}
|
|
47993
48437
|
for (const t of node.findDirectExpressions(Expressions.Target)) {
|
|
47994
|
-
target_1.Target.runSyntax(t, input);
|
|
48438
|
+
const type = target_1.Target.runSyntax(t, input);
|
|
48439
|
+
if (source_1.Source.reportReferenceOperand(type, t, input)) {
|
|
48440
|
+
return;
|
|
48441
|
+
}
|
|
47995
48442
|
}
|
|
47996
48443
|
}
|
|
47997
48444
|
}
|
|
@@ -49386,15 +49833,71 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
49386
49833
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
49387
49834
|
exports.Replace = void 0;
|
|
49388
49835
|
const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
|
|
49836
|
+
const nodes_1 = __webpack_require__(/*! ../../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
49389
49837
|
const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
|
|
49390
49838
|
const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
49839
|
+
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
|
|
49840
|
+
const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
|
|
49841
|
+
const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
|
|
49391
49842
|
class Replace {
|
|
49392
49843
|
runSyntax(node, input) {
|
|
49393
|
-
|
|
49394
|
-
|
|
49844
|
+
var _a;
|
|
49845
|
+
const byteMode = node.findDirectTokenByText("BYTE") !== undefined;
|
|
49846
|
+
const regex = (_a = node.findDirectExpression(Expressions.FindType)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
49847
|
+
const isRegex = regex === "REGEX" || regex === "PCRE";
|
|
49848
|
+
// operands which must be character like, or byte like in BYTE MODE
|
|
49849
|
+
const checks = [];
|
|
49850
|
+
let previous = undefined;
|
|
49851
|
+
let first = true;
|
|
49852
|
+
for (const child of node.getChildren()) {
|
|
49853
|
+
if (child instanceof nodes_1.TokenNode) {
|
|
49854
|
+
previous = child.concatTokens().toUpperCase();
|
|
49855
|
+
continue;
|
|
49856
|
+
}
|
|
49857
|
+
else if (child.get() instanceof Expressions.FindType) {
|
|
49858
|
+
previous = child.concatTokens() === "" ? previous : "FINDTYPE";
|
|
49859
|
+
continue;
|
|
49860
|
+
}
|
|
49861
|
+
if (child.get() instanceof Expressions.Source) {
|
|
49862
|
+
const type = source_1.Source.runSyntax(child, input);
|
|
49863
|
+
if (previous === "WITH"
|
|
49864
|
+
|| (first === true && previous === "REPLACE")
|
|
49865
|
+
|| ((previous === "OF" || previous === "FINDTYPE") && isRegex === false)) {
|
|
49866
|
+
checks.push({ node: child, type, table: false });
|
|
49867
|
+
}
|
|
49868
|
+
}
|
|
49869
|
+
else if (child.get() instanceof Expressions.Target) {
|
|
49870
|
+
const type = target_1.Target.runSyntax(child, input);
|
|
49871
|
+
if (previous === "IN" || previous === "OF" || previous === "INTO") {
|
|
49872
|
+
checks.push({ node: child, type, table: false });
|
|
49873
|
+
}
|
|
49874
|
+
else if (previous === "TABLE") {
|
|
49875
|
+
checks.push({ node: child, type, table: true });
|
|
49876
|
+
}
|
|
49877
|
+
}
|
|
49878
|
+
first = false;
|
|
49395
49879
|
}
|
|
49396
|
-
|
|
49397
|
-
|
|
49880
|
+
const utils = new _type_utils_1.TypeUtils(input.scope);
|
|
49881
|
+
for (const check of checks) {
|
|
49882
|
+
let type = check.type;
|
|
49883
|
+
if (check.table === true) {
|
|
49884
|
+
if (!(type instanceof basic_1.TableType)) {
|
|
49885
|
+
continue;
|
|
49886
|
+
}
|
|
49887
|
+
type = type.getRowType();
|
|
49888
|
+
}
|
|
49889
|
+
if (type === undefined) {
|
|
49890
|
+
continue;
|
|
49891
|
+
}
|
|
49892
|
+
const ok = byteMode ? utils.isHexLike(type) : utils.isCharLikeStrict(type);
|
|
49893
|
+
if (ok === false) {
|
|
49894
|
+
const kind = byteMode ? "byte like" : "character like";
|
|
49895
|
+
const message = check.table === true
|
|
49896
|
+
? "REPLACE, table row type must be " + kind
|
|
49897
|
+
: "REPLACE, \"" + check.node.concatTokens() + "\" must be " + kind;
|
|
49898
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, check.node.getFirstToken(), message));
|
|
49899
|
+
return;
|
|
49900
|
+
}
|
|
49398
49901
|
}
|
|
49399
49902
|
}
|
|
49400
49903
|
}
|
|
@@ -50716,11 +51219,18 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
|
|
|
50716
51219
|
const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
50717
51220
|
class Subtract {
|
|
50718
51221
|
runSyntax(node, input) {
|
|
51222
|
+
// both operands are converted into numbers, a reference cannot be
|
|
50719
51223
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
50720
|
-
source_1.Source.runSyntax(s, input);
|
|
51224
|
+
const type = source_1.Source.runSyntax(s, input);
|
|
51225
|
+
if (source_1.Source.reportReferenceOperand(type, s, input)) {
|
|
51226
|
+
return;
|
|
51227
|
+
}
|
|
50721
51228
|
}
|
|
50722
51229
|
for (const t of node.findDirectExpressions(Expressions.Target)) {
|
|
50723
|
-
target_1.Target.runSyntax(t, input);
|
|
51230
|
+
const type = target_1.Target.runSyntax(t, input);
|
|
51231
|
+
if (source_1.Source.reportReferenceOperand(type, t, input)) {
|
|
51232
|
+
return;
|
|
51233
|
+
}
|
|
50724
51234
|
}
|
|
50725
51235
|
}
|
|
50726
51236
|
}
|
|
@@ -51240,6 +51750,14 @@ class Type {
|
|
|
51240
51750
|
return new _typed_identifier_1.TypedIdentifier(found.getToken(), input.filename, basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey));
|
|
51241
51751
|
}
|
|
51242
51752
|
}
|
|
51753
|
+
if (input.scope.isAnyOO()) {
|
|
51754
|
+
const missing = this.lengthMissing(node);
|
|
51755
|
+
if (missing) {
|
|
51756
|
+
const message = "Specify LENGTH in OO context for types c, n, x and p";
|
|
51757
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, missing, message));
|
|
51758
|
+
return new _typed_identifier_1.TypedIdentifier(found.getToken(), input.filename, basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey));
|
|
51759
|
+
}
|
|
51760
|
+
}
|
|
51243
51761
|
return found;
|
|
51244
51762
|
}
|
|
51245
51763
|
const fallback = node.findFirstExpression(Expressions.NamespaceSimpleName);
|
|
@@ -51248,6 +51766,31 @@ class Type {
|
|
|
51248
51766
|
}
|
|
51249
51767
|
return undefined;
|
|
51250
51768
|
}
|
|
51769
|
+
/** returns the token to report when built-in c, n, x or p is used without a length */
|
|
51770
|
+
lengthMissing(node) {
|
|
51771
|
+
if (node.findDirectExpression(Expressions.Length) !== undefined
|
|
51772
|
+
|| node.findDirectExpression(Expressions.ConstantFieldLength) !== undefined) {
|
|
51773
|
+
return undefined;
|
|
51774
|
+
}
|
|
51775
|
+
const type = node.findDirectExpression(Expressions.Type);
|
|
51776
|
+
if (type === undefined) {
|
|
51777
|
+
// "TYPES foo." is implicitly type c with length 1
|
|
51778
|
+
const onlyName = node.getChildren().every(c => c.get() instanceof Expressions.NamespaceSimpleName
|
|
51779
|
+
|| ["TYPES", "BOXED", ".", ","].includes(c.concatTokens().toUpperCase()));
|
|
51780
|
+
return onlyName ? node.getFirstToken() : undefined;
|
|
51781
|
+
}
|
|
51782
|
+
const children = type.getChildren();
|
|
51783
|
+
if (children.length !== 2
|
|
51784
|
+
|| children[0].concatTokens().toUpperCase() !== "TYPE"
|
|
51785
|
+
|| !(children[1].get() instanceof Expressions.TypeName)) {
|
|
51786
|
+
return undefined;
|
|
51787
|
+
}
|
|
51788
|
+
const name = children[1].concatTokens().toUpperCase();
|
|
51789
|
+
if (["C", "N", "X", "P"].includes(name)) {
|
|
51790
|
+
return children[1].getFirstToken();
|
|
51791
|
+
}
|
|
51792
|
+
return undefined;
|
|
51793
|
+
}
|
|
51251
51794
|
}
|
|
51252
51795
|
exports.Type = Type;
|
|
51253
51796
|
//# sourceMappingURL=type.js.map
|
|
@@ -52617,7 +53160,8 @@ const Statements = __importStar(__webpack_require__(/*! ../../2_statements/state
|
|
|
52617
53160
|
const Structures = __importStar(__webpack_require__(/*! ../../3_structures/structures */ "./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js"));
|
|
52618
53161
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
|
|
52619
53162
|
// "special exceptions must be caught before general exceptions", a CATCH of a class that inherits
|
|
52620
|
-
// from a class named in an earlier CATCH
|
|
53163
|
+
// from a class named before it in the same TRY, in an earlier CATCH or earlier in the same CATCH, is never reached,
|
|
53164
|
+
// this is a syntax error
|
|
52621
53165
|
// only reported when the lineage of the later class is known up to the earlier class, void classes are skipped
|
|
52622
53166
|
class Try {
|
|
52623
53167
|
static runSyntax(node, input) {
|
|
@@ -52627,23 +53171,17 @@ class Try {
|
|
|
52627
53171
|
if (statement === undefined) {
|
|
52628
53172
|
continue;
|
|
52629
53173
|
}
|
|
52630
|
-
|
|
53174
|
+
// each class counts as caught right after it, also for the next classes of the same CATCH statement
|
|
52631
53175
|
for (const c of statement.findDirectExpressions(Expressions.ClassName)) {
|
|
52632
53176
|
const token = c.getFirstToken();
|
|
52633
53177
|
const className = token.getStr().toUpperCase();
|
|
52634
|
-
|
|
52635
|
-
if (caught.size === 0) {
|
|
52636
|
-
continue;
|
|
52637
|
-
}
|
|
52638
|
-
const superclass = this.findCaughtSuperclass(className, caught, input);
|
|
53178
|
+
const superclass = caught.size === 0 ? undefined : this.findCaughtSuperclass(className, caught, input);
|
|
52639
53179
|
if (superclass !== undefined) {
|
|
52640
53180
|
const message = `CATCH of ${className} after the CATCH of its superclass ${superclass}`;
|
|
52641
53181
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message));
|
|
52642
53182
|
return;
|
|
52643
53183
|
}
|
|
52644
|
-
|
|
52645
|
-
for (const name of names) {
|
|
52646
|
-
caught.add(name);
|
|
53184
|
+
caught.add(className);
|
|
52647
53185
|
}
|
|
52648
53186
|
}
|
|
52649
53187
|
}
|
|
@@ -76286,7 +76824,7 @@ class Registry {
|
|
|
76286
76824
|
}
|
|
76287
76825
|
static abaplintVersion() {
|
|
76288
76826
|
// magic, see build script "version.js"
|
|
76289
|
-
return "2.120.
|
|
76827
|
+
return "2.120.118";
|
|
76290
76828
|
}
|
|
76291
76829
|
getDDICReferences() {
|
|
76292
76830
|
return this.ddicReferences;
|
|
@@ -80120,8 +80658,7 @@ If BEGIN OF has an INCLUDE TYPE its ignored
|
|
|
80120
80658
|
Also note that clean ABAP does not recommend aligning TYPE clauses:
|
|
80121
80659
|
https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#dont-align-type-clauses`,
|
|
80122
80660
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix],
|
|
80123
|
-
badExample: `
|
|
80124
|
-
TYPES: BEGIN OF foo,
|
|
80661
|
+
badExample: `TYPES: BEGIN OF foo,
|
|
80125
80662
|
bar TYPE i,
|
|
80126
80663
|
foobar TYPE i,
|
|
80127
80664
|
END OF foo.
|
|
@@ -80132,8 +80669,7 @@ INTERFACE lif.
|
|
|
80132
80669
|
foo TYPE i
|
|
80133
80670
|
foobar TYPE i.
|
|
80134
80671
|
ENDINTERFACE.`,
|
|
80135
|
-
goodExample: `
|
|
80136
|
-
TYPES: BEGIN OF foo,
|
|
80672
|
+
goodExample: `TYPES: BEGIN OF foo,
|
|
80137
80673
|
bar TYPE i,
|
|
80138
80674
|
foobar TYPE i,
|
|
80139
80675
|
END OF foo.
|
|
@@ -89209,14 +89745,12 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
89209
89745
|
if (from === undefined) {
|
|
89210
89746
|
return undefined;
|
|
89211
89747
|
}
|
|
89212
|
-
// UP TO after INTO is
|
|
89748
|
+
// UP TO after INTO is not valid behind WHERE or ORDER BY, move it along in front of INTO
|
|
89213
89749
|
let move = into.concatTokens();
|
|
89214
89750
|
const fixes = [];
|
|
89215
89751
|
const upTo = high.findFirstExpression(Expressions.SQLUpTo);
|
|
89216
|
-
const orderBy = high.findFirstExpression(Expressions.SQLOrderBy);
|
|
89217
89752
|
if (upTo !== undefined
|
|
89218
|
-
&& into.getLastToken().getEnd().isBefore(upTo.getFirstToken().getStart())
|
|
89219
|
-
&& (orderBy === undefined || upTo.getFirstToken().getStart().isBefore(orderBy.getFirstToken().getStart()))) {
|
|
89753
|
+
&& into.getLastToken().getEnd().isBefore(upTo.getFirstToken().getStart())) {
|
|
89220
89754
|
move = upTo.concatTokens() + ` ` + move;
|
|
89221
89755
|
fixes.push(edit_helper_1.EditHelper.deleteRange(lowFile, upTo.getFirstToken().getStart(), upTo.getLastToken().getEnd()));
|
|
89222
89756
|
}
|
|
@@ -89980,7 +90514,7 @@ ${indentation}`);
|
|
|
89980
90514
|
|| !(targetType instanceof basic_1.TableType)
|
|
89981
90515
|
|| sourceType.isWithHeader() === true
|
|
89982
90516
|
|| targetType.isWithHeader() === true
|
|
89983
|
-
|| (
|
|
90517
|
+
|| (this.concreteAccessType(targetType) !== basic_1.TableAccessType.standard && this.concreteAccessType(targetType) !== undefined)) {
|
|
89984
90518
|
return undefined;
|
|
89985
90519
|
}
|
|
89986
90520
|
for (const t of [sourceType, targetType]) {
|
|
@@ -89992,7 +90526,7 @@ ${indentation}`);
|
|
|
89992
90526
|
const fsType = (name, type) => type.isGeneric() ? "TYPE any" : "LIKE LINE OF " + name;
|
|
89993
90527
|
const sourceFS = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax, true);
|
|
89994
90528
|
const targetFS = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax, true);
|
|
89995
|
-
const addRow =
|
|
90529
|
+
const addRow = this.concreteAccessType(targetType) === undefined
|
|
89996
90530
|
? `INSERT INITIAL LINE INTO TABLE ${targetName}`
|
|
89997
90531
|
: `APPEND INITIAL LINE TO ${targetName}`;
|
|
89998
90532
|
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
@@ -91926,6 +92460,10 @@ ${indentation} output = ${uniqueName}.\n`;
|
|
|
91926
92460
|
}
|
|
91927
92461
|
return undefined;
|
|
91928
92462
|
}
|
|
92463
|
+
/** the table kind of a table with a known line type, undefined for generic tables such as TYPE STANDARD TABLE */
|
|
92464
|
+
concreteAccessType(type) {
|
|
92465
|
+
return type.getRowType() instanceof basic_1.AnyType ? undefined : type.getAccessType();
|
|
92466
|
+
}
|
|
91929
92467
|
/** a FIELD-SYMBOLS declaration is known to the scope under its bracketed spelling, so
|
|
91930
92468
|
* the collision check has to use that spelling too - otherwise a second outline in the
|
|
91931
92469
|
* same method is handed a name that is already taken and the result does not compile */
|
|
@@ -92884,12 +93422,10 @@ class EmptyEvent extends _abap_rule_1.ABAPRule {
|
|
|
92884
93422
|
shortDescription: `Empty selection screen or list processing event block`,
|
|
92885
93423
|
extendedInformation: ``,
|
|
92886
93424
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
92887
|
-
badExample: `
|
|
92888
|
-
INITIALIZATION.
|
|
93425
|
+
badExample: `INITIALIZATION.
|
|
92889
93426
|
WRITE 'hello'.
|
|
92890
93427
|
END-OF-SELECTION.`,
|
|
92891
|
-
goodExample: `
|
|
92892
|
-
START-OF-SELECTION.
|
|
93428
|
+
goodExample: `START-OF-SELECTION.
|
|
92893
93429
|
PERFORM sdf.
|
|
92894
93430
|
COMMIT WORK.`,
|
|
92895
93431
|
};
|
|
@@ -101004,18 +101540,14 @@ class ManyParentheses extends _abap_rule_1.ABAPRule {
|
|
|
101004
101540
|
title: "Too many parentheses",
|
|
101005
101541
|
shortDescription: `Searches for expressions where extra parentheses can safely be removed`,
|
|
101006
101542
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
|
|
101007
|
-
badExample: `
|
|
101008
|
-
IF ( destination IS INITIAL ).
|
|
101543
|
+
badExample: `IF ( destination IS INITIAL ).
|
|
101009
101544
|
ENDIF.
|
|
101010
101545
|
IF foo = boo AND ( bar = lar AND moo = loo ).
|
|
101011
|
-
ENDIF
|
|
101012
|
-
|
|
101013
|
-
goodExample: `
|
|
101014
|
-
IF destination IS INITIAL.
|
|
101546
|
+
ENDIF.`,
|
|
101547
|
+
goodExample: `IF destination IS INITIAL.
|
|
101015
101548
|
ENDIF.
|
|
101016
101549
|
IF foo = boo AND bar = lar AND moo = loo.
|
|
101017
|
-
ENDIF
|
|
101018
|
-
`,
|
|
101550
|
+
ENDIF.`,
|
|
101019
101551
|
};
|
|
101020
101552
|
}
|
|
101021
101553
|
getConfig() {
|
|
@@ -101240,12 +101772,10 @@ class MaxOneMethodParameterPerLine extends _abap_rule_1.ABAPRule {
|
|
|
101240
101772
|
title: "Max one method parameter definition per line",
|
|
101241
101773
|
shortDescription: `Keep max one method parameter description per line`,
|
|
101242
101774
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix],
|
|
101243
|
-
badExample: `
|
|
101244
|
-
METHODS apps_scope_token
|
|
101775
|
+
badExample: `METHODS apps_scope_token
|
|
101245
101776
|
IMPORTING
|
|
101246
101777
|
body TYPE bodyapps_scope_token client_id TYPE str.`,
|
|
101247
|
-
goodExample: `
|
|
101248
|
-
METHODS apps_scope_token
|
|
101778
|
+
goodExample: `METHODS apps_scope_token
|
|
101249
101779
|
IMPORTING
|
|
101250
101780
|
body TYPE bodyapps_scope_token
|
|
101251
101781
|
client_id TYPE str.`,
|
|
@@ -105574,21 +106104,19 @@ class OmitReceiving extends _abap_rule_1.ABAPRule {
|
|
|
105574
106104
|
shortDescription: `Omit RECEIVING`,
|
|
105575
106105
|
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#omit-receiving`,
|
|
105576
106106
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
|
|
105577
|
-
badExample: `
|
|
105578
|
-
|
|
105579
|
-
|
|
105580
|
-
|
|
105581
|
-
|
|
105582
|
-
|
|
105583
|
-
|
|
105584
|
-
|
|
105585
|
-
|
|
105586
|
-
|
|
105587
|
-
|
|
105588
|
-
|
|
105589
|
-
|
|
105590
|
-
iv_deepen_level = iv_deepen_level
|
|
105591
|
-
it_hashes = lt_hashes ).`,
|
|
106107
|
+
badExample: `upload_pack(
|
|
106108
|
+
EXPORTING
|
|
106109
|
+
io_client = lo_client
|
|
106110
|
+
iv_url = iv_url
|
|
106111
|
+
iv_deepen_level = iv_deepen_level
|
|
106112
|
+
it_hashes = lt_hashes
|
|
106113
|
+
RECEIVING
|
|
106114
|
+
rt_objects = et_objects ).`,
|
|
106115
|
+
goodExample: `et_objects = upload_pack(
|
|
106116
|
+
io_client = lo_client
|
|
106117
|
+
iv_url = iv_url
|
|
106118
|
+
iv_deepen_level = iv_deepen_level
|
|
106119
|
+
it_hashes = lt_hashes ).`,
|
|
105592
106120
|
};
|
|
105593
106121
|
}
|
|
105594
106122
|
getConfig() {
|
|
@@ -106018,15 +106546,25 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
106018
106546
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
106019
106547
|
exports.ParserMissingSpace = exports.ParserMissingSpaceConf = void 0;
|
|
106020
106548
|
const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
|
|
106549
|
+
const Tokens = __importStar(__webpack_require__(/*! ../abap/1_lexer/tokens */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js"));
|
|
106021
106550
|
const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
|
|
106022
106551
|
const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
|
|
106023
106552
|
const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
106024
106553
|
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
|
|
106025
106554
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
|
|
106026
|
-
// todo: this rule needs refactoring
|
|
106027
106555
|
class ParserMissingSpaceConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
106028
106556
|
}
|
|
106029
106557
|
exports.ParserMissingSpaceConf = ParserMissingSpaceConf;
|
|
106558
|
+
/*
|
|
106559
|
+
* The lexer records whitespace around parentheses in the token type, eg. "WParenLeft" is a "(" with whitespace
|
|
106560
|
+
* before but not after. In the expressions below the grammar also accepts the variants without inner whitespace,
|
|
106561
|
+
* this rule reports them. Elsewhere the grammar is strict, and missing whitespace gives a parser error instead.
|
|
106562
|
+
* Matched on the constructor, none of these expressions is subclassed.
|
|
106563
|
+
*/
|
|
106564
|
+
const PAREN_EXPRESSIONS = new Set([
|
|
106565
|
+
Expressions.MethodCallParam, Expressions.CondSub, Expressions.ComponentCondSub, Expressions.SQLCond,
|
|
106566
|
+
Expressions.ValueBodyLine, Expressions.NewObject, Expressions.Source
|
|
106567
|
+
]);
|
|
106030
106568
|
class ParserMissingSpace extends _abap_rule_1.ABAPRule {
|
|
106031
106569
|
constructor() {
|
|
106032
106570
|
super(...arguments);
|
|
@@ -106051,272 +106589,104 @@ This rule makes sure the spaces are consistently required across the language.`,
|
|
|
106051
106589
|
}
|
|
106052
106590
|
runParsed(file) {
|
|
106053
106591
|
const issues = [];
|
|
106054
|
-
|
|
106592
|
+
const message = "Missing space between string or character literal and parentheses";
|
|
106055
106593
|
for (const statement of file.getStatements()) {
|
|
106056
106594
|
const missing = this.missingSpace(statement);
|
|
106057
106595
|
if (missing) {
|
|
106058
|
-
|
|
106059
|
-
start = missing;
|
|
106060
|
-
const issue = issue_1.Issue.atPosition(file, start, message, this.getMetadata().key, this.conf.severity);
|
|
106061
|
-
issues.push(issue);
|
|
106596
|
+
issues.push(issue_1.Issue.atPosition(file, missing, message, this.getMetadata().key, this.conf.severity));
|
|
106062
106597
|
}
|
|
106063
106598
|
}
|
|
106064
106599
|
return issues;
|
|
106065
106600
|
}
|
|
106601
|
+
/** returns the position of the first missing space in the statement, the rule reports one issue per statement */
|
|
106066
106602
|
missingSpace(statement) {
|
|
106067
|
-
{
|
|
106068
|
-
|
|
106069
|
-
|
|
106070
|
-
const prev = tokens[i - 1];
|
|
106071
|
-
const current = tokens[i];
|
|
106072
|
-
if (prev.getStr() === ")"
|
|
106073
|
-
&& current.getStr() === "="
|
|
106074
|
-
&& prev.getRow() === current.getRow()
|
|
106075
|
-
&& prev.getEnd().getCol() === current.getStart().getCol()) {
|
|
106076
|
-
return current.getStart();
|
|
106077
|
-
}
|
|
106078
|
-
}
|
|
106079
|
-
}
|
|
106080
|
-
const found = statement.findAllExpressionsMulti([
|
|
106081
|
-
Expressions.CondSub, Expressions.SQLCond, Expressions.ValueBodyLine,
|
|
106082
|
-
Expressions.NewObject, Expressions.Cond, Expressions.ComponentCond,
|
|
106083
|
-
Expressions.Source,
|
|
106084
|
-
Expressions.ComponentCondSub, Expressions.MethodCallParam
|
|
106085
|
-
], true);
|
|
106086
|
-
let pos = undefined;
|
|
106087
|
-
for (const f of found) {
|
|
106088
|
-
const type = f.get();
|
|
106089
|
-
if (type instanceof Expressions.Cond) {
|
|
106090
|
-
pos = this.checkCond(f);
|
|
106091
|
-
}
|
|
106092
|
-
else if (type instanceof Expressions.Source) {
|
|
106093
|
-
pos = this.checkSource(f);
|
|
106094
|
-
}
|
|
106095
|
-
else if (type instanceof Expressions.CondSub) {
|
|
106096
|
-
pos = this.checkCondSub(f);
|
|
106097
|
-
}
|
|
106098
|
-
else if (type instanceof Expressions.ComponentCond) {
|
|
106099
|
-
pos = this.checkComponentCond(f);
|
|
106100
|
-
}
|
|
106101
|
-
else if (type instanceof Expressions.ComponentCondSub) {
|
|
106102
|
-
pos = this.checkComponentCondSub(f);
|
|
106103
|
-
}
|
|
106104
|
-
else if (type instanceof Expressions.SQLCond) {
|
|
106105
|
-
pos = this.checkSQLCond(f);
|
|
106106
|
-
}
|
|
106107
|
-
else if (type instanceof Expressions.ValueBodyLine) {
|
|
106108
|
-
pos = this.checkValueBodyLine(f);
|
|
106109
|
-
}
|
|
106110
|
-
else if (type instanceof Expressions.NewObject) {
|
|
106111
|
-
pos = this.checkNewObject(f);
|
|
106112
|
-
}
|
|
106113
|
-
else if (type instanceof Expressions.MethodCallParam) {
|
|
106114
|
-
pos = this.checkMethodCallParam(f);
|
|
106115
|
-
}
|
|
106116
|
-
if (pos) {
|
|
106117
|
-
return pos;
|
|
106118
|
-
}
|
|
106603
|
+
const state = { prev: undefined, prevCond: undefined, prevInDynamic: false, first: undefined };
|
|
106604
|
+
for (const child of statement.getChildren()) {
|
|
106605
|
+
this.walk(child, undefined, false, state);
|
|
106119
106606
|
}
|
|
106120
|
-
return
|
|
106607
|
+
return state.first;
|
|
106121
106608
|
}
|
|
106122
|
-
|
|
106123
|
-
|
|
106124
|
-
|
|
106125
|
-
if (children[i].get() instanceof Expressions.SQLCond) {
|
|
106126
|
-
const current = children[i];
|
|
106127
|
-
const prev = children[i - 1].getLastToken();
|
|
106128
|
-
const next = children[i + 1].getFirstToken();
|
|
106129
|
-
if (prev.getStr() === "("
|
|
106130
|
-
&& prev.getRow() === current.getFirstToken().getRow()
|
|
106131
|
-
&& prev.getCol() + 1 === current.getFirstToken().getStart().getCol()) {
|
|
106132
|
-
return current.getFirstToken().getStart();
|
|
106133
|
-
}
|
|
106134
|
-
if (next.getStr() === ")"
|
|
106135
|
-
&& next.getRow() === current.getLastToken().getRow()
|
|
106136
|
-
&& next.getCol() === current.getLastToken().getEnd().getCol()) {
|
|
106137
|
-
return current.getLastToken().getEnd();
|
|
106138
|
-
}
|
|
106139
|
-
}
|
|
106609
|
+
report(state, pos) {
|
|
106610
|
+
if (state.first === undefined || pos.isBefore(state.first)) {
|
|
106611
|
+
state.first = pos;
|
|
106140
106612
|
}
|
|
106141
|
-
return undefined;
|
|
106142
106613
|
}
|
|
106143
|
-
|
|
106144
|
-
|
|
106145
|
-
{
|
|
106146
|
-
|
|
106147
|
-
|
|
106148
|
-
if (first.getRow() === second.getRow()
|
|
106149
|
-
&& first.getEnd().getCol() === second.getStart().getCol()) {
|
|
106150
|
-
return second.getStart();
|
|
106151
|
-
}
|
|
106614
|
+
/** visits each node once in source order, checking the parentheses of expressions and each pair of tokens */
|
|
106615
|
+
walk(node, cond, inDynamic, state) {
|
|
106616
|
+
if (node instanceof nodes_1.TokenNode) {
|
|
106617
|
+
this.checkToken(node.get(), cond, inDynamic, state);
|
|
106618
|
+
return;
|
|
106152
106619
|
}
|
|
106153
|
-
|
|
106154
|
-
|
|
106155
|
-
|
|
106156
|
-
const children = cond.getChildren();
|
|
106157
|
-
for (let i = 0; i < children.length; i++) {
|
|
106158
|
-
if (children[i].get() instanceof Expressions.Cond) {
|
|
106159
|
-
const current = children[i];
|
|
106160
|
-
const prev = children[i - 1].getLastToken();
|
|
106161
|
-
const next = children[i + 1].getFirstToken();
|
|
106162
|
-
if (prev.getStr() === "("
|
|
106163
|
-
&& prev.getRow() === current.getFirstToken().getRow()
|
|
106164
|
-
&& prev.getCol() + 1 === current.getFirstToken().getStart().getCol()) {
|
|
106165
|
-
return current.getFirstToken().getStart();
|
|
106166
|
-
}
|
|
106167
|
-
if (next.getStr() === ")"
|
|
106168
|
-
&& next.getRow() === current.getLastToken().getRow()
|
|
106169
|
-
&& next.getCol() === current.getLastToken().getEnd().getCol()) {
|
|
106170
|
-
return current.getLastToken().getEnd();
|
|
106171
|
-
}
|
|
106172
|
-
}
|
|
106620
|
+
const type = node.get();
|
|
106621
|
+
if (cond === undefined && (type instanceof Expressions.Cond || type instanceof Expressions.ComponentCond)) {
|
|
106622
|
+
cond = node;
|
|
106173
106623
|
}
|
|
106174
|
-
|
|
106175
|
-
|
|
106176
|
-
|
|
106177
|
-
const children = cond.getChildren();
|
|
106178
|
-
for (let i = 0; i < children.length; i++) {
|
|
106179
|
-
if (children[i].get() instanceof Expressions.ComponentCond) {
|
|
106180
|
-
const current = children[i];
|
|
106181
|
-
const prev = children[i - 1].getLastToken();
|
|
106182
|
-
const next = children[i + 1].getFirstToken();
|
|
106183
|
-
if (prev.getStr() === "("
|
|
106184
|
-
&& prev.getRow() === current.getFirstToken().getRow()
|
|
106185
|
-
&& prev.getCol() + 1 === current.getFirstToken().getStart().getCol()) {
|
|
106186
|
-
return current.getFirstToken().getStart();
|
|
106187
|
-
}
|
|
106188
|
-
if (next.getStr() === ")"
|
|
106189
|
-
&& next.getRow() === current.getLastToken().getRow()
|
|
106190
|
-
&& next.getCol() === current.getLastToken().getEnd().getCol()) {
|
|
106191
|
-
return current.getLastToken().getEnd();
|
|
106192
|
-
}
|
|
106193
|
-
}
|
|
106624
|
+
inDynamic = inDynamic || type instanceof Expressions.Dynamic;
|
|
106625
|
+
if (PAREN_EXPRESSIONS.has(type.constructor)) {
|
|
106626
|
+
this.checkParens(node, state);
|
|
106194
106627
|
}
|
|
106195
|
-
|
|
106196
|
-
|
|
106197
|
-
checkComponentCond(cond) {
|
|
106198
|
-
const children = cond.getAllTokens();
|
|
106199
|
-
for (let i = 0; i < children.length - 1; i++) {
|
|
106200
|
-
const current = children[i];
|
|
106201
|
-
const next = children[i + 1];
|
|
106202
|
-
if (next.getStr().startsWith("'")
|
|
106203
|
-
&& next.getRow() === current.getRow()
|
|
106204
|
-
&& next.getCol() === current.getEnd().getCol()) {
|
|
106205
|
-
return current.getEnd();
|
|
106206
|
-
}
|
|
106628
|
+
for (const child of node.getChildren()) {
|
|
106629
|
+
this.walk(child, cond, inDynamic, state);
|
|
106207
106630
|
}
|
|
106208
|
-
return undefined;
|
|
106209
106631
|
}
|
|
106210
|
-
|
|
106211
|
-
|
|
106212
|
-
|
|
106632
|
+
/** "foo( 'bar')" and "IF (foo = bar )", parentheses directly part of the expression need inner whitespace */
|
|
106633
|
+
checkParens(node, state) {
|
|
106634
|
+
var _a;
|
|
106635
|
+
const children = node.getChildren();
|
|
106636
|
+
let dynamicAccess = false;
|
|
106213
106637
|
for (let i = 0; i < children.length; i++) {
|
|
106214
|
-
const
|
|
106215
|
-
if (
|
|
106216
|
-
|
|
106217
|
-
|
|
106218
|
-
|
|
106219
|
-
|
|
106220
|
-
|
|
106221
|
-
|
|
106222
|
-
|
|
106638
|
+
const child = children[i];
|
|
106639
|
+
if (!(child instanceof nodes_1.TokenNode)) {
|
|
106640
|
+
continue;
|
|
106641
|
+
}
|
|
106642
|
+
const token = child.get();
|
|
106643
|
+
if (token instanceof Tokens.ParenLeft || token instanceof Tokens.WParenLeft) {
|
|
106644
|
+
// dynamic component and attribute access, "foo-(name)" and "foo->(name)"
|
|
106645
|
+
const prev = (_a = children[i - 1]) === null || _a === void 0 ? void 0 : _a.get();
|
|
106646
|
+
if (prev instanceof Tokens.Dash || prev instanceof Tokens.InstanceArrow) {
|
|
106647
|
+
dynamicAccess = true;
|
|
106223
106648
|
}
|
|
106224
|
-
|
|
106225
|
-
|
|
106226
|
-
&& prev.getRow() === current.getFirstToken().getRow()
|
|
106227
|
-
&& prev.getEnd().getCol() === current.getFirstToken().getStart().getCol()) {
|
|
106228
|
-
return current.getLastToken().getEnd();
|
|
106649
|
+
else {
|
|
106650
|
+
this.report(state, token.getEnd());
|
|
106229
106651
|
}
|
|
106230
106652
|
}
|
|
106231
|
-
|
|
106232
|
-
|
|
106233
|
-
|
|
106234
|
-
checkCond(cond) {
|
|
106235
|
-
const children = cond.getAllTokens();
|
|
106236
|
-
const dynamic = cond.findAllExpressions(Expressions.Dynamic);
|
|
106237
|
-
for (let i = 0; i < children.length - 1; i++) {
|
|
106238
|
-
const current = children[i];
|
|
106239
|
-
const next = children[i + 1];
|
|
106240
|
-
if (next.getStr().startsWith("'")
|
|
106241
|
-
&& next.getRow() === current.getRow()
|
|
106242
|
-
&& next.getCol() === current.getEnd().getCol()) {
|
|
106243
|
-
// skip if the token is part of a DYNAMIC expression
|
|
106244
|
-
let isDynamic = false;
|
|
106245
|
-
outer: for (const d of dynamic) {
|
|
106246
|
-
for (const t of d.getAllTokens()) {
|
|
106247
|
-
if (t === next || t === current) {
|
|
106248
|
-
isDynamic = true;
|
|
106249
|
-
break outer;
|
|
106250
|
-
}
|
|
106251
|
-
}
|
|
106653
|
+
else if (token instanceof Tokens.ParenRight || token instanceof Tokens.ParenRightW) {
|
|
106654
|
+
if (dynamicAccess) {
|
|
106655
|
+
dynamicAccess = false;
|
|
106252
106656
|
}
|
|
106253
|
-
|
|
106254
|
-
|
|
106657
|
+
else {
|
|
106658
|
+
this.report(state, token.getStart());
|
|
106255
106659
|
}
|
|
106256
106660
|
}
|
|
106257
|
-
|
|
106258
|
-
|
|
106259
|
-
}
|
|
106260
|
-
checkSource(cond) {
|
|
106261
|
-
var _a, _b;
|
|
106262
|
-
// Source nests recursively, eg. "a && b && c", read only the tokens at the edges
|
|
106263
|
-
const lastTokens = this.lastTokens(cond, 2);
|
|
106264
|
-
if (lastTokens.length < 2) {
|
|
106265
|
-
return undefined;
|
|
106266
|
-
}
|
|
106267
|
-
if (cond.getFirstToken().getStr().toUpperCase() === "CONV") {
|
|
106268
|
-
const directChildren = cond.getChildren();
|
|
106269
|
-
const first = (_a = directChildren[2]) === null || _a === void 0 ? void 0 : _a.getLastToken();
|
|
106270
|
-
const second = (_b = directChildren[3]) === null || _b === void 0 ? void 0 : _b.getFirstToken();
|
|
106271
|
-
if (first
|
|
106272
|
-
&& first.getStr() === "("
|
|
106273
|
-
&& second
|
|
106274
|
-
&& first.getRow() === second.getRow()
|
|
106275
|
-
&& first.getCol() + 1 === second.getStart().getCol()) {
|
|
106276
|
-
return second.getStart();
|
|
106277
|
-
}
|
|
106278
|
-
}
|
|
106279
|
-
{
|
|
106280
|
-
const [nextLast, last] = lastTokens;
|
|
106281
|
-
if (nextLast.getStr().startsWith("'")
|
|
106282
|
-
&& nextLast.getRow() === last.getRow()
|
|
106283
|
-
&& nextLast.getEnd().getCol() === last.getStart().getCol()) {
|
|
106284
|
-
return last.getEnd();
|
|
106661
|
+
else if (token instanceof Tokens.WParenRight || token instanceof Tokens.WParenRightW) {
|
|
106662
|
+
dynamicAccess = false;
|
|
106285
106663
|
}
|
|
106286
106664
|
}
|
|
106287
|
-
return undefined;
|
|
106288
|
-
}
|
|
106289
|
-
/** collects the last "count" tokens of the node in source order, without visiting the rest of the tree */
|
|
106290
|
-
lastTokens(node, count, found = []) {
|
|
106291
|
-
if (node instanceof nodes_1.TokenNode) {
|
|
106292
|
-
found.unshift(node.get());
|
|
106293
|
-
return found;
|
|
106294
|
-
}
|
|
106295
|
-
const children = node.getChildren();
|
|
106296
|
-
for (let i = children.length - 1; i >= 0 && found.length < count; i--) {
|
|
106297
|
-
this.lastTokens(children[i], count, found);
|
|
106298
|
-
}
|
|
106299
|
-
return found;
|
|
106300
106665
|
}
|
|
106301
|
-
|
|
106302
|
-
const
|
|
106303
|
-
{
|
|
106304
|
-
|
|
106305
|
-
|
|
106306
|
-
|
|
106307
|
-
&& first.getCol() + 1 === second.getStart().getCol()) {
|
|
106308
|
-
return second.getStart();
|
|
106666
|
+
checkToken(current, cond, inDynamic, state) {
|
|
106667
|
+
const prev = state.prev;
|
|
106668
|
+
if (prev !== undefined) {
|
|
106669
|
+
// "foo( )= bar"
|
|
106670
|
+
if ((prev instanceof Tokens.ParenRight || prev instanceof Tokens.WParenRight) && current.getStr() === "=") {
|
|
106671
|
+
this.report(state, current.getStart());
|
|
106309
106672
|
}
|
|
106310
|
-
|
|
106311
|
-
|
|
106312
|
-
|
|
106313
|
-
|
|
106314
|
-
|
|
106315
|
-
&&
|
|
106316
|
-
|
|
106673
|
+
// "IF foo ='bar'", dynamic parts like "('NAME')" are allowed without spaces
|
|
106674
|
+
if (current.getStr().startsWith("'")
|
|
106675
|
+
&& cond !== undefined
|
|
106676
|
+
&& cond === state.prevCond
|
|
106677
|
+
&& state.prevInDynamic === false
|
|
106678
|
+
&& inDynamic === false
|
|
106679
|
+
&& this.isAdjacent(prev, current)) {
|
|
106680
|
+
this.report(state, prev.getEnd());
|
|
106317
106681
|
}
|
|
106318
106682
|
}
|
|
106319
|
-
|
|
106683
|
+
state.prev = current;
|
|
106684
|
+
state.prevCond = cond;
|
|
106685
|
+
state.prevInDynamic = inDynamic;
|
|
106686
|
+
}
|
|
106687
|
+
isAdjacent(first, second) {
|
|
106688
|
+
return first.getRow() === second.getRow()
|
|
106689
|
+
&& first.getEnd().getCol() === second.getStart().getCol();
|
|
106320
106690
|
}
|
|
106321
106691
|
}
|
|
106322
106692
|
exports.ParserMissingSpace = ParserMissingSpace;
|
|
@@ -106587,7 +106957,7 @@ class PreferAbapBoolValues extends _abap_rule_1.ABAPRule {
|
|
|
106587
106957
|
title: "Prefer abap_true and abap_false",
|
|
106588
106958
|
shortDescription: `Use abap_true and abap_false instead of 'X' and ' ' for abap_bool variables`,
|
|
106589
106959
|
// eslint-disable-next-line max-len
|
|
106590
|
-
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-abap_true-
|
|
106960
|
+
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-abap_true-and-abap_false-for-comparisons`,
|
|
106591
106961
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
|
|
106592
106962
|
badExample: `DATA lv_flag TYPE abap_bool.\nlv_flag = 'X'.`,
|
|
106593
106963
|
goodExample: `DATA lv_flag TYPE abap_bool.\nlv_flag = abap_true.`,
|
|
@@ -122425,6 +122795,440 @@ function unescape(str) {
|
|
|
122425
122795
|
|
|
122426
122796
|
/***/ },
|
|
122427
122797
|
|
|
122798
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/cds_metadata.js"
|
|
122799
|
+
/*!*********************************************************************!*\
|
|
122800
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/cds_metadata.js ***!
|
|
122801
|
+
\*********************************************************************/
|
|
122802
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
122803
|
+
|
|
122804
|
+
"use strict";
|
|
122805
|
+
|
|
122806
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
122807
|
+
if (k2 === undefined) k2 = k;
|
|
122808
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
122809
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
122810
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
122811
|
+
}
|
|
122812
|
+
Object.defineProperty(o, k2, desc);
|
|
122813
|
+
}) : (function(o, m, k, k2) {
|
|
122814
|
+
if (k2 === undefined) k2 = k;
|
|
122815
|
+
o[k2] = m[k];
|
|
122816
|
+
}));
|
|
122817
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
122818
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
122819
|
+
}) : function(o, v) {
|
|
122820
|
+
o["default"] = v;
|
|
122821
|
+
});
|
|
122822
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
122823
|
+
var ownKeys = function(o) {
|
|
122824
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
122825
|
+
var ar = [];
|
|
122826
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
122827
|
+
return ar;
|
|
122828
|
+
};
|
|
122829
|
+
return ownKeys(o);
|
|
122830
|
+
};
|
|
122831
|
+
return function (mod) {
|
|
122832
|
+
if (mod && mod.__esModule) return mod;
|
|
122833
|
+
var result = {};
|
|
122834
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
122835
|
+
__setModuleDefault(result, mod);
|
|
122836
|
+
return result;
|
|
122837
|
+
};
|
|
122838
|
+
})();
|
|
122839
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
122840
|
+
exports.CDSMetadata = void 0;
|
|
122841
|
+
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
122842
|
+
const cds = abaplint.ExpressionsCDS;
|
|
122843
|
+
/** The metadata of a CDS entity, as far as it is written in its own source: its annotations, its
|
|
122844
|
+
* elements and its associations. Associations a projection or a view exposes from its source are
|
|
122845
|
+
* taken from that source's metadata. Metadata extensions (DDLX) are not merged. */
|
|
122846
|
+
class CDSMetadata {
|
|
122847
|
+
reg;
|
|
122848
|
+
cache = new Map();
|
|
122849
|
+
constructor(reg) {
|
|
122850
|
+
this.reg = reg;
|
|
122851
|
+
}
|
|
122852
|
+
build(obj) {
|
|
122853
|
+
const key = obj.getName().toUpperCase();
|
|
122854
|
+
if (this.cache.has(key)) {
|
|
122855
|
+
return this.cache.get(key);
|
|
122856
|
+
}
|
|
122857
|
+
this.cache.set(key, undefined); // cycle guard, associations can point back
|
|
122858
|
+
const tree = obj.getTree() ?? (obj.parse(), obj.getTree());
|
|
122859
|
+
const result = tree === undefined ? undefined : this.definition(tree);
|
|
122860
|
+
this.cache.set(key, result);
|
|
122861
|
+
return result;
|
|
122862
|
+
}
|
|
122863
|
+
definition(root) {
|
|
122864
|
+
const result = {
|
|
122865
|
+
definitionType: this.definitionType(root),
|
|
122866
|
+
root: root.findDirectTokenByText("ROOT") !== undefined,
|
|
122867
|
+
annotations: [],
|
|
122868
|
+
fields: [],
|
|
122869
|
+
associations: [],
|
|
122870
|
+
};
|
|
122871
|
+
for (const child of root.getChildren()) {
|
|
122872
|
+
if (child.get() instanceof cds.CDSAnnotation) {
|
|
122873
|
+
result.annotations.push(CDSMetadata.annotation(child));
|
|
122874
|
+
}
|
|
122875
|
+
else {
|
|
122876
|
+
break;
|
|
122877
|
+
}
|
|
122878
|
+
}
|
|
122879
|
+
const def = root.get();
|
|
122880
|
+
if (def instanceof cds.CDSDefineView || def instanceof cds.CDSDefineProjection) {
|
|
122881
|
+
const select = def instanceof cds.CDSDefineView ? root.findFirstExpression(cds.CDSSelect) : root;
|
|
122882
|
+
if (select !== undefined) {
|
|
122883
|
+
for (const a of select.findDirectExpressions(cds.CDSAssociation)) {
|
|
122884
|
+
result.associations.push(this.association(a, "ASSOCIATION"));
|
|
122885
|
+
}
|
|
122886
|
+
for (const c of select.findDirectExpressions(cds.CDSComposition)) {
|
|
122887
|
+
result.associations.push(this.association(c, "COMPOSITION"));
|
|
122888
|
+
}
|
|
122889
|
+
for (const e of select.findDirectExpressions(cds.CDSElement)) {
|
|
122890
|
+
this.element(e, result, this.sources(root));
|
|
122891
|
+
}
|
|
122892
|
+
}
|
|
122893
|
+
}
|
|
122894
|
+
else {
|
|
122895
|
+
this.signature(root, result);
|
|
122896
|
+
}
|
|
122897
|
+
return result;
|
|
122898
|
+
}
|
|
122899
|
+
definitionType(root) {
|
|
122900
|
+
const def = root.get();
|
|
122901
|
+
if (def instanceof cds.CDSDefineView) {
|
|
122902
|
+
return root.findDirectTokenByText("ENTITY") ? "VIEW_ENTITY" : "VIEW";
|
|
122903
|
+
}
|
|
122904
|
+
else if (def instanceof cds.CDSDefineProjection) {
|
|
122905
|
+
return "PROJECTION_VIEW";
|
|
122906
|
+
}
|
|
122907
|
+
else if (def instanceof cds.CDSDefineAbstract) {
|
|
122908
|
+
return "ABSTRACT_ENTITY";
|
|
122909
|
+
}
|
|
122910
|
+
else if (def instanceof cds.CDSDefineCustom) {
|
|
122911
|
+
return "CUSTOM_ENTITY";
|
|
122912
|
+
}
|
|
122913
|
+
else if (def instanceof cds.CDSDefineTableFunction) {
|
|
122914
|
+
return "TABLE_FUNCTION";
|
|
122915
|
+
}
|
|
122916
|
+
else if (def instanceof cds.CDSDefineHierarchy) {
|
|
122917
|
+
return "HIERARCHY";
|
|
122918
|
+
}
|
|
122919
|
+
else if (def instanceof cds.CDSDefineTableEntity) {
|
|
122920
|
+
return "TABLE_ENTITY";
|
|
122921
|
+
}
|
|
122922
|
+
else if (def instanceof cds.CDSDefineExternalEntity) {
|
|
122923
|
+
return "EXTERNAL_ENTITY";
|
|
122924
|
+
}
|
|
122925
|
+
return def.constructor.name;
|
|
122926
|
+
}
|
|
122927
|
+
/** The entities selected or projected from, for the associations they expose */
|
|
122928
|
+
sources(root) {
|
|
122929
|
+
const ret = [];
|
|
122930
|
+
if (root.get() instanceof cds.CDSDefineProjection) {
|
|
122931
|
+
// the first name is the projection's own, the second the projected entity
|
|
122932
|
+
const name = root.findDirectExpressions(cds.CDSName)[1];
|
|
122933
|
+
if (name) {
|
|
122934
|
+
ret.push(name.concatTokens().toUpperCase());
|
|
122935
|
+
}
|
|
122936
|
+
}
|
|
122937
|
+
for (const s of root.findAllExpressions(cds.CDSSource)) {
|
|
122938
|
+
const name = s.findDirectExpression(cds.CDSPrefixedName) ?? s.getFirstChild();
|
|
122939
|
+
if (name) {
|
|
122940
|
+
ret.push(name.concatTokens().replace(/ /g, "").toUpperCase());
|
|
122941
|
+
}
|
|
122942
|
+
}
|
|
122943
|
+
return ret;
|
|
122944
|
+
}
|
|
122945
|
+
sourceAssociation(sources, name) {
|
|
122946
|
+
for (const source of sources) {
|
|
122947
|
+
const obj = this.reg.getObject("DDLS", source);
|
|
122948
|
+
const found = obj ? this.build(obj)?.associations.find(a => a.name.toUpperCase() === name.toUpperCase()) : undefined;
|
|
122949
|
+
if (found) {
|
|
122950
|
+
return found;
|
|
122951
|
+
}
|
|
122952
|
+
}
|
|
122953
|
+
return undefined;
|
|
122954
|
+
}
|
|
122955
|
+
element(e, result, sources) {
|
|
122956
|
+
const annotations = e.findDirectExpressions(cds.CDSAnnotation).map(a => CDSMetadata.annotation(a));
|
|
122957
|
+
const prefixed = e.findDirectExpression(cds.CDSPrefixedName);
|
|
122958
|
+
const path = prefixed?.findAllExpressions(cds.CDSName).map(n => n.concatTokens()) ?? [];
|
|
122959
|
+
const as = e.findDirectExpressions(cds.CDSAs).map(a => this.alias(a)).find(a => a !== undefined);
|
|
122960
|
+
const redirected = this.redirection(e) ?? e.findDirectExpressions(cds.CDSAs).map(a => this.redirection(a)).find(r => r);
|
|
122961
|
+
let name = as;
|
|
122962
|
+
if (name === undefined && path.length > 0) {
|
|
122963
|
+
name = redirected ? path[0] : path[path.length - 1];
|
|
122964
|
+
}
|
|
122965
|
+
if (name === undefined && e.findDirectTokenByText("VIRTUAL")) {
|
|
122966
|
+
name = e.findFirstExpression(cds.CDSName)?.concatTokens();
|
|
122967
|
+
}
|
|
122968
|
+
if (name === undefined) {
|
|
122969
|
+
return;
|
|
122970
|
+
}
|
|
122971
|
+
// an exposed association, declared here or in a source
|
|
122972
|
+
const exposes = path.length > 0 ? path[path.length - 1] : name;
|
|
122973
|
+
const declared = path.length === 1
|
|
122974
|
+
? result.associations.find(a => a.name.toUpperCase() === exposes.toUpperCase()) : undefined;
|
|
122975
|
+
if (declared) {
|
|
122976
|
+
declared.exposed = true;
|
|
122977
|
+
declared.annotations.push(...annotations);
|
|
122978
|
+
if (redirected) {
|
|
122979
|
+
declared.target = redirected.target;
|
|
122980
|
+
}
|
|
122981
|
+
return;
|
|
122982
|
+
}
|
|
122983
|
+
const inherited = redirected !== undefined || path.length > 0 ? this.sourceAssociation(sources, exposes) : undefined;
|
|
122984
|
+
if (inherited || redirected) {
|
|
122985
|
+
result.associations.push({
|
|
122986
|
+
name: name,
|
|
122987
|
+
target: redirected?.target ?? inherited.target,
|
|
122988
|
+
type: redirected?.type ?? inherited.type,
|
|
122989
|
+
cardinality: inherited?.cardinality,
|
|
122990
|
+
condition: inherited?.condition,
|
|
122991
|
+
defaultFilter: inherited?.defaultFilter,
|
|
122992
|
+
exposed: true,
|
|
122993
|
+
annotations: annotations,
|
|
122994
|
+
});
|
|
122995
|
+
return;
|
|
122996
|
+
}
|
|
122997
|
+
result.fields.push({
|
|
122998
|
+
name: name,
|
|
122999
|
+
key: e.findDirectTokenByText("KEY") !== undefined,
|
|
123000
|
+
virtual: e.findDirectTokenByText("VIRTUAL") !== undefined,
|
|
123001
|
+
annotations: annotations,
|
|
123002
|
+
});
|
|
123003
|
+
}
|
|
123004
|
+
alias(as) {
|
|
123005
|
+
const ret = [];
|
|
123006
|
+
for (const c of as.getChildren().slice(1)) {
|
|
123007
|
+
if (c.concatTokens().startsWith(":")) {
|
|
123008
|
+
break;
|
|
123009
|
+
}
|
|
123010
|
+
ret.push(c.concatTokens());
|
|
123011
|
+
}
|
|
123012
|
+
return ret.length > 0 ? ret.join("") : undefined;
|
|
123013
|
+
}
|
|
123014
|
+
/** ": REDIRECTED TO [PARENT | COMPOSITION CHILD] target", in an element or its alias */
|
|
123015
|
+
redirection(node) {
|
|
123016
|
+
const children = node.getChildren();
|
|
123017
|
+
const to = children.findIndex(c => c instanceof abaplint.Nodes.TokenNode && c.getFirstToken().getStr().toUpperCase() === "TO"
|
|
123018
|
+
&& children.some(r => r instanceof abaplint.Nodes.TokenNode && r.getFirstToken().getStr().toUpperCase() === "REDIRECTED"));
|
|
123019
|
+
if (to < 0) {
|
|
123020
|
+
return undefined;
|
|
123021
|
+
}
|
|
123022
|
+
const rest = children.slice(to + 1).map(c => c.concatTokens().toUpperCase());
|
|
123023
|
+
const target = children.slice(to + 1).find(c => c.get() instanceof cds.CDSName)?.concatTokens();
|
|
123024
|
+
if (target === undefined) {
|
|
123025
|
+
return undefined;
|
|
123026
|
+
}
|
|
123027
|
+
let type = "ASSOCIATION";
|
|
123028
|
+
if (rest.includes("PARENT")) {
|
|
123029
|
+
type = "TO_PARENT";
|
|
123030
|
+
}
|
|
123031
|
+
else if (rest.includes("CHILD")) {
|
|
123032
|
+
type = "COMPOSITION";
|
|
123033
|
+
}
|
|
123034
|
+
return { target, type };
|
|
123035
|
+
}
|
|
123036
|
+
/** abstract and custom entities and table functions list their elements inline: name : type ; */
|
|
123037
|
+
signature(root, result) {
|
|
123038
|
+
let inBody = false;
|
|
123039
|
+
let annotations = [];
|
|
123040
|
+
let key = false;
|
|
123041
|
+
let name;
|
|
123042
|
+
let assoc;
|
|
123043
|
+
for (const child of root.getChildren()) {
|
|
123044
|
+
const text = child instanceof abaplint.Nodes.TokenNode ? child.getFirstToken().getStr().toUpperCase() : "";
|
|
123045
|
+
if (inBody === false) {
|
|
123046
|
+
inBody = text === "{";
|
|
123047
|
+
continue;
|
|
123048
|
+
}
|
|
123049
|
+
if (child.get() instanceof cds.CDSAnnotation) {
|
|
123050
|
+
annotations.push(CDSMetadata.annotation(child));
|
|
123051
|
+
}
|
|
123052
|
+
else if (text === "KEY") {
|
|
123053
|
+
key = true;
|
|
123054
|
+
}
|
|
123055
|
+
else if (child.get() instanceof cds.CDSName && name === undefined) {
|
|
123056
|
+
name = child.concatTokens();
|
|
123057
|
+
}
|
|
123058
|
+
else if (child.get() instanceof cds.CDSAssociation || child.get() instanceof cds.CDSComposition) {
|
|
123059
|
+
assoc = child;
|
|
123060
|
+
}
|
|
123061
|
+
else if (text === ";" || text === "}") {
|
|
123062
|
+
if (name !== undefined && assoc !== undefined) {
|
|
123063
|
+
const a = this.association(assoc, assoc.get() instanceof cds.CDSComposition ? "COMPOSITION" : "ASSOCIATION");
|
|
123064
|
+
a.name = name;
|
|
123065
|
+
a.exposed = true;
|
|
123066
|
+
a.annotations = annotations;
|
|
123067
|
+
result.associations.push(a);
|
|
123068
|
+
}
|
|
123069
|
+
else if (name !== undefined) {
|
|
123070
|
+
result.fields.push({ name, key, virtual: false, annotations });
|
|
123071
|
+
}
|
|
123072
|
+
annotations = [];
|
|
123073
|
+
key = false;
|
|
123074
|
+
name = undefined;
|
|
123075
|
+
assoc = undefined;
|
|
123076
|
+
if (text === "}") {
|
|
123077
|
+
return;
|
|
123078
|
+
}
|
|
123079
|
+
}
|
|
123080
|
+
}
|
|
123081
|
+
}
|
|
123082
|
+
association(node, type) {
|
|
123083
|
+
const relation = node.findDirectExpression(cds.CDSRelation);
|
|
123084
|
+
const skip = new Set();
|
|
123085
|
+
relation?.findDirectExpressions(cds.CDSAs).forEach(a => skip.add(a));
|
|
123086
|
+
relation?.findDirectExpressions(cds.CDSParametersSelect).forEach(a => skip.add(a));
|
|
123087
|
+
const target = relation?.getChildren().filter(c => !skip.has(c)).map(c => c.concatTokens().replace(/ /g, "")).join("") || "";
|
|
123088
|
+
const as = relation?.findDirectExpression(cds.CDSAs);
|
|
123089
|
+
const conditions = node.findDirectExpressions(cds.CDSCondition);
|
|
123090
|
+
// the words before the target: ASSOCIATION [0..1] TO, ASSOCIATION OF MANY TO ONE, COMPOSITION OF ONE TO MANY, ...
|
|
123091
|
+
const words = [];
|
|
123092
|
+
for (const c of node.getChildren()) {
|
|
123093
|
+
if (c === relation) {
|
|
123094
|
+
break;
|
|
123095
|
+
}
|
|
123096
|
+
words.push(...c.concatTokens().toUpperCase().split(/\s+|(?=\[|\]|\.\.)|(?<=\[|\]|\.\.)/).filter(w => w !== ""));
|
|
123097
|
+
}
|
|
123098
|
+
if (words.includes("PARENT")) {
|
|
123099
|
+
type = "TO_PARENT";
|
|
123100
|
+
}
|
|
123101
|
+
return {
|
|
123102
|
+
name: (as ? this.alias(as) : undefined) ?? target,
|
|
123103
|
+
target: target,
|
|
123104
|
+
type: type,
|
|
123105
|
+
cardinality: this.cardinality(words, type),
|
|
123106
|
+
condition: conditions[0] ? CDSMetadata.text(conditions[0]) : undefined,
|
|
123107
|
+
defaultFilter: conditions[1] ? CDSMetadata.text(conditions[1]) : undefined,
|
|
123108
|
+
exposed: false,
|
|
123109
|
+
annotations: [],
|
|
123110
|
+
};
|
|
123111
|
+
}
|
|
123112
|
+
cardinality(words, type) {
|
|
123113
|
+
if (type === "TO_PARENT") {
|
|
123114
|
+
return { min: 1, max: 1 };
|
|
123115
|
+
}
|
|
123116
|
+
const open = words.indexOf("[");
|
|
123117
|
+
if (open >= 0) {
|
|
123118
|
+
const inside = words.slice(open + 1, words.indexOf("]")).join("").split("..");
|
|
123119
|
+
const num = (s) => s === "*" ? "*" : parseInt(s, 10);
|
|
123120
|
+
// [n] is [0..n]
|
|
123121
|
+
return inside.length === 1 ? { min: 0, max: num(inside[0]) } : { min: num(inside[0]), max: num(inside[1]) };
|
|
123122
|
+
}
|
|
123123
|
+
// the target side is the last one: TO ONE, OF MANY TO ONE, OF EXACT ONE, ONE TO MANY TO
|
|
123124
|
+
const sides = words.filter(w => w !== "ASSOCIATION" && w !== "COMPOSITION" && w !== "OF")
|
|
123125
|
+
.join(" ").split("TO").map(s => s.trim()).filter(s => s !== "");
|
|
123126
|
+
const side = sides[sides.length - 1];
|
|
123127
|
+
if (side === "EXACT ONE") {
|
|
123128
|
+
return { min: 1, max: 1 };
|
|
123129
|
+
}
|
|
123130
|
+
else if (side === "ONE") {
|
|
123131
|
+
return { min: 0, max: 1 };
|
|
123132
|
+
}
|
|
123133
|
+
else if (side === "MANY") {
|
|
123134
|
+
return { min: 0, max: "*" };
|
|
123135
|
+
}
|
|
123136
|
+
return type === "COMPOSITION" ? { min: 0, max: "*" } : { min: 0, max: 1 };
|
|
123137
|
+
}
|
|
123138
|
+
///////////////////////////////
|
|
123139
|
+
/** the source text, tokens separated by single spaces except around path dots: $projection.id = _Item.id */
|
|
123140
|
+
static text(node) {
|
|
123141
|
+
let ret = "";
|
|
123142
|
+
let previous = "";
|
|
123143
|
+
for (const token of node.getTokens().map(t => t.getStr())) {
|
|
123144
|
+
ret += (ret === "" || token === "." || previous === "." ? "" : " ") + token;
|
|
123145
|
+
previous = token;
|
|
123146
|
+
}
|
|
123147
|
+
return ret;
|
|
123148
|
+
}
|
|
123149
|
+
static annotation(node) {
|
|
123150
|
+
const children = node.getChildren();
|
|
123151
|
+
const colon = children.findIndex(c => c instanceof abaplint.Nodes.TokenNode && c.getFirstToken().getStr() === ":");
|
|
123152
|
+
const nameParts = (colon < 0 ? children : children.slice(0, colon)).map(c => c.concatTokens());
|
|
123153
|
+
const name = nameParts.join("").replace(/\s/g, "").replace(/^@<?/, "");
|
|
123154
|
+
const valueNode = colon < 0 ? undefined : children[colon + 1];
|
|
123155
|
+
// an annotation without a value is true
|
|
123156
|
+
const value = valueNode instanceof abaplint.Nodes.ExpressionNode ? CDSMetadata.value(valueNode) : true;
|
|
123157
|
+
return { name, value };
|
|
123158
|
+
}
|
|
123159
|
+
static value(node) {
|
|
123160
|
+
const type = node.get();
|
|
123161
|
+
if (type instanceof cds.CDSAnnotationArray) {
|
|
123162
|
+
return node.getChildren()
|
|
123163
|
+
.filter((c) => c instanceof abaplint.Nodes.ExpressionNode)
|
|
123164
|
+
.map(c => CDSMetadata.value(c));
|
|
123165
|
+
}
|
|
123166
|
+
else if (type instanceof cds.CDSAnnotationObject) {
|
|
123167
|
+
const record = {};
|
|
123168
|
+
let path = [];
|
|
123169
|
+
let assigned = false;
|
|
123170
|
+
for (const c of node.getChildren()) {
|
|
123171
|
+
if (c.get() instanceof cds.CDSName) {
|
|
123172
|
+
path.push(c.concatTokens());
|
|
123173
|
+
}
|
|
123174
|
+
else if (c instanceof abaplint.Nodes.ExpressionNode) {
|
|
123175
|
+
CDSMetadata.set(record, path, CDSMetadata.value(c));
|
|
123176
|
+
assigned = true;
|
|
123177
|
+
}
|
|
123178
|
+
else {
|
|
123179
|
+
const text = c.getFirstToken().getStr();
|
|
123180
|
+
if ((text === "," || text === "}") && path.length > 0) {
|
|
123181
|
+
if (assigned === false) {
|
|
123182
|
+
CDSMetadata.set(record, path, true);
|
|
123183
|
+
}
|
|
123184
|
+
path = [];
|
|
123185
|
+
assigned = false;
|
|
123186
|
+
}
|
|
123187
|
+
}
|
|
123188
|
+
}
|
|
123189
|
+
return record;
|
|
123190
|
+
}
|
|
123191
|
+
return CDSMetadata.simple(node);
|
|
123192
|
+
}
|
|
123193
|
+
static simple(node) {
|
|
123194
|
+
const tokens = node.getTokens().map(t => t.getStr());
|
|
123195
|
+
const first = tokens[0] ?? "";
|
|
123196
|
+
if (first.startsWith("'")) {
|
|
123197
|
+
return first.substring(1, first.length - 1).replace(/''/g, "'");
|
|
123198
|
+
}
|
|
123199
|
+
else if (first === "#" && tokens[1] === "(") {
|
|
123200
|
+
return { "#()": tokens.slice(2, tokens.length - 1).join(" ") };
|
|
123201
|
+
}
|
|
123202
|
+
else if (first.startsWith("#")) {
|
|
123203
|
+
return { "#": first.substring(1) };
|
|
123204
|
+
}
|
|
123205
|
+
const lower = tokens.join("").toLowerCase();
|
|
123206
|
+
if (lower === "true" || lower === "false") {
|
|
123207
|
+
return lower === "true";
|
|
123208
|
+
}
|
|
123209
|
+
else if (lower === "null") {
|
|
123210
|
+
return null;
|
|
123211
|
+
}
|
|
123212
|
+
const num = Number(tokens.join(""));
|
|
123213
|
+
return isNaN(num) ? tokens.join("") : num;
|
|
123214
|
+
}
|
|
123215
|
+
static set(record, path, value) {
|
|
123216
|
+
let current = record;
|
|
123217
|
+
for (const part of path.slice(0, path.length - 1)) {
|
|
123218
|
+
const next = current[part];
|
|
123219
|
+
if (typeof next !== "object" || next === null || Array.isArray(next)) {
|
|
123220
|
+
current[part] = {};
|
|
123221
|
+
}
|
|
123222
|
+
current = current[part];
|
|
123223
|
+
}
|
|
123224
|
+
current[path[path.length - 1]] = value;
|
|
123225
|
+
}
|
|
123226
|
+
}
|
|
123227
|
+
exports.CDSMetadata = CDSMetadata;
|
|
123228
|
+
//# sourceMappingURL=cds_metadata.js.map
|
|
123229
|
+
|
|
123230
|
+
/***/ },
|
|
123231
|
+
|
|
122428
123232
|
/***/ "./node_modules/@abaplint/transpiler/build/src/chunk.js"
|
|
122429
123233
|
/*!**************************************************************!*\
|
|
122430
123234
|
!*** ./node_modules/@abaplint/transpiler/build/src/chunk.js ***!
|
|
@@ -122850,14 +123654,21 @@ class CDSDatabaseView {
|
|
|
122850
123654
|
for (const join of select.findDirectExpressions(cds.CDSJoin)) {
|
|
122851
123655
|
from.push(this.join(join));
|
|
122852
123656
|
}
|
|
122853
|
-
|
|
123657
|
+
// associations are not columns, neither are virtual elements
|
|
123658
|
+
const associations = this.associationNames(select);
|
|
123659
|
+
const elements = select.findDirectExpressions(cds.CDSElement).filter(e => {
|
|
123660
|
+
const path = e.findDirectExpression(cds.CDSPrefixedName)?.findAllExpressions(cds.CDSName) || [];
|
|
123661
|
+
const last = path[path.length - 1]?.concatTokens().toUpperCase();
|
|
123662
|
+
return e.findDirectTokenByText("VIRTUAL") === undefined && (last === undefined || !associations.has(last));
|
|
123663
|
+
});
|
|
122854
123664
|
if (elements.length === 0) {
|
|
122855
123665
|
return this.unsupported("expected explicit projected fields");
|
|
122856
123666
|
}
|
|
122857
123667
|
const columns = elements.map(e => this.element(e)).join(", ");
|
|
122858
123668
|
let where = "";
|
|
122859
123669
|
for (const child of select.getChildren()) {
|
|
122860
|
-
if (child === source || child.get() instanceof cds.CDSJoin || child.get() instanceof cds.CDSElement
|
|
123670
|
+
if (child === source || child.get() instanceof cds.CDSJoin || child.get() instanceof cds.CDSElement
|
|
123671
|
+
|| child.get() instanceof cds.CDSAssociation || child.get() instanceof cds.CDSComposition) {
|
|
122861
123672
|
continue;
|
|
122862
123673
|
}
|
|
122863
123674
|
else if (child.get() instanceof cds.CDSWhere) {
|
|
@@ -122870,6 +123681,26 @@ class CDSDatabaseView {
|
|
|
122870
123681
|
const distinct = select.findDirectTokenByText("DISTINCT") ? "DISTINCT " : "";
|
|
122871
123682
|
return `CREATE VIEW ${this.quote(this.viewName)} AS SELECT ${distinct}${columns} FROM ${from.join(" ")}${where};`;
|
|
122872
123683
|
}
|
|
123684
|
+
/** Aliases of the associations declared here or in the CDS sources, they can be exposed as elements */
|
|
123685
|
+
associationNames(select) {
|
|
123686
|
+
const ret = new Set();
|
|
123687
|
+
for (const a of [...select.findDirectExpressions(cds.CDSAssociation), ...select.findDirectExpressions(cds.CDSComposition)]) {
|
|
123688
|
+
const relation = a.findDirectExpression(cds.CDSRelation);
|
|
123689
|
+
const name = relation?.findDirectExpression(cds.CDSAs)?.findDirectExpression(cds.CDSName) || relation?.getFirstChild();
|
|
123690
|
+
if (name) {
|
|
123691
|
+
ret.add(name.concatTokens().toUpperCase());
|
|
123692
|
+
}
|
|
123693
|
+
}
|
|
123694
|
+
for (const s of select.findAllExpressions(cds.CDSSource)) {
|
|
123695
|
+
const name = s.findDirectExpression(cds.CDSPrefixedName)?.concatTokens().replace(/ /g, "");
|
|
123696
|
+
const ddls = name ? this.reg.getObject("DDLS", name) : undefined;
|
|
123697
|
+
ddls?.parse();
|
|
123698
|
+
for (const a of ddls?.getParsedData()?.associations || []) {
|
|
123699
|
+
ret.add((a.as || a.name).toUpperCase());
|
|
123700
|
+
}
|
|
123701
|
+
}
|
|
123702
|
+
return ret;
|
|
123703
|
+
}
|
|
122873
123704
|
source(node) {
|
|
122874
123705
|
const nameNode = node.findDirectExpression(cds.CDSPrefixedName);
|
|
122875
123706
|
if (nameNode === undefined) {
|
|
@@ -125216,14 +126047,83 @@ const type_name_or_infer_1 = __webpack_require__(/*! ./type_name_or_infer */ "./
|
|
|
125216
126047
|
const component_chain_1 = __webpack_require__(/*! ./component_chain */ "./node_modules/@abaplint/transpiler/build/src/expressions/component_chain.js");
|
|
125217
126048
|
const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
|
|
125218
126049
|
class CorrespondingBodyTranspiler {
|
|
125219
|
-
|
|
126050
|
+
/** genericTarget: code of the target the result is assigned to, used when the inferred type is generic,
|
|
126051
|
+
* the result then gets the runtime type of the target, eg. "ct = CORRESPONDING #( ... )" with
|
|
126052
|
+
* "CHANGING ct TYPE STANDARD TABLE" */
|
|
126053
|
+
transpile(typ, body, traversal, genericTarget) {
|
|
125220
126054
|
if (!(typ.get() instanceof core_1.Expressions.TypeNameOrInfer)) {
|
|
125221
126055
|
throw new Error("CorrespondingBodyTranspiler, Expected TypeNameOrInfer");
|
|
125222
126056
|
}
|
|
125223
126057
|
const type = new type_name_or_infer_1.TypeNameOrInfer().findType(typ, traversal);
|
|
126058
|
+
if (genericTarget !== undefined && type.isGeneric() === true) {
|
|
126059
|
+
return this.transpileGeneric(body, traversal, genericTarget);
|
|
126060
|
+
}
|
|
126061
|
+
const { source, base, mapping } = this.parseBody(body, traversal);
|
|
125224
126062
|
let target = traversal.toType(type);
|
|
125225
|
-
|
|
126063
|
+
if (base !== undefined) {
|
|
126064
|
+
target = `abap.statements.moveCorresponding(${base.getCode()}, ${target})`;
|
|
126065
|
+
}
|
|
125226
126066
|
const isTableType = type instanceof core_1.BasicTypes.TableType;
|
|
126067
|
+
const ret = new chunk_1.Chunk();
|
|
126068
|
+
const id = unique_identifier_1.UniqueIdentifier.get();
|
|
126069
|
+
const sourceId = unique_identifier_1.UniqueIdentifier.get();
|
|
126070
|
+
ret.appendString("(await (async () => {\n");
|
|
126071
|
+
ret.appendString(`const ${id} = ${target};\n`);
|
|
126072
|
+
ret.appendString(`const ${sourceId} = ${source.getCode()};\n`);
|
|
126073
|
+
if (isTableType) {
|
|
126074
|
+
const rowTargetType = traversal.toType(type.getRowType());
|
|
126075
|
+
const sourceRowId = unique_identifier_1.UniqueIdentifier.get();
|
|
126076
|
+
const targetRowId = unique_identifier_1.UniqueIdentifier.get();
|
|
126077
|
+
ret.appendString(`for (const ${sourceRowId} of ${sourceId}.array()) {\n`);
|
|
126078
|
+
ret.appendString(`const ${targetRowId} = ${rowTargetType};\n`);
|
|
126079
|
+
ret.appendString(`abap.statements.moveCorresponding(${sourceRowId}, ${targetRowId});\n`);
|
|
126080
|
+
ret.appendString(this.mappingCode(mapping, targetRowId, sourceRowId, traversal));
|
|
126081
|
+
ret.appendString(`abap.statements.insertInternal({table: ${id}, data: ${targetRowId}});\n`);
|
|
126082
|
+
ret.appendString("}\n");
|
|
126083
|
+
}
|
|
126084
|
+
else {
|
|
126085
|
+
ret.appendString(`abap.statements.moveCorresponding(${sourceId}, ${id});\n`);
|
|
126086
|
+
ret.appendString(this.mappingCode(mapping, id, sourceId, traversal));
|
|
126087
|
+
}
|
|
126088
|
+
ret.appendString("return " + id + ";\n");
|
|
126089
|
+
ret.appendString("})())");
|
|
126090
|
+
return ret;
|
|
126091
|
+
}
|
|
126092
|
+
/** the type is only known at runtime, it is taken from the target, a table or a structure */
|
|
126093
|
+
transpileGeneric(body, traversal, genericTarget) {
|
|
126094
|
+
const { source, base, mapping } = this.parseBody(body, traversal);
|
|
126095
|
+
const ret = new chunk_1.Chunk();
|
|
126096
|
+
const id = unique_identifier_1.UniqueIdentifier.get();
|
|
126097
|
+
const sourceId = unique_identifier_1.UniqueIdentifier.get();
|
|
126098
|
+
const sourceRowId = unique_identifier_1.UniqueIdentifier.get();
|
|
126099
|
+
const targetRowId = unique_identifier_1.UniqueIdentifier.get();
|
|
126100
|
+
ret.appendString("(await (async () => {\n");
|
|
126101
|
+
const pointer = `(${genericTarget} instanceof abap.types.FieldSymbol ? ${genericTarget}.getPointer() : ${genericTarget})`;
|
|
126102
|
+
ret.appendString(`const ${id} = ${pointer}.clone();\n`);
|
|
126103
|
+
ret.appendString(`${id}.clear();\n`);
|
|
126104
|
+
if (base !== undefined) {
|
|
126105
|
+
ret.appendString(`${id}.set(${base.getCode()});\n`);
|
|
126106
|
+
}
|
|
126107
|
+
ret.appendString(`const ${sourceId} = ${source.getCode()};\n`);
|
|
126108
|
+
ret.appendString(`if (${id} instanceof abap.types.Table || ${id} instanceof abap.types.HashedTable) {\n`);
|
|
126109
|
+
ret.appendString(`for (const ${sourceRowId} of ${sourceId}.array()) {\n`);
|
|
126110
|
+
ret.appendString(`const ${targetRowId} = ${id}.getRowType().clone();\n`);
|
|
126111
|
+
ret.appendString(`${targetRowId}.clear();\n`);
|
|
126112
|
+
ret.appendString(`abap.statements.moveCorresponding(${sourceRowId}, ${targetRowId});\n`);
|
|
126113
|
+
ret.appendString(this.mappingCode(mapping, targetRowId, sourceRowId, traversal));
|
|
126114
|
+
ret.appendString(`abap.statements.insertInternal({table: ${id}, data: ${targetRowId}});\n`);
|
|
126115
|
+
ret.appendString("}\n");
|
|
126116
|
+
ret.appendString("} else {\n");
|
|
126117
|
+
ret.appendString(`abap.statements.moveCorresponding(${sourceId}, ${id});\n`);
|
|
126118
|
+
ret.appendString(this.mappingCode(mapping, id, sourceId, traversal));
|
|
126119
|
+
ret.appendString("}\n");
|
|
126120
|
+
ret.appendString("return " + id + ";\n");
|
|
126121
|
+
ret.appendString("})())");
|
|
126122
|
+
return ret;
|
|
126123
|
+
}
|
|
126124
|
+
parseBody(body, traversal) {
|
|
126125
|
+
let source;
|
|
126126
|
+
let base;
|
|
125227
126127
|
const mapping = [];
|
|
125228
126128
|
for (const child of body.getChildren()) {
|
|
125229
126129
|
const c = child.get();
|
|
@@ -125231,8 +126131,7 @@ class CorrespondingBodyTranspiler {
|
|
|
125231
126131
|
source = traversal.traverse(child);
|
|
125232
126132
|
}
|
|
125233
126133
|
else if (c instanceof core_1.Expressions.CorrespondingBodyBase && child instanceof core_1.Nodes.ExpressionNode) {
|
|
125234
|
-
|
|
125235
|
-
target = `abap.statements.moveCorresponding(${source.getCode()}, ${target})`;
|
|
126134
|
+
base = traversal.traverse(child.findDirectExpression(core_1.Expressions.Source));
|
|
125236
126135
|
}
|
|
125237
126136
|
else if (c instanceof core_1.Expressions.CorrespondingBodyMapping && child instanceof core_1.Nodes.ExpressionNode) {
|
|
125238
126137
|
let mappingRow = { componentName: undefined, componentChain: undefined };
|
|
@@ -125251,38 +126150,16 @@ class CorrespondingBodyTranspiler {
|
|
|
125251
126150
|
throw new Error("CorrespondingBodyTranspiler, todo, " + c.constructor.name + ", " + body.concatTokens());
|
|
125252
126151
|
}
|
|
125253
126152
|
}
|
|
125254
|
-
|
|
125255
|
-
|
|
125256
|
-
|
|
125257
|
-
|
|
125258
|
-
|
|
125259
|
-
|
|
125260
|
-
|
|
125261
|
-
|
|
125262
|
-
const sourceRowId = unique_identifier_1.UniqueIdentifier.get();
|
|
125263
|
-
const targetRowId = unique_identifier_1.UniqueIdentifier.get();
|
|
125264
|
-
ret.appendString(`for (const ${sourceRowId} of ${sourceId}.array()) {\n`);
|
|
125265
|
-
ret.appendString(`const ${targetRowId} = ${rowTargetType};\n`);
|
|
125266
|
-
ret.appendString(`abap.statements.moveCorresponding(${sourceRowId}, ${targetRowId});\n`);
|
|
125267
|
-
for (const map of mapping) {
|
|
125268
|
-
const componentName = map.componentName.concatTokens().toLowerCase();
|
|
125269
|
-
const chain = new component_chain_1.ComponentChainTranspiler().transpile(map.componentChain, traversal).getCode();
|
|
125270
|
-
ret.appendString(`${targetRowId}.get().${componentName}.set(${sourceRowId}.get().${chain});\n`);
|
|
125271
|
-
}
|
|
125272
|
-
ret.appendString(`abap.statements.insertInternal({table: ${id}, data: ${targetRowId}});\n`);
|
|
125273
|
-
ret.appendString("}\n");
|
|
125274
|
-
}
|
|
125275
|
-
else {
|
|
125276
|
-
ret.appendString(`abap.statements.moveCorresponding(${sourceId}, ${id});\n`);
|
|
125277
|
-
for (const map of mapping) {
|
|
125278
|
-
const componentName = map.componentName.concatTokens().toLowerCase();
|
|
125279
|
-
const chain = new component_chain_1.ComponentChainTranspiler().transpile(map.componentChain, traversal).getCode();
|
|
125280
|
-
ret.appendString(`${id}.get().${componentName}.set(${sourceId}.get().${chain});\n`);
|
|
125281
|
-
}
|
|
126153
|
+
return { source: source, base, mapping };
|
|
126154
|
+
}
|
|
126155
|
+
mappingCode(mapping, targetId, sourceId, traversal) {
|
|
126156
|
+
let code = "";
|
|
126157
|
+
for (const map of mapping) {
|
|
126158
|
+
const componentName = map.componentName.concatTokens().toLowerCase();
|
|
126159
|
+
const chain = new component_chain_1.ComponentChainTranspiler().transpile(map.componentChain, traversal).getCode();
|
|
126160
|
+
code += `${targetId}.get().${componentName}.set(${sourceId}.get().${chain});\n`;
|
|
125282
126161
|
}
|
|
125283
|
-
|
|
125284
|
-
ret.appendString("})())");
|
|
125285
|
-
return ret;
|
|
126162
|
+
return code;
|
|
125286
126163
|
}
|
|
125287
126164
|
}
|
|
125288
126165
|
exports.CorrespondingBodyTranspiler = CorrespondingBodyTranspiler;
|
|
@@ -130715,6 +131592,108 @@ exports.HandleABAP = HandleABAP;
|
|
|
130715
131592
|
|
|
130716
131593
|
/***/ },
|
|
130717
131594
|
|
|
131595
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_data_definition.js"
|
|
131596
|
+
/*!****************************************************************************************!*\
|
|
131597
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/handlers/handle_data_definition.js ***!
|
|
131598
|
+
\****************************************************************************************/
|
|
131599
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
131600
|
+
|
|
131601
|
+
"use strict";
|
|
131602
|
+
|
|
131603
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
131604
|
+
if (k2 === undefined) k2 = k;
|
|
131605
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
131606
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
131607
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
131608
|
+
}
|
|
131609
|
+
Object.defineProperty(o, k2, desc);
|
|
131610
|
+
}) : (function(o, m, k, k2) {
|
|
131611
|
+
if (k2 === undefined) k2 = k;
|
|
131612
|
+
o[k2] = m[k];
|
|
131613
|
+
}));
|
|
131614
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
131615
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
131616
|
+
}) : function(o, v) {
|
|
131617
|
+
o["default"] = v;
|
|
131618
|
+
});
|
|
131619
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
131620
|
+
var ownKeys = function(o) {
|
|
131621
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
131622
|
+
var ar = [];
|
|
131623
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
131624
|
+
return ar;
|
|
131625
|
+
};
|
|
131626
|
+
return ownKeys(o);
|
|
131627
|
+
};
|
|
131628
|
+
return function (mod) {
|
|
131629
|
+
if (mod && mod.__esModule) return mod;
|
|
131630
|
+
var result = {};
|
|
131631
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
131632
|
+
__setModuleDefault(result, mod);
|
|
131633
|
+
return result;
|
|
131634
|
+
};
|
|
131635
|
+
})();
|
|
131636
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
131637
|
+
exports.HandleDataDefinition = void 0;
|
|
131638
|
+
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
131639
|
+
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
131640
|
+
const transpile_types_1 = __webpack_require__(/*! ../transpile_types */ "./node_modules/@abaplint/transpiler/build/src/transpile_types.js");
|
|
131641
|
+
const type_factory_registry_1 = __webpack_require__(/*! ../type_factory_registry */ "./node_modules/@abaplint/transpiler/build/src/type_factory_registry.js");
|
|
131642
|
+
// CDS entities: the row type like tables and views, plus the CDS metadata, eg. for XCO
|
|
131643
|
+
class HandleDataDefinition {
|
|
131644
|
+
metadata;
|
|
131645
|
+
constructor(metadata) {
|
|
131646
|
+
this.metadata = metadata;
|
|
131647
|
+
}
|
|
131648
|
+
runObject(obj, reg) {
|
|
131649
|
+
if (obj.findSourceFile() === undefined) {
|
|
131650
|
+
return [];
|
|
131651
|
+
}
|
|
131652
|
+
const filename = obj.getName().toLowerCase().replace(/\//g, "#") + ".ddls.mjs";
|
|
131653
|
+
const cds = this.metadata.build(obj);
|
|
131654
|
+
const type = this.withoutAssociations(obj.parseType(reg), cds);
|
|
131655
|
+
const typeFactory = new type_factory_registry_1.TypeFactoryRegistry(filename);
|
|
131656
|
+
const body = `abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
131657
|
+
"objectType": "DDLS",
|
|
131658
|
+
"type": ${transpile_types_1.TranspileTypes.toTypeFunction(type, typeFactory)},
|
|
131659
|
+
"keyFields": ${JSON.stringify(cds?.fields.filter(f => f.key).map(f => f.name.toUpperCase()) ?? [])},
|
|
131660
|
+
"description": ${JSON.stringify(obj.getDescription())},
|
|
131661
|
+
"sqlViewName": ${JSON.stringify(obj.getSQLViewName())},
|
|
131662
|
+
"cds": ${JSON.stringify(cds)},
|
|
131663
|
+
};`;
|
|
131664
|
+
const chunk = new chunk_1.Chunk(body);
|
|
131665
|
+
const helpers = typeFactory.finalize(chunk);
|
|
131666
|
+
const outputChunk = helpers === "" ? chunk : new chunk_1.Chunk(helpers).appendChunk(chunk);
|
|
131667
|
+
const output = {
|
|
131668
|
+
object: {
|
|
131669
|
+
name: obj.getName(),
|
|
131670
|
+
type: obj.getType(),
|
|
131671
|
+
},
|
|
131672
|
+
filename: filename,
|
|
131673
|
+
chunk: outputChunk,
|
|
131674
|
+
requires: [],
|
|
131675
|
+
exports: [],
|
|
131676
|
+
};
|
|
131677
|
+
return [output];
|
|
131678
|
+
}
|
|
131679
|
+
/** exposed associations are elements of the signature, but not components of the row type */
|
|
131680
|
+
withoutAssociations(type, cds) {
|
|
131681
|
+
if (!(type instanceof abaplint.BasicTypes.StructureType) || cds === undefined) {
|
|
131682
|
+
return type;
|
|
131683
|
+
}
|
|
131684
|
+
const associations = new Set(cds.associations.map(a => a.name.toUpperCase()));
|
|
131685
|
+
const components = type.getComponents().filter(c => !associations.has(c.name.toUpperCase()));
|
|
131686
|
+
if (components.length === type.getComponents().length) {
|
|
131687
|
+
return type;
|
|
131688
|
+
}
|
|
131689
|
+
return new abaplint.BasicTypes.StructureType(components, type.getQualifiedName(), type.getDDICName(), type.getDescription());
|
|
131690
|
+
}
|
|
131691
|
+
}
|
|
131692
|
+
exports.HandleDataDefinition = HandleDataDefinition;
|
|
131693
|
+
//# sourceMappingURL=handle_data_definition.js.map
|
|
131694
|
+
|
|
131695
|
+
/***/ },
|
|
131696
|
+
|
|
130718
131697
|
/***/ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_data_element.js"
|
|
130719
131698
|
/*!*************************************************************************************!*\
|
|
130720
131699
|
!*** ./node_modules/@abaplint/transpiler/build/src/handlers/handle_data_element.js ***!
|
|
@@ -131444,6 +132423,8 @@ const handle_abap_1 = __webpack_require__(/*! ./handlers/handle_abap */ "./node_
|
|
|
131444
132423
|
const handle_data_element_1 = __webpack_require__(/*! ./handlers/handle_data_element */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_data_element.js");
|
|
131445
132424
|
const handle_table_type_1 = __webpack_require__(/*! ./handlers/handle_table_type */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_table_type.js");
|
|
131446
132425
|
const handle_view_1 = __webpack_require__(/*! ./handlers/handle_view */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_view.js");
|
|
132426
|
+
const handle_data_definition_1 = __webpack_require__(/*! ./handlers/handle_data_definition */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_data_definition.js");
|
|
132427
|
+
const cds_metadata_1 = __webpack_require__(/*! ./cds_metadata */ "./node_modules/@abaplint/transpiler/build/src/cds_metadata.js");
|
|
131447
132428
|
const handle_enqu_1 = __webpack_require__(/*! ./handlers/handle_enqu */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_enqu.js");
|
|
131448
132429
|
const handle_type_pool_1 = __webpack_require__(/*! ./handlers/handle_type_pool */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_type_pool.js");
|
|
131449
132430
|
const handle_w3mi_1 = __webpack_require__(/*! ./handlers/handle_w3mi */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_w3mi.js");
|
|
@@ -131490,6 +132471,7 @@ class Transpiler {
|
|
|
131490
132471
|
databaseSetup: dbSetup,
|
|
131491
132472
|
reg: reg,
|
|
131492
132473
|
};
|
|
132474
|
+
const cdsMetadata = new cds_metadata_1.CDSMetadata(reg);
|
|
131493
132475
|
progress?.set(reg.getObjectCount().total, "Building");
|
|
131494
132476
|
for (const obj of reg.getObjects()) {
|
|
131495
132477
|
await progress?.tick("Building, " + obj.getName());
|
|
@@ -131517,6 +132499,9 @@ class Transpiler {
|
|
|
131517
132499
|
else if (obj instanceof abaplint.Objects.View) {
|
|
131518
132500
|
output.objects.push(...new handle_view_1.HandleView().runObject(obj, reg));
|
|
131519
132501
|
}
|
|
132502
|
+
else if (obj instanceof abaplint.Objects.DataDefinition) {
|
|
132503
|
+
output.objects.push(...new handle_data_definition_1.HandleDataDefinition(cdsMetadata).runObject(obj, reg));
|
|
132504
|
+
}
|
|
131520
132505
|
else if (obj instanceof abaplint.Objects.LockObject) {
|
|
131521
132506
|
output.objects.push(...new handle_enqu_1.HandleEnqu().runObject(obj, reg));
|
|
131522
132507
|
}
|
|
@@ -131671,12 +132656,12 @@ class Initialization {
|
|
|
131671
132656
|
script(reg, dbSetup, options, useImport) {
|
|
131672
132657
|
let ret = "";
|
|
131673
132658
|
if (useImport === true) {
|
|
131674
|
-
ret = `/* eslint-disable import/newline-after-import */
|
|
132659
|
+
ret = `/* eslint-disable import/newline-after-import */
|
|
131675
132660
|
import "./_top.mjs";\n`;
|
|
131676
132661
|
}
|
|
131677
132662
|
else {
|
|
131678
|
-
ret = `/* eslint-disable import/newline-after-import */
|
|
131679
|
-
import runtime from "@abaplint/runtime";
|
|
132663
|
+
ret = `/* eslint-disable import/newline-after-import */
|
|
132664
|
+
import runtime from "@abaplint/runtime";
|
|
131680
132665
|
globalThis.abap = new runtime.ABAP();\n`;
|
|
131681
132666
|
}
|
|
131682
132667
|
if (options?.setup?.filename === undefined || options?.setup?.filename === "") {
|
|
@@ -131744,7 +132729,8 @@ globalThis.abap = new runtime.ABAP();\n`;
|
|
|
131744
132729
|
|| obj instanceof abaplint.Objects.WebMIME
|
|
131745
132730
|
|| obj instanceof abaplint.Objects.TypePool
|
|
131746
132731
|
|| obj instanceof abaplint.Objects.TableType
|
|
131747
|
-
|| obj instanceof abaplint.Objects.View
|
|
132732
|
+
|| obj instanceof abaplint.Objects.View
|
|
132733
|
+
|| (obj instanceof abaplint.Objects.DataDefinition && obj.findSourceFile() !== undefined)) {
|
|
131748
132734
|
list.push(imp(this.layout.objectModule(obj)));
|
|
131749
132735
|
}
|
|
131750
132736
|
}
|
|
@@ -131946,7 +132932,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
131946
132932
|
exports.OutputLayout = exports.DDIC_MODULE = exports.DDIC_TYPES = void 0;
|
|
131947
132933
|
exports.importPath = importPath;
|
|
131948
132934
|
/** Object types whose module only sets abap.DDIC[...] */
|
|
131949
|
-
exports.DDIC_TYPES = new Set(["DTEL", "TABL", "TTYP", "VIEW"]);
|
|
132935
|
+
exports.DDIC_TYPES = new Set(["DDLS", "DTEL", "TABL", "TTYP", "VIEW"]);
|
|
131950
132936
|
/** Per folder module holding all its DDIC definitions. Object filenames never start
|
|
131951
132937
|
* with an underscore, so it cannot collide with an object module. Loading tens of
|
|
131952
132938
|
* thousands of tiny modules dominates startup, one module per folder avoids that. */
|
|
@@ -132531,64 +133517,82 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
132531
133517
|
};
|
|
132532
133518
|
})();
|
|
132533
133519
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
132534
|
-
exports.
|
|
133520
|
+
exports.dataClusterMedium = dataClusterMedium;
|
|
132535
133521
|
exports.mediumOptions = mediumOptions;
|
|
132536
133522
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
132537
|
-
function
|
|
133523
|
+
function word(node) {
|
|
133524
|
+
return node instanceof abaplint.Nodes.TokenNode ? node.getFirstToken().getStr().toUpperCase() : "";
|
|
133525
|
+
}
|
|
133526
|
+
function dataClusterMedium(node, keyword, traversal) {
|
|
132538
133527
|
const children = node.getChildren();
|
|
132539
|
-
|
|
132540
|
-
|
|
132541
|
-
const here = children[i];
|
|
132542
|
-
const next = children[i + 1];
|
|
132543
|
-
if (here instanceof abaplint.Nodes.TokenNode && here.getFirstToken().getStr().toUpperCase() === keyword
|
|
132544
|
-
&& next instanceof abaplint.Nodes.TokenNode && next.getFirstToken().getStr().toUpperCase() === "SHARED") {
|
|
132545
|
-
at = i + 1;
|
|
132546
|
-
break;
|
|
132547
|
-
}
|
|
132548
|
-
}
|
|
132549
|
-
if (at < 0) {
|
|
133528
|
+
const at = children.findIndex(c => word(c) === keyword) + 1;
|
|
133529
|
+
if (at === 0) {
|
|
132550
133530
|
return undefined;
|
|
132551
133531
|
}
|
|
132552
|
-
|
|
132553
|
-
|
|
132554
|
-
|
|
133532
|
+
let ret;
|
|
133533
|
+
let additions;
|
|
133534
|
+
if (word(children[at]) === "MEMORY") {
|
|
133535
|
+
ret = { medium: "MEMORY" };
|
|
133536
|
+
additions = at + 1;
|
|
132555
133537
|
}
|
|
132556
|
-
|
|
132557
|
-
|
|
132558
|
-
|
|
132559
|
-
return undefined;
|
|
133538
|
+
else if (word(children[at]) === "DATA" && word(children[at + 1]) === "BUFFER"
|
|
133539
|
+
&& children[at + 2] instanceof abaplint.Nodes.ExpressionNode) {
|
|
133540
|
+
return { medium: "DATA BUFFER", buffer: traversal.traverse(children[at + 2]).getCode() };
|
|
132560
133541
|
}
|
|
132561
|
-
|
|
132562
|
-
|
|
132563
|
-
|
|
132564
|
-
|
|
132565
|
-
|
|
132566
|
-
|
|
132567
|
-
|
|
132568
|
-
|
|
132569
|
-
|
|
133542
|
+
else {
|
|
133543
|
+
// DATABASE dbtab(ar) ... / SHARED MEMORY|BUFFER dbtab(ar) ...
|
|
133544
|
+
let tableAt;
|
|
133545
|
+
if (word(children[at]) === "DATABASE") {
|
|
133546
|
+
ret = { medium: "DATABASE" };
|
|
133547
|
+
tableAt = at + 1;
|
|
133548
|
+
}
|
|
133549
|
+
else if (word(children[at]) === "SHARED" && (word(children[at + 1]) === "MEMORY" || word(children[at + 1]) === "BUFFER")) {
|
|
133550
|
+
ret = { medium: word(children[at + 1]) === "MEMORY" ? "SHARED MEMORY" : "SHARED BUFFER" };
|
|
133551
|
+
tableAt = at + 2;
|
|
133552
|
+
}
|
|
133553
|
+
else {
|
|
133554
|
+
return undefined;
|
|
133555
|
+
}
|
|
133556
|
+
const tableNode = children[tableAt];
|
|
133557
|
+
const areaNode = children[tableAt + 2];
|
|
133558
|
+
if (!(tableNode instanceof abaplint.Nodes.ExpressionNode) || areaNode === undefined) {
|
|
133559
|
+
return undefined;
|
|
133560
|
+
}
|
|
133561
|
+
ret.table = tableNode.concatTokens().toUpperCase();
|
|
133562
|
+
ret.area = areaNode.getFirstToken().getStr().toUpperCase();
|
|
133563
|
+
additions = tableAt + 4;
|
|
133564
|
+
}
|
|
133565
|
+
// the additions in any order, ID / CLIENT followed by a Source; FROM wa
|
|
133566
|
+
// (EXPORT) and TO wa (IMPORT) name the dbtab's work area, whose extra
|
|
133567
|
+
// fields have no place in this store and are not read
|
|
133568
|
+
for (let i = additions; i < children.length - 1; i++) {
|
|
132570
133569
|
const here = children[i];
|
|
132571
133570
|
const next = children[i + 1];
|
|
132572
133571
|
if (!(here instanceof abaplint.Nodes.TokenNode) || !(next instanceof abaplint.Nodes.ExpressionNode)) {
|
|
132573
133572
|
continue;
|
|
132574
133573
|
}
|
|
132575
|
-
|
|
132576
|
-
if (word === "ID") {
|
|
133574
|
+
if (word(here) === "ID") {
|
|
132577
133575
|
ret.id = traversal.traverse(next).getCode();
|
|
132578
133576
|
}
|
|
132579
|
-
else if (word === "CLIENT") {
|
|
133577
|
+
else if (word(here) === "CLIENT") {
|
|
132580
133578
|
ret.client = traversal.traverse(next).getCode();
|
|
132581
133579
|
}
|
|
133580
|
+
else if (word(here) === "USING") {
|
|
133581
|
+
return undefined;
|
|
133582
|
+
}
|
|
132582
133583
|
}
|
|
132583
|
-
if (ret.id === undefined) {
|
|
133584
|
+
if (ret.medium !== "MEMORY" && ret.id === undefined) {
|
|
132584
133585
|
return undefined;
|
|
132585
133586
|
}
|
|
132586
133587
|
return ret;
|
|
132587
133588
|
}
|
|
132588
133589
|
function mediumOptions(medium) {
|
|
132589
|
-
return `medium: ${JSON.stringify(medium.medium)}
|
|
132590
|
-
+
|
|
132591
|
-
+ (medium.
|
|
133590
|
+
return `medium: ${JSON.stringify(medium.medium)}`
|
|
133591
|
+
+ (medium.table === undefined ? "" : `, table: ${JSON.stringify(medium.table)}`)
|
|
133592
|
+
+ (medium.area === undefined ? "" : `, area: ${JSON.stringify(medium.area)}`)
|
|
133593
|
+
+ (medium.id === undefined ? "" : `, id: ${medium.id}`)
|
|
133594
|
+
+ (medium.client === undefined ? "" : `, client: ${medium.client}`)
|
|
133595
|
+
+ (medium.buffer === undefined ? "" : `, buffer: ${medium.buffer}`);
|
|
132592
133596
|
}
|
|
132593
133597
|
//# sourceMappingURL=_data_cluster.js.map
|
|
132594
133598
|
|
|
@@ -135841,9 +136845,14 @@ exports.DataTranspiler = DataTranspiler;
|
|
|
135841
136845
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
135842
136846
|
exports.DeleteClusterTranspiler = void 0;
|
|
135843
136847
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
136848
|
+
const _data_cluster_1 = __webpack_require__(/*! ./_data_cluster */ "./node_modules/@abaplint/transpiler/build/src/statements/_data_cluster.js");
|
|
135844
136849
|
class DeleteClusterTranspiler {
|
|
135845
|
-
transpile(
|
|
135846
|
-
|
|
136850
|
+
transpile(node, traversal) {
|
|
136851
|
+
const medium = (0, _data_cluster_1.dataClusterMedium)(node, "FROM", traversal);
|
|
136852
|
+
if (medium === undefined) {
|
|
136853
|
+
return new chunk_1.Chunk(`throw new Error("DELETE CLUSTER, not supported, transpiler");`);
|
|
136854
|
+
}
|
|
136855
|
+
return new chunk_1.Chunk(`abap.statements.deleteCluster({${(0, _data_cluster_1.mediumOptions)(medium)}});`);
|
|
135847
136856
|
}
|
|
135848
136857
|
}
|
|
135849
136858
|
exports.DeleteClusterTranspiler = DeleteClusterTranspiler;
|
|
@@ -136050,8 +137059,15 @@ const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_
|
|
|
136050
137059
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
136051
137060
|
class DeleteInternalTranspiler {
|
|
136052
137061
|
transpile(node, traversal) {
|
|
136053
|
-
const
|
|
137062
|
+
const targetNode = node.findDirectExpression(abaplint.Expressions.Target);
|
|
137063
|
+
const target = traversal.traverse(targetNode).getCode();
|
|
136054
137064
|
const concat = node.concatTokens().toUpperCase();
|
|
137065
|
+
if (node.getChildren().length <= 5 && (node.getChildren().length === 3 || node.findDirectTokenByText("FROM"))
|
|
137066
|
+
&& concat.startsWith("DELETE TABLE ") === false && traversal.isDatabaseShortForm(targetNode)) {
|
|
137067
|
+
const row = node.findExpressionAfterToken("FROM");
|
|
137068
|
+
const source = row ? traversal.traverse(row).getCode() : target;
|
|
137069
|
+
return new chunk_1.Chunk(`await abap.statements.deleteDatabase("${targetNode.concatTokens().toLowerCase()}", {from: ${source}});`);
|
|
137070
|
+
}
|
|
136055
137071
|
const extra = [];
|
|
136056
137072
|
const componentCond = node.findDirectExpression(abaplint.Expressions.ComponentCond);
|
|
136057
137073
|
if (componentCond) {
|
|
@@ -136119,9 +137135,14 @@ exports.DeleteInternalTranspiler = DeleteInternalTranspiler;
|
|
|
136119
137135
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
136120
137136
|
exports.DeleteMemoryTranspiler = void 0;
|
|
136121
137137
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
137138
|
+
const _data_cluster_1 = __webpack_require__(/*! ./_data_cluster */ "./node_modules/@abaplint/transpiler/build/src/statements/_data_cluster.js");
|
|
136122
137139
|
class DeleteMemoryTranspiler {
|
|
136123
|
-
transpile(
|
|
136124
|
-
|
|
137140
|
+
transpile(node, traversal) {
|
|
137141
|
+
const medium = (0, _data_cluster_1.dataClusterMedium)(node, "FROM", traversal);
|
|
137142
|
+
if (medium === undefined) {
|
|
137143
|
+
return new chunk_1.Chunk(`throw new Error("DeleteMemory, not supported, transpiler");`);
|
|
137144
|
+
}
|
|
137145
|
+
return new chunk_1.Chunk(`abap.statements.deleteCluster({${(0, _data_cluster_1.mediumOptions)(medium)}});`);
|
|
136125
137146
|
}
|
|
136126
137147
|
}
|
|
136127
137148
|
exports.DeleteMemoryTranspiler = DeleteMemoryTranspiler;
|
|
@@ -137049,7 +138070,7 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
|
|
|
137049
138070
|
const _data_cluster_1 = __webpack_require__(/*! ./_data_cluster */ "./node_modules/@abaplint/transpiler/build/src/statements/_data_cluster.js");
|
|
137050
138071
|
class ExportTranspiler {
|
|
137051
138072
|
transpile(node, traversal) {
|
|
137052
|
-
const medium = (0, _data_cluster_1.
|
|
138073
|
+
const medium = (0, _data_cluster_1.dataClusterMedium)(node, "TO", traversal);
|
|
137053
138074
|
const parameters = medium === undefined ? undefined : this.parameters(node, traversal);
|
|
137054
138075
|
if (medium === undefined || parameters === undefined) {
|
|
137055
138076
|
return new chunk_1.Chunk(`throw new Error("Export, transpiler todo");`);
|
|
@@ -137637,12 +138658,47 @@ exports.FreeTranspiler = FreeTranspiler;
|
|
|
137637
138658
|
|
|
137638
138659
|
"use strict";
|
|
137639
138660
|
|
|
138661
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
138662
|
+
if (k2 === undefined) k2 = k;
|
|
138663
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
138664
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
138665
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
138666
|
+
}
|
|
138667
|
+
Object.defineProperty(o, k2, desc);
|
|
138668
|
+
}) : (function(o, m, k, k2) {
|
|
138669
|
+
if (k2 === undefined) k2 = k;
|
|
138670
|
+
o[k2] = m[k];
|
|
138671
|
+
}));
|
|
138672
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
138673
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
138674
|
+
}) : function(o, v) {
|
|
138675
|
+
o["default"] = v;
|
|
138676
|
+
});
|
|
138677
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
138678
|
+
var ownKeys = function(o) {
|
|
138679
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
138680
|
+
var ar = [];
|
|
138681
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
138682
|
+
return ar;
|
|
138683
|
+
};
|
|
138684
|
+
return ownKeys(o);
|
|
138685
|
+
};
|
|
138686
|
+
return function (mod) {
|
|
138687
|
+
if (mod && mod.__esModule) return mod;
|
|
138688
|
+
var result = {};
|
|
138689
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
138690
|
+
__setModuleDefault(result, mod);
|
|
138691
|
+
return result;
|
|
138692
|
+
};
|
|
138693
|
+
})();
|
|
137640
138694
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
137641
138695
|
exports.FreeMemoryTranspiler = void 0;
|
|
138696
|
+
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
137642
138697
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
137643
138698
|
class FreeMemoryTranspiler {
|
|
137644
|
-
transpile(
|
|
137645
|
-
|
|
138699
|
+
transpile(node, traversal) {
|
|
138700
|
+
const id = node.findDirectExpression(abaplint.Expressions.Source);
|
|
138701
|
+
return new chunk_1.Chunk(`abap.statements.freeMemory({${id === undefined ? "" : "id: " + traversal.traverse(id).getCode()}});`);
|
|
137646
138702
|
}
|
|
137647
138703
|
}
|
|
137648
138704
|
exports.FreeMemoryTranspiler = FreeMemoryTranspiler;
|
|
@@ -138490,7 +139546,7 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
|
|
|
138490
139546
|
const _data_cluster_1 = __webpack_require__(/*! ./_data_cluster */ "./node_modules/@abaplint/transpiler/build/src/statements/_data_cluster.js");
|
|
138491
139547
|
class ImportTranspiler {
|
|
138492
139548
|
transpile(node, traversal) {
|
|
138493
|
-
const medium = (0, _data_cluster_1.
|
|
139549
|
+
const medium = (0, _data_cluster_1.dataClusterMedium)(node, "FROM", traversal);
|
|
138494
139550
|
const parameters = medium === undefined ? undefined : this.parameters(node, traversal);
|
|
138495
139551
|
if (medium === undefined || parameters === undefined) {
|
|
138496
139552
|
return new chunk_1.Chunk(`throw new Error("Import, transpiler todo");`);
|
|
@@ -139204,6 +140260,11 @@ class InsertInternalTranspiler {
|
|
|
139204
140260
|
if (index) {
|
|
139205
140261
|
options.push("index: " + traversal.traverse(index).getCode());
|
|
139206
140262
|
}
|
|
140263
|
+
else if (!concat.startsWith("INSERT LINES OF ") && !concat.includes(" INTO TABLE ") && concat.includes(" INTO ")
|
|
140264
|
+
&& node.findDirectExpression(abaplint.Expressions.Target) !== undefined) {
|
|
140265
|
+
// INSERT wa INTO itab: in a LOOP over itab, in front of the current row
|
|
140266
|
+
options.push("currentRow: true");
|
|
140267
|
+
}
|
|
139207
140268
|
if (concat.includes(" REFERENCE INTO ")) {
|
|
139208
140269
|
const targets = node.findDirectExpressions(abaplint.Expressions.Target);
|
|
139209
140270
|
options.push("referenceInto: " + traversal.traverse(targets[1]).getCode());
|
|
@@ -140022,10 +141083,11 @@ class MethodImplementationTranspiler {
|
|
|
140022
141083
|
}
|
|
140023
141084
|
else if (type instanceof abaplint.BasicTypes.XSequenceType) {
|
|
140024
141085
|
// only a literal can be character-like here, its content is the bytes: '010203' is
|
|
140025
|
-
// x LENGTH 3, and an odd number of digits is filled with 0 on the right, '012' is 0120
|
|
141086
|
+
// x LENGTH 3, and an odd number of digits is filled with 0 on the right, '012' is 0120.
|
|
141087
|
+
// The empty string literal `` has no bytes; a Hex cannot have length 0
|
|
140026
141088
|
after += `if (${varPrefixed}?.constructor.name === "Character" || ${varPrefixed}?.constructor.name === "String") {
|
|
140027
141089
|
const hex = ${varPrefixed}.get().trimEnd();
|
|
140028
|
-
${varPrefixed} = new abap.types.Hex({length: Math.ceil(hex.length / 2)}).set(hex.padEnd(Math.ceil(hex.length / 2) * 2, "0"));
|
|
141090
|
+
${varPrefixed} = hex.length === 0 ? new abap.types.XString() : new abap.types.Hex({length: Math.ceil(hex.length / 2)}).set(hex.padEnd(Math.ceil(hex.length / 2) * 2, "0"));
|
|
140029
141091
|
}\n`;
|
|
140030
141092
|
}
|
|
140031
141093
|
}
|
|
@@ -140472,7 +141534,11 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
|
|
|
140472
141534
|
const modify_database_1 = __webpack_require__(/*! ./modify_database */ "./node_modules/@abaplint/transpiler/build/src/statements/modify_database.js");
|
|
140473
141535
|
class ModifyInternalTranspiler {
|
|
140474
141536
|
transpile(node, traversal) {
|
|
140475
|
-
const
|
|
141537
|
+
const targetNode = node.findDirectExpression(abaplint.Expressions.Target);
|
|
141538
|
+
const target = traversal.traverse(targetNode).getCode();
|
|
141539
|
+
if (node.getChildren().length === 3 && traversal.isDatabaseShortForm(targetNode)) {
|
|
141540
|
+
return new chunk_1.Chunk(`await abap.statements.modifyDatabase("${targetNode.concatTokens().toLowerCase()}", {values: ${target}});`);
|
|
141541
|
+
}
|
|
140476
141542
|
const extra = [];
|
|
140477
141543
|
const index = node.findExpressionAfterToken("INDEX");
|
|
140478
141544
|
if (index) {
|
|
@@ -140628,6 +141694,8 @@ exports.MoveTranspiler = void 0;
|
|
|
140628
141694
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
140629
141695
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
140630
141696
|
const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_modules/@abaplint/transpiler/build/src/expressions/source.js");
|
|
141697
|
+
const type_name_or_infer_1 = __webpack_require__(/*! ../expressions/type_name_or_infer */ "./node_modules/@abaplint/transpiler/build/src/expressions/type_name_or_infer.js");
|
|
141698
|
+
const corresponding_body_1 = __webpack_require__(/*! ../expressions/corresponding_body */ "./node_modules/@abaplint/transpiler/build/src/expressions/corresponding_body.js");
|
|
140631
141699
|
class MoveTranspiler {
|
|
140632
141700
|
transpile(node, traversal) {
|
|
140633
141701
|
const sourceExpression = node.findDirectExpression(abaplint.Expressions.Source);
|
|
@@ -140647,10 +141715,15 @@ class MoveTranspiler {
|
|
|
140647
141715
|
ret.appendString(target + `.set(abap.alphaIn(${tSource.getCode()}, ${target}, ${target}));`);
|
|
140648
141716
|
return ret;
|
|
140649
141717
|
}
|
|
140650
|
-
let source = this.isInt8Calculation(node, sourceExpression, targetExpressions.length, traversal)
|
|
140651
|
-
? new source_1.SourceTranspiler(false, true).transpile(sourceExpression, traversal)
|
|
140652
|
-
: traversal.traverse(sourceExpression);
|
|
140653
141718
|
const second = node.getChildren()[1]?.concatTokens();
|
|
141719
|
+
let source = second === "=" && targetExpressions.length === 1
|
|
141720
|
+
? this.correspondingGeneric(sourceExpression, targets[0], traversal)
|
|
141721
|
+
: undefined;
|
|
141722
|
+
if (source === undefined) {
|
|
141723
|
+
source = this.isInt8Calculation(node, sourceExpression, targetExpressions.length, traversal)
|
|
141724
|
+
? new source_1.SourceTranspiler(false, true).transpile(sourceExpression, traversal)
|
|
141725
|
+
: traversal.traverse(sourceExpression);
|
|
141726
|
+
}
|
|
140654
141727
|
switch (second) {
|
|
140655
141728
|
case "?=":
|
|
140656
141729
|
ret.appendString("await abap.statements.cast(")
|
|
@@ -140712,6 +141785,22 @@ class MoveTranspiler {
|
|
|
140712
141785
|
}
|
|
140713
141786
|
return ret;
|
|
140714
141787
|
}
|
|
141788
|
+
// "target = CORRESPONDING #( ... )" with a generic target, eg. "CHANGING ct TYPE STANDARD TABLE",
|
|
141789
|
+
// the type of the result is only known at runtime, so the target is passed on
|
|
141790
|
+
correspondingGeneric(source, target, traversal) {
|
|
141791
|
+
const children = source?.getChildren() || [];
|
|
141792
|
+
const typ = source?.findDirectExpression(abaplint.Expressions.TypeNameOrInfer);
|
|
141793
|
+
const body = source?.findDirectExpression(abaplint.Expressions.CorrespondingBody);
|
|
141794
|
+
if (children.length !== 5
|
|
141795
|
+
|| children[0].concatTokens().toUpperCase() !== "CORRESPONDING"
|
|
141796
|
+
|| typ === undefined
|
|
141797
|
+
|| typ.concatTokens() !== "#"
|
|
141798
|
+
|| body === undefined
|
|
141799
|
+
|| new type_name_or_infer_1.TypeNameOrInfer().findTypeOrUndefined(typ, traversal)?.isGeneric() !== true) {
|
|
141800
|
+
return undefined;
|
|
141801
|
+
}
|
|
141802
|
+
return new corresponding_body_1.CorrespondingBodyTranspiler().transpile(typ, body, traversal, target.getCode());
|
|
141803
|
+
}
|
|
140715
141804
|
// The calculation type of an arithmetic expression comes from its operands and the target
|
|
140716
141805
|
// field, the type with the largest range wins. With operands of type i or int8 it is int8
|
|
140717
141806
|
// when the target or an operand is int8: i * i into int8 is exact up to 2^62, and "/"
|
|
@@ -140834,9 +141923,18 @@ class MoveCorrespondingTranspiler {
|
|
|
140834
141923
|
transpile(node, traversal) {
|
|
140835
141924
|
const target = new expressions_1.TargetTranspiler().transpile(node.findDirectExpression(abaplint.Expressions.SimpleTarget), traversal);
|
|
140836
141925
|
const source = traversal.traverse(node.findDirectExpression(abaplint.Expressions.Source));
|
|
141926
|
+
const concat = node.concatTokens().toUpperCase();
|
|
141927
|
+
const options = [];
|
|
141928
|
+
if (concat.includes(" KEEPING TARGET LINES")) {
|
|
141929
|
+
options.push("keepingTargetLines: true");
|
|
141930
|
+
}
|
|
141931
|
+
if (concat.includes(" EXPANDING NESTED TABLES")) {
|
|
141932
|
+
options.push("expandingNestedTables: true");
|
|
141933
|
+
}
|
|
141934
|
+
const extra = options.length > 0 ? ", {" + options.join(", ") + "}" : "";
|
|
140837
141935
|
return new chunk_1.Chunk().append("abap.statements.moveCorresponding(", node, traversal)
|
|
140838
141936
|
.join([source, target])
|
|
140839
|
-
.append(");", node.getLastToken(), traversal);
|
|
141937
|
+
.append(extra + ");", node.getLastToken(), traversal);
|
|
140840
141938
|
}
|
|
140841
141939
|
}
|
|
140842
141940
|
exports.MoveCorrespondingTranspiler = MoveCorrespondingTranspiler;
|
|
@@ -141752,6 +142850,22 @@ class RaiseEventTranspiler {
|
|
|
141752
142850
|
if (parameters) {
|
|
141753
142851
|
extra = "," + new expressions_1.ParameterListSTranspiler().transpile(parameters, traversal).getCode();
|
|
141754
142852
|
}
|
|
142853
|
+
// a static event: handlers may only react when the class of this statement is theirs, it is passed along
|
|
142854
|
+
const def = traversal.getClassDefinition(node.getFirstToken());
|
|
142855
|
+
const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
|
|
142856
|
+
let search = def;
|
|
142857
|
+
let isStatic = false;
|
|
142858
|
+
while (search !== undefined) {
|
|
142859
|
+
const event = search.getEvents().find(e => e.getName().toLowerCase() === eventName);
|
|
142860
|
+
if (event !== undefined) {
|
|
142861
|
+
isStatic = event.isStatic();
|
|
142862
|
+
break;
|
|
142863
|
+
}
|
|
142864
|
+
search = search.getSuperClass() ? traversal.findClassDefinition(search.getSuperClass(), scope) : undefined;
|
|
142865
|
+
}
|
|
142866
|
+
if (isStatic === true && def !== undefined) {
|
|
142867
|
+
extra = (extra === "" ? ", undefined" : extra) + ", " + traversal_1.Traversal.escapeNamespace(def.getName().toLowerCase());
|
|
142868
|
+
}
|
|
141755
142869
|
return new chunk_1.Chunk().append(`await abap.statements.raiseEvent(this.${eventName}, this.me${extra});`, node, traversal);
|
|
141756
142870
|
}
|
|
141757
142871
|
}
|
|
@@ -143544,6 +144658,7 @@ class SetHandlerTranspiler {
|
|
|
143544
144658
|
const methods = [];
|
|
143545
144659
|
let eventClass = undefined;
|
|
143546
144660
|
let eventName = undefined;
|
|
144661
|
+
let forClass = "";
|
|
143547
144662
|
for (const m of node.findDirectExpressions(abaplint.Expressions.MethodSource)) {
|
|
143548
144663
|
// the handler method is registered as a reference, it is dispatched dynamically when the event is raised,
|
|
143549
144664
|
// so no static binding even if the SET HANDLER is inside a constructor
|
|
@@ -143560,6 +144675,7 @@ class SetHandlerTranspiler {
|
|
|
143560
144675
|
}
|
|
143561
144676
|
eventName = method.def.getEventName();
|
|
143562
144677
|
eventClass = this.findEventClass(method.def, traversal, scope);
|
|
144678
|
+
forClass = this.findForClass(method.def, eventClass, traversal, scope);
|
|
143563
144679
|
}
|
|
143564
144680
|
}
|
|
143565
144681
|
let f = undefined;
|
|
@@ -143575,9 +144691,23 @@ class SetHandlerTranspiler {
|
|
|
143575
144691
|
if (activationExpression) {
|
|
143576
144692
|
activation = ", " + new expressions_1.SourceTranspiler().transpile(activationExpression, traversal).getCode();
|
|
143577
144693
|
}
|
|
143578
|
-
return new chunk_1.Chunk().append(`abap.statements.setHandler({EVENT_NAME: "${eventName}", EVENT_CLASS: "${eventClass}"}, [${methods.join(",")}], ${f}${activation});`, node, traversal);
|
|
144694
|
+
return new chunk_1.Chunk().append(`abap.statements.setHandler({EVENT_NAME: "${eventName}", EVENT_CLASS: "${eventClass}"${forClass}}, [${methods.join(",")}], ${f}${activation});`, node, traversal);
|
|
143579
144695
|
}
|
|
143580
144696
|
///////////////////////////////////////////////////////////////////////
|
|
144697
|
+
/** a handler FOR EVENT ... OF a subclass of the class declaring the event only reacts to that subclass */
|
|
144698
|
+
findForClass(mdef, eventClass, traversal, scope) {
|
|
144699
|
+
const own = traversal.findClassDefinition(mdef.getEventClass(), scope);
|
|
144700
|
+
if (own === undefined || traversal.buildInternalName(own.getName(), own) === eventClass) {
|
|
144701
|
+
return "";
|
|
144702
|
+
}
|
|
144703
|
+
let def = own;
|
|
144704
|
+
let event = undefined;
|
|
144705
|
+
while (def !== undefined && event === undefined) {
|
|
144706
|
+
event = def.getEvents().find(e => e.getName().toUpperCase() === mdef.getEventName()?.toUpperCase());
|
|
144707
|
+
def = def.getSuperClass() ? traversal.findClassDefinition(def.getSuperClass(), scope) : undefined;
|
|
144708
|
+
}
|
|
144709
|
+
return `, FOR_CLASS: "${traversal.buildInternalName(own.getName(), own)}", STATIC: ${event?.isStatic() === true}`;
|
|
144710
|
+
}
|
|
143581
144711
|
findEventClass(mdef, traversal, scope) {
|
|
143582
144712
|
let def = traversal.findClassDefinition(mdef.getEventClass(), scope);
|
|
143583
144713
|
if (def === undefined) {
|
|
@@ -148297,11 +149427,11 @@ class TranspileTypes {
|
|
|
148297
149427
|
extra = "{qualifiedName: \"" + type.getQualifiedName()?.toUpperCase() + "\"}";
|
|
148298
149428
|
}
|
|
148299
149429
|
}
|
|
148300
|
-
else if (type instanceof abaplint.BasicTypes.
|
|
148301
|
-
|
|
148302
|
-
|
|
148303
|
-
|
|
148304
|
-
|
|
149430
|
+
else if (type instanceof abaplint.BasicTypes.DecFloat16Type) {
|
|
149431
|
+
// the range of decfloat16 is not modelled
|
|
149432
|
+
resolved = "DecFloat16";
|
|
149433
|
+
}
|
|
149434
|
+
else if (type instanceof abaplint.BasicTypes.DecFloat34Type) {
|
|
148305
149435
|
resolved = "DecFloat34";
|
|
148306
149436
|
}
|
|
148307
149437
|
else if (type instanceof abaplint.BasicTypes.EnumType) {
|
|
@@ -148659,6 +149789,15 @@ class Traversal {
|
|
|
148659
149789
|
return undefined;
|
|
148660
149790
|
}
|
|
148661
149791
|
scopeCache = undefined;
|
|
149792
|
+
/** MODIFY name. and DELETE name [FROM wa].: the name is a database table unless it is a variable of table type */
|
|
149793
|
+
isDatabaseShortForm(target) {
|
|
149794
|
+
if (target === undefined || target.getChildren().length !== 1) {
|
|
149795
|
+
return false;
|
|
149796
|
+
}
|
|
149797
|
+
const token = target.getFirstToken();
|
|
149798
|
+
const type = this.findCurrentScopeByToken(token)?.findVariable(token.getStr())?.getType();
|
|
149799
|
+
return !(type instanceof abaplint.BasicTypes.TableType);
|
|
149800
|
+
}
|
|
148662
149801
|
findCurrentScopeByToken(token) {
|
|
148663
149802
|
const filename = this.file.getFilename();
|
|
148664
149803
|
if (this.scopeCache
|
|
@@ -150469,6 +151608,7 @@ const defaultAllowedObjectTypes = [
|
|
|
150469
151608
|
"CHKO",
|
|
150470
151609
|
"CHKV",
|
|
150471
151610
|
"CLAS",
|
|
151611
|
+
"DCLS",
|
|
150472
151612
|
"DDLS",
|
|
150473
151613
|
"DDLX",
|
|
150474
151614
|
"DEVC",
|
|
@@ -150611,11 +151751,11 @@ class Validation {
|
|
|
150611
151751
|
const conf = new core_1.Config(JSON.stringify(exports.config));
|
|
150612
151752
|
reg.setConfig(conf);
|
|
150613
151753
|
const issues = reg.findIssues();
|
|
150614
|
-
return issues.filter(i => i.getKey() !== "ambiguous_statement" || this.
|
|
151754
|
+
return issues.filter(i => i.getKey() !== "ambiguous_statement" || this.isUnambiguous(reg, i) === false);
|
|
150615
151755
|
}
|
|
150616
|
-
/**
|
|
150617
|
-
*
|
|
150618
|
-
|
|
151756
|
+
/** DELETE name., DELETE name FROM x., MODIFY name. and MODIFY name FROM x. read two ways, so abaplint calls them
|
|
151757
|
+
* ambiguous. ABAP decides by the name: a variable of table type is the internal table, anything else the database table */
|
|
151758
|
+
isUnambiguous(reg, issue) {
|
|
150619
151759
|
const file = reg.getFileByName(issue.getFilename());
|
|
150620
151760
|
const obj = file ? reg.findObjectForFile(file) : undefined;
|
|
150621
151761
|
if (!(obj instanceof core_1.ABAPObject)) {
|
|
@@ -150637,7 +151777,10 @@ class Validation {
|
|
|
150637
151777
|
this.scopes.set(obj, spaghetti);
|
|
150638
151778
|
}
|
|
150639
151779
|
const variable = spaghetti.lookupPosition(token.getStart(), issue.getFilename())?.findVariable(token.getStr());
|
|
150640
|
-
|
|
151780
|
+
if (variable?.getType() instanceof core_1.BasicTypes.TableType) {
|
|
151781
|
+
return true;
|
|
151782
|
+
}
|
|
151783
|
+
return variable !== undefined || statement.findExpressionAfterToken("FROM") !== undefined;
|
|
150641
151784
|
}
|
|
150642
151785
|
}
|
|
150643
151786
|
exports.Validation = Validation;
|