@abaplint/core 2.86.5 → 2.86.8

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.86.5";
71
+ return "2.86.8";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -56,6 +56,7 @@ class DoubleSpace extends _abap_rule_1.ABAPRule {
56
56
  && !(s.get() instanceof _statement_1.Unknown)
57
57
  && !(s.get() instanceof statements_1.MethodDef)
58
58
  && !(s.get() instanceof _statement_1.MacroCall)
59
+ && !(s.get() instanceof statements_1.Events)
59
60
  && !(s.get() instanceof _statement_1.MacroContent)) {
60
61
  issues = issues.concat(this.checkKeywords(s, file));
61
62
  }
@@ -267,6 +267,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
267
267
  if (found) {
268
268
  return found;
269
269
  }
270
+ found = this.replaceMethodConditional(high, lowFile, highSyntax);
271
+ if (found) {
272
+ return found;
273
+ }
270
274
  found = this.replaceTableExpression(high, lowFile, highSyntax);
271
275
  if (found) {
272
276
  return found;
@@ -511,16 +515,29 @@ ${indentation}`);
511
515
  }
512
516
  tableCondition(tableExpression) {
513
517
  let condition = "";
518
+ let keyName = "";
514
519
  for (const c of tableExpression.getChildren() || []) {
515
520
  if (c.getFirstToken().getStr() === "[" || c.getFirstToken().getStr() === "]") {
516
521
  continue;
517
522
  }
518
523
  else if (c.get() instanceof Expressions.ComponentChainSimple && condition === "") {
519
- condition = "WITH KEY ";
524
+ if (keyName === "") {
525
+ condition = "WITH KEY ";
526
+ }
527
+ else {
528
+ condition = "WITH TABLE KEY " + keyName + " COMPONENTS ";
529
+ }
520
530
  }
521
531
  else if (c.get() instanceof Expressions.Source && condition === "") {
522
532
  condition = "INDEX ";
523
533
  }
534
+ else if (c instanceof nodes_1.TokenNode && c.getFirstToken().getStr().toUpperCase() === "KEY") {
535
+ continue;
536
+ }
537
+ else if (c.get() instanceof Expressions.SimpleName) {
538
+ keyName = c.concatTokens();
539
+ continue;
540
+ }
524
541
  condition += c.concatTokens() + " ";
525
542
  }
526
543
  return condition;
@@ -1139,6 +1156,7 @@ ${indentation} output = ${topTarget}.`;
1139
1156
  body += indentation + end;
1140
1157
  }
1141
1158
  const abap = `DATA ${uniqueName} ${type}.\n` +
1159
+ indentation + `CLEAR ${uniqueName}.\n` + // might be called inside a loop
1142
1160
  body +
1143
1161
  indentation;
1144
1162
  const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), abap);
@@ -1307,6 +1325,7 @@ ${indentation} output = ${topTarget}.`;
1307
1325
  buildCondBody(body, uniqueName, indent, lowFile, highSyntax) {
1308
1326
  let code = "";
1309
1327
  let first = true;
1328
+ let addElse = true;
1310
1329
  for (const c of body.getChildren()) {
1311
1330
  if (c instanceof nodes_1.TokenNode) {
1312
1331
  switch (c.getFirstToken().getStr().toUpperCase()) {
@@ -1324,6 +1343,7 @@ ${indentation} output = ${topTarget}.`;
1324
1343
  break;
1325
1344
  case "ELSE":
1326
1345
  code += indent + "ELSE.\n";
1346
+ addElse = false;
1327
1347
  break;
1328
1348
  default:
1329
1349
  throw "buildCondBody, unexpected token";
@@ -1342,6 +1362,11 @@ ${indentation} output = ${topTarget}.`;
1342
1362
  throw "buildCondBody, unexpected expression, " + c.get().constructor.name;
1343
1363
  }
1344
1364
  }
1365
+ if (addElse) {
1366
+ // COND might be called inside a loop
1367
+ code += indent + "ELSE.\n";
1368
+ code += indent + ` CLEAR ${uniqueName}.\n`;
1369
+ }
1345
1370
  code += indent + "ENDIF.\n";
1346
1371
  code += indent;
1347
1372
  return code;
@@ -1428,6 +1453,18 @@ ${indentation} output = ${topTarget}.`;
1428
1453
  }
1429
1454
  return undefined;
1430
1455
  }
1456
+ replaceMethodConditional(node, lowFile, _highSyntax) {
1457
+ for (const c of node.findAllExpressionsRecursive(Expressions.Compare)) {
1458
+ const chain = c.findDirectExpression(Expressions.MethodCallChain);
1459
+ if (chain === undefined) {
1460
+ continue;
1461
+ }
1462
+ const end = chain.getLastToken().getEnd();
1463
+ const fix = edit_helper_1.EditHelper.insertAt(lowFile, end, " IS NOT INITIAL");
1464
+ return issue_1.Issue.atToken(lowFile, chain.getFirstToken(), "Downport method conditional", this.getMetadata().key, this.conf.severity, fix);
1465
+ }
1466
+ return undefined;
1467
+ }
1431
1468
  replaceContains(node, lowFile, highSyntax) {
1432
1469
  const spag = highSyntax.spaghetti.lookupPosition(node.getFirstToken().getStart(), lowFile.getFilename());
1433
1470
  // only downport if its an single method call condition
@@ -141,12 +141,16 @@ class KeywordCase extends _abap_rule_1.ABAPRule {
141
141
  }
142
142
  }
143
143
  const skip = new Skip(this.getConfig());
144
+ let prev = undefined;
144
145
  for (const statement of file.getStatements()) {
145
146
  if (skip.skipStatement(statement) === true) {
146
147
  continue;
147
148
  }
148
149
  let result = this.traverse(statement, statement.get());
149
150
  if (result.length > 0) {
151
+ if (prev && result[0].token.getStart().equals(prev.getStart())) {
152
+ continue;
153
+ }
150
154
  if (statement.getColon() !== undefined) {
151
155
  // if its a chained statement, go token by token
152
156
  result = [result[0]];
@@ -156,6 +160,7 @@ class KeywordCase extends _abap_rule_1.ABAPRule {
156
160
  if (issues.length > MAX_ISSUES) {
157
161
  break;
158
162
  }
163
+ prev = result[0].token;
159
164
  }
160
165
  }
161
166
  return issues;
@@ -20,7 +20,7 @@ class UnsecureFAE {
20
20
  title: "Unsecure FAE",
21
21
  shortDescription: `Checks for unsecure FAE`,
22
22
  extendedInformation: `Issues from rule check_syntax must be fixed before this rule takes effect`,
23
- tags: [_irule_1.RuleTag.Experimental],
23
+ tags: [_irule_1.RuleTag.Experimental, _irule_1.RuleTag.Performance],
24
24
  };
25
25
  }
26
26
  getConfig() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.86.5",
3
+ "version": "2.86.8",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",