@abaplint/core 2.89.3 → 2.89.4
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 +43 -5
- package/package.json +1 -1
package/build/src/registry.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Downport = exports.DownportConf = void 0;
|
|
4
|
+
const Statements = require("../abap/2_statements/statements");
|
|
5
|
+
const Expressions = require("../abap/2_statements/expressions");
|
|
6
|
+
const Structures = require("../abap/3_structures/structures");
|
|
4
7
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
5
8
|
const issue_1 = require("../issue");
|
|
6
9
|
const _irule_1 = require("./_irule");
|
|
7
10
|
const _statement_1 = require("../abap/2_statements/statements/_statement");
|
|
8
11
|
const nodes_1 = require("../abap/nodes");
|
|
9
|
-
const Statements = require("../abap/2_statements/statements");
|
|
10
|
-
const Expressions = require("../abap/2_statements/expressions");
|
|
11
12
|
const edit_helper_1 = require("../edit_helper");
|
|
12
13
|
const position_1 = require("../position");
|
|
13
14
|
const _abap_object_1 = require("../objects/_abap_object");
|
|
@@ -61,6 +62,7 @@ Current rules:
|
|
|
61
62
|
* RAISE EXCEPTION ... MESSAGE
|
|
62
63
|
* Moving with +=, -=, /=, *=, &&= is expanded
|
|
63
64
|
* line_exists and line_index is downported to READ TABLE
|
|
65
|
+
* ENUMs, but does not nessesarily give the correct type and value
|
|
64
66
|
|
|
65
67
|
Only one transformation is applied to a statement at a time, so multiple steps might be required to do the full downport.`,
|
|
66
68
|
tags: [_irule_1.RuleTag.Experimental, _irule_1.RuleTag.Downport, _irule_1.RuleTag.Quickfix],
|
|
@@ -131,7 +133,7 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
131
133
|
const high = highStatements[i];
|
|
132
134
|
if ((low.get() instanceof _statement_1.Unknown && !(high.get() instanceof _statement_1.Unknown))
|
|
133
135
|
|| high.findFirstExpression(Expressions.InlineData)) {
|
|
134
|
-
const issue = this.checkStatement(low, high, lowFile, highSyntax);
|
|
136
|
+
const issue = this.checkStatement(low, high, lowFile, highSyntax, highFile);
|
|
135
137
|
if (issue) {
|
|
136
138
|
ret.push(issue);
|
|
137
139
|
}
|
|
@@ -163,11 +165,15 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
163
165
|
this.highReg.parse();
|
|
164
166
|
}
|
|
165
167
|
/** applies one rule at a time, multiple iterations are required to transform complex statements */
|
|
166
|
-
checkStatement(low, high, lowFile, highSyntax) {
|
|
168
|
+
checkStatement(low, high, lowFile, highSyntax, highFile) {
|
|
167
169
|
if (low.getFirstToken().getStart() instanceof position_1.VirtualPosition) {
|
|
168
170
|
return undefined;
|
|
169
171
|
}
|
|
170
|
-
let found = this.
|
|
172
|
+
let found = this.downportEnum(low, high, lowFile, highSyntax, highFile);
|
|
173
|
+
if (found) {
|
|
174
|
+
return found;
|
|
175
|
+
}
|
|
176
|
+
found = this.partiallyImplemented(high, lowFile);
|
|
171
177
|
if (found) {
|
|
172
178
|
return found;
|
|
173
179
|
}
|
|
@@ -738,6 +744,38 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
|
|
|
738
744
|
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
|
|
739
745
|
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, simple move", this.getMetadata().key, this.conf.severity, fix);
|
|
740
746
|
}
|
|
747
|
+
// note, downporting ENUM does not give the correct types, but it will work in most cases?
|
|
748
|
+
downportEnum(_low, high, lowFile, _highSyntax, highFile) {
|
|
749
|
+
var _a, _b, _c, _d, _e;
|
|
750
|
+
if (!(high.get() instanceof Statements.TypeEnumBegin)) {
|
|
751
|
+
return undefined;
|
|
752
|
+
}
|
|
753
|
+
const enumStructure = (_a = highFile.getStructure()) === null || _a === void 0 ? void 0 : _a.findFirstStructure(Structures.TypeEnum);
|
|
754
|
+
if (enumStructure === undefined) {
|
|
755
|
+
return undefined;
|
|
756
|
+
}
|
|
757
|
+
if (enumStructure.getFirstStatement() !== high) {
|
|
758
|
+
return undefined;
|
|
759
|
+
}
|
|
760
|
+
const enumName = (_b = high.findExpressionAfterToken("ENUM")) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
761
|
+
const structureName = (_c = high.findExpressionAfterToken("STRUCTURE")) === null || _c === void 0 ? void 0 : _c.concatTokens();
|
|
762
|
+
let code = `TYPES ${enumName} TYPE i.
|
|
763
|
+
CONSTANTS: BEGIN OF ${structureName},\n`;
|
|
764
|
+
let count = 1;
|
|
765
|
+
for (const e of enumStructure.findDirectStatements(Statements.TypeEnum).concat(enumStructure.findDirectStatements(Statements.Type))) {
|
|
766
|
+
const name = (_d = e.findFirstExpression(Expressions.NamespaceSimpleName)) === null || _d === void 0 ? void 0 : _d.concatTokens();
|
|
767
|
+
let value = (_e = e.findFirstExpression(Expressions.Value)) === null || _e === void 0 ? void 0 : _e.concatTokens();
|
|
768
|
+
if (value === undefined) {
|
|
769
|
+
value = "VALUE " + count++;
|
|
770
|
+
}
|
|
771
|
+
code += ` ${name} TYPE ${enumName} ${value},\n`;
|
|
772
|
+
}
|
|
773
|
+
code += ` END OF ${structureName}.`;
|
|
774
|
+
const start = enumStructure.getFirstToken().getStart();
|
|
775
|
+
const end = enumStructure.getLastToken().getEnd();
|
|
776
|
+
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
|
|
777
|
+
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport ENUM", this.getMetadata().key, this.conf.severity, fix);
|
|
778
|
+
}
|
|
741
779
|
moveWithTableTarget(node, high, lowFile, highSyntax) {
|
|
742
780
|
var _a;
|
|
743
781
|
if (!(high.get() instanceof Statements.Move)) {
|