@abaplint/transpiler-cli 2.14.27 → 2.14.28
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 +175 -62
- package/package.json +3 -3
- package/schema.json +104 -97
package/build/bundle.js
CHANGED
|
@@ -36603,6 +36603,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36603
36603
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
36604
36604
|
exports.Select = void 0;
|
|
36605
36605
|
const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
|
|
36606
|
+
const nodes_1 = __webpack_require__(/*! ../../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
|
|
36606
36607
|
const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
|
|
36607
36608
|
const inline_data_1 = __webpack_require__(/*! ./inline_data */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/inline_data.js");
|
|
36608
36609
|
const target_1 = __webpack_require__(/*! ./target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
@@ -36618,6 +36619,8 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modu
|
|
|
36618
36619
|
const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
|
|
36619
36620
|
const _check_database_fields_1 = __webpack_require__(/*! ./_check_database_fields */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/_check_database_fields.js");
|
|
36620
36621
|
const isSimple = /^\w+$/;
|
|
36622
|
+
// SQL functions where the result has the same type as the first argument
|
|
36623
|
+
const sameTypeAsFirstArgument = new Set(["UPPER", "LOWER", "LTRIM", "RTRIM"]);
|
|
36621
36624
|
class Select {
|
|
36622
36625
|
static runSyntax(node, input, skipImplicitInto = false, selectLoop = false) {
|
|
36623
36626
|
var _a;
|
|
@@ -36823,7 +36826,7 @@ class Select {
|
|
|
36823
36826
|
if (intoStructure) {
|
|
36824
36827
|
const inlineList = intoStructure.findAllExpressions(Expressions.InlineData);
|
|
36825
36828
|
if (inlineList.length === 1) {
|
|
36826
|
-
inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input.scope));
|
|
36829
|
+
inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input.scope, from));
|
|
36827
36830
|
}
|
|
36828
36831
|
else {
|
|
36829
36832
|
for (const inline of inlineList) {
|
|
@@ -36853,7 +36856,12 @@ class Select {
|
|
|
36853
36856
|
return;
|
|
36854
36857
|
}
|
|
36855
36858
|
let type = basic_1.VoidType.get("SELECT_todo2");
|
|
36856
|
-
|
|
36859
|
+
const fn = this.findFunctionColumn(field, false);
|
|
36860
|
+
if (fn) {
|
|
36861
|
+
const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
|
|
36862
|
+
type = this.inferFunctionType(fn, code => this.findFieldType(code, sourceInfos, input.scope)) || type;
|
|
36863
|
+
}
|
|
36864
|
+
else if (isSimple.test(field.code)) {
|
|
36857
36865
|
for (const dbSource of dbSources) {
|
|
36858
36866
|
if (dbSource === undefined) {
|
|
36859
36867
|
continue;
|
|
@@ -36885,7 +36893,7 @@ class Select {
|
|
|
36885
36893
|
return basic_1.IntegerType.get();
|
|
36886
36894
|
}
|
|
36887
36895
|
}
|
|
36888
|
-
static buildStructureType(fields, dbSources, scope) {
|
|
36896
|
+
static buildStructureType(fields, dbSources, scope, from) {
|
|
36889
36897
|
var _a, _b, _c, _d, _e, _f;
|
|
36890
36898
|
if (fields.length === 1 && dbSources.length === 1) {
|
|
36891
36899
|
// COUNT( * ) yields an integer regardless of the (possibly dynamic) table
|
|
@@ -36921,10 +36929,16 @@ class Select {
|
|
|
36921
36929
|
return basic_1.IntegerType.get();
|
|
36922
36930
|
}
|
|
36923
36931
|
}
|
|
36924
|
-
|
|
36925
|
-
|
|
36926
|
-
|
|
36932
|
+
const fn = this.findFunctionColumn(fields[0], false);
|
|
36933
|
+
if (fn) {
|
|
36934
|
+
const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
|
|
36935
|
+
const type = this.inferFunctionType(fn, code => this.findFieldType(code, sourceInfos, scope));
|
|
36936
|
+
if (type) {
|
|
36937
|
+
return type;
|
|
36938
|
+
}
|
|
36927
36939
|
}
|
|
36940
|
+
// todo: aggregated/calculated values
|
|
36941
|
+
return basic_1.VoidType.get("SELECT_todo11");
|
|
36928
36942
|
}
|
|
36929
36943
|
else {
|
|
36930
36944
|
return basic_1.VoidType.get("SELECT_todo10");
|
|
@@ -36945,15 +36959,10 @@ class Select {
|
|
|
36945
36959
|
if (!(dbType instanceof basic_1.StructureType)) {
|
|
36946
36960
|
return basic_1.VoidType.get("SELECT_todo14");
|
|
36947
36961
|
}
|
|
36948
|
-
|
|
36949
|
-
|
|
36950
|
-
|
|
36951
|
-
|
|
36952
|
-
const type = dbType.getComponentByName(field.code);
|
|
36953
|
-
if (type === undefined) {
|
|
36954
|
-
return basic_1.VoidType.get("SELECT_todo9");
|
|
36955
|
-
}
|
|
36956
|
-
components.push({ name: field.as || field.code, type });
|
|
36962
|
+
if (this.allFieldsSupported(fields) === true) {
|
|
36963
|
+
const components = this.buildSingleSourceComponents(fields, dbType, from, dbSources, scope);
|
|
36964
|
+
if (components === undefined) {
|
|
36965
|
+
return basic_1.VoidType.get("SELECT_todo9");
|
|
36957
36966
|
}
|
|
36958
36967
|
return new basic_1.StructureType(components);
|
|
36959
36968
|
}
|
|
@@ -36979,9 +36988,15 @@ class Select {
|
|
|
36979
36988
|
}
|
|
36980
36989
|
return new basic_1.TableType(new basic_1.StructureType(components), tableOptions, undefined);
|
|
36981
36990
|
}
|
|
36991
|
+
const lookup = code => this.findFieldType(code, sourceInfos, scope);
|
|
36982
36992
|
const components = [];
|
|
36983
36993
|
for (const field of fields) {
|
|
36984
|
-
const
|
|
36994
|
+
const fn = this.findFunctionColumn(field);
|
|
36995
|
+
if (fn) {
|
|
36996
|
+
components.push({ name: field.as, type: this.inferFunctionType(fn, lookup) || basic_1.VoidType.get("SELECT_function") });
|
|
36997
|
+
continue;
|
|
36998
|
+
}
|
|
36999
|
+
const type = lookup(field.code);
|
|
36985
37000
|
if (type === undefined) {
|
|
36986
37001
|
return basic_1.VoidType.get("SELECT_todo3");
|
|
36987
37002
|
}
|
|
@@ -37004,20 +37019,101 @@ class Select {
|
|
|
37004
37019
|
if (fields.length === 1 && fields[0].code === "*") {
|
|
37005
37020
|
return new basic_1.TableType(dbType, tableOptions, undefined);
|
|
37006
37021
|
}
|
|
37007
|
-
|
|
37008
|
-
|
|
37009
|
-
|
|
37010
|
-
|
|
37011
|
-
const type = dbType.getComponentByName(field.code);
|
|
37012
|
-
if (type === undefined) {
|
|
37013
|
-
return basic_1.VoidType.get("SELECT_todo6");
|
|
37014
|
-
}
|
|
37015
|
-
components.push({ name: field.as || field.code, type });
|
|
37022
|
+
if (this.allFieldsSupported(fields) === true) {
|
|
37023
|
+
const components = this.buildSingleSourceComponents(fields, dbType, from, dbSources, scope);
|
|
37024
|
+
if (components === undefined) {
|
|
37025
|
+
return basic_1.VoidType.get("SELECT_todo6");
|
|
37016
37026
|
}
|
|
37017
37027
|
return new basic_1.TableType(new basic_1.StructureType(components), tableOptions, undefined);
|
|
37018
37028
|
}
|
|
37019
37029
|
return basic_1.VoidType.get("SELECT_todo7");
|
|
37020
37030
|
}
|
|
37031
|
+
/** plain field names, or SQL function columns with an alias */
|
|
37032
|
+
static allFieldsSupported(fields) {
|
|
37033
|
+
return fields.every(f => isSimple.test(f.code) || this.findFunctionColumn(f) !== undefined);
|
|
37034
|
+
}
|
|
37035
|
+
/** returns undefined if a plain field is not found in the database table */
|
|
37036
|
+
static buildSingleSourceComponents(fields, dbType, from, dbSources, scope) {
|
|
37037
|
+
const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
|
|
37038
|
+
const lookup = code => this.findFieldType(code, sourceInfos, scope);
|
|
37039
|
+
const components = [];
|
|
37040
|
+
for (const field of fields) {
|
|
37041
|
+
const fn = this.findFunctionColumn(field);
|
|
37042
|
+
if (fn) {
|
|
37043
|
+
components.push({ name: field.as, type: this.inferFunctionType(fn, lookup) || basic_1.VoidType.get("SELECT_function") });
|
|
37044
|
+
continue;
|
|
37045
|
+
}
|
|
37046
|
+
const type = dbType.getComponentByName(field.code);
|
|
37047
|
+
if (type === undefined) {
|
|
37048
|
+
return undefined;
|
|
37049
|
+
}
|
|
37050
|
+
components.push({ name: field.as || field.code, type });
|
|
37051
|
+
}
|
|
37052
|
+
return components;
|
|
37053
|
+
}
|
|
37054
|
+
/** returns the SQLFunction node if the field list entry is a single SQL function call */
|
|
37055
|
+
static findFunctionColumn(field, requireAlias = true) {
|
|
37056
|
+
if (requireAlias === true && field.as === "") {
|
|
37057
|
+
return undefined;
|
|
37058
|
+
}
|
|
37059
|
+
else if (!(field.expression.get() instanceof Expressions.SQLField)) {
|
|
37060
|
+
return undefined;
|
|
37061
|
+
}
|
|
37062
|
+
const children = field.expression.getChildren().filter(c => !(c.get() instanceof Expressions.SQLAsName) && c.concatTokens().toUpperCase() !== "AS");
|
|
37063
|
+
if (children.length === 1
|
|
37064
|
+
&& children[0] instanceof nodes_1.ExpressionNode
|
|
37065
|
+
&& children[0].get() instanceof Expressions.SQLFunction) {
|
|
37066
|
+
return children[0];
|
|
37067
|
+
}
|
|
37068
|
+
return undefined;
|
|
37069
|
+
}
|
|
37070
|
+
/** infers the result type of a SQL function, returns undefined if not possible */
|
|
37071
|
+
static inferFunctionType(fn, lookup) {
|
|
37072
|
+
const name = fn.getFirstToken().getStr().toUpperCase();
|
|
37073
|
+
const inputs = fn.findDirectExpressions(Expressions.SQLFunctionInput);
|
|
37074
|
+
if (inputs.length === 0) {
|
|
37075
|
+
return undefined;
|
|
37076
|
+
}
|
|
37077
|
+
if (name === "SUBSTRING" && inputs.length === 3) {
|
|
37078
|
+
const len = inputs[2].concatTokens();
|
|
37079
|
+
if (/^\d+$/.test(len) === false || parseInt(len, 10) <= 0) {
|
|
37080
|
+
return undefined;
|
|
37081
|
+
}
|
|
37082
|
+
const argType = this.inferFunctionInputType(inputs[0], lookup);
|
|
37083
|
+
if (argType instanceof basic_1.StringType) {
|
|
37084
|
+
return argType;
|
|
37085
|
+
}
|
|
37086
|
+
else if (argType instanceof basic_1.CharacterType
|
|
37087
|
+
|| argType instanceof basic_1.NumericType
|
|
37088
|
+
|| argType instanceof basic_1.DateType
|
|
37089
|
+
|| argType instanceof basic_1.TimeType) {
|
|
37090
|
+
return new basic_1.CharacterType(parseInt(len, 10));
|
|
37091
|
+
}
|
|
37092
|
+
return undefined;
|
|
37093
|
+
}
|
|
37094
|
+
else if (sameTypeAsFirstArgument.has(name)) {
|
|
37095
|
+
const argType = this.inferFunctionInputType(inputs[0], lookup);
|
|
37096
|
+
if (argType instanceof basic_1.CharacterType || argType instanceof basic_1.StringType) {
|
|
37097
|
+
return argType;
|
|
37098
|
+
}
|
|
37099
|
+
return undefined;
|
|
37100
|
+
}
|
|
37101
|
+
return undefined;
|
|
37102
|
+
}
|
|
37103
|
+
static inferFunctionInputType(input, lookup) {
|
|
37104
|
+
const children = input.getChildren();
|
|
37105
|
+
if (children.length !== 1 || !(children[0] instanceof nodes_1.ExpressionNode)) {
|
|
37106
|
+
return undefined;
|
|
37107
|
+
}
|
|
37108
|
+
const child = children[0];
|
|
37109
|
+
if (child.get() instanceof Expressions.SQLFieldName || child.get() instanceof Expressions.SQLAliasField) {
|
|
37110
|
+
return lookup(child.concatTokens().toUpperCase());
|
|
37111
|
+
}
|
|
37112
|
+
else if (child.get() instanceof Expressions.SQLFunction) {
|
|
37113
|
+
return this.inferFunctionType(child, lookup);
|
|
37114
|
+
}
|
|
37115
|
+
return undefined;
|
|
37116
|
+
}
|
|
37021
37117
|
static buildDatabaseSourceInfos(from, dbSources) {
|
|
37022
37118
|
const fromSources = from.findAllExpressions(Expressions.SQLFromSource);
|
|
37023
37119
|
return dbSources.map((source, index) => {
|
|
@@ -37052,16 +37148,20 @@ class Select {
|
|
|
37052
37148
|
return undefined;
|
|
37053
37149
|
}
|
|
37054
37150
|
static findFields(node, input) {
|
|
37055
|
-
var _a, _b;
|
|
37056
|
-
|
|
37151
|
+
var _a, _b, _c;
|
|
37152
|
+
let expr = node.findFirstExpression(Expressions.SQLFieldList);
|
|
37153
|
+
// a single field can be wrapped in a nested SQLFieldList
|
|
37154
|
+
while (expr && expr.getChildren().length === 1 && ((_a = expr.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.SQLFieldList) {
|
|
37155
|
+
expr = expr.getFirstChild();
|
|
37156
|
+
}
|
|
37057
37157
|
const ret = [];
|
|
37058
|
-
if (((
|
|
37158
|
+
if (((_b = expr === null || expr === void 0 ? void 0 : expr.getFirstChild()) === null || _b === void 0 ? void 0 : _b.get()) instanceof Expressions.Dynamic) {
|
|
37059
37159
|
dynamic_1.Dynamic.runSyntax(expr.getFirstChild(), input);
|
|
37060
37160
|
}
|
|
37061
37161
|
// eslint-disable-next-line max-len
|
|
37062
37162
|
for (const field of (expr === null || expr === void 0 ? void 0 : expr.findDirectExpressionsMulti([Expressions.SQLField, Expressions.SQLFieldName, Expressions.SQLAggregation])) || []) {
|
|
37063
37163
|
let code = field.concatTokens().toUpperCase();
|
|
37064
|
-
const as = ((
|
|
37164
|
+
const as = ((_c = field.findDirectExpression(Expressions.SQLAsName)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "";
|
|
37065
37165
|
if (as !== "") {
|
|
37066
37166
|
code = code.replace(" AS " + as.toUpperCase(), "");
|
|
37067
37167
|
}
|
|
@@ -74276,7 +74376,7 @@ class Registry {
|
|
|
74276
74376
|
}
|
|
74277
74377
|
static abaplintVersion() {
|
|
74278
74378
|
// magic, see build script "version.js"
|
|
74279
|
-
return "2.120.
|
|
74379
|
+
return "2.120.100";
|
|
74280
74380
|
}
|
|
74281
74381
|
getDDICReferences() {
|
|
74282
74382
|
return this.ddicReferences;
|
|
@@ -117936,6 +118036,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
117936
118036
|
exports.CallTransformationOptionsTranspiler = void 0;
|
|
117937
118037
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
117938
118038
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
118039
|
+
const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/expressions/constant.js");
|
|
117939
118040
|
class CallTransformationOptionsTranspiler {
|
|
117940
118041
|
transpile(node, traversal) {
|
|
117941
118042
|
const res = new chunk_1.Chunk().appendString("{");
|
|
@@ -117944,7 +118045,7 @@ class CallTransformationOptionsTranspiler {
|
|
|
117944
118045
|
if (res.getCode() !== "{") {
|
|
117945
118046
|
res.appendString(",");
|
|
117946
118047
|
}
|
|
117947
|
-
res.appendString(c.concatTokens());
|
|
118048
|
+
res.appendString(constant_1.ConstantTranspiler.normalizeInteger(c.concatTokens()));
|
|
117948
118049
|
}
|
|
117949
118050
|
else if (c.get() instanceof abaplint.Expressions.Source) {
|
|
117950
118051
|
res.appendChunk(traversal.traverse(c));
|
|
@@ -118010,6 +118111,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
118010
118111
|
exports.CallTransformationParametersTranspiler = void 0;
|
|
118011
118112
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
118012
118113
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
118114
|
+
const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/expressions/constant.js");
|
|
118013
118115
|
class CallTransformationParametersTranspiler {
|
|
118014
118116
|
transpile(node, traversal) {
|
|
118015
118117
|
if (node.getFirstChild()?.get() instanceof abaplint.Expressions.Dynamic) {
|
|
@@ -118022,7 +118124,7 @@ class CallTransformationParametersTranspiler {
|
|
|
118022
118124
|
if (res.getCode() !== "{") {
|
|
118023
118125
|
res.appendString(",");
|
|
118024
118126
|
}
|
|
118025
|
-
res.appendString(c.concatTokens());
|
|
118127
|
+
res.appendString(constant_1.ConstantTranspiler.normalizeInteger(c.concatTokens()));
|
|
118026
118128
|
}
|
|
118027
118129
|
else if (c.get() instanceof abaplint.Expressions.SimpleSource3) {
|
|
118028
118130
|
res.appendChunk(traversal.traverse(c));
|
|
@@ -118784,11 +118886,20 @@ class ConstantTranspiler {
|
|
|
118784
118886
|
constructor(addGet = false) {
|
|
118785
118887
|
this.addGet = addGet;
|
|
118786
118888
|
}
|
|
118787
|
-
|
|
118788
|
-
|
|
118789
|
-
|
|
118790
|
-
|
|
118889
|
+
/** Normalizes an ABAP integer literal to a JavaScript decimal integer literal, which is also
|
|
118890
|
+
* valid in strict mode, where leading zeros give an octal literal and a SyntaxError.
|
|
118891
|
+
* "007" -> "7", "000" -> "0", "-007" -> "-7", "- 010" -> "-10", "+5" -> "5", "-000" -> "0".
|
|
118892
|
+
* Input that is not an integer literal is returned unchanged */
|
|
118893
|
+
static normalizeInteger(str) {
|
|
118894
|
+
const match = str.replace(/\s/g, "").match(/^([+-]?)(\d+)$/);
|
|
118895
|
+
if (match === null) {
|
|
118896
|
+
return str;
|
|
118791
118897
|
}
|
|
118898
|
+
const digits = match[2].replace(/^0+(?=\d)/, "");
|
|
118899
|
+
return match[1] === "-" && digits !== "0" ? "-" + digits : digits;
|
|
118900
|
+
}
|
|
118901
|
+
handleInteger(int, traversal) {
|
|
118902
|
+
const concat = ConstantTranspiler.normalizeInteger(int.concatTokens());
|
|
118792
118903
|
const parsed = Number.parseInt(concat, 10);
|
|
118793
118904
|
let code = "";
|
|
118794
118905
|
if (concat.length > 18) {
|
|
@@ -119338,6 +119449,7 @@ exports.FieldLengthTranspiler = void 0;
|
|
|
119338
119449
|
const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
|
|
119339
119450
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
119340
119451
|
const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_chain.js");
|
|
119452
|
+
const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/expressions/constant.js");
|
|
119341
119453
|
class FieldLengthTranspiler {
|
|
119342
119454
|
transpile(node, traversal) {
|
|
119343
119455
|
let ret = "";
|
|
@@ -119349,11 +119461,7 @@ class FieldLengthTranspiler {
|
|
|
119349
119461
|
}
|
|
119350
119462
|
else if (c instanceof core_1.Nodes.TokenNode) {
|
|
119351
119463
|
if (c.get() instanceof core_1.Tokens.Identifier) {
|
|
119352
|
-
|
|
119353
|
-
if (/^0+\d+$/.test(value)) {
|
|
119354
|
-
value = value.replace(/^0+/, "") || "0";
|
|
119355
|
-
}
|
|
119356
|
-
ret += value;
|
|
119464
|
+
ret += constant_1.ConstantTranspiler.normalizeInteger(c.getFirstToken().getStr());
|
|
119357
119465
|
}
|
|
119358
119466
|
}
|
|
119359
119467
|
}
|
|
@@ -119378,6 +119486,7 @@ exports.FieldOffsetTranspiler = void 0;
|
|
|
119378
119486
|
const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
|
|
119379
119487
|
const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
|
|
119380
119488
|
const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_chain.js");
|
|
119489
|
+
const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/expressions/constant.js");
|
|
119381
119490
|
class FieldOffsetTranspiler {
|
|
119382
119491
|
transpile(node, traversal) {
|
|
119383
119492
|
let ret = "";
|
|
@@ -119389,11 +119498,7 @@ class FieldOffsetTranspiler {
|
|
|
119389
119498
|
}
|
|
119390
119499
|
else if (c instanceof core_1.Nodes.TokenNode) {
|
|
119391
119500
|
if (c.get() instanceof core_1.Tokens.Identifier) {
|
|
119392
|
-
|
|
119393
|
-
if (/^0+\d+$/.test(value)) {
|
|
119394
|
-
value = value.replace(/^0+/, "") || "0";
|
|
119395
|
-
}
|
|
119396
|
-
ret += value;
|
|
119501
|
+
ret += constant_1.ConstantTranspiler.normalizeInteger(c.getFirstToken().getStr().toLowerCase());
|
|
119397
119502
|
}
|
|
119398
119503
|
}
|
|
119399
119504
|
}
|
|
@@ -121715,6 +121820,7 @@ const simple_source3_1 = __webpack_require__(/*! ./simple_source3 */ "./node_mod
|
|
|
121715
121820
|
const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_chain.js");
|
|
121716
121821
|
const sql_field_name_1 = __webpack_require__(/*! ./sql_field_name */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field_name.js");
|
|
121717
121822
|
const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/transpiler/build/src/expressions/source.js");
|
|
121823
|
+
const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/expressions/constant.js");
|
|
121718
121824
|
const sql_field_list_1 = __webpack_require__(/*! ./sql_field_list */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field_list.js");
|
|
121719
121825
|
const sql_from_1 = __webpack_require__(/*! ./sql_from */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_from.js");
|
|
121720
121826
|
const sql_function_1 = __webpack_require__(/*! ./sql_function */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_function.js");
|
|
@@ -121767,18 +121873,22 @@ class SQLCondTranspiler {
|
|
|
121767
121873
|
sqlIn(c, traversal, filename, table) {
|
|
121768
121874
|
const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName)
|
|
121769
121875
|
|| c.findDirectExpression(abaplint.Expressions.SQLAliasField);
|
|
121876
|
+
const sqlFunction = c.getFirstChild()?.get() instanceof abaplint.Expressions.SQLFunction
|
|
121877
|
+
? c.getFirstChild() : undefined;
|
|
121770
121878
|
const sqlin = c.findDirectExpression(abaplint.Expressions.SQLIn);
|
|
121771
121879
|
const subselect = sqlin === undefined ? undefined : this.findSubselect(sqlin);
|
|
121772
|
-
if (fieldName === undefined || sqlin === undefined) {
|
|
121880
|
+
if ((fieldName === undefined && sqlFunction === undefined) || sqlin === undefined) {
|
|
121773
121881
|
throw new Error("SQL Condition, transpiler todo, " + c.concatTokens());
|
|
121774
121882
|
}
|
|
121883
|
+
const fieldCode = () => sqlFunction
|
|
121884
|
+
? new sql_function_1.SQLFunctionTranspiler().transpile(sqlFunction, traversal).getCode()
|
|
121885
|
+
: new sql_field_name_1.SQLFieldNameTranspiler().transpile(fieldName, traversal).getCode();
|
|
121775
121886
|
let pre = "";
|
|
121776
121887
|
if (c.concatTokens().toUpperCase().includes(" NOT IN ")) {
|
|
121777
121888
|
pre = "NOT ";
|
|
121778
121889
|
}
|
|
121779
121890
|
if (subselect) {
|
|
121780
|
-
|
|
121781
|
-
return `${field} ${pre}IN ${this.sqlSubselect(subselect, traversal, table)}`;
|
|
121891
|
+
return `${fieldCode()} ${pre}IN ${this.sqlSubselect(subselect, traversal, table)}`;
|
|
121782
121892
|
}
|
|
121783
121893
|
const source = c.findFirstExpression(abaplint.Expressions.SimpleSource3);
|
|
121784
121894
|
if (source === undefined) {
|
|
@@ -121786,12 +121896,15 @@ class SQLCondTranspiler {
|
|
|
121786
121896
|
}
|
|
121787
121897
|
if (sqlin.getChildren().length === 2) {
|
|
121788
121898
|
const s = new source_1.SourceTranspiler().transpile(source, traversal).getCode();
|
|
121899
|
+
if (sqlFunction) {
|
|
121900
|
+
return `${pre}" + abap.expandIN("${fieldCode()}", ${s}, true) + "`;
|
|
121901
|
+
}
|
|
121789
121902
|
return `${pre}" + abap.expandIN("${fieldName.concatTokens()}", ${s}) + "`;
|
|
121790
121903
|
}
|
|
121791
121904
|
else {
|
|
121792
121905
|
const cond = [];
|
|
121793
121906
|
for (const s of sqlin.findDirectExpressions(abaplint.Expressions.SQLSource).concat(sqlin.findDirectExpressions(abaplint.Expressions.SQLSourceNoSpace))) {
|
|
121794
|
-
const field =
|
|
121907
|
+
const field = fieldCode();
|
|
121795
121908
|
const sourc = this.sqlSource(s, traversal, filename, table);
|
|
121796
121909
|
cond.push(field + " = " + sourc);
|
|
121797
121910
|
}
|
|
@@ -121932,7 +122045,9 @@ class SQLCondTranspiler {
|
|
|
121932
122045
|
const conversionField = traversal.isSQLConversion(source.getFirstToken());
|
|
121933
122046
|
if (conversionField) {
|
|
121934
122047
|
const field = (table?.parseType(traversal.reg)).getComponentByName(conversionField);
|
|
121935
|
-
|
|
122048
|
+
// the literal is emitted as JavaScript, an integer like 007 must not become an octal literal
|
|
122049
|
+
const value = constant_1.ConstantTranspiler.normalizeInteger(concat);
|
|
122050
|
+
ret += "'\" + abap.sqlEscape(" + traversal.toType(field) + ".set(" + value + ").get()) + \"'";
|
|
121936
122051
|
}
|
|
121937
122052
|
else if (concat.startsWith("`")) {
|
|
121938
122053
|
ret += "'" + concat.substring(1, concat.length - 1).replace(/'/g, "''") + "'";
|
|
@@ -127134,14 +127249,11 @@ switch (e.classic.toUpperCase()) {\n`;
|
|
|
127134
127249
|
for (const e of node.findAllExpressions(abaplint.Expressions.ParameterException)) {
|
|
127135
127250
|
const name = e.getFirstToken().getStr().toUpperCase();
|
|
127136
127251
|
// todo, also handle SimpleChain,
|
|
127137
|
-
|
|
127138
|
-
if (
|
|
127252
|
+
const integer = e.findFirstExpression(abaplint.Expressions.Integer);
|
|
127253
|
+
if (integer === undefined) {
|
|
127139
127254
|
continue;
|
|
127140
127255
|
}
|
|
127141
|
-
|
|
127142
|
-
// remove leading zeros
|
|
127143
|
-
value = value.substring(1);
|
|
127144
|
-
}
|
|
127256
|
+
const value = expressions_1.ConstantTranspiler.normalizeInteger(integer.concatTokens());
|
|
127145
127257
|
if (name === "OTHERS") {
|
|
127146
127258
|
post += `default: abap.builtin.sy.get().subrc.set(${value}); break;\n`;
|
|
127147
127259
|
}
|
|
@@ -128916,12 +129028,13 @@ class DataTranspiler {
|
|
|
128916
129028
|
let value = "";
|
|
128917
129029
|
const val = node.findFirstExpression(abaplint.Expressions.Value);
|
|
128918
129030
|
if (val) {
|
|
128919
|
-
|
|
128920
|
-
|
|
128921
|
-
int = val.findFirstExpression(abaplint.Expressions.ConstantString);
|
|
128922
|
-
}
|
|
129031
|
+
const int = val.findFirstExpression(abaplint.Expressions.Integer);
|
|
129032
|
+
const str = val.findFirstExpression(abaplint.Expressions.ConstantString);
|
|
128923
129033
|
if (int) {
|
|
128924
|
-
|
|
129034
|
+
value = "\n" + name + ".set(" + constant_1.ConstantTranspiler.normalizeInteger(int.concatTokens()) + ");";
|
|
129035
|
+
}
|
|
129036
|
+
else if (str) {
|
|
129037
|
+
const escaped = constant_1.ConstantTranspiler.escape(constant_1.ConstantTranspiler.trimTextFieldLiteral(str.concatTokens()));
|
|
128925
129038
|
value = "\n" + name + ".set(" + escaped + ");";
|
|
128926
129039
|
}
|
|
128927
129040
|
else if (val.getChildren()[1].get() instanceof abaplint.Expressions.SimpleFieldChain) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.28",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"author": "abaplint",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@abaplint/core": "^2.120.
|
|
31
|
-
"@abaplint/transpiler": "^2.14.
|
|
30
|
+
"@abaplint/core": "^2.120.100",
|
|
31
|
+
"@abaplint/transpiler": "^2.14.28",
|
|
32
32
|
"@types/glob": "^9.0.0",
|
|
33
33
|
"@types/node": "^26.6.6",
|
|
34
34
|
"@types/progress": "^2.0.7",
|
package/schema.json
CHANGED
|
@@ -1,7 +1,105 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$ref": "#/definitions/ITranspilerConfig",
|
|
3
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
3
|
"definitions": {
|
|
4
|
+
"ICLITranspilerOptions": {
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"properties": {
|
|
7
|
+
"addCommonJS": {
|
|
8
|
+
"description": "adds common js modules",
|
|
9
|
+
"type": "boolean"
|
|
10
|
+
},
|
|
11
|
+
"addFilenames": {
|
|
12
|
+
"description": "adds filenames as comments in the output js",
|
|
13
|
+
"type": "boolean"
|
|
14
|
+
},
|
|
15
|
+
"ignoreSourceMap": {
|
|
16
|
+
"description": "ignore source map",
|
|
17
|
+
"type": "boolean"
|
|
18
|
+
},
|
|
19
|
+
"ignoreSyntaxCheck": {
|
|
20
|
+
"description": "ignore syntax check, used for internal testing",
|
|
21
|
+
"type": "boolean"
|
|
22
|
+
},
|
|
23
|
+
"importProg": {
|
|
24
|
+
"description": "import programs",
|
|
25
|
+
"type": "boolean"
|
|
26
|
+
},
|
|
27
|
+
"keywords": {
|
|
28
|
+
"description": "list of keywords to rename, if not supplied default will be used",
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
},
|
|
32
|
+
"type": "array"
|
|
33
|
+
},
|
|
34
|
+
"populateTables": {
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"description": "populate tables, all tables are populated if undefined and they exist",
|
|
37
|
+
"properties": {
|
|
38
|
+
"reposrc": {
|
|
39
|
+
"description": "insert into REPOSRC, skips if equals false",
|
|
40
|
+
"type": "boolean"
|
|
41
|
+
},
|
|
42
|
+
"seosubco": {
|
|
43
|
+
"description": "insert into SEOSUBCO, skips if equals false",
|
|
44
|
+
"type": "boolean"
|
|
45
|
+
},
|
|
46
|
+
"seosubcodf": {
|
|
47
|
+
"description": "insert into SEOSUBCODF, skips if equals false",
|
|
48
|
+
"type": "boolean"
|
|
49
|
+
},
|
|
50
|
+
"seosubcotx": {
|
|
51
|
+
"description": "insert into SEOSUBCOTX, skips if equals false",
|
|
52
|
+
"type": "boolean"
|
|
53
|
+
},
|
|
54
|
+
"tadir": {
|
|
55
|
+
"description": "insert into TADIR, skips if equals false",
|
|
56
|
+
"type": "boolean"
|
|
57
|
+
},
|
|
58
|
+
"wwwparams": {
|
|
59
|
+
"description": "insert into WWWPARAMS, skips if equals false",
|
|
60
|
+
"type": "boolean"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"type": "object"
|
|
64
|
+
},
|
|
65
|
+
"setup": {
|
|
66
|
+
"additionalProperties": false,
|
|
67
|
+
"description": "extra setup script to be executed during initialization",
|
|
68
|
+
"properties": {
|
|
69
|
+
"filename": {
|
|
70
|
+
"type": "string"
|
|
71
|
+
},
|
|
72
|
+
"postFunction": {
|
|
73
|
+
"type": "string"
|
|
74
|
+
},
|
|
75
|
+
"preFunction": {
|
|
76
|
+
"type": "string"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"required": [
|
|
80
|
+
"filename"
|
|
81
|
+
],
|
|
82
|
+
"type": "object"
|
|
83
|
+
},
|
|
84
|
+
"sharedTypeFactories": {
|
|
85
|
+
"description": "Deduplicate generated composite type constructors within each output module (default: true).",
|
|
86
|
+
"type": "boolean"
|
|
87
|
+
},
|
|
88
|
+
"skip": {
|
|
89
|
+
"$ref": "#/definitions/TestMethodList",
|
|
90
|
+
"description": "list of unit tests to skip"
|
|
91
|
+
},
|
|
92
|
+
"skipVersionCheck": {
|
|
93
|
+
"description": "skips version check, not recommended",
|
|
94
|
+
"type": "boolean"
|
|
95
|
+
},
|
|
96
|
+
"unknownTypes": {
|
|
97
|
+
"$ref": "#/definitions/UnknownTypesEnum",
|
|
98
|
+
"description": "sets behavior for unknown types, either fail at compile- or run-time"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"type": "object"
|
|
102
|
+
},
|
|
5
103
|
"ITranspilerConfig": {
|
|
6
104
|
"additionalProperties": false,
|
|
7
105
|
"properties": {
|
|
@@ -110,6 +208,10 @@
|
|
|
110
208
|
"minLength": 1,
|
|
111
209
|
"type": "string"
|
|
112
210
|
},
|
|
211
|
+
"ref": {
|
|
212
|
+
"description": "commit SHA, tag or branch to check out from url; defaults to the default branch",
|
|
213
|
+
"type": "string"
|
|
214
|
+
},
|
|
113
215
|
"url": {
|
|
114
216
|
"type": "string"
|
|
115
217
|
}
|
|
@@ -119,7 +221,7 @@
|
|
|
119
221
|
"type": "array"
|
|
120
222
|
},
|
|
121
223
|
"options": {
|
|
122
|
-
"$ref": "#/definitions/
|
|
224
|
+
"$ref": "#/definitions/ICLITranspilerOptions"
|
|
123
225
|
},
|
|
124
226
|
"output_folder": {
|
|
125
227
|
"minLength": 1,
|
|
@@ -143,101 +245,6 @@
|
|
|
143
245
|
],
|
|
144
246
|
"type": "object"
|
|
145
247
|
},
|
|
146
|
-
"ITranspilerOptions": {
|
|
147
|
-
"additionalProperties": false,
|
|
148
|
-
"properties": {
|
|
149
|
-
"addCommonJS": {
|
|
150
|
-
"description": "adds common js modules",
|
|
151
|
-
"type": "boolean"
|
|
152
|
-
},
|
|
153
|
-
"addFilenames": {
|
|
154
|
-
"description": "adds filenames as comments in the output js",
|
|
155
|
-
"type": "boolean"
|
|
156
|
-
},
|
|
157
|
-
"ignoreSourceMap": {
|
|
158
|
-
"description": "ignore source map",
|
|
159
|
-
"type": "boolean"
|
|
160
|
-
},
|
|
161
|
-
"ignoreSyntaxCheck": {
|
|
162
|
-
"description": "ignore syntax check, used for internal testing",
|
|
163
|
-
"type": "boolean"
|
|
164
|
-
},
|
|
165
|
-
"importProg": {
|
|
166
|
-
"description": "import programs",
|
|
167
|
-
"type": "boolean"
|
|
168
|
-
},
|
|
169
|
-
"keywords": {
|
|
170
|
-
"description": "list of keywords to rename, if not supplied default will be used",
|
|
171
|
-
"items": {
|
|
172
|
-
"type": "string"
|
|
173
|
-
},
|
|
174
|
-
"type": "array"
|
|
175
|
-
},
|
|
176
|
-
"populateTables": {
|
|
177
|
-
"additionalProperties": false,
|
|
178
|
-
"description": "populate tables, all tables are populated if undefined and they exist",
|
|
179
|
-
"properties": {
|
|
180
|
-
"reposrc": {
|
|
181
|
-
"description": "insert into REPOSRC, skips if equals false",
|
|
182
|
-
"type": "boolean"
|
|
183
|
-
},
|
|
184
|
-
"seosubco": {
|
|
185
|
-
"description": "insert into SEOSUBCO, skips if equals false",
|
|
186
|
-
"type": "boolean"
|
|
187
|
-
},
|
|
188
|
-
"seosubcodf": {
|
|
189
|
-
"description": "insert into SEOSUBCODF, skips if equals false",
|
|
190
|
-
"type": "boolean"
|
|
191
|
-
},
|
|
192
|
-
"seosubcotx": {
|
|
193
|
-
"description": "insert into SEOSUBCOTX, skips if equals false",
|
|
194
|
-
"type": "boolean"
|
|
195
|
-
},
|
|
196
|
-
"tadir": {
|
|
197
|
-
"description": "insert into TADIR, skips if equals false",
|
|
198
|
-
"type": "boolean"
|
|
199
|
-
},
|
|
200
|
-
"wwwparams": {
|
|
201
|
-
"description": "insert into WWWPARAMS, skips if equals false",
|
|
202
|
-
"type": "boolean"
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
"type": "object"
|
|
206
|
-
},
|
|
207
|
-
"setup": {
|
|
208
|
-
"additionalProperties": false,
|
|
209
|
-
"description": "extra setup script to be executed during initialization",
|
|
210
|
-
"properties": {
|
|
211
|
-
"filename": {
|
|
212
|
-
"type": "string"
|
|
213
|
-
},
|
|
214
|
-
"postFunction": {
|
|
215
|
-
"type": "string"
|
|
216
|
-
},
|
|
217
|
-
"preFunction": {
|
|
218
|
-
"type": "string"
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
"required": [
|
|
222
|
-
"filename"
|
|
223
|
-
],
|
|
224
|
-
"type": "object"
|
|
225
|
-
},
|
|
226
|
-
"skip": {
|
|
227
|
-
"$ref": "#/definitions/TestMethodList",
|
|
228
|
-
"description": "list of unit tests to skip"
|
|
229
|
-
},
|
|
230
|
-
"skipVersionCheck": {
|
|
231
|
-
"description": "skips version check, not recommended",
|
|
232
|
-
"type": "boolean"
|
|
233
|
-
},
|
|
234
|
-
"unknownTypes": {
|
|
235
|
-
"$ref": "#/definitions/UnknownTypesEnum",
|
|
236
|
-
"description": "sets behavior for unknown types, either fail at compile- or run-time"
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
"type": "object"
|
|
240
|
-
},
|
|
241
248
|
"TestMethodList": {
|
|
242
249
|
"items": {
|
|
243
250
|
"additionalProperties": false,
|