@abaplint/core 2.85.15 → 2.85.19
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 +9 -0
- package/build/src/abap/5_syntax/_builtin.js +6 -6
- package/build/src/abap/5_syntax/_scope_type.js +1 -0
- package/build/src/abap/5_syntax/_type_utils.js +7 -4
- package/build/src/abap/5_syntax/expressions/cond_body.js +5 -1
- package/build/src/abap/5_syntax/expressions/conv_body.js +5 -1
- package/build/src/abap/5_syntax/expressions/for.js +4 -4
- package/build/src/abap/5_syntax/expressions/inline_field_definition.js +8 -3
- package/build/src/abap/5_syntax/expressions/let.js +4 -1
- package/build/src/abap/5_syntax/expressions/raise_with.js +14 -0
- package/build/src/abap/5_syntax/expressions/value_body.js +8 -4
- package/build/src/abap/5_syntax/statements/raise.js +4 -0
- package/build/src/objects/number_range.js +36 -2
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +95 -27
- package/build/src/rules/function_module_recommendations.js +3 -1
- package/build/src/rules/superclass_final.js +6 -2
- package/build/src/rules/use_new.js +3 -1
- package/build/src/version.js +1 -1
- package/package.json +5 -5
package/build/abaplint.d.ts
CHANGED
|
@@ -3824,11 +3824,19 @@ declare class Normal implements IStructure {
|
|
|
3824
3824
|
}
|
|
3825
3825
|
|
|
3826
3826
|
declare class NumberRange extends AbstractObject {
|
|
3827
|
+
private parsedXML;
|
|
3827
3828
|
getType(): string;
|
|
3828
3829
|
getAllowedNaming(): {
|
|
3829
3830
|
maxLength: number;
|
|
3830
3831
|
allowNamespace: boolean;
|
|
3831
3832
|
};
|
|
3833
|
+
getDomain(): string | undefined;
|
|
3834
|
+
getPercentage(): number | undefined;
|
|
3835
|
+
setDirty(): void;
|
|
3836
|
+
parse(): {
|
|
3837
|
+
updated: boolean;
|
|
3838
|
+
runtime: number;
|
|
3839
|
+
};
|
|
3832
3840
|
getDescription(): string | undefined;
|
|
3833
3841
|
}
|
|
3834
3842
|
|
|
@@ -4547,6 +4555,7 @@ export declare enum ScopeType {
|
|
|
4547
4555
|
Method = "method",
|
|
4548
4556
|
MethodInstance = "method_instance",
|
|
4549
4557
|
For = "for",
|
|
4558
|
+
Let = "let",
|
|
4550
4559
|
OpenSQL = "open_sql"
|
|
4551
4560
|
}
|
|
4552
4561
|
|
|
@@ -887,14 +887,14 @@ BuiltIn.methods = [
|
|
|
887
887
|
{
|
|
888
888
|
name: "STRLEN",
|
|
889
889
|
mandatory: {
|
|
890
|
-
"val": new basic_1.
|
|
890
|
+
"val": new basic_1.CLikeType(),
|
|
891
891
|
},
|
|
892
892
|
return: new basic_1.IntegerType(),
|
|
893
893
|
},
|
|
894
894
|
{
|
|
895
895
|
name: "SUBSTRING",
|
|
896
896
|
mandatory: {
|
|
897
|
-
"val": new basic_1.
|
|
897
|
+
"val": new basic_1.CLikeType(),
|
|
898
898
|
},
|
|
899
899
|
optional: {
|
|
900
900
|
"off": new basic_1.IntegerType(),
|
|
@@ -906,7 +906,7 @@ BuiltIn.methods = [
|
|
|
906
906
|
{
|
|
907
907
|
name: "SUBSTRING_AFTER",
|
|
908
908
|
mandatory: {
|
|
909
|
-
"val": new basic_1.
|
|
909
|
+
"val": new basic_1.CLikeType(),
|
|
910
910
|
},
|
|
911
911
|
optional: {
|
|
912
912
|
"sub": new basic_1.StringType(),
|
|
@@ -922,7 +922,7 @@ BuiltIn.methods = [
|
|
|
922
922
|
{
|
|
923
923
|
name: "SUBSTRING_BEFORE",
|
|
924
924
|
mandatory: {
|
|
925
|
-
"val": new basic_1.
|
|
925
|
+
"val": new basic_1.CLikeType(),
|
|
926
926
|
},
|
|
927
927
|
optional: {
|
|
928
928
|
"sub": new basic_1.StringType(),
|
|
@@ -938,7 +938,7 @@ BuiltIn.methods = [
|
|
|
938
938
|
{
|
|
939
939
|
name: "SUBSTRING_FROM",
|
|
940
940
|
mandatory: {
|
|
941
|
-
"val": new basic_1.
|
|
941
|
+
"val": new basic_1.CLikeType(),
|
|
942
942
|
},
|
|
943
943
|
optional: {
|
|
944
944
|
"sub": new basic_1.StringType(),
|
|
@@ -954,7 +954,7 @@ BuiltIn.methods = [
|
|
|
954
954
|
{
|
|
955
955
|
name: "SUBSTRING_TO",
|
|
956
956
|
mandatory: {
|
|
957
|
-
"val": new basic_1.
|
|
957
|
+
"val": new basic_1.CLikeType(),
|
|
958
958
|
},
|
|
959
959
|
optional: {
|
|
960
960
|
"sub": new basic_1.StringType(),
|
|
@@ -17,6 +17,7 @@ var ScopeType;
|
|
|
17
17
|
ScopeType["Method"] = "method";
|
|
18
18
|
ScopeType["MethodInstance"] = "method_instance";
|
|
19
19
|
ScopeType["For"] = "for";
|
|
20
|
+
ScopeType["Let"] = "let";
|
|
20
21
|
ScopeType["OpenSQL"] = "open_sql";
|
|
21
22
|
})(ScopeType = exports.ScopeType || (exports.ScopeType = {}));
|
|
22
23
|
//# sourceMappingURL=_scope_type.js.map
|
|
@@ -78,7 +78,8 @@ class TypeUtils {
|
|
|
78
78
|
}
|
|
79
79
|
return false;
|
|
80
80
|
}
|
|
81
|
-
else if (target instanceof basic_1.ObjectReferenceType
|
|
81
|
+
else if (target instanceof basic_1.ObjectReferenceType
|
|
82
|
+
|| target instanceof basic_1.GenericObjectReferenceType) {
|
|
82
83
|
if (source instanceof basic_1.ObjectReferenceType
|
|
83
84
|
|| source instanceof basic_1.GenericObjectReferenceType
|
|
84
85
|
|| source instanceof basic_1.VoidType
|
|
@@ -120,10 +121,12 @@ class TypeUtils {
|
|
|
120
121
|
}
|
|
121
122
|
else if (target instanceof basic_1.IntegerType
|
|
122
123
|
|| target instanceof basic_1.StringType) {
|
|
123
|
-
if (source instanceof basic_1.
|
|
124
|
+
if (source instanceof basic_1.TableType && source.isWithHeader() === false) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
else if (source instanceof basic_1.DataReference
|
|
124
128
|
|| source instanceof basic_1.ObjectReferenceType
|
|
125
|
-
|| source instanceof basic_1.GenericObjectReferenceType
|
|
126
|
-
|| source instanceof basic_1.TableType) {
|
|
129
|
+
|| source instanceof basic_1.GenericObjectReferenceType) {
|
|
127
130
|
return false;
|
|
128
131
|
}
|
|
129
132
|
return true;
|
|
@@ -10,9 +10,10 @@ class CondBody {
|
|
|
10
10
|
if (node === undefined) {
|
|
11
11
|
return targetType;
|
|
12
12
|
}
|
|
13
|
+
let scoped = false;
|
|
13
14
|
const l = node.findDirectExpression(Expressions.Let);
|
|
14
15
|
if (l) {
|
|
15
|
-
new let_1.Let().runSyntax(l, scope, filename);
|
|
16
|
+
scoped = new let_1.Let().runSyntax(l, scope, filename);
|
|
16
17
|
}
|
|
17
18
|
for (const s of node.findDirectExpressions(Expressions.Cond)) {
|
|
18
19
|
new cond_1.Cond().runSyntax(s, scope, filename);
|
|
@@ -26,6 +27,9 @@ class CondBody {
|
|
|
26
27
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
30
|
+
if (scoped === true) {
|
|
31
|
+
scope.pop(node.getLastToken().getEnd());
|
|
32
|
+
}
|
|
29
33
|
return targetType ? targetType : type;
|
|
30
34
|
}
|
|
31
35
|
}
|
|
@@ -9,13 +9,17 @@ class ConvBody {
|
|
|
9
9
|
if (node === undefined) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
+
let scoped = false;
|
|
12
13
|
const l = node.findDirectExpression(Expressions.Let);
|
|
13
14
|
if (l) {
|
|
14
|
-
new let_1.Let().runSyntax(l, scope, filename);
|
|
15
|
+
scoped = new let_1.Let().runSyntax(l, scope, filename);
|
|
15
16
|
}
|
|
16
17
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
17
18
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
18
19
|
}
|
|
20
|
+
if (scoped === true) {
|
|
21
|
+
scope.pop(node.getLastToken().getEnd());
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
exports.ConvBody = ConvBody;
|
|
@@ -7,12 +7,14 @@ const source_1 = require("./source");
|
|
|
7
7
|
const inline_loop_definition_1 = require("./inline_loop_definition");
|
|
8
8
|
const _scope_type_1 = require("../_scope_type");
|
|
9
9
|
const component_cond_1 = require("./component_cond");
|
|
10
|
+
const cond_1 = require("./cond");
|
|
10
11
|
class For {
|
|
11
12
|
runSyntax(node, scope, filename) {
|
|
12
13
|
const inlineLoop = node.findDirectExpressions(Expressions.InlineLoopDefinition);
|
|
13
14
|
const inlineField = node.findAllExpressions(Expressions.InlineFieldDefinition);
|
|
14
15
|
const addScope = inlineLoop.length > 0 || inlineField.length > 0;
|
|
15
16
|
if (addScope) {
|
|
17
|
+
// this scope is popped in parent expressions
|
|
16
18
|
scope.push(_scope_type_1.ScopeType.For, "FOR", node.getFirstToken().getStart(), filename);
|
|
17
19
|
}
|
|
18
20
|
for (const s of inlineLoop) {
|
|
@@ -27,11 +29,9 @@ class For {
|
|
|
27
29
|
for (const s of node.findDirectExpressions(Expressions.ComponentCond)) {
|
|
28
30
|
new component_cond_1.ComponentCond().runSyntax(s, scope, filename);
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
scope.pop(node.getLastToken().getEnd());
|
|
32
|
+
for (const s of node.findDirectExpressions(Expressions.Cond)) {
|
|
33
|
+
new cond_1.Cond().runSyntax(s, scope, filename);
|
|
33
34
|
}
|
|
34
|
-
*/
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
exports.For = For;
|
|
@@ -9,8 +9,9 @@ const unknown_type_1 = require("../../types/basic/unknown_type");
|
|
|
9
9
|
const _reference_1 = require("../_reference");
|
|
10
10
|
class InlineFieldDefinition {
|
|
11
11
|
runSyntax(node, scope, filename) {
|
|
12
|
+
var _a;
|
|
12
13
|
let type = undefined;
|
|
13
|
-
const field = node.findDirectExpression(Expressions.Field);
|
|
14
|
+
const field = (_a = node.findDirectExpression(Expressions.Field)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
14
15
|
if (field === undefined) {
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
@@ -25,8 +26,12 @@ class InlineFieldDefinition {
|
|
|
25
26
|
if (type === undefined) {
|
|
26
27
|
type = new unknown_type_1.UnknownType("InlineFieldDefinition, fallback");
|
|
27
28
|
}
|
|
28
|
-
const
|
|
29
|
-
scope.
|
|
29
|
+
const name = field.getStr();
|
|
30
|
+
if (scope.findVariable(name) !== undefined) {
|
|
31
|
+
throw new Error(`Variable ${name} already defined`);
|
|
32
|
+
}
|
|
33
|
+
const identifier = new _typed_identifier_1.TypedIdentifier(field, filename, type, ["inline" /* InlineDefinition */]);
|
|
34
|
+
scope.addReference(field, identifier, _reference_1.ReferenceType.DataWriteReference, filename);
|
|
30
35
|
scope.addIdentifier(identifier);
|
|
31
36
|
}
|
|
32
37
|
}
|
|
@@ -3,14 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Let = void 0;
|
|
4
4
|
const Expressions = require("../../2_statements/expressions");
|
|
5
5
|
const inline_field_definition_1 = require("./inline_field_definition");
|
|
6
|
+
const _scope_type_1 = require("../_scope_type");
|
|
6
7
|
class Let {
|
|
7
8
|
runSyntax(node, scope, filename) {
|
|
8
9
|
if (node === undefined) {
|
|
9
|
-
return;
|
|
10
|
+
return false;
|
|
10
11
|
}
|
|
12
|
+
scope.push(_scope_type_1.ScopeType.Let, "LET", node.getFirstToken().getStart(), filename);
|
|
11
13
|
for (const f of node.findDirectExpressions(Expressions.InlineFieldDefinition)) {
|
|
12
14
|
new inline_field_definition_1.InlineFieldDefinition().runSyntax(f, scope, filename);
|
|
13
15
|
}
|
|
16
|
+
return true;
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
19
|
exports.Let = Let;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RaiseWith = void 0;
|
|
4
|
+
const Expressions = require("../../2_statements/expressions");
|
|
5
|
+
const source_1 = require("./source");
|
|
6
|
+
class RaiseWith {
|
|
7
|
+
runSyntax(node, scope, filename) {
|
|
8
|
+
for (const f of node.findDirectExpressions(Expressions.Source)) {
|
|
9
|
+
new source_1.Source().runSyntax(f, scope, filename);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.RaiseWith = RaiseWith;
|
|
14
|
+
//# sourceMappingURL=raise_with.js.map
|
|
@@ -12,14 +12,15 @@ class ValueBody {
|
|
|
12
12
|
if (node === undefined) {
|
|
13
13
|
return targetType;
|
|
14
14
|
}
|
|
15
|
-
const letNode = node.findDirectExpression(Expressions.Let);
|
|
16
|
-
if (letNode) {
|
|
17
|
-
new let_1.Let().runSyntax(letNode, scope, filename);
|
|
18
|
-
}
|
|
19
15
|
const forNode = node.findDirectExpression(Expressions.For);
|
|
20
16
|
if (forNode) {
|
|
21
17
|
new for_1.For().runSyntax(forNode, scope, filename);
|
|
22
18
|
}
|
|
19
|
+
let scoped = false;
|
|
20
|
+
const letNode = node.findDirectExpression(Expressions.Let);
|
|
21
|
+
if (letNode) {
|
|
22
|
+
scoped = new let_1.Let().runSyntax(letNode, scope, filename);
|
|
23
|
+
}
|
|
23
24
|
for (const s of node.findDirectExpressions(Expressions.FieldAssignment)) {
|
|
24
25
|
new field_assignment_1.FieldAssignment().runSyntax(s, scope, filename, targetType);
|
|
25
26
|
}
|
|
@@ -27,6 +28,9 @@ class ValueBody {
|
|
|
27
28
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
28
29
|
type = new source_1.Source().runSyntax(s, scope, filename);
|
|
29
30
|
}
|
|
31
|
+
if (scoped === true) {
|
|
32
|
+
scope.pop(node.getLastToken().getEnd());
|
|
33
|
+
}
|
|
30
34
|
if (scope.getType() === _scope_type_1.ScopeType.For) {
|
|
31
35
|
scope.pop(node.getLastToken().getEnd());
|
|
32
36
|
}
|
|
@@ -7,6 +7,7 @@ const source_1 = require("../expressions/source");
|
|
|
7
7
|
const _reference_1 = require("../_reference");
|
|
8
8
|
const basic_1 = require("../../types/basic");
|
|
9
9
|
const message_source_1 = require("../expressions/message_source");
|
|
10
|
+
const raise_with_1 = require("../expressions/raise_with");
|
|
10
11
|
class Raise {
|
|
11
12
|
runSyntax(node, scope, filename) {
|
|
12
13
|
// todo
|
|
@@ -47,6 +48,9 @@ class Raise {
|
|
|
47
48
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
51
|
+
for (const s of node.findDirectExpressions(Expressions.RaiseWith)) {
|
|
52
|
+
new raise_with_1.RaiseWith().runSyntax(s, scope, filename);
|
|
53
|
+
}
|
|
50
54
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
51
55
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
52
56
|
}
|
|
@@ -12,9 +12,43 @@ class NumberRange extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
getDomain() {
|
|
16
|
+
var _a;
|
|
17
|
+
this.parse();
|
|
18
|
+
return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.domain;
|
|
19
|
+
}
|
|
20
|
+
getPercentage() {
|
|
21
|
+
var _a;
|
|
22
|
+
this.parse();
|
|
23
|
+
return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.percentage;
|
|
24
|
+
}
|
|
25
|
+
setDirty() {
|
|
26
|
+
this.parsedXML = undefined;
|
|
27
|
+
super.setDirty();
|
|
28
|
+
}
|
|
29
|
+
parse() {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f;
|
|
31
|
+
if (this.parsedXML) {
|
|
32
|
+
return { updated: false, runtime: 0 };
|
|
33
|
+
}
|
|
34
|
+
const start = Date.now();
|
|
35
|
+
this.parsedXML = {};
|
|
36
|
+
const parsed = super.parseRaw2();
|
|
37
|
+
if (parsed === undefined) {
|
|
38
|
+
return { updated: false, runtime: 0 };
|
|
39
|
+
}
|
|
40
|
+
const text = (_c = (_b = (_a = parsed.abapGit) === null || _a === void 0 ? void 0 : _a["asx:abap"]) === null || _b === void 0 ? void 0 : _b["asx:values"]) === null || _c === void 0 ? void 0 : _c.TEXT;
|
|
41
|
+
this.parsedXML.description = text === null || text === void 0 ? void 0 : text.TXT;
|
|
42
|
+
const attributes = (_f = (_e = (_d = parsed.abapGit) === null || _d === void 0 ? void 0 : _d["asx:abap"]) === null || _e === void 0 ? void 0 : _e["asx:values"]) === null || _f === void 0 ? void 0 : _f.ATTRIBUTES;
|
|
43
|
+
this.parsedXML.domain = attributes === null || attributes === void 0 ? void 0 : attributes.DOMLEN;
|
|
44
|
+
this.parsedXML.percentage = parseFloat((attributes === null || attributes === void 0 ? void 0 : attributes.PERCENTAGE) || "");
|
|
45
|
+
const end = Date.now();
|
|
46
|
+
return { updated: true, runtime: end - start };
|
|
47
|
+
}
|
|
15
48
|
getDescription() {
|
|
16
|
-
|
|
17
|
-
|
|
49
|
+
var _a;
|
|
50
|
+
this.parse();
|
|
51
|
+
return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.description;
|
|
18
52
|
}
|
|
19
53
|
}
|
|
20
54
|
exports.NumberRange = NumberRange;
|
package/build/src/registry.js
CHANGED
|
@@ -56,6 +56,7 @@ Current rules:
|
|
|
56
56
|
* PARTIALLY IMPLEMENTED removed, it can be quick fixed via rule implement_methods
|
|
57
57
|
* RAISE EXCEPTION ... MESSAGE
|
|
58
58
|
* APPEND expression is outlined
|
|
59
|
+
* Moving with +=, -=, /=, *=, &&=
|
|
59
60
|
|
|
60
61
|
Only one transformation is applied to a statement at a time, so multiple steps might be required to do the full downport.`,
|
|
61
62
|
tags: [_irule_1.RuleTag.Experimental, _irule_1.RuleTag.Downport, _irule_1.RuleTag.Quickfix],
|
|
@@ -163,6 +164,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
163
164
|
if (found) {
|
|
164
165
|
return found;
|
|
165
166
|
}
|
|
167
|
+
found = this.moveWithOperator(high, lowFile);
|
|
168
|
+
if (found) {
|
|
169
|
+
return found;
|
|
170
|
+
}
|
|
166
171
|
found = this.downportSelectInline(low, high, lowFile, highSyntax);
|
|
167
172
|
if (found) {
|
|
168
173
|
return found;
|
|
@@ -560,6 +565,48 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
|
|
|
560
565
|
}
|
|
561
566
|
return undefined;
|
|
562
567
|
}
|
|
568
|
+
moveWithOperator(high, lowFile) {
|
|
569
|
+
var _a, _b, _c;
|
|
570
|
+
if (!(high.get() instanceof Statements.Move)) {
|
|
571
|
+
return undefined;
|
|
572
|
+
}
|
|
573
|
+
const children = high.getChildren();
|
|
574
|
+
const secondChild = children[1];
|
|
575
|
+
if (secondChild === undefined) {
|
|
576
|
+
return undefined;
|
|
577
|
+
}
|
|
578
|
+
const op = secondChild.getFirstToken();
|
|
579
|
+
let operator = "";
|
|
580
|
+
switch (op.getStr()) {
|
|
581
|
+
case "+":
|
|
582
|
+
operator = " + ";
|
|
583
|
+
break;
|
|
584
|
+
case "-":
|
|
585
|
+
operator = " - ";
|
|
586
|
+
break;
|
|
587
|
+
case "/=":
|
|
588
|
+
operator = " / ";
|
|
589
|
+
break;
|
|
590
|
+
case "*=":
|
|
591
|
+
operator = " * ";
|
|
592
|
+
break;
|
|
593
|
+
case "&&=":
|
|
594
|
+
operator = " && ";
|
|
595
|
+
break;
|
|
596
|
+
default:
|
|
597
|
+
return undefined;
|
|
598
|
+
}
|
|
599
|
+
const target = (_a = high.findDirectExpression(Expressions.Target)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
600
|
+
if (target === undefined) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
const sourceStart = (_c = (_b = high.findDirectExpression(Expressions.Source)) === null || _b === void 0 ? void 0 : _b.getFirstChild()) === null || _c === void 0 ? void 0 : _c.getFirstToken().getStart();
|
|
604
|
+
if (sourceStart === undefined) {
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
const fix = edit_helper_1.EditHelper.replaceRange(lowFile, op.getStart(), sourceStart, "= " + target + operator);
|
|
608
|
+
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Expand operator", this.getMetadata().key, this.conf.severity, fix);
|
|
609
|
+
}
|
|
563
610
|
// must be very simple string templates, like "|{ ls_line-no ALPHA = IN }|"
|
|
564
611
|
stringTemplateAlpha(node, lowFile) {
|
|
565
612
|
var _a, _b, _c;
|
|
@@ -659,8 +706,34 @@ ${indentation} output = ${topTarget}.`;
|
|
|
659
706
|
}
|
|
660
707
|
return undefined;
|
|
661
708
|
}
|
|
709
|
+
outlineFor(forLoop, indentation) {
|
|
710
|
+
var _a, _b, _c, _d, _e, _f;
|
|
711
|
+
let body = "";
|
|
712
|
+
let end = "";
|
|
713
|
+
const loopSource = (_a = forLoop.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
714
|
+
const loopTargetField = (_b = forLoop.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
715
|
+
if (forLoop.findDirectTokenByText("UNTIL")) {
|
|
716
|
+
const name = (_c = forLoop.findFirstExpression(Expressions.Field)) === null || _c === void 0 ? void 0 : _c.concatTokens();
|
|
717
|
+
body += indentation + "DATA " + name + " TYPE i.\n";
|
|
718
|
+
const cond = forLoop.findFirstExpression(Expressions.Cond);
|
|
719
|
+
body += indentation + `WHILE NOT ${cond === null || cond === void 0 ? void 0 : cond.concatTokens()}.\n`;
|
|
720
|
+
const field = (_e = (_d = forLoop.findDirectExpression(Expressions.InlineFieldDefinition)) === null || _d === void 0 ? void 0 : _d.findFirstExpression(Expressions.Field)) === null || _e === void 0 ? void 0 : _e.concatTokens();
|
|
721
|
+
body += indentation + ` ${field} = ${field} + 1.\n`;
|
|
722
|
+
end = "ENDWHILE";
|
|
723
|
+
}
|
|
724
|
+
else if (loopTargetField) {
|
|
725
|
+
body += indentation + `LOOP AT ${loopSource} INTO DATA(${loopTargetField}).\n`;
|
|
726
|
+
end = "ENDLOOP";
|
|
727
|
+
}
|
|
728
|
+
else if (loopTargetField === undefined) {
|
|
729
|
+
const loopTargetFieldSymbol = (_f = forLoop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _f === void 0 ? void 0 : _f.concatTokens();
|
|
730
|
+
body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol}).\n`;
|
|
731
|
+
end = "ENDLOOP";
|
|
732
|
+
}
|
|
733
|
+
return { body, end };
|
|
734
|
+
}
|
|
662
735
|
outlineReduce(node, lowFile, highSyntax) {
|
|
663
|
-
var _a
|
|
736
|
+
var _a;
|
|
664
737
|
for (const i of node.findAllExpressionsRecursive(Expressions.Source)) {
|
|
665
738
|
const firstToken = i.getFirstToken();
|
|
666
739
|
if (firstToken.getStr().toUpperCase() !== "REDUCE") {
|
|
@@ -682,19 +755,12 @@ ${indentation} output = ${topTarget}.`;
|
|
|
682
755
|
name = init.getFirstToken().getStr();
|
|
683
756
|
body += indentation + `DATA(${name}) = ${(_a = reduceBody.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens()}.\n`;
|
|
684
757
|
}
|
|
685
|
-
const
|
|
686
|
-
if (
|
|
758
|
+
const forLoop = reduceBody.findDirectExpression(Expressions.For);
|
|
759
|
+
if (forLoop === undefined) {
|
|
687
760
|
continue;
|
|
688
761
|
}
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
if (loopTargetField) {
|
|
692
|
-
body += indentation + `LOOP AT ${loopSource} INTO DATA(${loopTargetField}).\n`;
|
|
693
|
-
}
|
|
694
|
-
if (loopTargetField === undefined) {
|
|
695
|
-
const loopTargetFieldSymbol = (_d = loop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _d === void 0 ? void 0 : _d.concatTokens();
|
|
696
|
-
body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol}).\n`;
|
|
697
|
-
}
|
|
762
|
+
const outlineFor = this.outlineFor(forLoop, indentation);
|
|
763
|
+
body += outlineFor.body;
|
|
698
764
|
const next = reduceBody.findDirectExpression(Expressions.ReduceNext);
|
|
699
765
|
if (next === undefined) {
|
|
700
766
|
continue;
|
|
@@ -713,7 +779,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
713
779
|
body += n.concatTokens() + ".\n";
|
|
714
780
|
}
|
|
715
781
|
}
|
|
716
|
-
body += indentation +
|
|
782
|
+
body += indentation + outlineFor.end + `.\n`;
|
|
717
783
|
body += indentation + `${uniqueName} = ${name}.\n`;
|
|
718
784
|
const abap = `DATA ${uniqueName} TYPE ${type}.\n` +
|
|
719
785
|
body +
|
|
@@ -726,7 +792,6 @@ ${indentation} output = ${topTarget}.`;
|
|
|
726
792
|
return undefined;
|
|
727
793
|
}
|
|
728
794
|
outlineValue(node, lowFile, highSyntax) {
|
|
729
|
-
var _a, _b;
|
|
730
795
|
const allSources = node.findAllExpressionsRecursive(Expressions.Source);
|
|
731
796
|
for (const i of allSources) {
|
|
732
797
|
const firstToken = i.getFirstToken();
|
|
@@ -741,11 +806,11 @@ ${indentation} output = ${topTarget}.`;
|
|
|
741
806
|
const uniqueName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
|
|
742
807
|
let indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
|
|
743
808
|
let body = "";
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
body +=
|
|
809
|
+
const forLoop = valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectExpression(Expressions.For);
|
|
810
|
+
let outlineFor = { body: "", end: "" };
|
|
811
|
+
if (forLoop !== undefined) {
|
|
812
|
+
outlineFor = this.outlineFor(forLoop, indentation);
|
|
813
|
+
body += outlineFor.body;
|
|
749
814
|
indentation += " ";
|
|
750
815
|
}
|
|
751
816
|
let structureName = uniqueName;
|
|
@@ -773,9 +838,9 @@ ${indentation} output = ${topTarget}.`;
|
|
|
773
838
|
body += indentation + `APPEND ${structureName} TO ${uniqueName}.\n`;
|
|
774
839
|
}
|
|
775
840
|
}
|
|
776
|
-
if (
|
|
777
|
-
indentation = indentation.
|
|
778
|
-
body += indentation +
|
|
841
|
+
if (forLoop !== undefined) {
|
|
842
|
+
indentation = indentation.substring(2);
|
|
843
|
+
body += indentation + outlineFor.end + `.\n`;
|
|
779
844
|
}
|
|
780
845
|
const abap = `DATA ${uniqueName} TYPE ${type}.\n` +
|
|
781
846
|
body +
|
|
@@ -913,7 +978,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
913
978
|
const uniqueName = this.uniqueName(i.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
914
979
|
const type = this.findType(i, lowFile, highSyntax);
|
|
915
980
|
const indent = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
|
|
916
|
-
const bodyCode = this.buildCondBody(body, uniqueName, indent);
|
|
981
|
+
const bodyCode = this.buildCondBody(body, uniqueName, indent, lowFile, highSyntax);
|
|
917
982
|
const abap = `DATA ${uniqueName} TYPE ${type}.\n` + bodyCode;
|
|
918
983
|
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), abap);
|
|
919
984
|
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, i.getFirstToken().getStart(), i.getLastToken().getEnd(), uniqueName);
|
|
@@ -922,13 +987,13 @@ ${indentation} output = ${topTarget}.`;
|
|
|
922
987
|
}
|
|
923
988
|
return undefined;
|
|
924
989
|
}
|
|
925
|
-
buildCondBody(body, uniqueName, indent) {
|
|
926
|
-
let code =
|
|
990
|
+
buildCondBody(body, uniqueName, indent, lowFile, highSyntax) {
|
|
991
|
+
let code = "";
|
|
927
992
|
for (const c of body.getChildren()) {
|
|
928
993
|
if (c instanceof nodes_1.TokenNode) {
|
|
929
994
|
switch (c.getFirstToken().getStr().toUpperCase()) {
|
|
930
995
|
case "WHEN":
|
|
931
|
-
code += "IF ";
|
|
996
|
+
code += indent + "IF ";
|
|
932
997
|
break;
|
|
933
998
|
case "THEN":
|
|
934
999
|
code += ".\n";
|
|
@@ -943,11 +1008,14 @@ ${indentation} output = ${topTarget}.`;
|
|
|
943
1008
|
else if (c.get() instanceof Expressions.Cond) {
|
|
944
1009
|
code += c.concatTokens();
|
|
945
1010
|
}
|
|
1011
|
+
else if (c.get() instanceof Expressions.Let) {
|
|
1012
|
+
code += this.outlineLet(c, indent, highSyntax, lowFile);
|
|
1013
|
+
}
|
|
946
1014
|
else if (c.get() instanceof Expressions.Source) {
|
|
947
1015
|
code += indent + " " + uniqueName + " = " + c.concatTokens() + ".\n";
|
|
948
1016
|
}
|
|
949
1017
|
else {
|
|
950
|
-
throw "buildCondBody, unexpected expression";
|
|
1018
|
+
throw "buildCondBody, unexpected expression, " + c.get().constructor.name;
|
|
951
1019
|
}
|
|
952
1020
|
}
|
|
953
1021
|
code += indent + "ENDIF.\n";
|
|
@@ -32,6 +32,8 @@ class FunctionModuleRecommendationsConf extends _basic_rule_config_1.BasicRuleCo
|
|
|
32
32
|
{ name: "REUSE_ALV_GRID_DISPLAY", replace: "use CL_SALV_TABLE=>FACTORY or CL_GUI_ALV_GRID" },
|
|
33
33
|
{ name: "CALCULATE_HASH_FOR_RAW", replace: "use CL_ABAP_HMAC" },
|
|
34
34
|
{ name: "FUNCTION_EXISTS", replace: "surround with try-catch CX_SY_DYN_CALL_ILLEGAL_METHOD instead" },
|
|
35
|
+
{ name: "IGN_TIMESTAMP_DIFFERENCE", replace: "use CL_ABAP_TSTMP" },
|
|
36
|
+
{ name: "IGN_TIMESTAMP_PLUSMINUS", replace: "use CL_ABAP_TSTMP" },
|
|
35
37
|
];
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -45,7 +47,7 @@ class FunctionModuleRecommendations extends _abap_rule_1.ABAPRule {
|
|
|
45
47
|
return {
|
|
46
48
|
key: "function_module_recommendations",
|
|
47
49
|
title: "Function Module Recommendations",
|
|
48
|
-
shortDescription: `
|
|
50
|
+
shortDescription: `Suggests replacements for various function modules`,
|
|
49
51
|
extendedInformation: `https://docs.abapopenchecks.org/checks/53/`,
|
|
50
52
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
51
53
|
};
|
|
@@ -44,8 +44,12 @@ class SuperclassFinal extends _abap_rule_1.ABAPRule {
|
|
|
44
44
|
}
|
|
45
45
|
let found = undefined;
|
|
46
46
|
if (localLookup) {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
for (const f of obj.getABAPFiles()) {
|
|
48
|
+
found = f.getInfo().getClassDefinitionByName(sup);
|
|
49
|
+
if (found !== undefined) {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
if (found === undefined) {
|
|
51
55
|
const clas = this.reg.getObject("CLAS", sup);
|
|
@@ -25,7 +25,9 @@ class UseNew extends _abap_rule_1.ABAPRule {
|
|
|
25
25
|
shortDescription: `Checks for deprecated CREATE OBJECT statements.`,
|
|
26
26
|
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-new-to-create-object
|
|
27
27
|
|
|
28
|
-
If the target variable is referenced in the CREATE OBJECT statement, no errors are issued
|
|
28
|
+
If the target variable is referenced in the CREATE OBJECT statement, no errors are issued
|
|
29
|
+
|
|
30
|
+
Applicable from v740sp02 and up`,
|
|
29
31
|
badExample: `CREATE OBJECT ref.`,
|
|
30
32
|
goodExample: `ref = NEW #( ).`,
|
|
31
33
|
tags: [_irule_1.RuleTag.Upport, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
|
package/build/src/version.js
CHANGED
|
@@ -18,7 +18,7 @@ var Version;
|
|
|
18
18
|
Version["v756"] = "v756";
|
|
19
19
|
Version["Cloud"] = "Cloud";
|
|
20
20
|
})(Version = exports.Version || (exports.Version = {}));
|
|
21
|
-
exports.defaultVersion = Version.
|
|
21
|
+
exports.defaultVersion = Version.v756;
|
|
22
22
|
function getPreviousVersion(v) {
|
|
23
23
|
if (v === Version.OpenABAP) {
|
|
24
24
|
return Version.v702;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.85.
|
|
3
|
+
"version": "2.85.19",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -48,17 +48,17 @@
|
|
|
48
48
|
"@microsoft/api-extractor": "^7.19.4",
|
|
49
49
|
"@types/chai": "^4.3.0",
|
|
50
50
|
"@types/mocha": "^9.1.0",
|
|
51
|
-
"@types/node": "^17.0.
|
|
51
|
+
"@types/node": "^17.0.18",
|
|
52
52
|
"chai": "^4.3.6",
|
|
53
|
-
"eslint": "^8.
|
|
53
|
+
"eslint": "^8.9.0",
|
|
54
54
|
"mocha": "^9.2.0",
|
|
55
55
|
"c8": "^7.11.0",
|
|
56
56
|
"source-map-support": "^0.5.21",
|
|
57
|
-
"ts-json-schema-generator": "^0.
|
|
57
|
+
"ts-json-schema-generator": "^0.98.0",
|
|
58
58
|
"typescript": "^4.5.5"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"fast-xml-parser": "^4.0.
|
|
61
|
+
"fast-xml-parser": "^4.0.3",
|
|
62
62
|
"json5": "^2.2.0",
|
|
63
63
|
"vscode-languageserver-protocol": "^3.16.0",
|
|
64
64
|
"vscode-languageserver-types": "^3.16.0"
|