@abaplint/transpiler-cli 2.14.36 → 2.14.37
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 +667 -319
- 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);
|
|
@@ -9275,10 +9274,14 @@ class SQLCompare extends combi_1.Expression {
|
|
|
9275
9274
|
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
9275
|
const sub = (0, combi_1.seq)((0, combi_1.optPrio)((0, combi_1.altPrio)("ALL", "ANY", "SOME")), (0, combi_1.altPrio)(subSelect, simpleScalarSubSelect));
|
|
9277
9276
|
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
9277
|
const paren = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.ParenLeftW), _1.Source, (0, combi_1.tok)(tokens_1.WParenRightW));
|
|
9280
9278
|
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
|
|
9279
|
+
const arithmetic = (0, combi_1.seq)((0, combi_1.altPrio)("+", "-", "*", "/"), _1.SQLFieldName);
|
|
9280
|
+
const arith = (0, combi_1.ver)(version_1.Release.v750, (0, combi_1.plusPrio)(arithmetic), { also: combi_1.AlsoIn.OpenABAP });
|
|
9281
|
+
// the left hand side can also concatenate with &&, the right hand side can not
|
|
9282
|
+
const concat = (0, combi_1.seq)("&&", (0, combi_1.altPrio)(_1.SQLFieldName, _1.ConstantString, at));
|
|
9283
|
+
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 });
|
|
9284
|
+
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
9285
|
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
9286
|
const rett = (0, combi_1.seq)(lhs, rhs);
|
|
9284
9287
|
const exists = (0, combi_1.seq)("EXISTS", (0, combi_1.altPrio)(subSelect, simpleSubSelect));
|
|
@@ -10940,7 +10943,12 @@ class SQLOrderBy extends combi_1.Expression {
|
|
|
10940
10943
|
const ding = (0, combi_1.alt)("ASCENDING", "DESCENDING");
|
|
10941
10944
|
const nulls = (0, combi_1.ver)(version_1.Release.v778, (0, combi_1.seq)("NULLS", (0, combi_1.alt)("FIRST", "LAST")));
|
|
10942
10945
|
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
|
|
10946
|
+
const entry = (0, combi_1.seq)(item, (0, combi_1.opt)(ding), (0, combi_1.opt)(nulls));
|
|
10947
|
+
// without commas only column names, SQL expressions need the comma separated list.
|
|
10948
|
+
// UP TO and OFFSET are not taken as column names, they are not allowed after ORDER BY, #2555
|
|
10949
|
+
const commaList = (0, combi_1.seq)(entry, (0, combi_1.star)((0, combi_1.seq)(",", entry)));
|
|
10950
|
+
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)));
|
|
10951
|
+
const ofields = (0, combi_1.alt)(commaList, blankList);
|
|
10944
10952
|
const order = (0, combi_1.seq)("ORDER BY", (0, combi_1.altPrio)("PRIMARY KEY", dynamic_1.Dynamic, ofields));
|
|
10945
10953
|
return order;
|
|
10946
10954
|
}
|
|
@@ -30081,6 +30089,8 @@ const enum_type_1 = __webpack_require__(/*! ../types/basic/enum_type */ "./node_
|
|
|
30081
30089
|
const cgeneric_type_1 = __webpack_require__(/*! ../types/basic/cgeneric_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/cgeneric_type.js");
|
|
30082
30090
|
const Expressions = __importStar(__webpack_require__(/*! ../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
|
|
30083
30091
|
const nodes_1 = __webpack_require__(/*! ../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
30092
|
+
const ngeneric_type_1 = __webpack_require__(/*! ../types/basic/ngeneric_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/ngeneric_type.js");
|
|
30093
|
+
const _builtin_1 = __webpack_require__(/*! ./_builtin */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js");
|
|
30084
30094
|
// todo: refactor to static? for performance
|
|
30085
30095
|
class TypeUtils {
|
|
30086
30096
|
constructor(scope) {
|
|
@@ -30378,6 +30388,117 @@ class TypeUtils {
|
|
|
30378
30388
|
|| node.findFirstExpression(Expressions.ArithOperator) !== undefined;
|
|
30379
30389
|
return calculated;
|
|
30380
30390
|
}
|
|
30391
|
+
/** the source is only a call of a functional method, not a built-in function */
|
|
30392
|
+
isFunctionalMethodResult(node) {
|
|
30393
|
+
var _a;
|
|
30394
|
+
if (!(node.get() instanceof Expressions.Source) || node.getChildren().length !== 1) {
|
|
30395
|
+
return false;
|
|
30396
|
+
}
|
|
30397
|
+
const chain = node.getFirstChild();
|
|
30398
|
+
if (!(chain instanceof nodes_1.ExpressionNode) || !(chain.get() instanceof Expressions.MethodCallChain)) {
|
|
30399
|
+
return false;
|
|
30400
|
+
}
|
|
30401
|
+
const children = chain.getChildren();
|
|
30402
|
+
const last = children[children.length - 1];
|
|
30403
|
+
if (!(last instanceof nodes_1.ExpressionNode) || !(last.get() instanceof Expressions.MethodCall)) {
|
|
30404
|
+
return false;
|
|
30405
|
+
}
|
|
30406
|
+
if (children.length === 1) {
|
|
30407
|
+
const name = (_a = last.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
30408
|
+
if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name) !== undefined) {
|
|
30409
|
+
return false;
|
|
30410
|
+
}
|
|
30411
|
+
}
|
|
30412
|
+
return true;
|
|
30413
|
+
}
|
|
30414
|
+
/** the result of a functional method passed to a formal parameter: the result is expected to be of
|
|
30415
|
+
* the same kind as the parameter, numeric types mix, c, n and x only into the same or a longer length.
|
|
30416
|
+
* Returns false for a known mismatch of elementary types, true otherwise */
|
|
30417
|
+
isFunctionalResultAssignable(source, target) {
|
|
30418
|
+
const isNumber = (t) => t instanceof basic_1.IntegerType
|
|
30419
|
+
|| t instanceof basic_1.Integer8Type
|
|
30420
|
+
|| t instanceof basic_1.PackedType
|
|
30421
|
+
|| t instanceof basic_1.FloatType
|
|
30422
|
+
|| t instanceof basic_1.DecFloat16Type
|
|
30423
|
+
|| t instanceof basic_1.DecFloat34Type;
|
|
30424
|
+
let kind;
|
|
30425
|
+
if (isNumber(source)) {
|
|
30426
|
+
kind = "number";
|
|
30427
|
+
}
|
|
30428
|
+
else if (source instanceof basic_1.CharacterType) {
|
|
30429
|
+
kind = "c";
|
|
30430
|
+
}
|
|
30431
|
+
else if (source instanceof basic_1.NumericType && !(source instanceof ngeneric_type_1.NGenericType)) {
|
|
30432
|
+
kind = "n";
|
|
30433
|
+
}
|
|
30434
|
+
else if (source instanceof basic_1.HexType) {
|
|
30435
|
+
kind = "x";
|
|
30436
|
+
}
|
|
30437
|
+
else if (source instanceof basic_1.StringType) {
|
|
30438
|
+
kind = "string";
|
|
30439
|
+
}
|
|
30440
|
+
else if (source instanceof basic_1.XStringType) {
|
|
30441
|
+
kind = "xstring";
|
|
30442
|
+
}
|
|
30443
|
+
else if (source instanceof basic_1.DateType) {
|
|
30444
|
+
kind = "d";
|
|
30445
|
+
}
|
|
30446
|
+
else if (source instanceof basic_1.TimeType) {
|
|
30447
|
+
kind = "t";
|
|
30448
|
+
}
|
|
30449
|
+
else if (source instanceof basic_1.UTCLongType) {
|
|
30450
|
+
kind = "utclong";
|
|
30451
|
+
}
|
|
30452
|
+
else {
|
|
30453
|
+
return true;
|
|
30454
|
+
}
|
|
30455
|
+
if (isNumber(target) || target instanceof basic_1.NumericGenericType || target instanceof basic_1.PGenericType) {
|
|
30456
|
+
return kind === "number";
|
|
30457
|
+
}
|
|
30458
|
+
else if (target instanceof basic_1.CharacterType) {
|
|
30459
|
+
return source instanceof basic_1.CharacterType && source.getLength() <= target.getLength();
|
|
30460
|
+
}
|
|
30461
|
+
else if (target instanceof ngeneric_type_1.NGenericType) {
|
|
30462
|
+
return kind === "n";
|
|
30463
|
+
}
|
|
30464
|
+
else if (target instanceof basic_1.NumericType) {
|
|
30465
|
+
return source instanceof basic_1.NumericType && source.getLength() <= target.getLength();
|
|
30466
|
+
}
|
|
30467
|
+
else if (target instanceof basic_1.HexType) {
|
|
30468
|
+
return source instanceof basic_1.HexType && source.getLength() <= target.getLength();
|
|
30469
|
+
}
|
|
30470
|
+
else if (target instanceof basic_1.StringType) {
|
|
30471
|
+
return kind === "c" || kind === "string";
|
|
30472
|
+
}
|
|
30473
|
+
else if (target instanceof basic_1.XStringType) {
|
|
30474
|
+
return kind === "x" || kind === "xstring";
|
|
30475
|
+
}
|
|
30476
|
+
else if (target instanceof basic_1.DateType) {
|
|
30477
|
+
return kind === "d";
|
|
30478
|
+
}
|
|
30479
|
+
else if (target instanceof basic_1.TimeType) {
|
|
30480
|
+
return kind === "t";
|
|
30481
|
+
}
|
|
30482
|
+
else if (target instanceof basic_1.UTCLongType) {
|
|
30483
|
+
return kind === "utclong";
|
|
30484
|
+
}
|
|
30485
|
+
else if (target instanceof cgeneric_type_1.CGenericType) {
|
|
30486
|
+
return kind === "c";
|
|
30487
|
+
}
|
|
30488
|
+
else if (target instanceof basic_1.XGenericType) {
|
|
30489
|
+
return kind === "x";
|
|
30490
|
+
}
|
|
30491
|
+
else if (target instanceof basic_1.CSequenceType) {
|
|
30492
|
+
return kind === "c" || kind === "string";
|
|
30493
|
+
}
|
|
30494
|
+
else if (target instanceof basic_1.XSequenceType) {
|
|
30495
|
+
return kind === "x" || kind === "xstring";
|
|
30496
|
+
}
|
|
30497
|
+
else if (target instanceof basic_1.CLikeType) {
|
|
30498
|
+
return kind !== "number" && kind !== "x" && kind !== "xstring" && kind !== "utclong";
|
|
30499
|
+
}
|
|
30500
|
+
return true;
|
|
30501
|
+
}
|
|
30381
30502
|
// a text or string literal is only assignable to an xstring or xsequence parameter if its
|
|
30382
30503
|
// content is hexadecimal: one or more of 0-9 and A-F, upper case, nothing else, or ``
|
|
30383
30504
|
isHexConstant(node) {
|
|
@@ -30400,7 +30521,7 @@ class TypeUtils {
|
|
|
30400
30521
|
}
|
|
30401
30522
|
return this.isAssignable(source, target);
|
|
30402
30523
|
}
|
|
30403
|
-
isAssignableStrict(source, target, node) {
|
|
30524
|
+
isAssignableStrict(source, target, node, builtin = false) {
|
|
30404
30525
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
30405
30526
|
const calculated = node ? this.isCalculated(node) : false;
|
|
30406
30527
|
/*
|
|
@@ -30426,9 +30547,19 @@ class TypeUtils {
|
|
|
30426
30547
|
return false;
|
|
30427
30548
|
}
|
|
30428
30549
|
}
|
|
30550
|
+
if (node && builtin === false && this.isFunctionalMethodResult(node)
|
|
30551
|
+
&& this.isFunctionalResultAssignable(source, target) === false) {
|
|
30552
|
+
return false;
|
|
30553
|
+
}
|
|
30429
30554
|
if (calculated) {
|
|
30430
30555
|
return this.isAssignable(source, target);
|
|
30431
30556
|
}
|
|
30557
|
+
// an elementary text field is not compatible with a structure, also not with a flat character-like one
|
|
30558
|
+
if (target instanceof basic_1.StructureType
|
|
30559
|
+
&& target.containsVoid() === false
|
|
30560
|
+
&& (source instanceof basic_1.CharacterType || source instanceof basic_1.StringType || source instanceof basic_1.NumericType)) {
|
|
30561
|
+
return false;
|
|
30562
|
+
}
|
|
30432
30563
|
if (target instanceof basic_1.CLikeType) {
|
|
30433
30564
|
return this.isCharLikeStrict(source);
|
|
30434
30565
|
}
|
|
@@ -30615,8 +30746,14 @@ class TypeUtils {
|
|
|
30615
30746
|
return false;
|
|
30616
30747
|
}
|
|
30617
30748
|
}
|
|
30749
|
+
else if (source instanceof basic_1.DataReference && target instanceof basic_1.DataReference) {
|
|
30750
|
+
return this.isDataReferenceCompatible(source, target);
|
|
30751
|
+
}
|
|
30618
30752
|
else if (source instanceof basic_1.TableType) {
|
|
30619
|
-
if (
|
|
30753
|
+
if (target instanceof basic_1.TableType && this.isTableKindCompatible(source, target) === false) {
|
|
30754
|
+
return false;
|
|
30755
|
+
}
|
|
30756
|
+
else if (source.getRowType() instanceof basic_1.AnyType) {
|
|
30620
30757
|
// then its a generic table, todo: add top level generic table type?
|
|
30621
30758
|
return true;
|
|
30622
30759
|
}
|
|
@@ -30646,6 +30783,81 @@ class TypeUtils {
|
|
|
30646
30783
|
}
|
|
30647
30784
|
return this.isAssignable(source, target);
|
|
30648
30785
|
}
|
|
30786
|
+
// a standard, sorted or hashed table only fits a table type of the same kind, generic or not,
|
|
30787
|
+
// INDEX TABLE takes standard and sorted tables, ANY TABLE takes all
|
|
30788
|
+
isTableKindCompatible(source, target) {
|
|
30789
|
+
const sourceAccess = source.getAccessType();
|
|
30790
|
+
const targetAccess = target.getAccessType();
|
|
30791
|
+
if (sourceAccess === undefined
|
|
30792
|
+
|| targetAccess === undefined
|
|
30793
|
+
|| sourceAccess === table_type_1.TableAccessType.index
|
|
30794
|
+
|| sourceAccess === table_type_1.TableAccessType.any
|
|
30795
|
+
|| source.isWithHeader()
|
|
30796
|
+
|| target.isWithHeader()) {
|
|
30797
|
+
return true;
|
|
30798
|
+
}
|
|
30799
|
+
else if (targetAccess === table_type_1.TableAccessType.any) {
|
|
30800
|
+
return true;
|
|
30801
|
+
}
|
|
30802
|
+
else if (targetAccess === table_type_1.TableAccessType.index) {
|
|
30803
|
+
return sourceAccess !== table_type_1.TableAccessType.hashed;
|
|
30804
|
+
}
|
|
30805
|
+
return sourceAccess === targetAccess;
|
|
30806
|
+
}
|
|
30807
|
+
// a data reference fits REF TO data, or a reference to the same type, no down cast
|
|
30808
|
+
isDataReferenceCompatible(source, target) {
|
|
30809
|
+
const targetType = target.getType();
|
|
30810
|
+
const sourceType = source.getType();
|
|
30811
|
+
if (targetType instanceof basic_1.DataType || targetType instanceof basic_1.AnyType || target.isGeneric()) {
|
|
30812
|
+
return true;
|
|
30813
|
+
}
|
|
30814
|
+
else if (sourceType instanceof basic_1.DataType || sourceType instanceof basic_1.AnyType) {
|
|
30815
|
+
return false;
|
|
30816
|
+
}
|
|
30817
|
+
return this.isSameType(sourceType, targetType);
|
|
30818
|
+
}
|
|
30819
|
+
// types of the same kind and technical attributes, structures also with the same component names;
|
|
30820
|
+
// returns true whenever this cannot be decided
|
|
30821
|
+
isSameType(source, target) {
|
|
30822
|
+
if (source instanceof basic_1.VoidType || target instanceof basic_1.VoidType
|
|
30823
|
+
|| source instanceof basic_1.UnknownType || target instanceof basic_1.UnknownType
|
|
30824
|
+
|| source instanceof basic_1.AnyType || target instanceof basic_1.AnyType
|
|
30825
|
+
|| source.containsVoid() || target.containsVoid()) {
|
|
30826
|
+
return true;
|
|
30827
|
+
}
|
|
30828
|
+
else if (source.constructor !== target.constructor) {
|
|
30829
|
+
return false;
|
|
30830
|
+
}
|
|
30831
|
+
if ((source instanceof basic_1.CharacterType && target instanceof basic_1.CharacterType)
|
|
30832
|
+
|| (source instanceof basic_1.HexType && target instanceof basic_1.HexType)
|
|
30833
|
+
|| (source instanceof basic_1.NumericType && target instanceof basic_1.NumericType)) {
|
|
30834
|
+
return source.getLength() === target.getLength();
|
|
30835
|
+
}
|
|
30836
|
+
else if (source instanceof basic_1.PackedType && target instanceof basic_1.PackedType) {
|
|
30837
|
+
return source.getLength() === target.getLength() && source.getDecimals() === target.getDecimals();
|
|
30838
|
+
}
|
|
30839
|
+
else if (source instanceof basic_1.StructureType && target instanceof basic_1.StructureType) {
|
|
30840
|
+
const sourceComponents = source.getComponents();
|
|
30841
|
+
const targetComponents = target.getComponents();
|
|
30842
|
+
if (sourceComponents.length !== targetComponents.length) {
|
|
30843
|
+
return false;
|
|
30844
|
+
}
|
|
30845
|
+
for (let i = 0; i < sourceComponents.length; i++) {
|
|
30846
|
+
if (sourceComponents[i].name.toUpperCase() !== targetComponents[i].name.toUpperCase()
|
|
30847
|
+
|| this.isSameType(sourceComponents[i].type, targetComponents[i].type) === false) {
|
|
30848
|
+
return false;
|
|
30849
|
+
}
|
|
30850
|
+
}
|
|
30851
|
+
}
|
|
30852
|
+
else if (source instanceof basic_1.TableType && target instanceof basic_1.TableType) {
|
|
30853
|
+
return source.getAccessType() === target.getAccessType()
|
|
30854
|
+
&& this.isSameType(source.getRowType(), target.getRowType());
|
|
30855
|
+
}
|
|
30856
|
+
else if (source instanceof basic_1.DataReference && target instanceof basic_1.DataReference) {
|
|
30857
|
+
return this.isSameType(source.getType(), target.getType());
|
|
30858
|
+
}
|
|
30859
|
+
return true;
|
|
30860
|
+
}
|
|
30649
30861
|
// character-like arguments of built-in functions must be elementary, flat character-like structures are not allowed
|
|
30650
30862
|
isAssignableBuiltin(source, target, node) {
|
|
30651
30863
|
if (target instanceof basic_1.CLikeType
|
|
@@ -30653,7 +30865,7 @@ class TypeUtils {
|
|
|
30653
30865
|
|| (source instanceof basic_1.TableType && source.isWithHeader() && source.getRowType() instanceof basic_1.StructureType))) {
|
|
30654
30866
|
return false;
|
|
30655
30867
|
}
|
|
30656
|
-
return this.isAssignableStrict(source, target, node);
|
|
30868
|
+
return this.isAssignableStrict(source, target, node, true);
|
|
30657
30869
|
}
|
|
30658
30870
|
// Typing with the classic STRUCTURE addition, ie. "FORM foo USING bar STRUCTURE zkey",
|
|
30659
30871
|
// is not a compatibility check: ABAP only checks the fragment view up to the end of the
|
|
@@ -31553,7 +31765,13 @@ class BasicTypes {
|
|
|
31553
31765
|
|| text === "TYPE HASHED TABLE"
|
|
31554
31766
|
|| text === "TYPE INDEX TABLE"
|
|
31555
31767
|
|| text === "TYPE ANY TABLE") {
|
|
31556
|
-
|
|
31768
|
+
// the table kind is kept, the key is left open
|
|
31769
|
+
const access = text.split(" ")[1];
|
|
31770
|
+
return new Types.TableType(Types.AnyType.get(), {
|
|
31771
|
+
withHeader: node.concatTokens().toUpperCase().includes("WITH HEADER LINE"),
|
|
31772
|
+
keyType: Types.TableKeyType.user,
|
|
31773
|
+
primaryKey: { name: "primary_key", type: access, isUnique: false, keyFields: [] },
|
|
31774
|
+
});
|
|
31557
31775
|
}
|
|
31558
31776
|
else if (text.startsWith("LIKE ")) {
|
|
31559
31777
|
let sub = node.findFirstExpression(Expressions.Type);
|
|
@@ -31732,6 +31950,10 @@ class BasicTypes {
|
|
|
31732
31950
|
this.input.scope.addReference(token, foundId, _reference_1.ReferenceType.TypeReference, this.input.filename);
|
|
31733
31951
|
}
|
|
31734
31952
|
}
|
|
31953
|
+
else if (className === "ME") {
|
|
31954
|
+
// me is the reference to the instance, not a class or interface; "me->ty" names the type through it
|
|
31955
|
+
return new Types.UnknownType("\"me\" is not a class or interface, \"" + chainText + "\" cannot be resolved");
|
|
31956
|
+
}
|
|
31735
31957
|
else {
|
|
31736
31958
|
// lookup in local and global scope
|
|
31737
31959
|
const obj = this.input.scope.findObjectDefinition(className);
|
|
@@ -31989,6 +32211,10 @@ class BasicTypes {
|
|
|
31989
32211
|
else if (chain.concatTokens().toUpperCase() === "DATA") {
|
|
31990
32212
|
return new Types.DataReference(new Types.DataType());
|
|
31991
32213
|
}
|
|
32214
|
+
else if (found instanceof Types.UnknownType && name.toUpperCase() === "ME") {
|
|
32215
|
+
// "REF TO me=>ty", me is not a class or interface whatever the error namespace
|
|
32216
|
+
return found;
|
|
32217
|
+
}
|
|
31992
32218
|
if (this.input.scope.isBadiDef(name) === true) {
|
|
31993
32219
|
return Types.VoidType.get(name);
|
|
31994
32220
|
}
|
|
@@ -33177,6 +33403,11 @@ class Compare {
|
|
|
33177
33403
|
if (operandMessage !== undefined) {
|
|
33178
33404
|
return;
|
|
33179
33405
|
}
|
|
33406
|
+
const arithmeticMessage = this.checkArithmeticOperands(node, sources, sourceTypes);
|
|
33407
|
+
if (arithmeticMessage !== undefined) {
|
|
33408
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), arithmeticMessage));
|
|
33409
|
+
return;
|
|
33410
|
+
}
|
|
33180
33411
|
const typeUtils = new _type_utils_1.TypeUtils(input.scope);
|
|
33181
33412
|
const compareOperator = (_a = node.findDirectExpression(Expressions.CompareOperator)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
33182
33413
|
if (compareOperator === "CS"
|
|
@@ -33245,6 +33476,67 @@ class Compare {
|
|
|
33245
33476
|
const call = _builtin_call_1.BuiltInCall.fromSource(source, input);
|
|
33246
33477
|
return call === undefined ? undefined : _builtin_call_1.BuiltInCall.callName(call);
|
|
33247
33478
|
}
|
|
33479
|
+
// an arithmetic expression can only be compared with a numeric operand or another arithmetic expression,
|
|
33480
|
+
// a character-like, byte-like, date, time or structured operand is expected to be a syntax error,
|
|
33481
|
+
// the operand can be made an arithmetic expression with a "+" in front, "+ lv_c"
|
|
33482
|
+
static checkArithmeticOperands(node, sources, types) {
|
|
33483
|
+
let pairs = [];
|
|
33484
|
+
if (node.findDirectExpression(Expressions.CompareOperator) !== undefined && sources.length === 2) {
|
|
33485
|
+
pairs = [[0, 1]];
|
|
33486
|
+
}
|
|
33487
|
+
else if (node.findDirectTokenByText("BETWEEN") !== undefined && sources.length === 3) {
|
|
33488
|
+
pairs = [[0, 1], [0, 2]];
|
|
33489
|
+
}
|
|
33490
|
+
for (const [a, b] of pairs) {
|
|
33491
|
+
for (const [arith, other] of [[a, b], [b, a]]) {
|
|
33492
|
+
if (this.isArithmetic(sources[arith]) === true
|
|
33493
|
+
&& this.isArithmetic(sources[other]) === false
|
|
33494
|
+
&& this.isNonNumeric(types[other]) === true) {
|
|
33495
|
+
const operand = sources[other].concatTokens();
|
|
33496
|
+
return `Arithmetic expression cannot be compared with non-numeric operand "${operand}", use "+ ${operand}"`;
|
|
33497
|
+
}
|
|
33498
|
+
}
|
|
33499
|
+
}
|
|
33500
|
+
return undefined;
|
|
33501
|
+
}
|
|
33502
|
+
// "a + b", "- a", "( a * b )", but not "( a )", "a && b" or "a BIT-AND b"
|
|
33503
|
+
static isArithmetic(source) {
|
|
33504
|
+
const children = source.getChildren();
|
|
33505
|
+
const first = children[0];
|
|
33506
|
+
if (first instanceof nodes_1.TokenNode) {
|
|
33507
|
+
const str = first.getFirstToken().getStr();
|
|
33508
|
+
if (str === "+" || str === "-") {
|
|
33509
|
+
return true;
|
|
33510
|
+
}
|
|
33511
|
+
else if (str === "(" && children.length === 3 && children[1] instanceof nodes_1.ExpressionNode) {
|
|
33512
|
+
return this.isArithmetic(children[1]);
|
|
33513
|
+
}
|
|
33514
|
+
}
|
|
33515
|
+
for (const child of children) {
|
|
33516
|
+
if (child instanceof nodes_1.ExpressionNode
|
|
33517
|
+
&& child.get() instanceof Expressions.ArithOperator
|
|
33518
|
+
&& child.concatTokens().toUpperCase().startsWith("BIT-") === false) {
|
|
33519
|
+
return true;
|
|
33520
|
+
}
|
|
33521
|
+
}
|
|
33522
|
+
return false;
|
|
33523
|
+
}
|
|
33524
|
+
static isNonNumeric(type) {
|
|
33525
|
+
return type instanceof basic_1.CharacterType
|
|
33526
|
+
|| type instanceof basic_1.StringType
|
|
33527
|
+
|| type instanceof basic_1.NumericType
|
|
33528
|
+
|| type instanceof basic_1.DateType
|
|
33529
|
+
|| type instanceof basic_1.TimeType
|
|
33530
|
+
|| type instanceof basic_1.HexType
|
|
33531
|
+
|| type instanceof basic_1.XStringType
|
|
33532
|
+
|| type instanceof basic_1.StructureType
|
|
33533
|
+
|| type instanceof basic_1.CLikeType
|
|
33534
|
+
|| type instanceof basic_1.CSequenceType
|
|
33535
|
+
|| type instanceof basic_1.CGenericType
|
|
33536
|
+
|| type instanceof basic_1.NGenericType
|
|
33537
|
+
|| type instanceof basic_1.XSequenceType
|
|
33538
|
+
|| type instanceof basic_1.XGenericType;
|
|
33539
|
+
}
|
|
33248
33540
|
}
|
|
33249
33541
|
exports.Compare = Compare;
|
|
33250
33542
|
//# sourceMappingURL=compare.js.map
|
|
@@ -34386,6 +34678,7 @@ const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expr
|
|
|
34386
34678
|
const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
|
|
34387
34679
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
|
|
34388
34680
|
const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
|
|
34681
|
+
const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
|
|
34389
34682
|
class FieldAssignment {
|
|
34390
34683
|
static runSyntax(node, input, targetType) {
|
|
34391
34684
|
const fieldSub = node.findDirectExpression(Expressions.FieldSub);
|
|
@@ -34419,7 +34712,19 @@ class FieldAssignment {
|
|
|
34419
34712
|
else if (targetType instanceof basic_1.VoidType) {
|
|
34420
34713
|
type = targetType;
|
|
34421
34714
|
}
|
|
34422
|
-
source_1.Source.runSyntax(s, input, type);
|
|
34715
|
+
const sourceType = source_1.Source.runSyntax(s, input, type);
|
|
34716
|
+
if (this.isReference(type)
|
|
34717
|
+
&& !(type instanceof basic_1.ObjectReferenceType && sourceType instanceof basic_1.ObjectReferenceType)
|
|
34718
|
+
&& new _type_utils_1.TypeUtils(input.scope).isAssignable(sourceType, type) === false) {
|
|
34719
|
+
// a reference component only takes a reference, values like '' or 1 are not converted
|
|
34720
|
+
const message = `Type of source cannot be converted to the type of ${fieldSub.concatTokens()}`;
|
|
34721
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
|
|
34722
|
+
}
|
|
34723
|
+
}
|
|
34724
|
+
static isReference(type) {
|
|
34725
|
+
return type instanceof basic_1.ObjectReferenceType
|
|
34726
|
+
|| type instanceof basic_1.GenericObjectReferenceType
|
|
34727
|
+
|| type instanceof basic_1.DataReference;
|
|
34423
34728
|
}
|
|
34424
34729
|
}
|
|
34425
34730
|
exports.FieldAssignment = FieldAssignment;
|
|
@@ -36861,7 +37166,11 @@ class MethodParameters {
|
|
|
36861
37166
|
}
|
|
36862
37167
|
// the parameter is supplied, even if its type is wrong
|
|
36863
37168
|
(_a = this.requiredParameters) === null || _a === void 0 ? void 0 : _a.delete(item.name);
|
|
36864
|
-
|
|
37169
|
+
const typeUtils = new _type_utils_1.TypeUtils(input.scope);
|
|
37170
|
+
if (item.targetType && (typeUtils.isAssignableStrict(parameterType, item.targetType) === false
|
|
37171
|
+
// a CHANGING parameter is read and written, so a data reference is checked in both directions
|
|
37172
|
+
|| (parameterType instanceof basic_1.DataReference && item.targetType instanceof basic_1.DataReference
|
|
37173
|
+
&& typeUtils.isAssignableStrict(item.targetType, parameterType) === false))) {
|
|
36865
37174
|
const message = "Method parameter type not compatible, " + item.name;
|
|
36866
37175
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
36867
37176
|
return;
|
|
@@ -37929,17 +38238,19 @@ class Select {
|
|
|
37929
38238
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
37930
38239
|
}
|
|
37931
38240
|
}
|
|
38241
|
+
/** an inline declaration cannot be the target of INTO or APPENDING CORRESPONDING FIELDS OF,
|
|
38242
|
+
* the declaration is still made, so later reads give no follow-up errors */
|
|
38243
|
+
static checkCorrespondingInline(into, inline, node, input) {
|
|
38244
|
+
if (inline !== undefined && into.findDirectTokenByText("CORRESPONDING") !== undefined) {
|
|
38245
|
+
const message = "Inline declarations cannot be used together with INTO CORRESPONDING FIELDS OF";
|
|
38246
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
38247
|
+
}
|
|
38248
|
+
}
|
|
37932
38249
|
static handleInto(node, input, fields, dbSources, from) {
|
|
37933
38250
|
const intoTable = node.findDirectExpression(Expressions.SQLIntoTable);
|
|
37934
38251
|
if (intoTable) {
|
|
37935
38252
|
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
|
-
}
|
|
38253
|
+
this.checkCorrespondingInline(intoTable, inline, node, input);
|
|
37943
38254
|
if (inline) {
|
|
37944
38255
|
inline_data_1.InlineData.runSyntax(inline, input, this.buildTableType(fields, dbSources, input.scope, from));
|
|
37945
38256
|
}
|
|
@@ -37948,6 +38259,7 @@ class Select {
|
|
|
37948
38259
|
const intoStructure = node.findDirectExpression(Expressions.SQLIntoStructure);
|
|
37949
38260
|
if (intoStructure) {
|
|
37950
38261
|
const inlineList = intoStructure.findAllExpressions(Expressions.InlineData);
|
|
38262
|
+
this.checkCorrespondingInline(intoStructure, inlineList[0], node, input);
|
|
37951
38263
|
if (inlineList.length === 1) {
|
|
37952
38264
|
inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input, from));
|
|
37953
38265
|
}
|
|
@@ -38425,13 +38737,17 @@ class Source {
|
|
|
38425
38737
|
}
|
|
38426
38738
|
const children = node.getChildren().slice();
|
|
38427
38739
|
let first = children.shift();
|
|
38740
|
+
// a leading sign makes the operand part of a calculation, "- foo"
|
|
38741
|
+
let signed = false;
|
|
38428
38742
|
if (first instanceof nodes_1.TokenNode) {
|
|
38429
38743
|
const token = first.getFirstToken();
|
|
38430
38744
|
const tok = token.getStr().toUpperCase();
|
|
38431
38745
|
switch (tok) {
|
|
38432
|
-
case "(":
|
|
38433
38746
|
case "-":
|
|
38434
38747
|
case "+":
|
|
38748
|
+
signed = true;
|
|
38749
|
+
break;
|
|
38750
|
+
case "(":
|
|
38435
38751
|
case "BIT":
|
|
38436
38752
|
break;
|
|
38437
38753
|
case "BOOLC":
|
|
@@ -38624,9 +38940,14 @@ class Source {
|
|
|
38624
38940
|
// an arithmetic operator has been seen, so the operands that follow
|
|
38625
38941
|
// determine a calculation type rather than simply replacing the context
|
|
38626
38942
|
let arithmetic = false;
|
|
38943
|
+
// the expressions of the operand in front of the next arithmetic operator
|
|
38944
|
+
let operand = [];
|
|
38627
38945
|
while (children.length >= 0) {
|
|
38628
38946
|
if (first instanceof nodes_1.ExpressionNode) {
|
|
38629
38947
|
const get = first.get();
|
|
38948
|
+
if (!(get instanceof Expressions.ArithOperator) && !(get instanceof Expressions.Source && arithmetic === true)) {
|
|
38949
|
+
operand.push(first);
|
|
38950
|
+
}
|
|
38630
38951
|
if (get instanceof Expressions.MethodCallChain) {
|
|
38631
38952
|
const predicate = this.predicateCall(node, first, input);
|
|
38632
38953
|
if (predicate !== undefined) {
|
|
@@ -38657,6 +38978,9 @@ class Source {
|
|
|
38657
38978
|
}
|
|
38658
38979
|
else if (get instanceof Expressions.Source) {
|
|
38659
38980
|
const found = Source.runSyntax(first, input);
|
|
38981
|
+
if (arithmetic === true && this.reportReferenceOperand(found, first, input)) {
|
|
38982
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
38983
|
+
}
|
|
38660
38984
|
context = this.infer(context, found, arithmetic);
|
|
38661
38985
|
}
|
|
38662
38986
|
else if (get instanceof Expressions.Constant) {
|
|
@@ -38675,11 +38999,15 @@ class Source {
|
|
|
38675
38999
|
context = component_chain_1.ComponentChain.runSyntax(context, first, input);
|
|
38676
39000
|
}
|
|
38677
39001
|
else if (get instanceof Expressions.ArithOperator) {
|
|
39002
|
+
const operator = first.concatTokens().toUpperCase();
|
|
39003
|
+
if (!operator.startsWith("BIT-") && this.reportReferenceOperand(context, operand, input)) {
|
|
39004
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
39005
|
+
}
|
|
39006
|
+
operand = [];
|
|
38678
39007
|
arithmetic = true;
|
|
38679
|
-
if (
|
|
39008
|
+
if (operator === "**") {
|
|
38680
39009
|
context = new basic_1.FloatType();
|
|
38681
39010
|
}
|
|
38682
|
-
const operator = first.concatTokens().toUpperCase();
|
|
38683
39011
|
if (operator === "BIT-OR" || operator === "BIT-AND" || operator === "BIT-XOR") {
|
|
38684
39012
|
hexExpected = true;
|
|
38685
39013
|
hexNext = true;
|
|
@@ -38713,8 +39041,28 @@ class Source {
|
|
|
38713
39041
|
if (node.findDirectTokenByText("&&")) {
|
|
38714
39042
|
return basic_1.StringType.get();
|
|
38715
39043
|
}
|
|
39044
|
+
if (signed === true && arithmetic === false && this.reportReferenceOperand(context, operand, input)) {
|
|
39045
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
39046
|
+
}
|
|
38716
39047
|
return context;
|
|
38717
39048
|
}
|
|
39049
|
+
static isReference(type) {
|
|
39050
|
+
return type instanceof basic_1.ObjectReferenceType
|
|
39051
|
+
|| type instanceof basic_1.GenericObjectReferenceType
|
|
39052
|
+
|| type instanceof basic_1.DataReference;
|
|
39053
|
+
}
|
|
39054
|
+
/** an operand of an arithmetic calculation is converted into a number, which is not possible for a
|
|
39055
|
+
* data or object reference, "foo - 1"; a dereferenced "foo->* - 1" is fine. Returns true if reported */
|
|
39056
|
+
static reportReferenceOperand(type, operand, input) {
|
|
39057
|
+
const nodes = Array.isArray(operand) ? operand : [operand];
|
|
39058
|
+
if (nodes.length === 0 || this.isReference(type) === false) {
|
|
39059
|
+
return false;
|
|
39060
|
+
}
|
|
39061
|
+
const name = nodes.map(n => n.concatTokens()).join("");
|
|
39062
|
+
const message = `"${name}" is a reference, it cannot be used in a calculation`;
|
|
39063
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, nodes[0].getFirstToken(), message));
|
|
39064
|
+
return true;
|
|
39065
|
+
}
|
|
38718
39066
|
////////////////////////////////
|
|
38719
39067
|
static traverseRemainingChildren(children, input) {
|
|
38720
39068
|
const last = children[children.length - 1];
|
|
@@ -41187,11 +41535,18 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
|
|
|
41187
41535
|
const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
41188
41536
|
class Add {
|
|
41189
41537
|
runSyntax(node, input) {
|
|
41538
|
+
// both operands are converted into numbers, a reference cannot be
|
|
41190
41539
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
41191
|
-
source_1.Source.runSyntax(s, input);
|
|
41540
|
+
const type = source_1.Source.runSyntax(s, input);
|
|
41541
|
+
if (source_1.Source.reportReferenceOperand(type, s, input)) {
|
|
41542
|
+
return;
|
|
41543
|
+
}
|
|
41192
41544
|
}
|
|
41193
41545
|
for (const t of node.findDirectExpressions(Expressions.Target)) {
|
|
41194
|
-
target_1.Target.runSyntax(t, input);
|
|
41546
|
+
const type = target_1.Target.runSyntax(t, input);
|
|
41547
|
+
if (source_1.Source.reportReferenceOperand(type, t, input)) {
|
|
41548
|
+
return;
|
|
41549
|
+
}
|
|
41195
41550
|
}
|
|
41196
41551
|
}
|
|
41197
41552
|
}
|
|
@@ -42355,12 +42710,9 @@ class Catch {
|
|
|
42355
42710
|
if (token) {
|
|
42356
42711
|
const classNames = Array.from(names);
|
|
42357
42712
|
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(" "));
|
|
42713
|
+
const type = unknownClass === undefined
|
|
42714
|
+
? this.inlineType(classNames, input)
|
|
42715
|
+
: basic_1.VoidType.get(unknownClass);
|
|
42364
42716
|
const identifier = new _typed_identifier_1.TypedIdentifier(token, input.filename, type, ["inline" /* IdentifierMeta.InlineDefinition */]);
|
|
42365
42717
|
input.scope.addIdentifier(identifier);
|
|
42366
42718
|
input.scope.addReference(token, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename);
|
|
@@ -42385,21 +42737,35 @@ class Catch {
|
|
|
42385
42737
|
}
|
|
42386
42738
|
}
|
|
42387
42739
|
}
|
|
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());
|
|
42740
|
+
// static type of an inline target: the first class, replaced by each following class that is one of its
|
|
42741
|
+
// super classes; any other following class makes it CX_ROOT, also when the classes share a closer super class
|
|
42742
|
+
inlineType(classNames, input) {
|
|
42743
|
+
let current = input.scope.findClassDefinition(classNames[0]);
|
|
42744
|
+
for (const name of classNames.slice(1)) {
|
|
42745
|
+
if (current === undefined) {
|
|
42746
|
+
break;
|
|
42399
42747
|
}
|
|
42400
|
-
|
|
42748
|
+
const next = input.scope.findClassDefinition(name);
|
|
42749
|
+
current = next && this.isSuperClass(next, current, input) ? next : undefined;
|
|
42401
42750
|
}
|
|
42402
|
-
|
|
42751
|
+
if (current !== undefined) {
|
|
42752
|
+
return new basic_1.ObjectReferenceType(current);
|
|
42753
|
+
}
|
|
42754
|
+
const root = input.scope.findClassDefinition("CX_ROOT");
|
|
42755
|
+
return root ? new basic_1.ObjectReferenceType(root) : basic_1.VoidType.get("CX_ROOT");
|
|
42756
|
+
}
|
|
42757
|
+
isSuperClass(candidate, cls, input) {
|
|
42758
|
+
const name = candidate.getName().toUpperCase();
|
|
42759
|
+
const visited = new Set();
|
|
42760
|
+
let current = cls;
|
|
42761
|
+
while (current && visited.has(current.getName().toUpperCase()) === false) {
|
|
42762
|
+
if (current.getName().toUpperCase() === name) {
|
|
42763
|
+
return true;
|
|
42764
|
+
}
|
|
42765
|
+
visited.add(current.getName().toUpperCase());
|
|
42766
|
+
current = input.scope.findClassDefinition(current.getSuperClass());
|
|
42767
|
+
}
|
|
42768
|
+
return false;
|
|
42403
42769
|
}
|
|
42404
42770
|
}
|
|
42405
42771
|
exports.Catch = Catch;
|
|
@@ -44510,11 +44876,18 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
|
|
|
44510
44876
|
const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
44511
44877
|
class Divide {
|
|
44512
44878
|
runSyntax(node, input) {
|
|
44879
|
+
// both operands are converted into numbers, a reference cannot be
|
|
44513
44880
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
44514
|
-
source_1.Source.runSyntax(s, input);
|
|
44881
|
+
const type = source_1.Source.runSyntax(s, input);
|
|
44882
|
+
if (source_1.Source.reportReferenceOperand(type, s, input)) {
|
|
44883
|
+
return;
|
|
44884
|
+
}
|
|
44515
44885
|
}
|
|
44516
44886
|
for (const t of node.findDirectExpressions(Expressions.Target)) {
|
|
44517
|
-
target_1.Target.runSyntax(t, input);
|
|
44887
|
+
const type = target_1.Target.runSyntax(t, input);
|
|
44888
|
+
if (source_1.Source.reportReferenceOperand(type, t, input)) {
|
|
44889
|
+
return;
|
|
44890
|
+
}
|
|
44518
44891
|
}
|
|
44519
44892
|
}
|
|
44520
44893
|
}
|
|
@@ -47987,11 +48360,18 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
|
|
|
47987
48360
|
const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
47988
48361
|
class Multiply {
|
|
47989
48362
|
runSyntax(node, input) {
|
|
48363
|
+
// both operands are converted into numbers, a reference cannot be
|
|
47990
48364
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
47991
|
-
source_1.Source.runSyntax(s, input);
|
|
48365
|
+
const type = source_1.Source.runSyntax(s, input);
|
|
48366
|
+
if (source_1.Source.reportReferenceOperand(type, s, input)) {
|
|
48367
|
+
return;
|
|
48368
|
+
}
|
|
47992
48369
|
}
|
|
47993
48370
|
for (const t of node.findDirectExpressions(Expressions.Target)) {
|
|
47994
|
-
target_1.Target.runSyntax(t, input);
|
|
48371
|
+
const type = target_1.Target.runSyntax(t, input);
|
|
48372
|
+
if (source_1.Source.reportReferenceOperand(type, t, input)) {
|
|
48373
|
+
return;
|
|
48374
|
+
}
|
|
47995
48375
|
}
|
|
47996
48376
|
}
|
|
47997
48377
|
}
|
|
@@ -49386,15 +49766,71 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
49386
49766
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
49387
49767
|
exports.Replace = void 0;
|
|
49388
49768
|
const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
|
|
49769
|
+
const nodes_1 = __webpack_require__(/*! ../../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
49389
49770
|
const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
|
|
49390
49771
|
const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
49772
|
+
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
|
|
49773
|
+
const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
|
|
49774
|
+
const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
|
|
49391
49775
|
class Replace {
|
|
49392
49776
|
runSyntax(node, input) {
|
|
49393
|
-
|
|
49394
|
-
|
|
49777
|
+
var _a;
|
|
49778
|
+
const byteMode = node.findDirectTokenByText("BYTE") !== undefined;
|
|
49779
|
+
const regex = (_a = node.findDirectExpression(Expressions.FindType)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
49780
|
+
const isRegex = regex === "REGEX" || regex === "PCRE";
|
|
49781
|
+
// operands which must be character like, or byte like in BYTE MODE
|
|
49782
|
+
const checks = [];
|
|
49783
|
+
let previous = undefined;
|
|
49784
|
+
let first = true;
|
|
49785
|
+
for (const child of node.getChildren()) {
|
|
49786
|
+
if (child instanceof nodes_1.TokenNode) {
|
|
49787
|
+
previous = child.concatTokens().toUpperCase();
|
|
49788
|
+
continue;
|
|
49789
|
+
}
|
|
49790
|
+
else if (child.get() instanceof Expressions.FindType) {
|
|
49791
|
+
previous = child.concatTokens() === "" ? previous : "FINDTYPE";
|
|
49792
|
+
continue;
|
|
49793
|
+
}
|
|
49794
|
+
if (child.get() instanceof Expressions.Source) {
|
|
49795
|
+
const type = source_1.Source.runSyntax(child, input);
|
|
49796
|
+
if (previous === "WITH"
|
|
49797
|
+
|| (first === true && previous === "REPLACE")
|
|
49798
|
+
|| ((previous === "OF" || previous === "FINDTYPE") && isRegex === false)) {
|
|
49799
|
+
checks.push({ node: child, type, table: false });
|
|
49800
|
+
}
|
|
49801
|
+
}
|
|
49802
|
+
else if (child.get() instanceof Expressions.Target) {
|
|
49803
|
+
const type = target_1.Target.runSyntax(child, input);
|
|
49804
|
+
if (previous === "IN" || previous === "OF" || previous === "INTO") {
|
|
49805
|
+
checks.push({ node: child, type, table: false });
|
|
49806
|
+
}
|
|
49807
|
+
else if (previous === "TABLE") {
|
|
49808
|
+
checks.push({ node: child, type, table: true });
|
|
49809
|
+
}
|
|
49810
|
+
}
|
|
49811
|
+
first = false;
|
|
49395
49812
|
}
|
|
49396
|
-
|
|
49397
|
-
|
|
49813
|
+
const utils = new _type_utils_1.TypeUtils(input.scope);
|
|
49814
|
+
for (const check of checks) {
|
|
49815
|
+
let type = check.type;
|
|
49816
|
+
if (check.table === true) {
|
|
49817
|
+
if (!(type instanceof basic_1.TableType)) {
|
|
49818
|
+
continue;
|
|
49819
|
+
}
|
|
49820
|
+
type = type.getRowType();
|
|
49821
|
+
}
|
|
49822
|
+
if (type === undefined) {
|
|
49823
|
+
continue;
|
|
49824
|
+
}
|
|
49825
|
+
const ok = byteMode ? utils.isHexLike(type) : utils.isCharLikeStrict(type);
|
|
49826
|
+
if (ok === false) {
|
|
49827
|
+
const kind = byteMode ? "byte like" : "character like";
|
|
49828
|
+
const message = check.table === true
|
|
49829
|
+
? "REPLACE, table row type must be " + kind
|
|
49830
|
+
: "REPLACE, \"" + check.node.concatTokens() + "\" must be " + kind;
|
|
49831
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, check.node.getFirstToken(), message));
|
|
49832
|
+
return;
|
|
49833
|
+
}
|
|
49398
49834
|
}
|
|
49399
49835
|
}
|
|
49400
49836
|
}
|
|
@@ -50716,11 +51152,18 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
|
|
|
50716
51152
|
const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
50717
51153
|
class Subtract {
|
|
50718
51154
|
runSyntax(node, input) {
|
|
51155
|
+
// both operands are converted into numbers, a reference cannot be
|
|
50719
51156
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
50720
|
-
source_1.Source.runSyntax(s, input);
|
|
51157
|
+
const type = source_1.Source.runSyntax(s, input);
|
|
51158
|
+
if (source_1.Source.reportReferenceOperand(type, s, input)) {
|
|
51159
|
+
return;
|
|
51160
|
+
}
|
|
50721
51161
|
}
|
|
50722
51162
|
for (const t of node.findDirectExpressions(Expressions.Target)) {
|
|
50723
|
-
target_1.Target.runSyntax(t, input);
|
|
51163
|
+
const type = target_1.Target.runSyntax(t, input);
|
|
51164
|
+
if (source_1.Source.reportReferenceOperand(type, t, input)) {
|
|
51165
|
+
return;
|
|
51166
|
+
}
|
|
50724
51167
|
}
|
|
50725
51168
|
}
|
|
50726
51169
|
}
|
|
@@ -51240,6 +51683,14 @@ class Type {
|
|
|
51240
51683
|
return new _typed_identifier_1.TypedIdentifier(found.getToken(), input.filename, basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey));
|
|
51241
51684
|
}
|
|
51242
51685
|
}
|
|
51686
|
+
if (input.scope.isAnyOO()) {
|
|
51687
|
+
const missing = this.lengthMissing(node);
|
|
51688
|
+
if (missing) {
|
|
51689
|
+
const message = "Specify LENGTH in OO context for types c, n, x and p";
|
|
51690
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, missing, message));
|
|
51691
|
+
return new _typed_identifier_1.TypedIdentifier(found.getToken(), input.filename, basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey));
|
|
51692
|
+
}
|
|
51693
|
+
}
|
|
51243
51694
|
return found;
|
|
51244
51695
|
}
|
|
51245
51696
|
const fallback = node.findFirstExpression(Expressions.NamespaceSimpleName);
|
|
@@ -51248,6 +51699,31 @@ class Type {
|
|
|
51248
51699
|
}
|
|
51249
51700
|
return undefined;
|
|
51250
51701
|
}
|
|
51702
|
+
/** returns the token to report when built-in c, n, x or p is used without a length */
|
|
51703
|
+
lengthMissing(node) {
|
|
51704
|
+
if (node.findDirectExpression(Expressions.Length) !== undefined
|
|
51705
|
+
|| node.findDirectExpression(Expressions.ConstantFieldLength) !== undefined) {
|
|
51706
|
+
return undefined;
|
|
51707
|
+
}
|
|
51708
|
+
const type = node.findDirectExpression(Expressions.Type);
|
|
51709
|
+
if (type === undefined) {
|
|
51710
|
+
// "TYPES foo." is implicitly type c with length 1
|
|
51711
|
+
const onlyName = node.getChildren().every(c => c.get() instanceof Expressions.NamespaceSimpleName
|
|
51712
|
+
|| ["TYPES", "BOXED", ".", ","].includes(c.concatTokens().toUpperCase()));
|
|
51713
|
+
return onlyName ? node.getFirstToken() : undefined;
|
|
51714
|
+
}
|
|
51715
|
+
const children = type.getChildren();
|
|
51716
|
+
if (children.length !== 2
|
|
51717
|
+
|| children[0].concatTokens().toUpperCase() !== "TYPE"
|
|
51718
|
+
|| !(children[1].get() instanceof Expressions.TypeName)) {
|
|
51719
|
+
return undefined;
|
|
51720
|
+
}
|
|
51721
|
+
const name = children[1].concatTokens().toUpperCase();
|
|
51722
|
+
if (["C", "N", "X", "P"].includes(name)) {
|
|
51723
|
+
return children[1].getFirstToken();
|
|
51724
|
+
}
|
|
51725
|
+
return undefined;
|
|
51726
|
+
}
|
|
51251
51727
|
}
|
|
51252
51728
|
exports.Type = Type;
|
|
51253
51729
|
//# sourceMappingURL=type.js.map
|
|
@@ -52617,7 +53093,8 @@ const Statements = __importStar(__webpack_require__(/*! ../../2_statements/state
|
|
|
52617
53093
|
const Structures = __importStar(__webpack_require__(/*! ../../3_structures/structures */ "./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js"));
|
|
52618
53094
|
const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
|
|
52619
53095
|
// "special exceptions must be caught before general exceptions", a CATCH of a class that inherits
|
|
52620
|
-
// from a class named in an earlier CATCH
|
|
53096
|
+
// from a class named before it in the same TRY, in an earlier CATCH or earlier in the same CATCH, is never reached,
|
|
53097
|
+
// this is a syntax error
|
|
52621
53098
|
// only reported when the lineage of the later class is known up to the earlier class, void classes are skipped
|
|
52622
53099
|
class Try {
|
|
52623
53100
|
static runSyntax(node, input) {
|
|
@@ -52627,23 +53104,17 @@ class Try {
|
|
|
52627
53104
|
if (statement === undefined) {
|
|
52628
53105
|
continue;
|
|
52629
53106
|
}
|
|
52630
|
-
|
|
53107
|
+
// each class counts as caught right after it, also for the next classes of the same CATCH statement
|
|
52631
53108
|
for (const c of statement.findDirectExpressions(Expressions.ClassName)) {
|
|
52632
53109
|
const token = c.getFirstToken();
|
|
52633
53110
|
const className = token.getStr().toUpperCase();
|
|
52634
|
-
|
|
52635
|
-
if (caught.size === 0) {
|
|
52636
|
-
continue;
|
|
52637
|
-
}
|
|
52638
|
-
const superclass = this.findCaughtSuperclass(className, caught, input);
|
|
53111
|
+
const superclass = caught.size === 0 ? undefined : this.findCaughtSuperclass(className, caught, input);
|
|
52639
53112
|
if (superclass !== undefined) {
|
|
52640
53113
|
const message = `CATCH of ${className} after the CATCH of its superclass ${superclass}`;
|
|
52641
53114
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message));
|
|
52642
53115
|
return;
|
|
52643
53116
|
}
|
|
52644
|
-
|
|
52645
|
-
for (const name of names) {
|
|
52646
|
-
caught.add(name);
|
|
53117
|
+
caught.add(className);
|
|
52647
53118
|
}
|
|
52648
53119
|
}
|
|
52649
53120
|
}
|
|
@@ -76286,7 +76757,7 @@ class Registry {
|
|
|
76286
76757
|
}
|
|
76287
76758
|
static abaplintVersion() {
|
|
76288
76759
|
// magic, see build script "version.js"
|
|
76289
|
-
return "2.120.
|
|
76760
|
+
return "2.120.116";
|
|
76290
76761
|
}
|
|
76291
76762
|
getDDICReferences() {
|
|
76292
76763
|
return this.ddicReferences;
|
|
@@ -89209,14 +89680,12 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
89209
89680
|
if (from === undefined) {
|
|
89210
89681
|
return undefined;
|
|
89211
89682
|
}
|
|
89212
|
-
// UP TO after INTO is
|
|
89683
|
+
// UP TO after INTO is not valid behind WHERE or ORDER BY, move it along in front of INTO
|
|
89213
89684
|
let move = into.concatTokens();
|
|
89214
89685
|
const fixes = [];
|
|
89215
89686
|
const upTo = high.findFirstExpression(Expressions.SQLUpTo);
|
|
89216
|
-
const orderBy = high.findFirstExpression(Expressions.SQLOrderBy);
|
|
89217
89687
|
if (upTo !== undefined
|
|
89218
|
-
&& into.getLastToken().getEnd().isBefore(upTo.getFirstToken().getStart())
|
|
89219
|
-
&& (orderBy === undefined || upTo.getFirstToken().getStart().isBefore(orderBy.getFirstToken().getStart()))) {
|
|
89688
|
+
&& into.getLastToken().getEnd().isBefore(upTo.getFirstToken().getStart())) {
|
|
89220
89689
|
move = upTo.concatTokens() + ` ` + move;
|
|
89221
89690
|
fixes.push(edit_helper_1.EditHelper.deleteRange(lowFile, upTo.getFirstToken().getStart(), upTo.getLastToken().getEnd()));
|
|
89222
89691
|
}
|
|
@@ -89980,7 +90449,7 @@ ${indentation}`);
|
|
|
89980
90449
|
|| !(targetType instanceof basic_1.TableType)
|
|
89981
90450
|
|| sourceType.isWithHeader() === true
|
|
89982
90451
|
|| targetType.isWithHeader() === true
|
|
89983
|
-
|| (
|
|
90452
|
+
|| (this.concreteAccessType(targetType) !== basic_1.TableAccessType.standard && this.concreteAccessType(targetType) !== undefined)) {
|
|
89984
90453
|
return undefined;
|
|
89985
90454
|
}
|
|
89986
90455
|
for (const t of [sourceType, targetType]) {
|
|
@@ -89992,7 +90461,7 @@ ${indentation}`);
|
|
|
89992
90461
|
const fsType = (name, type) => type.isGeneric() ? "TYPE any" : "LIKE LINE OF " + name;
|
|
89993
90462
|
const sourceFS = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax, true);
|
|
89994
90463
|
const targetFS = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax, true);
|
|
89995
|
-
const addRow =
|
|
90464
|
+
const addRow = this.concreteAccessType(targetType) === undefined
|
|
89996
90465
|
? `INSERT INITIAL LINE INTO TABLE ${targetName}`
|
|
89997
90466
|
: `APPEND INITIAL LINE TO ${targetName}`;
|
|
89998
90467
|
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
@@ -91926,6 +92395,10 @@ ${indentation} output = ${uniqueName}.\n`;
|
|
|
91926
92395
|
}
|
|
91927
92396
|
return undefined;
|
|
91928
92397
|
}
|
|
92398
|
+
/** the table kind of a table with a known line type, undefined for generic tables such as TYPE STANDARD TABLE */
|
|
92399
|
+
concreteAccessType(type) {
|
|
92400
|
+
return type.getRowType() instanceof basic_1.AnyType ? undefined : type.getAccessType();
|
|
92401
|
+
}
|
|
91929
92402
|
/** a FIELD-SYMBOLS declaration is known to the scope under its bracketed spelling, so
|
|
91930
92403
|
* the collision check has to use that spelling too - otherwise a second outline in the
|
|
91931
92404
|
* same method is handed a name that is already taken and the result does not compile */
|
|
@@ -106018,15 +106491,25 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
106018
106491
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
106019
106492
|
exports.ParserMissingSpace = exports.ParserMissingSpaceConf = void 0;
|
|
106020
106493
|
const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
|
|
106494
|
+
const Tokens = __importStar(__webpack_require__(/*! ../abap/1_lexer/tokens */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js"));
|
|
106021
106495
|
const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
|
|
106022
106496
|
const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
|
|
106023
106497
|
const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
106024
106498
|
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
|
|
106025
106499
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
|
|
106026
|
-
// todo: this rule needs refactoring
|
|
106027
106500
|
class ParserMissingSpaceConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
106028
106501
|
}
|
|
106029
106502
|
exports.ParserMissingSpaceConf = ParserMissingSpaceConf;
|
|
106503
|
+
/*
|
|
106504
|
+
* The lexer records whitespace around parentheses in the token type, eg. "WParenLeft" is a "(" with whitespace
|
|
106505
|
+
* before but not after. In the expressions below the grammar also accepts the variants without inner whitespace,
|
|
106506
|
+
* this rule reports them. Elsewhere the grammar is strict, and missing whitespace gives a parser error instead.
|
|
106507
|
+
* Matched on the constructor, none of these expressions is subclassed.
|
|
106508
|
+
*/
|
|
106509
|
+
const PAREN_EXPRESSIONS = new Set([
|
|
106510
|
+
Expressions.MethodCallParam, Expressions.CondSub, Expressions.ComponentCondSub, Expressions.SQLCond,
|
|
106511
|
+
Expressions.ValueBodyLine, Expressions.NewObject, Expressions.Source
|
|
106512
|
+
]);
|
|
106030
106513
|
class ParserMissingSpace extends _abap_rule_1.ABAPRule {
|
|
106031
106514
|
constructor() {
|
|
106032
106515
|
super(...arguments);
|
|
@@ -106051,272 +106534,104 @@ This rule makes sure the spaces are consistently required across the language.`,
|
|
|
106051
106534
|
}
|
|
106052
106535
|
runParsed(file) {
|
|
106053
106536
|
const issues = [];
|
|
106054
|
-
|
|
106537
|
+
const message = "Missing space between string or character literal and parentheses";
|
|
106055
106538
|
for (const statement of file.getStatements()) {
|
|
106056
106539
|
const missing = this.missingSpace(statement);
|
|
106057
106540
|
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);
|
|
106541
|
+
issues.push(issue_1.Issue.atPosition(file, missing, message, this.getMetadata().key, this.conf.severity));
|
|
106062
106542
|
}
|
|
106063
106543
|
}
|
|
106064
106544
|
return issues;
|
|
106065
106545
|
}
|
|
106546
|
+
/** returns the position of the first missing space in the statement, the rule reports one issue per statement */
|
|
106066
106547
|
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
|
-
}
|
|
106548
|
+
const state = { prev: undefined, prevCond: undefined, prevInDynamic: false, first: undefined };
|
|
106549
|
+
for (const child of statement.getChildren()) {
|
|
106550
|
+
this.walk(child, undefined, false, state);
|
|
106119
106551
|
}
|
|
106120
|
-
return
|
|
106552
|
+
return state.first;
|
|
106121
106553
|
}
|
|
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
|
-
}
|
|
106554
|
+
report(state, pos) {
|
|
106555
|
+
if (state.first === undefined || pos.isBefore(state.first)) {
|
|
106556
|
+
state.first = pos;
|
|
106140
106557
|
}
|
|
106141
|
-
return undefined;
|
|
106142
106558
|
}
|
|
106143
|
-
|
|
106144
|
-
|
|
106145
|
-
{
|
|
106146
|
-
|
|
106147
|
-
|
|
106148
|
-
if (first.getRow() === second.getRow()
|
|
106149
|
-
&& first.getEnd().getCol() === second.getStart().getCol()) {
|
|
106150
|
-
return second.getStart();
|
|
106151
|
-
}
|
|
106559
|
+
/** visits each node once in source order, checking the parentheses of expressions and each pair of tokens */
|
|
106560
|
+
walk(node, cond, inDynamic, state) {
|
|
106561
|
+
if (node instanceof nodes_1.TokenNode) {
|
|
106562
|
+
this.checkToken(node.get(), cond, inDynamic, state);
|
|
106563
|
+
return;
|
|
106152
106564
|
}
|
|
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
|
-
}
|
|
106565
|
+
const type = node.get();
|
|
106566
|
+
if (cond === undefined && (type instanceof Expressions.Cond || type instanceof Expressions.ComponentCond)) {
|
|
106567
|
+
cond = node;
|
|
106173
106568
|
}
|
|
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
|
-
}
|
|
106569
|
+
inDynamic = inDynamic || type instanceof Expressions.Dynamic;
|
|
106570
|
+
if (PAREN_EXPRESSIONS.has(type.constructor)) {
|
|
106571
|
+
this.checkParens(node, state);
|
|
106194
106572
|
}
|
|
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
|
-
}
|
|
106573
|
+
for (const child of node.getChildren()) {
|
|
106574
|
+
this.walk(child, cond, inDynamic, state);
|
|
106207
106575
|
}
|
|
106208
|
-
return undefined;
|
|
106209
106576
|
}
|
|
106210
|
-
|
|
106211
|
-
|
|
106212
|
-
|
|
106577
|
+
/** "foo( 'bar')" and "IF (foo = bar )", parentheses directly part of the expression need inner whitespace */
|
|
106578
|
+
checkParens(node, state) {
|
|
106579
|
+
var _a;
|
|
106580
|
+
const children = node.getChildren();
|
|
106581
|
+
let dynamicAccess = false;
|
|
106213
106582
|
for (let i = 0; i < children.length; i++) {
|
|
106214
|
-
const
|
|
106215
|
-
if (
|
|
106216
|
-
|
|
106217
|
-
|
|
106218
|
-
|
|
106219
|
-
|
|
106220
|
-
|
|
106221
|
-
|
|
106222
|
-
|
|
106583
|
+
const child = children[i];
|
|
106584
|
+
if (!(child instanceof nodes_1.TokenNode)) {
|
|
106585
|
+
continue;
|
|
106586
|
+
}
|
|
106587
|
+
const token = child.get();
|
|
106588
|
+
if (token instanceof Tokens.ParenLeft || token instanceof Tokens.WParenLeft) {
|
|
106589
|
+
// dynamic component and attribute access, "foo-(name)" and "foo->(name)"
|
|
106590
|
+
const prev = (_a = children[i - 1]) === null || _a === void 0 ? void 0 : _a.get();
|
|
106591
|
+
if (prev instanceof Tokens.Dash || prev instanceof Tokens.InstanceArrow) {
|
|
106592
|
+
dynamicAccess = true;
|
|
106223
106593
|
}
|
|
106224
|
-
|
|
106225
|
-
|
|
106226
|
-
&& prev.getRow() === current.getFirstToken().getRow()
|
|
106227
|
-
&& prev.getEnd().getCol() === current.getFirstToken().getStart().getCol()) {
|
|
106228
|
-
return current.getLastToken().getEnd();
|
|
106594
|
+
else {
|
|
106595
|
+
this.report(state, token.getEnd());
|
|
106229
106596
|
}
|
|
106230
106597
|
}
|
|
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
|
-
}
|
|
106598
|
+
else if (token instanceof Tokens.ParenRight || token instanceof Tokens.ParenRightW) {
|
|
106599
|
+
if (dynamicAccess) {
|
|
106600
|
+
dynamicAccess = false;
|
|
106252
106601
|
}
|
|
106253
|
-
|
|
106254
|
-
|
|
106602
|
+
else {
|
|
106603
|
+
this.report(state, token.getStart());
|
|
106255
106604
|
}
|
|
106256
106605
|
}
|
|
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();
|
|
106606
|
+
else if (token instanceof Tokens.WParenRight || token instanceof Tokens.WParenRightW) {
|
|
106607
|
+
dynamicAccess = false;
|
|
106285
106608
|
}
|
|
106286
106609
|
}
|
|
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
106610
|
}
|
|
106301
|
-
|
|
106302
|
-
const
|
|
106303
|
-
{
|
|
106304
|
-
|
|
106305
|
-
|
|
106306
|
-
|
|
106307
|
-
&& first.getCol() + 1 === second.getStart().getCol()) {
|
|
106308
|
-
return second.getStart();
|
|
106611
|
+
checkToken(current, cond, inDynamic, state) {
|
|
106612
|
+
const prev = state.prev;
|
|
106613
|
+
if (prev !== undefined) {
|
|
106614
|
+
// "foo( )= bar"
|
|
106615
|
+
if ((prev instanceof Tokens.ParenRight || prev instanceof Tokens.WParenRight) && current.getStr() === "=") {
|
|
106616
|
+
this.report(state, current.getStart());
|
|
106309
106617
|
}
|
|
106310
|
-
|
|
106311
|
-
|
|
106312
|
-
|
|
106313
|
-
|
|
106314
|
-
|
|
106315
|
-
&&
|
|
106316
|
-
|
|
106618
|
+
// "IF foo ='bar'", dynamic parts like "('NAME')" are allowed without spaces
|
|
106619
|
+
if (current.getStr().startsWith("'")
|
|
106620
|
+
&& cond !== undefined
|
|
106621
|
+
&& cond === state.prevCond
|
|
106622
|
+
&& state.prevInDynamic === false
|
|
106623
|
+
&& inDynamic === false
|
|
106624
|
+
&& this.isAdjacent(prev, current)) {
|
|
106625
|
+
this.report(state, prev.getEnd());
|
|
106317
106626
|
}
|
|
106318
106627
|
}
|
|
106319
|
-
|
|
106628
|
+
state.prev = current;
|
|
106629
|
+
state.prevCond = cond;
|
|
106630
|
+
state.prevInDynamic = inDynamic;
|
|
106631
|
+
}
|
|
106632
|
+
isAdjacent(first, second) {
|
|
106633
|
+
return first.getRow() === second.getRow()
|
|
106634
|
+
&& first.getEnd().getCol() === second.getStart().getCol();
|
|
106320
106635
|
}
|
|
106321
106636
|
}
|
|
106322
106637
|
exports.ParserMissingSpace = ParserMissingSpace;
|
|
@@ -136050,8 +136365,15 @@ const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_
|
|
|
136050
136365
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
136051
136366
|
class DeleteInternalTranspiler {
|
|
136052
136367
|
transpile(node, traversal) {
|
|
136053
|
-
const
|
|
136368
|
+
const targetNode = node.findDirectExpression(abaplint.Expressions.Target);
|
|
136369
|
+
const target = traversal.traverse(targetNode).getCode();
|
|
136054
136370
|
const concat = node.concatTokens().toUpperCase();
|
|
136371
|
+
if (node.getChildren().length <= 5 && (node.getChildren().length === 3 || node.findDirectTokenByText("FROM"))
|
|
136372
|
+
&& concat.startsWith("DELETE TABLE ") === false && traversal.isDatabaseShortForm(targetNode)) {
|
|
136373
|
+
const row = node.findExpressionAfterToken("FROM");
|
|
136374
|
+
const source = row ? traversal.traverse(row).getCode() : target;
|
|
136375
|
+
return new chunk_1.Chunk(`await abap.statements.deleteDatabase("${targetNode.concatTokens().toLowerCase()}", {from: ${source}});`);
|
|
136376
|
+
}
|
|
136055
136377
|
const extra = [];
|
|
136056
136378
|
const componentCond = node.findDirectExpression(abaplint.Expressions.ComponentCond);
|
|
136057
136379
|
if (componentCond) {
|
|
@@ -140022,10 +140344,11 @@ class MethodImplementationTranspiler {
|
|
|
140022
140344
|
}
|
|
140023
140345
|
else if (type instanceof abaplint.BasicTypes.XSequenceType) {
|
|
140024
140346
|
// 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
|
|
140347
|
+
// x LENGTH 3, and an odd number of digits is filled with 0 on the right, '012' is 0120.
|
|
140348
|
+
// The empty string literal `` has no bytes; a Hex cannot have length 0
|
|
140026
140349
|
after += `if (${varPrefixed}?.constructor.name === "Character" || ${varPrefixed}?.constructor.name === "String") {
|
|
140027
140350
|
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"));
|
|
140351
|
+
${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
140352
|
}\n`;
|
|
140030
140353
|
}
|
|
140031
140354
|
}
|
|
@@ -140472,7 +140795,11 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
|
|
|
140472
140795
|
const modify_database_1 = __webpack_require__(/*! ./modify_database */ "./node_modules/@abaplint/transpiler/build/src/statements/modify_database.js");
|
|
140473
140796
|
class ModifyInternalTranspiler {
|
|
140474
140797
|
transpile(node, traversal) {
|
|
140475
|
-
const
|
|
140798
|
+
const targetNode = node.findDirectExpression(abaplint.Expressions.Target);
|
|
140799
|
+
const target = traversal.traverse(targetNode).getCode();
|
|
140800
|
+
if (node.getChildren().length === 3 && traversal.isDatabaseShortForm(targetNode)) {
|
|
140801
|
+
return new chunk_1.Chunk(`await abap.statements.modifyDatabase("${targetNode.concatTokens().toLowerCase()}", {values: ${target}});`);
|
|
140802
|
+
}
|
|
140476
140803
|
const extra = [];
|
|
140477
140804
|
const index = node.findExpressionAfterToken("INDEX");
|
|
140478
140805
|
if (index) {
|
|
@@ -140834,9 +141161,18 @@ class MoveCorrespondingTranspiler {
|
|
|
140834
141161
|
transpile(node, traversal) {
|
|
140835
141162
|
const target = new expressions_1.TargetTranspiler().transpile(node.findDirectExpression(abaplint.Expressions.SimpleTarget), traversal);
|
|
140836
141163
|
const source = traversal.traverse(node.findDirectExpression(abaplint.Expressions.Source));
|
|
141164
|
+
const concat = node.concatTokens().toUpperCase();
|
|
141165
|
+
const options = [];
|
|
141166
|
+
if (concat.includes(" KEEPING TARGET LINES")) {
|
|
141167
|
+
options.push("keepingTargetLines: true");
|
|
141168
|
+
}
|
|
141169
|
+
if (concat.includes(" EXPANDING NESTED TABLES")) {
|
|
141170
|
+
options.push("expandingNestedTables: true");
|
|
141171
|
+
}
|
|
141172
|
+
const extra = options.length > 0 ? ", {" + options.join(", ") + "}" : "";
|
|
140837
141173
|
return new chunk_1.Chunk().append("abap.statements.moveCorresponding(", node, traversal)
|
|
140838
141174
|
.join([source, target])
|
|
140839
|
-
.append(");", node.getLastToken(), traversal);
|
|
141175
|
+
.append(extra + ");", node.getLastToken(), traversal);
|
|
140840
141176
|
}
|
|
140841
141177
|
}
|
|
140842
141178
|
exports.MoveCorrespondingTranspiler = MoveCorrespondingTranspiler;
|
|
@@ -148659,6 +148995,15 @@ class Traversal {
|
|
|
148659
148995
|
return undefined;
|
|
148660
148996
|
}
|
|
148661
148997
|
scopeCache = undefined;
|
|
148998
|
+
/** MODIFY name. and DELETE name [FROM wa].: the name is a database table unless it is a variable of table type */
|
|
148999
|
+
isDatabaseShortForm(target) {
|
|
149000
|
+
if (target === undefined || target.getChildren().length !== 1) {
|
|
149001
|
+
return false;
|
|
149002
|
+
}
|
|
149003
|
+
const token = target.getFirstToken();
|
|
149004
|
+
const type = this.findCurrentScopeByToken(token)?.findVariable(token.getStr())?.getType();
|
|
149005
|
+
return !(type instanceof abaplint.BasicTypes.TableType);
|
|
149006
|
+
}
|
|
148662
149007
|
findCurrentScopeByToken(token) {
|
|
148663
149008
|
const filename = this.file.getFilename();
|
|
148664
149009
|
if (this.scopeCache
|
|
@@ -150611,11 +150956,11 @@ class Validation {
|
|
|
150611
150956
|
const conf = new core_1.Config(JSON.stringify(exports.config));
|
|
150612
150957
|
reg.setConfig(conf);
|
|
150613
150958
|
const issues = reg.findIssues();
|
|
150614
|
-
return issues.filter(i => i.getKey() !== "ambiguous_statement" || this.
|
|
150959
|
+
return issues.filter(i => i.getKey() !== "ambiguous_statement" || this.isUnambiguous(reg, i) === false);
|
|
150615
150960
|
}
|
|
150616
|
-
/**
|
|
150617
|
-
*
|
|
150618
|
-
|
|
150961
|
+
/** DELETE name., DELETE name FROM x., MODIFY name. and MODIFY name FROM x. read two ways, so abaplint calls them
|
|
150962
|
+
* ambiguous. ABAP decides by the name: a variable of table type is the internal table, anything else the database table */
|
|
150963
|
+
isUnambiguous(reg, issue) {
|
|
150619
150964
|
const file = reg.getFileByName(issue.getFilename());
|
|
150620
150965
|
const obj = file ? reg.findObjectForFile(file) : undefined;
|
|
150621
150966
|
if (!(obj instanceof core_1.ABAPObject)) {
|
|
@@ -150637,7 +150982,10 @@ class Validation {
|
|
|
150637
150982
|
this.scopes.set(obj, spaghetti);
|
|
150638
150983
|
}
|
|
150639
150984
|
const variable = spaghetti.lookupPosition(token.getStart(), issue.getFilename())?.findVariable(token.getStr());
|
|
150640
|
-
|
|
150985
|
+
if (variable?.getType() instanceof core_1.BasicTypes.TableType) {
|
|
150986
|
+
return true;
|
|
150987
|
+
}
|
|
150988
|
+
return variable !== undefined || statement.findExpressionAfterToken("FROM") !== undefined;
|
|
150641
150989
|
}
|
|
150642
150990
|
}
|
|
150643
150991
|
exports.Validation = Validation;
|