@abaplint/core 2.93.79 → 2.93.80

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.
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.93.79";
66
+ return "2.93.80";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
@@ -1459,28 +1459,40 @@ ${indentation} output = ${topTarget}.`;
1459
1459
  return undefined;
1460
1460
  }
1461
1461
  outlineFor(forLoop, indentation, lowFile, highSyntax) {
1462
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1462
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1463
1463
  let body = "";
1464
1464
  let end = "";
1465
1465
  const loopSource = (_a = forLoop.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
1466
- let loopTargetField = (_b = forLoop.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
1467
- const of = (_c = forLoop.findExpressionAfterToken("OF")) === null || _c === void 0 ? void 0 : _c.concatTokens();
1466
+ let loopTargetFieldExpression = forLoop.findFirstExpression(Expressions.TargetField);
1467
+ let loopTargetFieldName = loopTargetFieldExpression === null || loopTargetFieldExpression === void 0 ? void 0 : loopTargetFieldExpression.concatTokens();
1468
+ const of = forLoop.findExpressionAfterToken("OF");
1468
1469
  if (of !== undefined) {
1469
- loopTargetField = of;
1470
- }
1471
- if (((_e = (_d = forLoop.findDirectExpression(Expressions.InlineLoopDefinition)) === null || _d === void 0 ? void 0 : _d.getFirstChild()) === null || _e === void 0 ? void 0 : _e.get()) instanceof Expressions.TargetFieldSymbol) {
1472
- loopTargetField = undefined;
1470
+ loopTargetFieldExpression = of;
1471
+ loopTargetFieldName = of === null || of === void 0 ? void 0 : of.concatTokens();
1472
+ }
1473
+ if (((_c = (_b = forLoop.findDirectExpression(Expressions.InlineLoopDefinition)) === null || _b === void 0 ? void 0 : _b.getFirstChild()) === null || _c === void 0 ? void 0 : _c.get()) instanceof Expressions.TargetFieldSymbol) {
1474
+ loopTargetFieldExpression = undefined;
1475
+ loopTargetFieldName = undefined;
1476
+ }
1477
+ if (loopTargetFieldExpression) {
1478
+ const start = loopTargetFieldExpression.getFirstToken().getStart();
1479
+ const spag = highSyntax.spaghetti.lookupPosition(start, lowFile.getFilename());
1480
+ if (loopTargetFieldName && spag) {
1481
+ if (this.isDuplicateName(spag, loopTargetFieldName, start)) {
1482
+ this.renameVariable(spag, loopTargetFieldName, start, lowFile, highSyntax);
1483
+ }
1484
+ }
1473
1485
  }
1474
- let cond = ((_f = forLoop.findDirectExpression(Expressions.ComponentCond)) === null || _f === void 0 ? void 0 : _f.concatTokens()) || "";
1486
+ let cond = ((_d = forLoop.findDirectExpression(Expressions.ComponentCond)) === null || _d === void 0 ? void 0 : _d.concatTokens()) || "";
1475
1487
  if (cond !== "") {
1476
1488
  cond = " WHERE " + cond;
1477
1489
  }
1478
1490
  const loop = forLoop.findDirectExpression(Expressions.InlineLoopDefinition);
1479
- const indexInto = (_g = loop === null || loop === void 0 ? void 0 : loop.findExpressionAfterToken("INTO")) === null || _g === void 0 ? void 0 : _g.concatTokens();
1491
+ const indexInto = (_e = loop === null || loop === void 0 ? void 0 : loop.findExpressionAfterToken("INTO")) === null || _e === void 0 ? void 0 : _e.concatTokens();
1480
1492
  if (forLoop.findDirectTokenByText("UNTIL")
1481
1493
  || forLoop.findDirectTokenByText("WHILE")) {
1482
1494
  const fieldDef = forLoop.findDirectExpression(Expressions.InlineFieldDefinition);
1483
- const field = (_h = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.findFirstExpression(Expressions.Field)) === null || _h === void 0 ? void 0 : _h.concatTokens();
1495
+ const field = (_f = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.findFirstExpression(Expressions.Field)) === null || _f === void 0 ? void 0 : _f.concatTokens();
1484
1496
  const indexBackup = this.uniqueName(forLoop.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
1485
1497
  body += indentation + "DATA " + field + " TYPE i.\n";
1486
1498
  const second = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.getChildren()[2];
@@ -1502,10 +1514,10 @@ ${indentation} output = ${topTarget}.`;
1502
1514
  }
