@abaplint/core 2.91.15 → 2.91.16

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.15";
71
+ return "2.91.16";
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
  }
@@ -63,6 +67,13 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
63
67
  }
64
68
  //////////////////
65
69
  walk(r, file) {
70
+ var _a, _b, _c, _d, _e, _f;
71
+ if (this.reg.getConfig().getVersion() !== version_1.Version.v702) {
72
+ if (r.findFirstExpression(Expressions.InlineData)) {
73
+ return undefined;
74
+ }
75
+ }
76
+ let previous = undefined;
66
77
  for (const c of r.getChildren()) {
67
78
  if (c instanceof nodes_1.StatementNode && c.get() instanceof _statement_1.Comment) {
68
79
  continue;
@@ -79,8 +90,24 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
79
90
  || c.get() instanceof Structures.Constants
80
91
  || c.get() instanceof Structures.Statics)) {
81
92
  if (this.mode === AFTER) {
93
+ // These are chained structured statements
94
+ let fix = undefined;
95
+ if (((_b = (_a = c.getLastChild()) === null || _a === void 0 ? void 0 : _a.getLastChild()) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr()) === "."
96
+ && !(previous instanceof nodes_1.StructureNode)
97
+ && this.moveTo) {
98
+ // this is not perfect, but will work for now
99
+ const start = (_d = (_c = c.getFirstChild()) === null || _c === void 0 ? void 0 : _c.getFirstChild()) === null || _d === void 0 ? void 0 : _d.getFirstToken().getStart();
100
+ const end = (_f = (_e = c.getLastChild()) === null || _e === void 0 ? void 0 : _e.getLastChild()) === null || _f === void 0 ? void 0 : _f.getLastToken().getEnd();
101
+ if (start && end) {
102
+ let concat = c.concatTokens();
103
+ concat = concat.replace(/,/g, ".\n");
104
+ const fix1 = edit_helper_1.EditHelper.deleteRange(file, start, end);
105
+ const fix2 = edit_helper_1.EditHelper.insertAt(file, this.moveTo, "\n" + concat);
106
+ fix = edit_helper_1.EditHelper.merge(fix1, fix2);
107
+ }
108
+ }
82
109
  // no quick fixes for these, its difficult?
83
- return issue_1.Issue.atStatement(file, c.getFirstStatement(), this.getMessage(), this.getMetadata().key, this.conf.severity);
110
+ return issue_1.Issue.atStatement(file, c.getFirstStatement(), this.getMessage(), this.getMetadata().key, this.conf.severity, fix);
84
111
  }
85
112
  else {
86
113
  this.moveTo = c.getLastToken().getEnd();
@@ -122,6 +149,7 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
122
149
  return found;
123
150
  }
124
151
  }
152
+ previous = c;
125
153
  }
126
154
  return undefined;
127
155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.91.15",
3
+ "version": "2.91.16",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",