@abaplint/core 2.93.76 → 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/lsp/_lsp_utils.js +11 -15
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +52 -3
- package/package.json +1 -1
|
@@ -6,22 +6,18 @@ const _identifier_1 = require("../abap/4_file_information/_identifier");
|
|
|
6
6
|
const _abap_object_1 = require("../objects/_abap_object");
|
|
7
7
|
const position_1 = require("../position");
|
|
8
8
|
const LServer = require("vscode-languageserver-types");
|
|
9
|
-
function getABAPObjects(reg) {
|
|
10
|
-
const ret = [];
|
|
11
|
-
for (const o of reg.getObjects()) {
|
|
12
|
-
if (o instanceof _abap_object_1.ABAPObject) {
|
|
13
|
-
ret.push(o);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return ret;
|
|
17
|
-
}
|
|
18
9
|
class LSPUtils {
|
|
19
|
-
static getABAPFile(reg,
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
static getABAPFile(reg, filename) {
|
|
11
|
+
const file = reg.getFileByName(filename);
|
|
12
|
+
if (file === undefined) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const obj = reg.findObjectForFile(file);
|
|
16
|
+
obj === null || obj === void 0 ? void 0 : obj.parse();
|
|
17
|
+
if (obj instanceof _abap_object_1.ABAPObject) {
|
|
18
|
+
for (const abapfile of obj.getABAPFiles()) {
|
|
19
|
+
if (abapfile.getFilename().toUpperCase() === filename.toUpperCase()) {
|
|
20
|
+
return abapfile;
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
}
|
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);
|