@abaplint/core 2.91.15 → 2.91.18

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.
@@ -1475,6 +1475,7 @@ declare class Domain extends AbstractObject {
1475
1475
  private parsedType;
1476
1476
  getType(): string;
1477
1477
  getDescription(): string | undefined;
1478
+ getConversionExit(): string | undefined;
1478
1479
  getAllowedNaming(): {
1479
1480
  maxLength: number;
1480
1481
  allowNamespace: boolean;
@@ -13,6 +13,10 @@ class Domain extends _abstract_object_1.AbstractObject {
13
13
  var _a;
14
14
  return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.description;
15
15
  }
16
+ getConversionExit() {
17
+ var _a;
18
+ return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.conversionExit;
19
+ }
16
20
  getAllowedNaming() {
17
21
  return {
18
22
  maxLength: 30,
@@ -62,6 +66,7 @@ class Domain extends _abstract_object_1.AbstractObject {
62
66
  description: dd01v === null || dd01v === void 0 ? void 0 : dd01v.DDTEXT,
63
67
  datatype: dd01v === null || dd01v === void 0 ? void 0 : dd01v.DATATYPE,
64
68
  length: dd01v === null || dd01v === void 0 ? void 0 : dd01v.LENG,
69
+ conversionExit: dd01v === null || dd01v === void 0 ? void 0 : dd01v.CONVEXIT,
65
70
  decimals: dd01v === null || dd01v === void 0 ? void 0 : dd01v.DECIMALS,
66
71
  values: values,
67
72
  };
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.91.15";
71
+ return "2.91.18";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -4,12 +4,14 @@ exports.DefinitionsTop = exports.DefinitionsTopConf = void 0;
4
4
  const issue_1 = require("../issue");
5
5
  const _statement_1 = require("../abap/2_statements/statements/_statement");
6
6
  const Statements = require("../abap/2_statements/statements");
7
+ const Expressions = require("../abap/2_statements/expressions");
7
8
  const Structures = require("../abap/3_structures/structures");
8
9
  const _abap_rule_1 = require("./_abap_rule");
9
10
  const _basic_rule_config_1 = require("./_basic_rule_config");
10
11
  const _irule_1 = require("./_irule");
11
12
  const edit_helper_1 = require("../edit_helper");
12
13
  const nodes_1 = require("../abap/nodes");
14
+ const version_1 = require("../version");
13
15
  class DefinitionsTopConf extends _basic_rule_config_1.BasicRuleConfig {
14
16
  }
15
17
  exports.DefinitionsTopConf = DefinitionsTopConf;
@@ -28,7 +30,9 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
28
30
  key: "definitions_top",
29
31
  title: "Place definitions in top of routine",
30
32
  shortDescription: `Checks that definitions are placed at the beginning of METHODs and FORMs.`,
31
- extendedInformation: `https://docs.abapopenchecks.org/checks/17/`,
33
+ extendedInformation: `If the routine has inline definitions then no issues are reported
34
+
35
+ https://docs.abapopenchecks.org/checks/17/`,
32
36
  tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
33
37
  };
34
38
  }
@@ -48,12 +52,21 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
48
52
  if (structure === undefined) {
49
53
  return [];
50
54
  }
55
+ const containsUnknown = file.getStatements().some(s => s.get() instanceof _statement_1.Unknown);
56
+ if (containsUnknown === true) {
57
+ return [];
58
+ }
51
59
  const routines = structure.findAllStructures(Structures.Form).concat(structure.findAllStructures(Structures.Method));
52
60
  for (const r of routines) {
53
61
  // one fix per routine
54
62
  this.fixed = false;
55
63
  this.mode = DEFINITION;
56
64
  this.moveTo = (_a = r.getFirstStatement()) === null || _a === void 0 ? void 0 : _a.getLastToken().getEnd();
65
+ if (this.reg.getConfig().getVersion() !== version_1.Version.v702) {
66
+ if (r.findFirstExpression(Expressions.InlineData)) {
67
+ continue;
68
+ }
69
+ }
57
70
  const found = this.walk(r, file);
58
71
  if (found) {
59
72
  issues.push(found);
@@ -63,6 +76,8 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
63
76
  }
64
77
  //////////////////
65
78
  walk(r, file) {
79
+ var _a, _b, _c, _d, _e, _f;
80
+ let previous = undefined;
66
81
  for (const c of r.getChildren()) {
67
82
  if (c instanceof nodes_1.StatementNode && c.get() instanceof _statement_1.Comment) {
68
83
  continue;
@@ -79,8 +94,24 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
79
94
  || c.get() instanceof Structures.Constants
80
95
  || c.get() instanceof Structures.Statics)) {
81
96
  if (this.mode === AFTER) {
97
+ // These are chained structured statements
98
+ let fix = undefined;
99
+ if (((_b = (_a = c.getLastChild()) === null || _a === void 0 ? void 0 : _a.getLastChild()) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr()) === "."
100
+ && !(previous instanceof nodes_1.StructureNode)
101
+ && this.moveTo) {
102
+ // this is not perfect, but will work for now
103
+ const start = (_d = (_c = c.getFirstChild()) === null || _c === void 0 ? void 0 : _c.getFirstChild()) === null || _d === void 0 ? void 0 : _d.getFirstToken().getStart();
104
+ const end = (_f = (_e = c.getLastChild()) === null || _e === void 0 ? void 0 : _e.getLastChild()) === null || _f === void 0 ? void 0 : _f.getLastToken().getEnd();
105
+ if (start && end) {
106
+ let concat = c.concatTokens();
107
+ concat = concat.replace(/,/g, ".\n");
108
+ const fix1 = edit_helper_1.EditHelper.deleteRange(file, start, end);
109
+ const fix2 = edit_helper_1.EditHelper.insertAt(file, this.moveTo, "\n" + concat);
110
+ fix = edit_helper_1.EditHelper.merge(fix1, fix2);
111
+ }
112
+ }
82
113
  // no quick fixes for these, its difficult?
83
- return issue_1.Issue.atStatement(file, c.getFirstStatement(), this.getMessage(), this.getMetadata().key, this.conf.severity);
114
+ return issue_1.Issue.atStatement(file, c.getFirstStatement(), this.getMessage(), this.getMetadata().key, this.conf.severity, fix);
84
115
  }
85
116
  else {
86
117
  this.moveTo = c.getLastToken().getEnd();
@@ -122,6 +153,7 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
122
153
  return found;
123
154
  }
124
155
  }
156
+ previous = c;
125
157
  }
126
158
  return undefined;
127
159
  }
@@ -1342,7 +1342,7 @@ ${indentation} output = ${topTarget}.`;
1342
1342
  return undefined;
1343
1343
  }
1344
1344
  outlineValue(node, lowFile, highSyntax) {
1345
- var _a;
1345
+ var _a, _b, _c;
1346
1346
  const allSources = node.findAllExpressionsRecursive(Expressions.Source);
1347
1347
  for (const s of allSources) {
1348
1348
  const firstToken = s.getFirstToken();
@@ -1421,6 +1421,36 @@ ${indentation} output = ${topTarget}.`;
1421
1421
  }
1422
1422
  previous = b;
1423
1423
  }
