@abaplint/core 2.91.12 → 2.91.13

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.
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.91.12";
71
+ return "2.91.13";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -200,7 +200,11 @@ Only one transformation is applied to a statement at a time, so multiple steps m
200
200
  if (found) {
201
201
  return found;
202
202
  }
203
- found = this.moveWithSimpleRef(high, lowFile);
203
+ found = this.downportRefSimple(high, lowFile);
204
+ if (found) {
205
+ return found;
206
+ }
207
+ found = this.downportRef(high, lowFile, highSyntax);
204
208
  if (found) {
205
209
  return found;
206
210
  }
@@ -280,6 +284,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
280
284
  if (found) {
281
285
  return found;
282
286
  }
287
+ found = this.getReference(high, lowFile, highSyntax);
288
+ if (found) {
289
+ return found;
290
+ }
283
291
  found = this.replaceContains(high, lowFile, highSyntax);
284
292
  if (found) {
285
293
  return found;
@@ -814,7 +822,7 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
814
822
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
815
823
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, call function parameter", this.getMetadata().key, this.conf.severity, fix);
816
824
  }
817
- moveWithSimpleRef(high, lowFile) {
825
+ downportRefSimple(high, lowFile) {
818
826
  var _a;
819
827
  if (!(high.get() instanceof Statements.Move)
820
828
  || high.getChildren().length !== 4
@@ -835,6 +843,23 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
835
843
  const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
836
844
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, simple REF move", this.getMetadata().key, this.conf.severity, fix);
837
845
  }
846
+ downportRef(high, lowFile, highSyntax) {
847
+ let found = undefined;
848
+ for (const s of high.findAllExpressionsRecursive(Expressions.Source)) {
849
+ if (s.getFirstToken().getStr().toUpperCase() === "REF") {
850
+ found = s;
851
+ }
852
+ }
853
+ if (found === undefined) {
854
+ return undefined;
855
+ }
856
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
857
+ const code = `DATA(${uniqueName}) = ${found.concatTokens()}.\n`;
858
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getStart(), code);
859
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, found.getFirstToken().getStart(), found.getLastToken().getEnd(), uniqueName);
860
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
861
+ return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, REF", this.getMetadata().key, this.conf.severity, fix);
862
+ }
838
863
  moveWithSimpleValue(high, lowFile) {
839
864
  if (!(high.get() instanceof Statements.Move)
840
865
  || high.getChildren().length !== 4) {
@@ -1719,6 +1744,26 @@ ${indentation} output = ${topTarget}.`;
1719
1744
  }
1720
1745
  return undefined;
1721
1746
  }
1747
+ getReference(node, lowFile, _highSyntax) {
1748
+ var _a, _b, _c;
1749
+ if (!(node.get() instanceof Statements.GetReference)) {
1750
+ return undefined;
1751
+ }
1752
+ const inline = (_a = node.findDirectExpression(Expressions.Target)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.InlineData);
1753
+ if (inline === undefined) {
1754
+ return undefined;
1755
+ }
1756
+ const targetName = (_b = inline.findDirectExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
1757
+ const sourceName = (_c = node.findDirectExpression(Expressions.Source)) === null || _c === void 0 ? void 0 : _c.concatTokens();
1758
+ if (targetName === undefined || sourceName === undefined) {
1759
+ return undefined;
1760
+ }
1761
+ const code = `DATA ${targetName} LIKE REF TO ${sourceName}.\n`;
1762
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
1763
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, inline.getFirstToken().getStart(), inline.getLastToken().getEnd(), targetName);
1764
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
1765
+ return issue_1.Issue.atToken(lowFile, inline.getFirstToken(), "Downport, outline DATA ref", this.getMetadata().key, this.conf.severity, fix);
1766
+ }
1722
1767
  replaceContains(node, lowFile, highSyntax) {
1723
1768
  const spag = highSyntax.spaghetti.lookupPosition(node.getFirstToken().getStart(), lowFile.getFilename());
1724
1769
  // only downport if its an single method call condition
@@ -1810,8 +1855,10 @@ ${indentation} output = ${topTarget}.`;
1810
1855
  const target = node.findDirectExpression(Expressions.Target);
1811
1856
  const found = source === null || source === void 0 ? void 0 : source.findFirstExpression(Expressions.NewObject);
1812
1857
  // must be at top level of the source for quickfix to work(todo: handle more scenarios)
1813
- // todo, assumption: the target is not an inline definition
1814
- if (target && found && source.concatTokens() === found.concatTokens()) {
1858
+ if (target
1859
+ && found
1860
+ && source.concatTokens() === found.concatTokens()
1861
+ && target.findDirectExpression(Expressions.InlineData) === undefined) {
1815
1862
  const abap = this.newParameters(found, target.concatTokens(), highSyntax, lowFile);
1816
1863
  if (abap !== undefined) {
1817
1864
  fix = edit_helper_1.EditHelper.replaceRange(lowFile, node.getFirstToken().getStart(), node.getLastToken().getEnd(), abap);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.91.12",
3
+ "version": "2.91.13",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",