@abaplint/core 2.93.77 → 2.93.78
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.
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +52 -3
- package/package.json +1 -1
package/build/src/registry.js
CHANGED
|
@@ -29,6 +29,12 @@ const _builtin_1 = require("../abap/5_syntax/_builtin");
|
|
|
29
29
|
class DownportConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
30
30
|
}
|
|
31
31
|
exports.DownportConf = DownportConf;
|
|
32
|
+
class SkipToNextFile extends Error {
|
|
33
|
+
constructor(issue) {
|
|
34
|
+
super();
|
|
35
|
+
this.issue = issue;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
32
38
|
class Downport {
|
|
33
39
|
constructor() {
|
|
34
40
|
this.conf = new DownportConf();
|
|
@@ -151,9 +157,20 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
151
157
|
if (highSyntax === undefined) {
|
|
152
158
|
highSyntax = new syntax_1.SyntaxLogic(this.highReg, highSyntaxObj).run();
|
|
153
159
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
160
|
+
try {
|
|
161
|
+
const issue = this.checkStatement(low, high, lowFile, highSyntax, highFile);
|
|
162
|
+
if (issue) {
|
|
163
|
+
ret.push(issue);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
if (e instanceof SkipToNextFile) {
|
|
168
|
+
ret.push(e.issue);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
throw e;
|
|
173
|
+
}
|
|
157
174
|
}
|
|
158
175
|
}
|
|
159
176
|
}
|
|
@@ -1894,6 +1911,9 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1894
1911
|
if (spag === undefined) {
|
|
1895
1912
|
continue;
|
|
1896
1913
|
}
|
|
1914
|
+
if (this.isDuplicateName(spag, name, c.getFirstToken().getStart())) {
|
|
1915
|
+
this.renameVariable(spag, name, c.getFirstToken().getStart(), lowFile, highSyntax);
|
|
1916
|
+
}
|
|
1897
1917
|
const found = spag.findVariable(name);
|
|
1898
1918
|
if (found === undefined) {
|
|
1899
1919
|
const source = f.findFirstExpression(Expressions.Source);
|
|
@@ -1911,6 +1931,35 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1911
1931
|
}
|
|
1912
1932
|
return ret;
|
|
1913
1933
|
}
|
|
1934
|
+
renameVariable(spag, name, pos, lowFile, highSyntax) {
|
|
1935
|
+
var _a, _b;
|
|
1936
|
+
const uniqueName = this.uniqueName(pos, lowFile.getFilename(), highSyntax);
|
|
1937
|
+
let fix = undefined;
|
|
1938
|
+
for (const r of spag.getData().references) {
|
|
1939
|
+
if (((_a = r.resolved) === null || _a === void 0 ? void 0 : _a.getName()) === name && ((_b = r.resolved) === null || _b === void 0 ? void 0 : _b.getStart().equals(pos))) {
|
|
1940
|
+
const replace = edit_helper_1.EditHelper.replaceRange(lowFile, r.position.getStart(), r.position.getEnd(), uniqueName);
|
|
1941
|
+
if (fix === undefined) {
|
|
1942
|
+
fix = replace;
|
|
1943
|
+
}
|
|
1944
|
+
else {
|
|
1945
|
+
fix = edit_helper_1.EditHelper.merge(replace, fix);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
const issue = issue_1.Issue.atPosition(lowFile, pos, "Rename before outline", this.getMetadata().key, this.conf.severity, fix);
|
|
1950
|
+
throw new SkipToNextFile(issue);
|
|
1951
|
+
}
|
|
1952
|
+
isDuplicateName(spag, name, pos) {
|
|
1953
|
+
var _a;
|
|
1954
|
+
let isDuplicate = false;
|
|
1955
|
+
for (const child of ((_a = spag.getParent()) === null || _a === void 0 ? void 0 : _a.getChildren()) || []) {
|
|
1956
|
+
const found = child.findVariable(name);
|
|
1957
|
+
if ((found === null || found === void 0 ? void 0 : found.getStart().equals(pos)) === false) {
|
|
1958
|
+
isDuplicate = true;
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
return isDuplicate;
|
|
1962
|
+
}
|
|
1914
1963
|
findType(i, lowFile, highSyntax, ref = false) {
|
|
1915
1964
|
var _a;
|
|
1916
1965
|
const expr = i.findDirectExpression(Expressions.TypeNameOrInfer);
|