1424
+ if (body === "" && ((_b = valueBody === null || valueBody === void 0 ? void 0 : valueBody.getLastChild()) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr().toUpperCase()) === "OPTIONAL") {
1425
+ const fieldChain = valueBody.findFirstExpression(Expressions.FieldChain);
1426
+ const rowName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
1427
+ let tableExpression = undefined;
1428
+ let tabName = "";
1429
+ let after = "";
1430
+ for (const c of (fieldChain === null || fieldChain === void 0 ? void 0 : fieldChain.getChildren()) || []) {
1431
+ if (c.get() instanceof Expressions.TableExpression && c instanceof nodes_1.ExpressionNode) {
1432
+ tableExpression = c;
1433
+ }
1434
+ else if (tableExpression === undefined) {
1435
+ tabName += c.concatTokens();
1436
+ }
1437
+ else {
1438
+ after += c.concatTokens();
1439
+ }
1440
+ }
1441
+ let condition = "";
1442
+ if ((tableExpression === null || tableExpression === void 0 ? void 0 : tableExpression.getChildren().length) === 3) {
1443
+ condition = "INDEX " + ((_c = tableExpression === null || tableExpression === void 0 ? void 0 : tableExpression.findDirectExpression(Expressions.Source)) === null || _c === void 0 ? void 0 : _c.concatTokens());
1444
+ }
1445
+ else {
1446
+ condition = "WITH KEY " + (tableExpression === null || tableExpression === void 0 ? void 0 : tableExpression.concatTokens().replace("[ ", "").replace(" ]", ""));
1447
+ }
1448
+ body +=
1449
+ indentation + `READ TABLE ${tabName} INTO DATA(${rowName}) ${condition}.\n` +
1450
+ indentation + `IF sy-subrc = 0.\n` +
1451
+ indentation + ` ${uniqueName} = ${rowName}${after}.\n` +
1452
+ indentation + `ENDIF.\n`;
1453
+ }
1424
1454
  if (end !== "") {
1425
1455
  indentation = indentation.substring(2);
1426
1456
  body += indentation + end;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.91.15",
3
+ "version": "2.91.18",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -48,7 +48,7 @@
48
48
  "@microsoft/api-extractor": "^7.28.6",
49
49
  "@types/chai": "^4.3.1",
50
50
  "@types/mocha": "^9.1.1",
51
- "@types/node": "^18.6.1",
51
+ "@types/node": "^18.6.2",
52
52
  "chai": "^4.3.6",
53
53
  "eslint": "^8.20.0",
54
54
  "mocha": "^10.0.0",