@abaplint/transpiler-cli 2.13.92 → 2.13.93

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 +64 -20
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -111905,6 +111905,7 @@ exports.Transpiler = exports.Chunk = exports.UnknownTypesEnum = exports.config =
111905
111905
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
111906
111906
  const validation_1 = __webpack_require__(/*! ./validation */ "./node_modules/@abaplint/transpiler/build/src/validation.js");
111907
111907
  Object.defineProperty(exports, "config", ({ enumerable: true, get: function () { return validation_1.config; } }));
111908
+ const unique_identifier_1 = __webpack_require__(/*! ./unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
111908
111909
  const unit_test_1 = __webpack_require__(/*! ./unit_test */ "./node_modules/@abaplint/transpiler/build/src/unit_test.js");
111909
111910
  const types_1 = __webpack_require__(/*! ./types */ "./node_modules/@abaplint/transpiler/build/src/types.js");
111910
111911
  Object.defineProperty(exports, "UnknownTypesEnum", ({ enumerable: true, get: function () { return types_1.UnknownTypesEnum; } }));
@@ -111963,6 +111964,12 @@ class Transpiler {
111963
111964
  progress?.set(reg.getObjectCount().total, "Building");
111964
111965
  for (const obj of reg.getObjects()) {
111965
111966
  await progress?.tick("Building, " + obj.getName());
111967
+ // the temporary names ("unique1", ..., and the DO/WHILE sy-index backups
111968
+ // "indexBackup1", ...) are local to the module an object becomes, so each
111969
+ // object numbers its own: its output then depends on the registry alone,
111970
+ // not on the objects built before it or on an earlier run in the same process
111971
+ unique_identifier_1.UniqueIdentifier.reset();
111972
+ unique_identifier_1.UniqueIdentifier.resetIndexBackup();
111966
111973
  if (obj instanceof abaplint.Objects.TypePool) {
111967
111974
  output.objects.push(...new handle_type_pool_1.HandleTypePool().runObject(obj, reg));
111968
111975
  }
@@ -115378,10 +115385,12 @@ class DeleteInternalTranspiler {
115378
115385
  extra.push("where: async " + traversal.traverse(componentCompare).getCode());
115379
115386
  }
115380
115387
  // 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
115388
  if (node.findDirectTokenByText("ADJACENT")) {
115383
115389
  extra.push("adjacent: true");
115384
- if (node.findDirectTokenByText("COMPARING") && !concat.includes("COMPARING ALL FIELDS")) {
115390
+ if (concat.includes("COMPARING ALL FIELDS")) {
115391
+ extra.push("allFields: true");
115392
+ }
115393
+ else if (node.findDirectTokenByText("COMPARING")) {
115385
115394
  const comparing = node.findAllExpressions(abaplint.Expressions.SimpleFieldChain2);
115386
115395
  if (comparing) {
115387
115396
  const compareFields = comparing.map(i => "'" + i.getFirstToken().getStr() + "'").join(",");
@@ -117596,6 +117605,9 @@ class InsertDatabaseTranspiler {
117596
117605
  const tvalues = traversal.traverse(fromTable);
117597
117606
  options.push(`"table": ` + tvalues.getCode());
117598
117607
  }
117608
+ if (node.findDirectTokenByText("ACCEPTING") !== undefined) {
117609
+ options.push(`"acceptingDuplicateKeys": true`);
117610
+ }
117599
117611
  const connection = node.findDirectExpression(abaplint.Expressions.DatabaseConnection);
117600
117612
  if (connection) {
117601
117613
  const con = findConnection(connection, traversal);
@@ -120546,7 +120558,7 @@ class SelectTranspiler {
120546
120558
  }
120547
120559
  if (!(${target} instanceof abap.types.HashedTable) && ${target}.getOptions()?.primaryKey?.type !== "SORTED") {
120548
120560
  abap.statements.sort(${target}, {by: ${by}.map(k => { return {component: k}; })});
120549
- await abap.statements.deleteInternal(${target}, {adjacent: true, by: ${by}});
120561
+ await abap.statements.deleteInternal(${target}, {adjacent: true, allFields: true});
120550
120562
  }
120551
120563
  abap.builtin.sy.get().dbcnt.set(${target}.getArrayLength());
120552
120564
  }`;
@@ -124732,6 +124744,7 @@ var __importStar = (this && this.__importStar) || (function () {
124732
124744
  })();
124733
124745
  Object.defineProperty(exports, "__esModule", ({ value: true }));
124734
124746
  exports.Traversal = void 0;
124747
+ exports.referencesAt = referencesAt;
124735
124748
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
124736
124749
  const StatementTranspilers = __importStar(__webpack_require__(/*! ./statements */ "./node_modules/@abaplint/transpiler/build/src/statements/index.js"));
124737
124750
  const ExpressionTranspilers = __importStar(__webpack_require__(/*! ./expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js"));
@@ -124740,6 +124753,43 @@ const transpile_types_1 = __webpack_require__(/*! ./transpile_types */ "./node_m
124740
124753
  const chunk_1 = __webpack_require__(/*! ./chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
124741
124754
  const expressions_1 = __webpack_require__(/*! ./expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
124742
124755
  const keywords_1 = __webpack_require__(/*! ./keywords */ "./node_modules/@abaplint/transpiler/build/src/keywords.js");
124756
+ /** the references of one scope, by where they start: built once per scope,
124757
+ * so finding the reference at a token no longer walks every reference of
124758
+ * the scope for every token, which made a long method quadratic */
124759
+ const REFERENCE_INDEX = new WeakMap();
124760
+ /** the references of a scope whose start equals the token's start, in the
124761
+ * scope's own order -- the same set and order the linear scan found:
124762
+ * Position.equals compares row and column, a VirtualPosition compares its
124763
+ * virtual row and column and only with another VirtualPosition */
124764
+ function referencesAt(scope, token) {
124765
+ const references = scope.getData().references;
124766
+ let index = REFERENCE_INDEX.get(references);
124767
+ if (index === undefined) {
124768
+ index = { plain: new Map(), virtual: new Map() };
124769
+ references.forEach((r, n) => {
124770
+ const start = r.position.getStart();
124771
+ const key = start instanceof abaplint.VirtualPosition
124772
+ ? start.vrow + ":" + start.vcol
124773
+ : start.getRow() + ":" + start.getCol();
124774
+ const map = start instanceof abaplint.VirtualPosition ? index.virtual : index.plain;
124775
+ const list = map.get(key);
124776
+ if (list === undefined) {
124777
+ map.set(key, [n]);
124778
+ }
124779
+ else {
124780
+ list.push(n);
124781
+ }
124782
+ });
124783
+ REFERENCE_INDEX.set(references, index);
124784
+ }
124785
+ const start = token.getStart();
124786
+ const found = [...(index.plain.get(start.getRow() + ":" + start.getCol()) ?? [])];
124787
+ if (start instanceof abaplint.VirtualPosition) {
124788
+ found.push(...(index.virtual.get(start.vrow + ":" + start.vcol) ?? []));
124789
+ found.sort((a, b) => a - b);
124790
+ }
124791
+ return found.map(n => references[n]);
124792
+ }
124743
124793
  class Traversal {
124744
124794
  spaghetti;
124745
124795
  file;
@@ -125093,9 +125143,8 @@ class Traversal {
125093
125143
  if (scope === undefined) {
125094
125144
  return false;
125095
125145
  }
125096
- for (const r of scope.getData().references) {
125097
- if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference
125098
- && r.position.getStart().equals(token.getStart())) {
125146
+ for (const r of referencesAt(scope, token)) {
125147
+ if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference) {
125099
125148
  return true;
125100
125149
  }
125101
125150
  }
@@ -125115,9 +125164,8 @@ class Traversal {
125115
125164
  if (scope === undefined) {
125116
125165
  return undefined;
125117
125166
  }
125118
- for (const r of scope.getData().references) {
125167
+ for (const r of referencesAt(scope, token)) {
125119
125168
  if (r.referenceType === abaplint.ReferenceType.MethodReference
125120
- && r.position.getStart().equals(token.getStart())
125121
125169
  && r.resolved instanceof abaplint.Types.MethodDefinition) {
125122
125170
  let name = r.resolved.getName();
125123
125171
  if (r.extra?.ooName && r.extra?.ooType === "INTF") {
@@ -125131,8 +125179,7 @@ class Traversal {
125131
125179
  }
125132
125180
  return candidate;
125133
125181
  }
125134
- else if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference
125135
- && r.position.getStart().equals(token.getStart())) {
125182
+ else if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference) {
125136
125183
  const def = r.resolved;
125137
125184
  const name = def.getName();
125138
125185
  return { def, name };
@@ -125280,10 +125327,9 @@ class Traversal {
125280
125327
  if (scope === undefined) {
125281
125328
  return undefined;
125282
125329
  }
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())) {
125330
+ for (const r of referencesAt(scope, token)) {
125331
+ if (r.referenceType === abaplint.ReferenceType.DataReadReference
125332
+ || r.referenceType === abaplint.ReferenceType.DataWriteReference) {
125287
125333
  return r.resolved;
125288
125334
  }
125289
125335
  }
@@ -125294,9 +125340,8 @@ class Traversal {
125294
125340
  if (scope === undefined) {
125295
125341
  return undefined;
125296
125342
  }
125297
- for (const r of scope.getData().references) {
125298
- if (r.referenceType === abaplint.ReferenceType.InferredType
125299
- && r.position.getStart().equals(token.getStart())) {
125343
+ for (const r of referencesAt(scope, token)) {
125344
+ if (r.referenceType === abaplint.ReferenceType.InferredType) {
125300
125345
  if (r.resolved instanceof abaplint.TypedIdentifier) {
125301
125346
  return r.resolved.getType();
125302
125347
  }
@@ -125309,9 +125354,8 @@ class Traversal {
125309
125354
  if (scope === undefined) {
125310
125355
  return undefined;
125311
125356
  }
125312
- for (const r of scope.getData().references) {
125313
- if (r.referenceType === abaplint.ReferenceType.TypeReference
125314
- && r.position.getStart().equals(token.getStart())) {
125357
+ for (const r of referencesAt(scope, token)) {
125358
+ if (r.referenceType === abaplint.ReferenceType.TypeReference) {
125315
125359
  if (r.resolved instanceof abaplint.TypedIdentifier) {
125316
125360
  return r.resolved.getType();
125317
125361
  }
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.93",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -28,7 +28,7 @@
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
30
  "@abaplint/core": "^2.120.59",
31
- "@abaplint/transpiler": "^2.13.92",
31
+ "@abaplint/transpiler": "^2.13.93",
32
32
  "@types/glob": "^9.0.0",
33
33
  "@types/node": "^26.6.2",
34
34
  "@types/progress": "^2.0.7",