@abaplint/core 2.101.20 → 2.101.22

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.
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.101.20";
68
+ return "2.101.22";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
@@ -26,6 +26,10 @@ class AvoidUseConf extends _basic_rule_config_1.BasicRuleConfig {
26
26
  this.testSeams = true;
27
27
  /** Detects DESCRIBE TABLE LINES, use lines() instead */
28
28
  this.describeLines = true;
29
+ /** Detects EXPORT TO MEMORY */
30
+ this.exportToMemory = true;
31
+ /** Detects EXPORT TO DATABASE */
32
+ this.exportToDatabase = true;
29
33
  }
30
34
  }
31
35
  exports.AvoidUseConf = AvoidUseConf;
@@ -85,6 +89,12 @@ TEST-SEAMS: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md
85
89
  else if (this.conf.statics && statement instanceof Statements.StaticEnd) {
86
90
  isStaticsBlock = false;
87
91
  }
92
+ else if (this.conf.exportToMemory && statement instanceof Statements.Export && statementNode.concatTokens().includes("TO MEMORY ")) {
93
+ message = "EXPORT TO MEMORY";
94
+ }
95
+ else if (this.conf.exportToDatabase && statement instanceof Statements.Export && statementNode.concatTokens().includes("TO DATABASE ")) {
96
+ message = "EXPORT TO DATABASE";
97
+ }
88
98
  else if (this.conf.testSeams && statement instanceof Statements.TestSeam) {
89
99
  message = "TEST-SEAM";
90
100
  }
@@ -1062,7 +1062,7 @@ ${indentation}CATCH ${className} INTO ${targetName}.`;
1062
1062
  bar->if_t100_dyn_msg~msgv4 = 'abc'.
1063
1063
  RAISE EXCEPTION bar.
1064
1064
  */
1065
- var _a, _b, _c;
1065
+ var _a, _b, _c, _d, _e, _f, _g;
1066
1066
  if (!(node.get() instanceof Statements.Raise)) {
1067
1067
  return undefined;
1068
1068
  }
@@ -1086,20 +1086,45 @@ ${indentation}CATCH ${className} INTO ${targetName}.`;
1086
1086
  if (s === undefined) {
1087
1087
  return undefined;
1088
1088
  }
1089
- id = "'" + ((_a = s.findDirectExpression(Expressions.MessageClass)) === null || _a === void 0 ? void 0 : _a.concatTokens()) + "'";
1090
- number = "'" + ((_b = s.findDirectExpression(Expressions.MessageTypeAndNumber)) === null || _b === void 0 ? void 0 : _b.concatTokens().substring(1)) + "'";
1089
+ if (s.findDirectExpression(Expressions.MessageClass)) {
1090
+ id = "'" + ((_b = (_a = s.findDirectExpression(Expressions.MessageClass)) === null || _a === void 0 ? void 0 : _a.concatTokens()) === null || _b === void 0 ? void 0 : _b.toUpperCase()) + "'";
1091
+ }
1092
+ else {
1093
+ id = (_c = s.findExpressionAfterToken("ID")) === null || _c === void 0 ? void 0 : _c.concatTokens();
1094
+ }
1095
+ if (s.findDirectExpression(Expressions.MessageTypeAndNumber)) {
1096
+ number = "'" + ((_d = s.findDirectExpression(Expressions.MessageTypeAndNumber)) === null || _d === void 0 ? void 0 : _d.concatTokens().substring(1)) + "'";
1097
+ }
1098
+ else {
1099
+ number = (_e = s.findExpressionAfterToken("NUMBER")) === null || _e === void 0 ? void 0 : _e.concatTokens();
1100
+ }
1091
1101
  startToken = node.getFirstToken();
1092
1102
  }
