@abaplint/transpiler-cli 2.13.92 → 2.13.94

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.
Files changed (2) hide show
  1. package/build/bundle.js +154 -31
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -6907,7 +6907,9 @@ const combi_1 = __webpack_require__(/*! ../combi */ "./node_modules/@abaplint/co
6907
6907
  const _1 = __webpack_require__(/*! . */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
6908
6908
  class MethodDefExceptions extends combi_1.Expression {
6909
6909
  getRunnable() {
6910
- const exceptions = (0, combi_1.seq)("EXCEPTIONS", (0, combi_1.plusPrio)(_1.NamespaceSimpleName));
6910
+ // parameter section keywords cannot be exception names
6911
+ const name = (0, combi_1.seq)((0, combi_1.stopBefore1)("IMPORTING", "EXPORTING", "CHANGING", "RETURNING", "RAISING", "EXCEPTIONS"), _1.NamespaceSimpleName);
6912
+ const exceptions = (0, combi_1.seq)("EXCEPTIONS", (0, combi_1.plusPrio)(name));
6911
6913
  return exceptions;
6912
6914
  }
6913
6915
  }
@@ -6979,7 +6981,9 @@ const class_name_1 = __webpack_require__(/*! ./class_name */ "./node_modules/@ab
6979
6981
  class MethodDefRaising extends combi_1.Expression {
6980
6982
  getRunnable() {
6981
6983
  const resumable = (0, combi_1.seq)("RESUMABLE", (0, combi_1.tok)(tokens_1.ParenLeft), class_name_1.ClassName, (0, combi_1.tok)(tokens_1.ParenRightW));
6982
- const raising = (0, combi_1.seq)("RAISING", (0, combi_1.plus)((0, combi_1.altPrio)(resumable, class_name_1.ClassName)));
6984
+ // parameter section keywords cannot be exception names
6985
+ const name = (0, combi_1.seq)((0, combi_1.stopBefore1)("IMPORTING", "EXPORTING", "CHANGING", "RETURNING", "RAISING", "EXCEPTIONS"), class_name_1.ClassName);
6986
+ const raising = (0, combi_1.seq)("RAISING", (0, combi_1.plus)((0, combi_1.altPrio)(resumable, name)));
6983
6987
  return raising;
6984
6988
  }
6985
6989
  }
@@ -17283,7 +17287,7 @@ class MethodDef {
17283
17287
  (0, combi_1.seq)("VALIDATE ON SAVE IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("MODIFY", (0, combi_1.opt)("IMPORTING"), (0, combi_1.plus)((0, combi_1.seq)(expressions_1.MethodParamName, modify))), (0, combi_1.seq)("PRECHECK IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("DETERMINATION", expressions_1.TypeName, "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("VALIDATION", expressions_1.TypeName, "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("NUMBERING IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("READ IMPORTING", expressions_1.MethodParamName, (0, combi_1.altPrio)(forRead, forfunction)), (0, combi_1.seq)("FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.NamespaceSimpleName, "FOR", expressions_1.NamespaceSimpleName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR CREATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR DELETE", expressions_1.TypeName), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR READ", expressions_1.TypeName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName), (0, combi_1.seq)((0, combi_1.alt)("BEHAVIOR", "LOCK"), "IMPORTING", expressions_1.MethodParamName, "FOR LOCK", expressions_1.TypeName), (0, combi_1.seq)("DETERMINE", (0, combi_1.alt)("ON MODIFY", "ON SAVE"), "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("GLOBAL AUTHORIZATION IMPORTING REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)("GLOBAL FEATURES IMPORTING REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)((0, combi_1.seq)((0, combi_1.opt)("INSTANCE"), "AUTHORIZATION IMPORTING"), expressions_1.MethodParamName, "REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)("INSTANCE FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result));
17284
17288
  // todo, this is only from version something
17285
17289
  // AMDP OPTIONS clause blocked in KeyUser
17286
- const amdp = (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("AMDP OPTIONS", (0, combi_1.optPrio)("READ-ONLY"), "CDS SESSION CLIENT", (0, combi_1.alt)("CURRENT", "DEPENDENT"), (0, combi_1.optPrio)(expressions_1.MethodDefImporting), (0, combi_1.optPrio)(expressions_1.MethodDefExporting), (0, combi_1.optPrio)(expressions_1.MethodDefRaising)));
17290
+ const amdp = (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("AMDP OPTIONS", (0, combi_1.per)("READ-ONLY", (0, combi_1.seq)("CDS SESSION CLIENT", (0, combi_1.alt)("CURRENT", "DEPENDENT"))), (0, combi_1.optPrio)(expressions_1.MethodDefImporting), (0, combi_1.optPrio)(expressions_1.MethodDefExporting), (0, combi_1.optPrio)(expressions_1.MethodDefRaising)));
17287
17291
  // FOR DDL OBJECT / FOR TABLE FUNCTION / FOR SCALAR FUNCTION blocked in KeyUser
17288
17292
  const regular = (0, combi_1.seq)((0, combi_1.altPrio)("CLASS-METHODS", "METHODS"), expressions_1.MethodName, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.optPrio)(expressions_1.Abstract), (0, combi_1.optPrio)(def), expressions_1.EventHandler), parameters, testing, (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("FOR", behavior)), amdp, "NOT AT END OF MODE", (0, combi_1.optPrio)(expressions_1.Redefinition)));
17289
17293
  // RAP event handlers are instance methods; CLASS-METHODS is not allowed.
@@ -17314,7 +17318,8 @@ class MethodImplementation {
17314
17318
  const name = (0, combi_1.regex)(/[\w~]+/);
17315
17319
  const kernel = (0, combi_1.seq)("KERNEL MODULE", (0, combi_1.plus)(name), (0, combi_1.optPrio)((0, combi_1.altPrio)("FAIL", "IGNORE")));
17316
17320
  const using = (0, combi_1.seq)("USING", (0, combi_1.plus)(expressions_1.SimpleFieldChain));
17317
- const database = (0, combi_1.seq)("DATABASE", (0, combi_1.alt)("PROCEDURE", "FUNCTION", "GRAPH WORKSPACE"), "FOR HDB", expressions_1.Language, (0, combi_1.opt)("OPTIONS READ-ONLY"), (0, combi_1.opt)(using));
17321
+ const options = (0, combi_1.seq)("OPTIONS", (0, combi_1.per)("READ-ONLY", "SUPPRESS SYNTAX ERRORS", "DETERMINISTIC"));
17322
+ const database = (0, combi_1.seq)("DATABASE", (0, combi_1.alt)("PROCEDURE", "FUNCTION", "GRAPH WORKSPACE"), "FOR HDB", expressions_1.Language, (0, combi_1.opt)(options), (0, combi_1.opt)(using));
17318
17323
  // BY DATABASE and BY KERNEL both blocked in KeyUser
17319
17324
  const by = (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("BY", (0, combi_1.alt)(kernel, database)));
17320
17325
  return (0, combi_1.seq)("METHOD", expressions_1.MethodName, (0, combi_1.optPrio)(by));
@@ -25483,6 +25488,12 @@ class BuiltIn {
25483
25488
  }
25484
25489
  return this.buildDefinition(def, name);
25485
25490
  }
25491
+ static hasUnnamedArgument(name) {
25492
+ if (name === undefined) {
25493
+ return false;
25494
+ }
25495
+ return BuiltIn.unnamedArgument.has(name.toUpperCase());
25496
+ }
25486
25497
  static isPredicate(name) {
25487
25498
  if (name === undefined) {
25488
25499
  return undefined;
@@ -26584,6 +26595,12 @@ BuiltIn.methods = {
26584
26595
  return: basic_1.IntegerType.get(),
26585
26596
  },
26586
26597
  };
26598
+ // functions called with exactly one unnamed argument, all others take named arguments like "val"
26599
+ BuiltIn.unnamedArgument = new Set([
26600
+ "ABS", "ACOS", "ASIN", "ATAN", "BOOLC", "CEIL", "CHARLEN", "COS", "COSH", "DBMAXLEN", "EXP", "FLOOR",
26601
+ "FRAC", "LINES", "LOG", "LOG10", "NUMOFCHAR", "SIGN", "SIN", "SINH", "SQRT", "STRLEN", "TAN", "TANH",
26602
+ "TRUNC", "XSTRLEN"
26603
+ ]);
26587
26604
  //# sourceMappingURL=_builtin.js.map
26588
26605
 
26589
26606
  /***/ },
@@ -38637,17 +38654,54 @@ var __importStar = (this && this.__importStar) || (function () {
38637
38654
  })();
38638
38655
  Object.defineProperty(exports, "__esModule", ({ value: true }));
38639
38656
  exports.Case = void 0;
38657
+ exports.checkCaseOperand = checkCaseOperand;
38640
38658
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
38641
38659
  const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
38660
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
38661
+ const _builtin_1 = __webpack_require__(/*! ../_builtin */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js");
38662
+ const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js");
38663
+ const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
38664
+ const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
38642
38665
  class Case {
38643
38666
  runSyntax(node, input) {
38644
38667
  // just recurse
38645
38668
  for (const s of node.findDirectExpressions(Expressions.Source)) {
38646
38669
  source_1.Source.runSyntax(s, input);
38670
+ checkCaseOperand(s, input);
38647
38671
  }
38648
38672
  }
38649
38673
  }
38650
38674
  exports.Case = Case;
38675
+ // Before 7.40 SP02 the operands of CASE and WHEN are enhanced functional operand positions: besides
38676
+ // data objects and functional methods, only built-in functions with exactly one unnamed argument are allowed
38677
+ function checkCaseOperand(source, input) {
38678
+ var _a, _b;
38679
+ if ((0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v740sp02)
38680
+ || input.scope.getLanguageVersion() === version_1.LanguageVersion.Cloud
38681
+ || input.scope.getOpenABAP()) {
38682
+ return;
38683
+ }
38684
+ const chain = source.findDirectExpression(Expressions.MethodCallChain);
38685
+ if (chain === undefined || source.getChildren().length !== 1 || chain.getChildren().length !== 1) {
38686
+ return;
38687
+ }
38688
+ const call = chain.findDirectExpression(Expressions.MethodCall);
38689
+ const nameToken = (_a = call === null || call === void 0 ? void 0 : call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
38690
+ const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.getStr();
38691
+ if (nameToken === undefined || _builtin_1.BuiltIn.searchBuiltin(name) === undefined || _builtin_1.BuiltIn.hasUnnamedArgument(name)) {
38692
+ return;
38693
+ }
38694
+ // a method of the enclosing class takes precedence over the built-in function
38695
+ const meType = (_b = input.scope.findVariable("me")) === null || _b === void 0 ? void 0 : _b.getType();
38696
+ if (meType instanceof basic_1.ObjectReferenceType) {
38697
+ const def = input.scope.findObjectDefinition(meType.getIdentifierName());
38698
+ if (new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(def, name).method !== undefined) {
38699
+ return;
38700
+ }
38701
+ }
38702
+ const message = "Built-in function " + name + " not allowed as CASE/WHEN operand before v740sp02";
38703
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, nameToken, message));
38704
+ }
38651
38705
  //# sourceMappingURL=case.js.map
38652
38706
 
38653
38707
  /***/ },
@@ -40005,10 +40059,22 @@ const basic_types_1 = __webpack_require__(/*! ../basic_types */ "./node_modules/
40005
40059
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
40006
40060
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
40007
40061
  const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
40062
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
40008
40063
  class CreateData {
40009
40064
  runSyntax(node, input) {
40065
+ const likeLineOf = node.concatTokens().toUpperCase().includes(" LIKE LINE OF ");
40010
40066
  for (const s of node.findDirectExpressions(Expressions.Source)) {
40011
- source_1.Source.runSyntax(s, input);
40067
+ const sourceType = source_1.Source.runSyntax(s, input);
40068
+ if (likeLineOf === true
40069
+ && sourceType !== undefined
40070
+ && !(sourceType instanceof basic_1.TableType)
40071
+ && !(sourceType instanceof basic_1.VoidType)
40072
+ && !(sourceType instanceof basic_1.UnknownType)
40073
+ && !(sourceType instanceof basic_1.AnyType)) {
40074
+ const message = `"${s.concatTokens()}" is not an internal table`;
40075
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
40076
+ return;
40077
+ }
40012
40078
  }
40013
40079
  for (const t of node.findDirectExpressions(Expressions.Target)) {
40014
40080
  target_1.Target.runSyntax(t, input);
@@ -40193,6 +40259,11 @@ class CreateObject {
40193
40259
  ooName = found.getVoided();
40194
40260
  }
40195
40261
  input.scope.addReference(t === null || t === void 0 ? void 0 : t.getFirstToken(), cdef, _reference_1.ReferenceType.ConstructorReference, input.filename, { ooName: ooName });
40262
+ if (type && type.get() instanceof Expressions.Dynamic) {
40263
+ // the class is only known at runtime, cdef is the static type of the target
40264
+ this.validateParameters(undefined, node, input);
40265
+ return;
40266
+ }
40196
40267
  if (cdef !== undefined) {
40197
40268
  const err = CreateObject.checkInstantiationAllowed(cdef, input);
40198
40269
  if (err) {
@@ -47704,11 +47775,15 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
47704
47775
  exports.When = void 0;
47705
47776
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
47706
47777
  const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
47778
+ const case_1 = __webpack_require__(/*! ./case */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/case.js");
47707
47779
  class When {
47708
47780
  runSyntax(node, input) {
47709
47781
  for (const s of node.findAllExpressions(Expressions.Source)) {
47710
47782
  source_1.Source.runSyntax(s, input);
47711
47783
  }
47784
+ for (const s of node.findDirectExpressions(Expressions.Source)) {
47785
+ (0, case_1.checkCaseOperand)(s, input);
47786
+ }
47712
47787
  }
47713
47788
  }
47714
47789
  exports.When = When;
@@ -71242,7 +71317,7 @@ class Registry {
71242
71317
  }
71243
71318
  static abaplintVersion() {
71244
71319
  // magic, see build script "version.js"
71245
- return "2.120.59";
71320
+ return "2.120.61";
71246
71321
  }
71247
71322
  getDDICReferences() {
71248
71323
  return this.ddicReferences;
@@ -71875,12 +71950,13 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#abap-doc-on
71875
71950
  return issues;
71876
71951
  }
71877
71952
  getAbapdoc(rows, pos) {
71953
+ var _a, _b, _c;
71878
71954
  let previousRow = pos.getRow() - 2;
71879
- let rowText = rows[previousRow].trim().toUpperCase();
71955
+ let rowText = ((_a = rows[previousRow]) !== null && _a !== void 0 ? _a : "").trim().toUpperCase();
71880
71956
  const text = [];
71881
71957
  if (rowText === "METHODS" || rowText === "CLASS-METHODS") {
71882
71958
  previousRow--;
71883
- rowText = rows[previousRow].trim().toUpperCase();
71959
+ rowText = ((_b = rows[previousRow]) !== null && _b !== void 0 ? _b : "").trim().toUpperCase();
71884
71960
  }
71885
71961
  text.push(rowText);
71886
71962
  //we need to push the first row despite if it is actually an abapdoc or not
@@ -71888,7 +71964,7 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#abap-doc-on
71888
71964
  if (rowText.trim().substring(0, 2) === "\"!") {
71889
71965
  while (previousRow >= 0) {
71890
71966
  previousRow--;
71891
- rowText = rows[previousRow].trim().toUpperCase();
71967
+ rowText = ((_c = rows[previousRow]) !== null && _c !== void 0 ? _c : "").trim().toUpperCase();
71892
71968
  if (rowText.trim().substring(0, 2) !== "\"!") {
71893
71969
  break;
71894
71970
  }
@@ -111905,6 +111981,7 @@ exports.Transpiler = exports.Chunk = exports.UnknownTypesEnum = exports.config =
111905
111981
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
111906
111982
  const validation_1 = __webpack_require__(/*! ./validation */ "./node_modules/@abaplint/transpiler/build/src/validation.js");
111907
111983
  Object.defineProperty(exports, "config", ({ enumerable: true, get: function () { return validation_1.config; } }));
111984
+ const unique_identifier_1 = __webpack_require__(/*! ./unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
111908
111985
  const unit_test_1 = __webpack_require__(/*! ./unit_test */ "./node_modules/@abaplint/transpiler/build/src/unit_test.js");
111909
111986
  const types_1 = __webpack_require__(/*! ./types */ "./node_modules/@abaplint/transpiler/build/src/types.js");
111910
111987
  Object.defineProperty(exports, "UnknownTypesEnum", ({ enumerable: true, get: function () { return types_1.UnknownTypesEnum; } }));
@@ -111963,6 +112040,12 @@ class Transpiler {
111963
112040
  progress?.set(reg.getObjectCount().total, "Building");
111964
112041
  for (const obj of reg.getObjects()) {
111965
112042
  await progress?.tick("Building, " + obj.getName());
112043
+ // the temporary names ("unique1", ..., and the DO/WHILE sy-index backups
112044
+ // "indexBackup1", ...) are local to the module an object becomes, so each
112045
+ // object numbers its own: its output then depends on the registry alone,
112046
+ // not on the objects built before it or on an earlier run in the same process
112047
+ unique_identifier_1.UniqueIdentifier.reset();
112048
+ unique_identifier_1.UniqueIdentifier.resetIndexBackup();
111966
112049
  if (obj instanceof abaplint.Objects.TypePool) {
111967
112050
  output.objects.push(...new handle_type_pool_1.HandleTypePool().runObject(obj, reg));
111968
112051
  }
@@ -115378,10 +115461,12 @@ class DeleteInternalTranspiler {
115378
115461
  extra.push("where: async " + traversal.traverse(componentCompare).getCode());
115379
115462
  }
115380
115463
  // todo, this is not completely correct, fields might have the name ADJACENT
115381
- // comparisons should be on table key unless other is specified, but we're unaware
115382
115464
  if (node.findDirectTokenByText("ADJACENT")) {
115383
115465
  extra.push("adjacent: true");
115384
- if (node.findDirectTokenByText("COMPARING") && !concat.includes("COMPARING ALL FIELDS")) {
115466
+ if (concat.includes("COMPARING ALL FIELDS")) {
115467
+ extra.push("allFields: true");
115468
+ }
115469
+ else if (node.findDirectTokenByText("COMPARING")) {
115385
115470
  const comparing = node.findAllExpressions(abaplint.Expressions.SimpleFieldChain2);
115386
115471
  if (comparing) {
115387
115472
  const compareFields = comparing.map(i => "'" + i.getFirstToken().getStr() + "'").join(",");
@@ -115656,11 +115741,14 @@ class DoTranspiler {
115656
115741
  transpile(node, traversal) {
115657
115742
  const found = node.findFirstExpression(abaplint.Expressions.Source);
115658
115743
  if (found) {
115659
- const source = new expressions_1.SourceTranspiler(true).transpile(found, traversal).getCode();
115744
+ // the count is converted to i, like any numeric expression position: an
115745
+ // f count read with get( ) gives its text 3,0000000000000000E+00, which
115746
+ // no loop counter compares with, and a p count of 2.4 means 2 passes
115747
+ const source = new expressions_1.SourceTranspiler(false).transpile(found, traversal).getCode();
115660
115748
  const idSource = unique_identifier_1.UniqueIdentifier.get();
115661
115749
  const id = unique_identifier_1.UniqueIdentifier.get();
115662
115750
  return new chunk_1.Chunk(`const ${this.syIndexBackup} = abap.builtin.sy.get().index.get();
115663
- const ${idSource} = ${source};
115751
+ const ${idSource} = new abap.types.Integer().set(${source}).get();
115664
115752
  for (let ${id} = 0; ${id} < ${idSource}; ${id}++) {
115665
115753
  abap.builtin.sy.get().index.set(${id} + 1);`);
115666
115754
  }
@@ -117596,6 +117684,9 @@ class InsertDatabaseTranspiler {
117596
117684
  const tvalues = traversal.traverse(fromTable);
117597
117685
  options.push(`"table": ` + tvalues.getCode());
117598
117686
  }
117687
+ if (node.findDirectTokenByText("ACCEPTING") !== undefined) {
117688
+ options.push(`"acceptingDuplicateKeys": true`);
117689
+ }
117599
117690
  const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
117600
117691
  if (connection) {
117601
117692
  const con = findConnection(connection, traversal);
@@ -120546,7 +120637,7 @@ class SelectTranspiler {
120546
120637
  }
120547
120638
  if (!(${target} instanceof abap.types.HashedTable) && ${target}.getOptions()?.primaryKey?.type !== "SORTED") {
120548
120639
  abap.statements.sort(${target}, {by: ${by}.map(k => { return {component: k}; })});
120549
- await abap.statements.deleteInternal(${target}, {adjacent: true, by: ${by}});
120640
+ await abap.statements.deleteInternal(${target}, {adjacent: true, allFields: true});
120550
120641
  }
120551
120642
  abap.builtin.sy.get().dbcnt.set(${target}.getArrayLength());
120552
120643
  }`;
@@ -124732,6 +124823,7 @@ var __importStar = (this && this.__importStar) || (function () {
124732
124823
  })();
124733
124824
  Object.defineProperty(exports, "__esModule", ({ value: true }));
124734
124825
  exports.Traversal = void 0;
124826
+ exports.referencesAt = referencesAt;
124735
124827
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
124736
124828
  const StatementTranspilers = __importStar(__webpack_require__(/*! ./statements */ "./node_modules/@abaplint/transpiler/build/src/statements/index.js"));
124737
124829
  const ExpressionTranspilers = __importStar(__webpack_require__(/*! ./expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js"));
@@ -124740,6 +124832,43 @@ const transpile_types_1 = __webpack_require__(/*! ./transpile_types */ "./node_m
124740
124832
  const chunk_1 = __webpack_require__(/*! ./chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
124741
124833
  const expressions_1 = __webpack_require__(/*! ./expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
124742
124834
  const keywords_1 = __webpack_require__(/*! ./keywords */ "./node_modules/@abaplint/transpiler/build/src/keywords.js");
124835
+ /** the references of one scope, by where they start: built once per scope,
124836
+ * so finding the reference at a token no longer walks every reference of
124837
+ * the scope for every token, which made a long method quadratic */
124838
+ const REFERENCE_INDEX = new WeakMap();
124839
+ /** the references of a scope whose start equals the token's start, in the
124840
+ * scope's own order -- the same set and order the linear scan found:
124841
+ * Position.equals compares row and column, a VirtualPosition compares its
124842
+ * virtual row and column and only with another VirtualPosition */
124843
+ function referencesAt(scope, token) {
124844
+ const references = scope.getData().references;
124845
+ let index = REFERENCE_INDEX.get(references);
124846
+ if (index === undefined) {
124847
+ index = { plain: new Map(), virtual: new Map() };
124848
+ references.forEach((r, n) => {
124849
+ const start = r.position.getStart();
124850
+ const key = start instanceof abaplint.VirtualPosition
124851
+ ? start.vrow + ":" + start.vcol
124852
+ : start.getRow() + ":" + start.getCol();
124853
+ const map = start instanceof abaplint.VirtualPosition ? index.virtual : index.plain;
124854
+ const list = map.get(key);
124855
+ if (list === undefined) {
124856
+ map.set(key, [n]);
124857
+ }
124858
+ else {
124859
+ list.push(n);
124860
+ }
124861
+ });
124862
+ REFERENCE_INDEX.set(references, index);
124863
+ }
124864
+ const start = token.getStart();
124865
+ const found = [...(index.plain.get(start.getRow() + ":" + start.getCol()) ?? [])];
124866
+ if (start instanceof abaplint.VirtualPosition) {
124867
+ found.push(...(index.virtual.get(start.vrow + ":" + start.vcol) ?? []));
124868
+ found.sort((a, b) => a - b);
124869
+ }
124870
+ return found.map(n => references[n]);
124871
+ }
124743
124872
  class Traversal {
124744
124873
  spaghetti;
124745
124874
  file;
@@ -125093,9 +125222,8 @@ class Traversal {
125093
125222
  if (scope === undefined) {
125094
125223
  return false;
125095
125224
  }
125096
- for (const r of scope.getData().references) {
125097
- if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference
125098
- && r.position.getStart().equals(token.getStart())) {
125225
+ for (const r of referencesAt(scope, token)) {
125226
+ if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference) {
125099
125227
  return true;
125100
125228
  }
125101
125229
  }
@@ -125115,9 +125243,8 @@ class Traversal {
125115
125243
  if (scope === undefined) {
125116
125244
  return undefined;
125117
125245
  }
125118
- for (const r of scope.getData().references) {
125246
+ for (const r of referencesAt(scope, token)) {
125119
125247
  if (r.referenceType === abaplint.ReferenceType.MethodReference
125120
- && r.position.getStart().equals(token.getStart())
125121
125248
  && r.resolved instanceof abaplint.Types.MethodDefinition) {
125122
125249
  let name = r.resolved.getName();
125123
125250
  if (r.extra?.ooName && r.extra?.ooType === "INTF") {
@@ -125131,8 +125258,7 @@ class Traversal {
125131
125258
  }
125132
125259
  return candidate;
125133
125260
  }
125134
- else if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference
125135
- && r.position.getStart().equals(token.getStart())) {
125261
+ else if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference) {
125136
125262
  const def = r.resolved;
125137
125263
  const name = def.getName();
125138
125264
  return { def, name };
@@ -125280,10 +125406,9 @@ class Traversal {
125280
125406
  if (scope === undefined) {
125281
125407
  return undefined;
125282
125408
  }
125283
- for (const r of scope.getData().references) {
125284
- if ((r.referenceType === abaplint.ReferenceType.DataReadReference
125285
- || r.referenceType === abaplint.ReferenceType.DataWriteReference)
125286
- && r.position.getStart().equals(token.getStart())) {
125409
+ for (const r of referencesAt(scope, token)) {
125410
+ if (r.referenceType === abaplint.ReferenceType.DataReadReference
125411
+ || r.referenceType === abaplint.ReferenceType.DataWriteReference) {
125287
125412
  return r.resolved;
125288
125413
  }
125289
125414
  }
@@ -125294,9 +125419,8 @@ class Traversal {
125294
125419
  if (scope === undefined) {
125295
125420
  return undefined;
125296
125421
  }
125297
- for (const r of scope.getData().references) {
125298
- if (r.referenceType === abaplint.ReferenceType.InferredType
125299
- && r.position.getStart().equals(token.getStart())) {
125422
+ for (const r of referencesAt(scope, token)) {
125423
+ if (r.referenceType === abaplint.ReferenceType.InferredType) {
125300
125424
  if (r.resolved instanceof abaplint.TypedIdentifier) {
125301
125425
  return r.resolved.getType();
125302
125426
  }
@@ -125309,9 +125433,8 @@ class Traversal {
125309
125433
  if (scope === undefined) {
125310
125434
  return undefined;
125311
125435
  }
125312
- for (const r of scope.getData().references) {
125313
- if (r.referenceType === abaplint.ReferenceType.TypeReference
125314
- && r.position.getStart().equals(token.getStart())) {
125436
+ for (const r of referencesAt(scope, token)) {
125437
+ if (r.referenceType === abaplint.ReferenceType.TypeReference) {
125315
125438
  if (r.resolved instanceof abaplint.TypedIdentifier) {
125316
125439
  return r.resolved.getType();
125317
125440
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.13.92",
3
+ "version": "2.13.94",
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.59",
31
- "@abaplint/transpiler": "^2.13.92",
30
+ "@abaplint/core": "^2.120.61",
31
+ "@abaplint/transpiler": "^2.13.94",
32
32
  "@types/glob": "^9.0.0",
33
33
  "@types/node": "^26.6.2",
34
34
  "@types/progress": "^2.0.7",