@abaplint/core 2.91.11 → 2.91.12

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.
@@ -105,7 +105,8 @@ class StatementParser {
105
105
  for (let statement of wa.statements) {
106
106
  // dont use CALL METHOD, when executing lazy, it easily gives a Move for the last statment if lazy logic is evaluated
107
107
  if (statement.get() instanceof _statement_1.Unknown
108
- && statement.concatTokens().toUpperCase().startsWith("CALL METHOD ") === false) {
108
+ && statement.concatTokens().toUpperCase().startsWith("CALL METHOD ") === false
109
+ && statement.concatTokens().toUpperCase().startsWith("CALL FUNCTION ") === false) {
109
110
  for (const { first, second } of this.buildSplits(statement.getTokens())) {
110
111
  if (second.length === 1) {
111
112
  continue; // probably punctuation
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.91.11";
71
+ return "2.91.12";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -188,7 +188,7 @@ Only one transformation is applied to a statement at a time, so multiple steps m
188
188
  if (found) {
189
189
  return found;
190
190
  }
191
- found = this.stringTemplateAlpha(high, lowFile);
191
+ found = this.stringTemplateAlpha(high, lowFile, highSyntax);
192
192
  if (found) {
193
193
  return found;
194
194
  }
@@ -200,6 +200,14 @@ 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);
204
+ if (found) {
205
+ return found;
206
+ }
207
+ found = this.callFunctionParameterSimple(high, lowFile, highSyntax);
208
+ if (found) {
209
+ return found;
210
+ }
203
211
  found = this.moveWithTableTarget(low, high, lowFile, highSyntax);
204
212
  if (found) {
205
213
  return found;
@@ -779,6 +787,54 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
779
787
  }
780
788
  return undefined;
781
789
  }
790
+ callFunctionParameterSimple(high, lowFile, highSyntax) {
791
+ if (!(high.get() instanceof Statements.CallFunction)) {
792
+ return undefined;
793
+ }
794
+ let found = undefined;
795
+ for (const p of high.findAllExpressions(Expressions.FunctionExportingParameter)) {
796
+ found = p.findDirectExpression(Expressions.Source);
797
+ if (found && (found.findDirectExpression(Expressions.FieldChain)
798
+ || found.findDirectExpression(Expressions.Constant)
799
+ || found.findDirectExpression(Expressions.TextElement))) {
800
+ // its actually simple, ok
801
+ found = undefined;
802
+ }
803
+ else if (found !== undefined) {
804
+ break;
805
+ }
806
+ }
807
+ if (found === undefined) {
808
+ return undefined;
809
+ }
810
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
811
+ const code = `DATA(${uniqueName}) = ${found.concatTokens()}.\n`;
812
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getStart(), code);
813
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, found.getFirstToken().getStart(), found.getLastToken().getEnd(), uniqueName);
814
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
815
+ return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, call function parameter", this.getMetadata().key, this.conf.severity, fix);
816
+ }
817
+ moveWithSimpleRef(high, lowFile) {
818
+ var _a;
819
+ if (!(high.get() instanceof Statements.Move)
820
+ || high.getChildren().length !== 4
821
+ || high.getChildren()[2].getFirstToken().getStr().toUpperCase() !== "REF") {
822
+ return undefined;
823
+ }
824
+ const target = high.findDirectExpression(Expressions.Target);
825
+ if (target === undefined) {
826
+ return undefined;
827
+ }
828
+ const sourceRef = (_a = high.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Source);
829
+ if (sourceRef === undefined || sourceRef.getChildren().length !== 1) {
830
+ return;
831
+ }
832
+ const code = `GET REFERENCE OF ${sourceRef.concatTokens()} INTO ${target.concatTokens()}`;
833
+ const start = high.getFirstToken().getStart();
834
+ const end = high.getLastToken().getStart();
835
+ const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
836
+ return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, simple REF move", this.getMetadata().key, this.conf.severity, fix);
837
+ }
782
838
  moveWithSimpleValue(high, lowFile) {
783
839
  if (!(high.get() instanceof Statements.Move)
784
840
  || high.getChildren().length !== 4) {
@@ -927,7 +983,7 @@ ${indentation}${uniqueName}`;
927
983
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Expand operator", this.getMetadata().key, this.conf.severity, fix);
928
984
  }
929
985
  // must be very simple string templates, like "|{ ls_line-no ALPHA = IN }|"
930
- stringTemplateAlpha(node, lowFile) {
986
+ stringTemplateAlpha(node, lowFile, highSyntax) {
931
987
  var _a, _b, _c;
932
988
  if (!(node.get() instanceof Statements.Move)) {
933
989
  return undefined;
@@ -936,8 +992,13 @@ ${indentation}${uniqueName}`;
936
992
  if (topSource === undefined || topSource.getChildren().length !== 1) {
937
993
  return undefined;
938
994
  }
939
- const child = topSource.getFirstChild();
995
+ let top = true;
996
+ let child = topSource.getFirstChild();
940
997
  if (!(child.get() instanceof Expressions.StringTemplate)) {
998
+ child = child.findFirstExpression(Expressions.StringTemplate);
999
+ top = false;
1000
+ }
1001
+ if (child === undefined || !(child.get() instanceof Expressions.StringTemplate)) {
941
1002
  return undefined;
942
1003
  }
943
1004
  const templateTokens = child.getChildren();
@@ -962,13 +1023,28 @@ ${indentation}${uniqueName}`;
962
1023
  const indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
963
1024
  const source = (_b = templateSource === null || templateSource === void 0 ? void 0 : templateSource.findDirectExpression(Expressions.Source)) === null || _b === void 0 ? void 0 : _b.concatTokens();
964
1025
  const topTarget = (_c = node.findDirectExpression(Expressions.Target)) === null || _c === void 0 ? void 0 : _c.concatTokens();
965
- const code = `CALL FUNCTION '${functionName}'
1026
+ const uniqueName = this.uniqueName(node.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
1027
+ if (top === false) {
1028
+ const code = `DATA ${uniqueName} TYPE string.
1029
+ ${indentation}CALL FUNCTION '${functionName}'
1030
+ ${indentation} EXPORTING
1031
+ ${indentation} input = ${source}
1032
+ ${indentation} IMPORTING
1033
+ ${indentation} output = ${uniqueName}.\n`;
1034
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
1035
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, child.getFirstToken().getStart(), child.getLastToken().getEnd(), uniqueName);
1036
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
1037
+ return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Downport ALPHA", this.getMetadata().key, this.conf.severity, fix);
1038
+ }
1039
+ else {
1040
+ const code = `CALL FUNCTION '${functionName}'
966
1041
  ${indentation} EXPORTING
967
1042
  ${indentation} input = ${source}
968
1043
  ${indentation} IMPORTING
969
1044
  ${indentation} output = ${topTarget}.`;
970
- const fix = edit_helper_1.EditHelper.replaceRange(lowFile, node.getFirstToken().getStart(), node.getLastToken().getEnd(), code);
971
- return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Downport ALPHA", this.getMetadata().key, this.conf.severity, fix);
1045
+ const fix = edit_helper_1.EditHelper.replaceRange(lowFile, node.getFirstToken().getStart(), node.getLastToken().getEnd(), code);
1046
+ return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Downport ALPHA", this.getMetadata().key, this.conf.severity, fix);
1047
+ }
972
1048
  }
973
1049
  outlineLoopInput(node, lowFile, highSyntax) {
974
1050
  if (!(node.get() instanceof Statements.Loop)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.91.11",
3
+ "version": "2.91.12",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "homepage": "https://abaplint.org",
47
47
  "devDependencies": {
48
- "@microsoft/api-extractor": "^7.28.4",
48
+ "@microsoft/api-extractor": "^7.28.6",
49
49
  "@types/chai": "^4.3.1",
50
50
  "@types/mocha": "^9.1.1",
51
51
  "@types/node": "^18.0.6",