@abaplint/core 2.89.3 → 2.89.6
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/abaplint.d.ts +1 -1
- package/build/src/abap/5_syntax/_current_scope.js +2 -2
- package/build/src/abap/5_syntax/basic_types.js +8 -2
- package/build/src/abap/5_syntax/expressions/source.js +5 -1
- package/build/src/abap/5_syntax/expressions/value_body.js +3 -0
- package/build/src/ddic.js +6 -6
- package/build/src/registry.js +1 -1
- package/build/src/rules/definitions_top.js +8 -4
- package/build/src/rules/downport.js +46 -5
- package/package.json +1 -1
package/build/abaplint.d.ts
CHANGED
|
@@ -1144,7 +1144,7 @@ export declare class CurrentScope {
|
|
|
1144
1144
|
/** Lookup class in local and global scope */
|
|
1145
1145
|
findClassDefinition(name: string | undefined): IClassDefinition | undefined;
|
|
1146
1146
|
findTypePoolConstant(name: string | undefined): TypedIdentifier | undefined;
|
|
1147
|
-
findTypePoolType(name: string):
|
|
1147
|
+
findTypePoolType(name: string): TypedIdentifier | undefined;
|
|
1148
1148
|
/** Lookup interface in local and global scope */
|
|
1149
1149
|
findInterfaceDefinition(name: string): IInterfaceDefinition | undefined;
|
|
1150
1150
|
findFormDefinition(name: string): IFormDefinition | undefined;
|
|
@@ -220,7 +220,7 @@ class CurrentScope {
|
|
|
220
220
|
return found;
|
|
221
221
|
}
|
|
222
222
|
findTypePoolType(name) {
|
|
223
|
-
var _a
|
|
223
|
+
var _a;
|
|
224
224
|
if (name.includes("_") === undefined) {
|
|
225
225
|
return undefined;
|
|
226
226
|
}
|
|
@@ -230,7 +230,7 @@ class CurrentScope {
|
|
|
230
230
|
return undefined;
|
|
231
231
|
}
|
|
232
232
|
const spag = (_a = new syntax_1.SyntaxLogic(this.reg, typePool).run().spaghetti.getFirstChild()) === null || _a === void 0 ? void 0 : _a.getFirstChild();
|
|
233
|
-
const found =
|
|
233
|
+
const found = spag === null || spag === void 0 ? void 0 : spag.findType(name);
|
|
234
234
|
return found;
|
|
235
235
|
}
|
|
236
236
|
/** Lookup interface in local and global scope */
|
|
@@ -52,6 +52,10 @@ class BasicTypes {
|
|
|
52
52
|
if (builtin) {
|
|
53
53
|
return new _typed_identifier_1.TypedIdentifier(new identifier_1.Identifier(new position_1.Position(1, 1), name), _builtin_1.BuiltIn.filename, builtin);
|
|
54
54
|
}
|
|
55
|
+
const type = this.scope.findTypePoolType(name);
|
|
56
|
+
if (type) {
|
|
57
|
+
return type;
|
|
58
|
+
}
|
|
55
59
|
return undefined;
|
|
56
60
|
}
|
|
57
61
|
resolveLikeName(node, headerLogic = true) {
|
|
@@ -145,6 +149,7 @@ class BasicTypes {
|
|
|
145
149
|
return type;
|
|
146
150
|
}
|
|
147
151
|
resolveTypeName(typeName, length, decimals, name) {
|
|
152
|
+
var _a;
|
|
148
153
|
if (typeName === undefined) {
|
|
149
154
|
return undefined;
|
|
150
155
|
}
|
|
@@ -170,7 +175,7 @@ class BasicTypes {
|
|
|
170
175
|
this.scope.addReference(token, typ, _reference_1.ReferenceType.TypeReference, this.filename);
|
|
171
176
|
return typ.getType();
|
|
172
177
|
}
|
|
173
|
-
const type = this.scope.findTypePoolType(chainText);
|
|
178
|
+
const type = (_a = this.scope.findTypePoolType(chainText)) === null || _a === void 0 ? void 0 : _a.getType();
|
|
174
179
|
if (type) {
|
|
175
180
|
// this.scope.addReference(typeName.getFirstToken(), type, ReferenceType.TypeReference, this.filename);
|
|
176
181
|
return type;
|
|
@@ -445,6 +450,7 @@ class BasicTypes {
|
|
|
445
450
|
/////////////////////
|
|
446
451
|
// todo, rewrite this method
|
|
447
452
|
resolveTypeChain(expr) {
|
|
453
|
+
var _a;
|
|
448
454
|
const chainText = expr.concatTokens().toUpperCase();
|
|
449
455
|
if (chainText.includes("=>") === false && chainText.includes("-") === false) {
|
|
450
456
|
return undefined;
|
|
@@ -496,7 +502,7 @@ class BasicTypes {
|
|
|
496
502
|
const found = this.scope.findType(subs[0]);
|
|
497
503
|
foundType = found === null || found === void 0 ? void 0 : found.getType();
|
|
498
504
|
if (foundType === undefined) {
|
|
499
|
-
const typePoolType = this.scope.findTypePoolType(subs[0]);
|
|
505
|
+
const typePoolType = (_a = this.scope.findTypePoolType(subs[0])) === null || _a === void 0 ? void 0 : _a.getType();
|
|
500
506
|
if (typePoolType) {
|
|
501
507
|
// this.scope.addReference(typeName.getFirstToken(), typePoolType, ReferenceType.TypeReference, this.filename);
|
|
502
508
|
foundType = typePoolType;
|
|
@@ -120,7 +120,11 @@ class Source {
|
|
|
120
120
|
case "VALUE":
|
|
121
121
|
{
|
|
122
122
|
const foundType = this.determineType(node, scope, filename, targetType);
|
|
123
|
-
|
|
123
|
+
const bodyType = new value_body_1.ValueBody().runSyntax(node.findDirectExpression(Expressions.ValueBody), scope, filename, foundType);
|
|
124
|
+
if (foundType === undefined || foundType.isGeneric()) {
|
|
125
|
+
this.addIfInferred(node, scope, filename, bodyType);
|
|
126
|
+
}
|
|
127
|
+
return foundType ? foundType : bodyType;
|
|
124
128
|
}
|
|
125
129
|
default:
|
|
126
130
|
return new unknown_type_1.UnknownType("todo, Source type " + tok);
|
|
@@ -33,6 +33,9 @@ class ValueBody {
|
|
|
33
33
|
while (scope.getType() === _scope_type_1.ScopeType.For) {
|
|
34
34
|
scope.pop(node.getLastToken().getEnd());
|
|
35
35
|
}
|
|
36
|
+
if ((targetType === null || targetType === void 0 ? void 0 : targetType.isGeneric()) && type) {
|
|
37
|
+
return type;
|
|
38
|
+
}
|
|
36
39
|
return targetType ? targetType : type;
|
|
37
40
|
}
|
|
38
41
|
}
|
package/build/src/ddic.js
CHANGED
|
@@ -46,13 +46,13 @@ class DDIC {
|
|
|
46
46
|
lookupBuiltinType(name, length, decimals, qualifiedName) {
|
|
47
47
|
switch (name) {
|
|
48
48
|
case "STRING":
|
|
49
|
-
return new Types.StringType(name);
|
|
49
|
+
return new Types.StringType(qualifiedName || name);
|
|
50
50
|
case "XSTRING":
|
|
51
|
-
return new Types.XStringType(name);
|
|
51
|
+
return new Types.XStringType(qualifiedName || name);
|
|
52
52
|
case "D":
|
|
53
|
-
return new Types.DateType(name);
|
|
53
|
+
return new Types.DateType(qualifiedName || name);
|
|
54
54
|
case "T":
|
|
55
|
-
return new Types.TimeType(name);
|
|
55
|
+
return new Types.TimeType(qualifiedName || name);
|
|
56
56
|
case "XSEQUENCE":
|
|
57
57
|
return new Types.XSequenceType(qualifiedName);
|
|
58
58
|
case "CLIKE":
|
|
@@ -81,9 +81,9 @@ class DDIC {
|
|
|
81
81
|
return new Types.CSequenceType(qualifiedName);
|
|
82
82
|
case "I":
|
|
83
83
|
case "INT8": // todo, take version into account
|
|
84
|
-
return new Types.IntegerType(name);
|
|
84
|
+
return new Types.IntegerType(qualifiedName || name);
|
|
85
85
|
case "F":
|
|
86
|
-
return new Types.FloatType(name);
|
|
86
|
+
return new Types.FloatType(qualifiedName || name);
|
|
87
87
|
case "P":
|
|
88
88
|
if (length && decimals) {
|
|
89
89
|
return new Types.PackedType(length, decimals, qualifiedName);
|
package/build/src/registry.js
CHANGED
|
@@ -42,6 +42,7 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
|
|
|
42
42
|
this.conf = conf;
|
|
43
43
|
}
|
|
44
44
|
runParsed(file) {
|
|
45
|
+
var _a;
|
|
45
46
|
const issues = [];
|
|
46
47
|
const structure = file.getStructure();
|
|
47
48
|
if (structure === undefined) {
|
|
@@ -52,7 +53,7 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
|
|
|
52
53
|
// one fix per routine
|
|
53
54
|
this.fixed = false;
|
|
54
55
|
this.mode = DEFINITION;
|
|
55
|
-
this.moveTo = r.getFirstStatement();
|
|
56
|
+
this.moveTo = (_a = r.getFirstStatement()) === null || _a === void 0 ? void 0 : _a.getLastToken().getEnd();
|
|
56
57
|
const found = this.walk(r, file);
|
|
57
58
|
if (found) {
|
|
58
59
|
issues.push(found);
|
|
@@ -81,6 +82,9 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
|
|
|
81
82
|
// no quick fixes for these, its difficult?
|
|
82
83
|
return issue_1.Issue.atStatement(file, c.getFirstStatement(), this.getMessage(), this.getMetadata().key, this.conf.severity);
|
|
83
84
|
}
|
|
85
|
+
else {
|
|
86
|
+
this.moveTo = c.getLastToken().getEnd();
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
else if (c instanceof nodes_1.StatementNode
|
|
86
90
|
&& (c.get() instanceof Statements.Data
|
|
@@ -98,7 +102,7 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
|
|
|
98
102
|
return issue_1.Issue.atStatement(file, c, this.getMessage(), this.getMetadata().key, this.conf.severity, fix);
|
|
99
103
|
}
|
|
100
104
|
else {
|
|
101
|
-
this.moveTo = c;
|
|
105
|
+
this.moveTo = c.getLastToken().getEnd();
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
else if (c instanceof nodes_1.StructureNode && c.get() instanceof Structures.Define) {
|
|
@@ -121,12 +125,12 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
|
|
|
121
125
|
}
|
|
122
126
|
return undefined;
|
|
123
127
|
}
|
|
124
|
-
buildFix(file, statement,
|
|
128
|
+
buildFix(file, statement, at) {
|
|
125
129
|
let concat = statement.concatTokens();
|
|
126
130
|
concat = concat.replace(/,$/, ".");
|
|
127
131
|
const fix1 = edit_helper_1.EditHelper.deleteStatement(file, statement);
|
|
128
132
|
const indentation = " ".repeat(statement.getFirstToken().getCol() - 1);
|
|
129
|
-
const fix2 = edit_helper_1.EditHelper.insertAt(file,
|
|
133
|
+
const fix2 = edit_helper_1.EditHelper.insertAt(file, at, "\n" + indentation + concat);
|
|
130
134
|
return edit_helper_1.EditHelper.merge(fix1, fix2);
|
|
131
135
|
}
|
|
132
136
|
}
|
|
@@ -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)) {
|
|
@@ -1164,6 +1202,9 @@ ${indentation} output = ${topTarget}.`;
|
|
|
1164
1202
|
}
|
|
1165
1203
|
else if (b.get() instanceof Expressions.Source) {
|
|
1166
1204
|
structureName = b.concatTokens();
|
|
1205
|
+
if (base && (valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectTokenByText("(")) === undefined) {
|
|
1206
|
+
structureName = uniqueName;
|
|
1207
|
+
}
|
|
1167
1208
|
}
|
|
1168
1209
|
else if (b.get() instanceof Expressions.ValueBodyLines) {
|
|
1169
1210
|
body += indentation + "APPEND " + b.concatTokens() + ` TO ${uniqueName}.\n`;
|