1093
- const className = ((_c = node.findDirectExpression(Expressions.ClassName)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "ERROR";
1103
+ const withs = ((_f = node.findDirectExpression(Expressions.RaiseWith)) === null || _f === void 0 ? void 0 : _f.findDirectExpressions(Expressions.Source)) || [];
1104
+ const className = ((_g = node.findDirectExpression(Expressions.ClassName)) === null || _g === void 0 ? void 0 : _g.concatTokens()) || "ERROR";
1094
1105
  const uniqueName1 = this.uniqueName(node.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
1095
1106
  const uniqueName2 = this.uniqueName(node.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
1096
1107
  const indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
1097
- const abap = `DATA ${uniqueName1} LIKE if_t100_message=>t100key.
1098
- ${indentation}${uniqueName1}-msgid = ${id === null || id === void 0 ? void 0 : id.toUpperCase()}.
1099
- ${indentation}${uniqueName1}-msgno = ${number}.
1100
- ${indentation}DATA ${uniqueName2} TYPE REF TO ${className}.
1101
- ${indentation}CREATE OBJECT ${uniqueName2} EXPORTING textid = ${uniqueName1}.
1102
- ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
1108
+ let abap = `DATA ${uniqueName1} LIKE if_t100_message=>t100key.
1109
+ ${indentation}${uniqueName1}-msgid = ${id}.
1110
+ ${indentation}${uniqueName1}-msgno = ${number}.\n`;
1111
+ if (withs.length > 0) {
1112
+ abap += `${indentation}${uniqueName1}-attr1 = 'IF_T100_DYN_MSG~MSGV1'.
1113
+ ${indentation}${uniqueName1}-attr2 = 'IF_T100_DYN_MSG~MSGV2'.
1114
+ ${indentation}${uniqueName1}-attr3 = 'IF_T100_DYN_MSG~MSGV3'.
1115
+ ${indentation}${uniqueName1}-attr4 = 'IF_T100_DYN_MSG~MSGV4'.\n`;
1116
+ }
1117
+ abap += `${indentation}DATA ${uniqueName2} TYPE REF TO ${className}.
1118
+ ${indentation}CREATE OBJECT ${uniqueName2} EXPORTING textid = ${uniqueName1}.\n`;
1119
+ if (withs.length > 0) {
1120
+ abap += `${indentation}${uniqueName2}->if_t100_dyn_msg~msgty = 'E'.\n`;
1121
+ }
1122
+ let count = 1;
1123
+ for (const w of withs) {
1124
+ abap += `${indentation}${uniqueName2}->if_t100_dyn_msg~msgv${count} = ${w.concatTokens()}.\n`;
1125
+ count++;
1126
+ }
1127
+ abap += `${indentation}RAISE EXCEPTION ${uniqueName2}.`;
1103
1128
  const fix = edit_helper_1.EditHelper.replaceRange(lowFile, node.getStart(), node.getEnd(), abap);
1104
1129
  return issue_1.Issue.atToken(lowFile, startToken, "Downport RAISE MESSAGE", this.getMetadata().key, this.conf.severity, fix);
1105
1130
  }
@@ -1569,50 +1594,36 @@ ${indentation}${uniqueName}`;
1569
1594
  }
1570
1595
  // must be very simple string templates, like "|{ ls_line-no ALPHA = IN }|"
1571
1596
  stringTemplateAlpha(low, high, lowFile, highSyntax) {
1572
- var _a, _b, _c;
1597
+ var _a, _b;
1573
1598
  if (!(low.get() instanceof _statement_1.Unknown)) {
1574
1599
  return undefined;
1575
1600
  }
1576
1601
  else if (!(high.get() instanceof Statements.Move)) {
1577
1602
  return undefined;
1578
1603
  }
1579
- const topSource = high.findDirectExpression(Expressions.Source);
1580
- if (topSource === undefined || topSource.getChildren().length !== 1) {
1581
- return undefined;
1582
- }
1583
- let top = true;
1584
- let child = topSource.getFirstChild();
1585
- if (!(child.get() instanceof Expressions.StringTemplate)) {
1586
- child = child.findFirstExpression(Expressions.StringTemplate);
1587
- top = false;
1588
- }
1589
- if (child === undefined || !(child.get() instanceof Expressions.StringTemplate)) {
1590
- return undefined;
1591
- }
1592
- const templateTokens = child.getChildren();
1593
- if (templateTokens.length !== 3
1594
- || templateTokens[0].getFirstToken().getStr() !== "|{"
1595
- || templateTokens[2].getFirstToken().getStr() !== "}|") {
1596
- return undefined;
1597
- }
1598
- const templateSource = child.findDirectExpression(Expressions.StringTemplateSource);
1599
- const formatting = (_a = templateSource === null || templateSource === void 0 ? void 0 : templateSource.findDirectExpression(Expressions.StringTemplateFormatting)) === null || _a === void 0 ? void 0 : _a.concatTokens();
1600
- let functionName = "";
1601
- switch (formatting) {
1602
- case "ALPHA = IN":
1603
- functionName = "CONVERSION_EXIT_ALPHA_INPUT";
1604
- break;
1605
- case "ALPHA = OUT":
1606
- functionName = "CONVERSION_EXIT_ALPHA_OUTPUT";
1607
- break;
1608
- default:
1604
+ for (const child of high.findAllExpressionsRecursive(Expressions.StringTemplate)) {
1605
+ const templateTokens = child.getChildren();
1606
+ if (templateTokens.length !== 3
1607
+ || templateTokens[0].getFirstToken().getStr() !== "|{"
1608
+ || templateTokens[2].getFirstToken().getStr() !== "}|") {
1609
1609
  return undefined;
1610
- }
1611
- const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
1612
- const source = (_b = templateSource === null || templateSource === void 0 ? void 0 : templateSource.findDirectExpression(Expressions.Source)) === null || _b === void 0 ? void 0 : _b.concatTokens();
1613
- const topTarget = (_c = high.findDirectExpression(Expressions.Target)) === null || _c === void 0 ? void 0 : _c.concatTokens();
1614
- const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
1615
- if (top === false) {
1610
+ }
1611
+ const templateSource = child.findDirectExpression(Expressions.StringTemplateSource);
1612
+ const formatting = (_a = templateSource === null || templateSource === void 0 ? void 0 : templateSource.findDirectExpression(Expressions.StringTemplateFormatting)) === null || _a === void 0 ? void 0 : _a.concatTokens();
1613
+ let functionName = "";
1614
+ switch (formatting) {
1615
+ case "ALPHA = IN":
1616
+ functionName = "CONVERSION_EXIT_ALPHA_INPUT";
1617
+ break;
1618
+ case "ALPHA = OUT":
1619
+ functionName = "CONVERSION_EXIT_ALPHA_OUTPUT";
1620
+ break;
1621
+ default:
1622
+ return undefined;
1623
+ }
1624
+ const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
1625
+ const source = (_b = templateSource === null || templateSource === void 0 ? void 0 : templateSource.findDirectExpression(Expressions.Source)) === null || _b === void 0 ? void 0 : _b.concatTokens();
1626
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
1616
1627
  const code = `DATA ${uniqueName} TYPE string.
1617
1628
  ${indentation}CALL FUNCTION '${functionName}'
1618
1629
  ${indentation} EXPORTING
@@ -1624,15 +1635,7 @@ ${indentation} output = ${uniqueName}.\n`;
1624
1635
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
1625
1636
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport ALPHA", this.getMetadata().key, this.conf.severity, fix);
1626
1637
  }
1627
- else {
1628
- const code = `CALL FUNCTION '${functionName}'
1629
- ${indentation} EXPORTING
1630
- ${indentation} input = ${source}
1631
- ${indentation} IMPORTING
1632
- ${indentation} output = ${topTarget}.`;
1633
- const fix = edit_helper_1.EditHelper.replaceRange(lowFile, high.getFirstToken().getStart(), high.getLastToken().getEnd(), code);
1634
- return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport ALPHA", this.getMetadata().key, this.conf.severity, fix);
1635
- }
1638
+ return undefined;
1636
1639
  }
1637
1640
  outlineLoopInput(low, high, lowFile, highSyntax) {
1638
1641
  if (!(low.get() instanceof _statement_1.Unknown)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.101.20",
3
+ "version": "2.101.22",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -50,14 +50,14 @@
50
50
  },
51
51
  "homepage": "https://abaplint.org",
52
52
  "devDependencies": {
53
- "@microsoft/api-extractor": "^7.35.3",
53
+ "@microsoft/api-extractor": "^7.35.4",
54
54
  "@types/chai": "^4.3.5",
55
55
  "@types/mocha": "^10.0.1",
56
56
  "@types/node": "^20.3.1",
57
57
  "chai": "^4.3.7",
58
- "eslint": "^8.42.0",
58
+ "eslint": "^8.43.0",
59
59
  "mocha": "^10.2.0",
60
- "c8": "^7.14.0",
60
+ "c8": "^8.0.0",
61
61
  "source-map-support": "^0.5.21",
62
62
  "ts-json-schema-generator": "^1.2.0",
63
63
  "typescript": "^5.1.3"