@abaplint/core 2.95.44 → 2.95.46
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 +45 -9
- package/package.json +1 -1
package/build/src/registry.js
CHANGED
|
@@ -246,14 +246,16 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
246
246
|
// actively editing the files
|
|
247
247
|
continue;
|
|
248
248
|
}
|
|
249
|
+
if (highSyntax === undefined) {
|
|
250
|
+
highSyntax = new syntax_1.SyntaxLogic(this.highReg, highSyntaxObj).run();
|
|
251
|
+
}
|
|
252
|
+
let containsUnknown = false;
|
|
249
253
|
for (let i = 0; i < lowStatements.length; i++) {
|
|
250
254
|
const low = lowStatements[i];
|
|
251
255
|
const high = highStatements[i];
|
|
252
256
|
if ((low.get() instanceof _statement_1.Unknown && !(high.get() instanceof _statement_1.Unknown))
|
|
253
257
|
|| high.findFirstExpression(Expressions.InlineData)) {
|
|
254
|
-
|
|
255
|
-
highSyntax = new syntax_1.SyntaxLogic(this.highReg, highSyntaxObj).run();
|
|
256
|
-
}
|
|
258
|
+
containsUnknown = true;
|
|
257
259
|
try {
|
|
258
260
|
const issue = this.checkStatement(low, high, lowFile, highSyntax, highFile);
|
|
259
261
|
if (issue) {
|
|
@@ -271,6 +273,18 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
271
273
|
}
|
|
272
274
|
}
|
|
273
275
|
}
|
|
276
|
+
if (ret.length === 0 && containsUnknown) {
|
|
277
|
+
// this is a hack in order not to change too many unit tests
|
|
278
|
+
for (let i = 0; i < lowStatements.length; i++) {
|
|
279
|
+
const high = highStatements[i];
|
|
280
|
+
if (high.get() instanceof Statements.Data) {
|
|
281
|
+
const issue = this.anonymousTableType(high, lowFile, highSyntax);
|
|
282
|
+
if (issue) {
|
|
283
|
+
ret.push(issue);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
274
288
|
}
|
|
275
289
|
return ret;
|
|
276
290
|
}
|
|
@@ -684,6 +698,22 @@ ${indentation}`);
|
|
|
684
698
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
685
699
|
return issue_1.Issue.atToken(lowFile, inlineData.getFirstToken(), "Outline SELECT @DATA", this.getMetadata().key, this.conf.severity, fix);
|
|
686
700
|
}
|
|
701
|
+
// the anonymous type minght be used in inferred type statements, define it so it can be referred
|
|
702
|
+
anonymousTableType(high, lowFile, highSyntax) {
|
|
703
|
+
if (!(high.get() instanceof Statements.Data)) {
|
|
704
|
+
return undefined;
|
|
705
|
+
}
|
|
706
|
+
const tt = high.findFirstExpression(Expressions.TypeTable);
|
|
707
|
+
if (tt === undefined) {
|
|
708
|
+
return undefined;
|
|
709
|
+
}
|
|
710
|
+
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
711
|
+
const code = `TYPES ${uniqueName} ${tt.concatTokens()}.\n`;
|
|
712
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getStart(), code);
|
|
713
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, tt.getFirstToken().getStart(), tt.getLastToken().getEnd(), "TYPE " + uniqueName);
|
|
714
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
715
|
+
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Add type for table definition", this.getMetadata().key, this.conf.severity, fix);
|
|
716
|
+
}
|
|
687
717
|
downportMessage(high, lowFile, highSyntax) {
|
|
688
718
|
var _a, _b;
|
|
689
719
|
if (!(high.get() instanceof Statements.Message)) {
|
|
@@ -1876,7 +1906,12 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1876
1906
|
const s = (_a = init.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
1877
1907
|
const t = (_b = init.findFirstExpression(Expressions.TypeName)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
1878
1908
|
if (s) {
|
|
1879
|
-
|
|
1909
|
+
if (s.toUpperCase().startsWith("VALUE #")) {
|
|
1910
|
+
body += indentation + `DATA(${name}) = ${s.replace("#", type)}.\n`;
|
|
1911
|
+
}
|
|
1912
|
+
else {
|
|
1913
|
+
body += indentation + `DATA(${name}) = ${s}.\n`;
|
|
1914
|
+
}
|
|
1880
1915
|
}
|
|
1881
1916
|
else {
|
|
1882
1917
|
body += indentation + `DATA ${name} TYPE ${t}.\n`;
|
|
@@ -1931,6 +1966,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1931
1966
|
if (firstToken.getStr().toUpperCase() !== "VALUE") {
|
|
1932
1967
|
continue;
|
|
1933
1968
|
}
|
|
1969
|
+
const valueBody = s.findDirectExpression(Expressions.ValueBody);
|
|
1934
1970
|
let type = this.findType(s, lowFile, highSyntax);
|
|
1935
1971
|
if (type === undefined) {
|
|
1936
1972
|
if (high.get() instanceof Statements.Move && high.findDirectExpression(Expressions.Source) === s) {
|
|
@@ -1943,7 +1979,6 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1943
1979
|
else {
|
|
1944
1980
|
type = "TYPE " + type;
|
|
1945
1981
|
}
|
|
1946
|
-
const valueBody = s.findDirectExpression(Expressions.ValueBody);
|
|
1947
1982
|
const uniqueName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
|
|
1948
1983
|
let indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
1949
1984
|
let body = "";
|
|
@@ -1956,6 +1991,11 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1956
1991
|
let added = false;
|
|
1957
1992
|
let data = "";
|
|
1958
1993
|
let previous = undefined;
|
|
1994
|
+
if ((valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectExpression(Expressions.ValueBodyLine)) !== undefined) {
|
|
1995
|
+
structureName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
|
|
1996
|
+
const extra = (valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectExpression(Expressions.For)) ? " " : "";
|
|
1997
|
+
data = indentation + extra + `DATA ${structureName} LIKE LINE OF ${uniqueName}.\n`;
|
|
1998
|
+
}
|
|
1959
1999
|
for (const a of (valueBody === null || valueBody === void 0 ? void 0 : valueBody.getChildren()) || []) {
|
|
1960
2000
|
if (a.get() instanceof Expressions.FieldAssignment) {
|
|
1961
2001
|
if (added === false) {
|
|
@@ -1982,10 +2022,6 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1982
2022
|
if (a instanceof nodes_1.ExpressionNode && a.get() instanceof Expressions.ValueBodyLine) {
|
|
1983
2023
|
let skip = false;
|
|
1984
2024
|
for (const b of (a === null || a === void 0 ? void 0 : a.getChildren()) || []) {
|
|
1985
|
-
if (b.concatTokens() === "(" && added === false) {
|
|
1986
|
-
structureName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
|
|
1987
|
-
data = indentation + `DATA ${structureName} LIKE LINE OF ${uniqueName}.\n`;
|
|
1988
|
-
}
|
|
1989
2025
|
if (b.get() instanceof Expressions.FieldAssignment) {
|
|
1990
2026
|
if (added === false) {
|
|
1991
2027
|
body += data;
|