1503
1515
  end += indentation + "ENDWHILE";
1504
1516
  }
1505
- else if (loopTargetField !== undefined) {
1506
- let from = (_j = forLoop.findExpressionAfterToken("FROM")) === null || _j === void 0 ? void 0 : _j.concatTokens();
1517
+ else if (loopTargetFieldName !== undefined) {
1518
+ let from = (_g = forLoop.findExpressionAfterToken("FROM")) === null || _g === void 0 ? void 0 : _g.concatTokens();
1507
1519
  from = from ? " FROM " + from : "";
1508
- let to = (_k = forLoop.findExpressionAfterToken("TO")) === null || _k === void 0 ? void 0 : _k.concatTokens();
1520
+ let to = (_h = forLoop.findExpressionAfterToken("TO")) === null || _h === void 0 ? void 0 : _h.concatTokens();
1509
1521
  to = to ? " TO " + to : "";
1510
1522
  let gby = "";
1511
1523
  for (const lg of forLoop.findDirectExpressions(Expressions.LoopGroupByComponent)) {
@@ -1542,19 +1554,19 @@ ${indentation} output = ${topTarget}.`;
1542
1554
  inGroup = "-items";
1543
1555
  }
1544
1556
  let into = "INTO DATA";
1545
- if (loopTargetField.startsWith("<")) {
1557
+ if (loopTargetFieldName.startsWith("<")) {
1546
1558
  into = "ASSIGNING FIELD-SYMBOL";
1547
1559
  }
1548
1560
  // todo, also backup sy-index / sy-tabix here?
1549
- body += indentation + `LOOP AT ${loopSource}${inGroup} ${into}(${loopTargetField})${from}${to}${cond}${gby}.\n`;
1561
+ body += indentation + `LOOP AT ${loopSource}${inGroup} ${into}(${loopTargetFieldName})${from}${to}${cond}${gby}.\n`;
1550
1562
  if (indexInto) {
1551
1563
  body += indentation + " DATA(" + indexInto + ") = sy-tabix.\n";
1552
1564
  }
1553
1565
  end = "ENDLOOP";
1554
1566
  }
1555
- else if (loopTargetField === undefined) {
1567
+ else if (loopTargetFieldName === undefined) {
1556
1568
  // todo, also backup sy-index / sy-tabix here?
1557
- const loopTargetFieldSymbol = (_l = forLoop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _l === void 0 ? void 0 : _l.concatTokens();
1569
+ const loopTargetFieldSymbol = (_j = forLoop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _j === void 0 ? void 0 : _j.concatTokens();
1558
1570
  body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol})${cond}.\n`;
1559
1571
  if (indexInto) {
1560
1572
  body += indentation + " DATA(" + indexInto + ") = sy-tabix.\n";
@@ -1934,9 +1946,15 @@ ${indentation} output = ${topTarget}.`;
1934
1946
  renameVariable(spag, name, pos, lowFile, highSyntax) {
1935
1947
  var _a, _b;
1936
1948
  const uniqueName = this.uniqueName(pos, lowFile.getFilename(), highSyntax);
1949
+ const positions = new Set();
1937
1950
  let fix = undefined;
1938
1951
  for (const r of spag.getData().references) {
1939
1952
  if (((_a = r.resolved) === null || _a === void 0 ? void 0 : _a.getName()) === name && ((_b = r.resolved) === null || _b === void 0 ? void 0 : _b.getStart().equals(pos))) {
1953
+ const key = JSON.stringify(r.position.getStart());
1954
+ if (positions.has(key)) {
1955
+ continue;
1956
+ }
1957
+ positions.add(key);
1940
1958
  const replace = edit_helper_1.EditHelper.replaceRange(lowFile, r.position.getStart(), r.position.getEnd(), uniqueName);
1941
1959
  if (fix === undefined) {
1942
1960
  fix = replace;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.93.79",
3
+ "version": "2.93.80",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",