@abaplint/core 2.85.14 → 2.85.18
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/basic_types.js +2 -1
- 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/value_body.js +8 -4
- package/build/src/objects/number_range.js +36 -2
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +48 -27
- package/build/src/rules/superclass_final.js +6 -2
- package/build/src/rules/use_new.js +3 -1
- package/package.json +2 -2
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;
|
|
@@ -515,7 +515,8 @@ class BasicTypes {
|
|
|
515
515
|
}
|
|
516
516
|
subs.shift();
|
|
517
517
|
while (subs.length > 0) {
|
|
518
|
-
if (foundType instanceof Types.UnknownType
|
|
518
|
+
if (foundType instanceof Types.UnknownType
|
|
519
|
+
|| foundType instanceof Types.VoidType) {
|
|
519
520
|
return foundType;
|
|
520
521
|
}
|
|
521
522
|
else if (!(foundType instanceof Types.StructureType)) {
|
|
@@ -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;
|
|
@@ -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
|
}
|
|
@@ -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
|
@@ -659,8 +659,34 @@ ${indentation} output = ${topTarget}.`;
|
|
|
659
659
|
}
|
|
660
660
|
return undefined;
|
|
661
661
|
}
|
|
662
|
+
outlineFor(forLoop, indentation) {
|
|
663
|
+
var _a, _b, _c, _d, _e, _f;
|
|
664
|
+
let body = "";
|
|
665
|
+
let end = "";
|
|
666
|
+
const loopSource = (_a = forLoop.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
667
|
+
const loopTargetField = (_b = forLoop.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
668
|
+
if (forLoop.findDirectTokenByText("UNTIL")) {
|
|
669
|
+
const name = (_c = forLoop.findFirstExpression(Expressions.Field)) === null || _c === void 0 ? void 0 : _c.concatTokens();
|
|
670
|
+
body += indentation + "DATA " + name + " TYPE i.\n";
|
|
671
|
+
const cond = forLoop.findFirstExpression(Expressions.Cond);
|
|
672
|
+
body += indentation + `WHILE NOT ${cond === null || cond === void 0 ? void 0 : cond.concatTokens()}.\n`;
|
|
673
|
+
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();
|
|
674
|
+
body += indentation + ` ${field} = ${field} + 1.\n`;
|
|
675
|
+
end = "ENDWHILE";
|
|
676
|
+
}
|
|
677
|
+
else if (loopTargetField) {
|
|
678
|
+
body += indentation + `LOOP AT ${loopSource} INTO DATA(${loopTargetField}).\n`;
|
|
679
|
+
end = "ENDLOOP";
|
|
680
|
+
}
|
|
681
|
+
else if (loopTargetField === undefined) {
|
|
682
|
+
const loopTargetFieldSymbol = (_f = forLoop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _f === void 0 ? void 0 : _f.concatTokens();
|
|
683
|
+
body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol}).\n`;
|
|
684
|
+
end = "ENDLOOP";
|
|
685
|
+
}
|
|
686
|
+
return { body, end };
|
|
687
|
+
}
|
|
662
688
|
outlineReduce(node, lowFile, highSyntax) {
|
|
663
|
-
var _a
|
|
689
|
+
var _a;
|
|
664
690
|
for (const i of node.findAllExpressionsRecursive(Expressions.Source)) {
|
|
665
691
|
const firstToken = i.getFirstToken();
|
|
666
692
|
if (firstToken.getStr().toUpperCase() !== "REDUCE") {
|
|
@@ -682,19 +708,12 @@ ${indentation} output = ${topTarget}.`;
|
|
|
682
708
|
name = init.getFirstToken().getStr();
|
|
683
709
|
body += indentation + `DATA(${name}) = ${(_a = reduceBody.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens()}.\n`;
|
|
684
710
|
}
|
|
685
|
-
const
|
|
686
|
-
if (
|
|
711
|
+
const forLoop = reduceBody.findDirectExpression(Expressions.For);
|
|
712
|
+
if (forLoop === undefined) {
|
|
687
713
|
continue;
|
|
688
714
|
}
|
|
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
|
-
}
|
|
715
|
+
const outlineFor = this.outlineFor(forLoop, indentation);
|
|
716
|
+
body += outlineFor.body;
|
|
698
717
|
const next = reduceBody.findDirectExpression(Expressions.ReduceNext);
|
|
699
718
|
if (next === undefined) {
|
|
700
719
|
continue;
|
|
@@ -713,7 +732,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
713
732
|
body += n.concatTokens() + ".\n";
|
|
714
733
|
}
|
|
715
734
|
}
|
|
716
|
-
body += indentation +
|
|
735
|
+
body += indentation + outlineFor.end + `.\n`;
|
|
717
736
|
body += indentation + `${uniqueName} = ${name}.\n`;
|
|
718
737
|
const abap = `DATA ${uniqueName} TYPE ${type}.\n` +
|
|
719
738
|
body +
|
|
@@ -726,7 +745,6 @@ ${indentation} output = ${topTarget}.`;
|
|
|
726
745
|
return undefined;
|
|
727
746
|
}
|
|
728
747
|
outlineValue(node, lowFile, highSyntax) {
|
|
729
|
-
var _a, _b;
|
|
730
748
|
const allSources = node.findAllExpressionsRecursive(Expressions.Source);
|
|
731
749
|
for (const i of allSources) {
|
|
732
750
|
const firstToken = i.getFirstToken();
|
|
@@ -741,11 +759,11 @@ ${indentation} output = ${topTarget}.`;
|
|
|
741
759
|
const uniqueName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
|
|
742
760
|
let indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
|
|
743
761
|
let body = "";
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
body +=
|
|
762
|
+
const forLoop = valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectExpression(Expressions.For);
|
|
763
|
+
let outlineFor = { body: "", end: "" };
|
|
764
|
+
if (forLoop !== undefined) {
|
|
765
|
+
outlineFor = this.outlineFor(forLoop, indentation);
|
|
766
|
+
body += outlineFor.body;
|
|
749
767
|
indentation += " ";
|
|
750
768
|
}
|
|
751
769
|
let structureName = uniqueName;
|
|
@@ -773,9 +791,9 @@ ${indentation} output = ${topTarget}.`;
|
|
|
773
791
|
body += indentation + `APPEND ${structureName} TO ${uniqueName}.\n`;
|
|
774
792
|
}
|
|
775
793
|
}
|
|
776
|
-
if (
|
|
777
|
-
indentation = indentation.
|
|
778
|
-
body += indentation +
|
|
794
|
+
if (forLoop !== undefined) {
|
|
795
|
+
indentation = indentation.substring(2);
|
|
796
|
+
body += indentation + outlineFor.end + `.\n`;
|
|
779
797
|
}
|
|
780
798
|
const abap = `DATA ${uniqueName} TYPE ${type}.\n` +
|
|
781
799
|
body +
|
|
@@ -913,7 +931,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
913
931
|
const uniqueName = this.uniqueName(i.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
914
932
|
const type = this.findType(i, lowFile, highSyntax);
|
|
915
933
|
const indent = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
|
|
916
|
-
const bodyCode = this.buildCondBody(body, uniqueName, indent);
|
|
934
|
+
const bodyCode = this.buildCondBody(body, uniqueName, indent, lowFile, highSyntax);
|
|
917
935
|
const abap = `DATA ${uniqueName} TYPE ${type}.\n` + bodyCode;
|
|
918
936
|
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), abap);
|
|
919
937
|
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, i.getFirstToken().getStart(), i.getLastToken().getEnd(), uniqueName);
|
|
@@ -922,13 +940,13 @@ ${indentation} output = ${topTarget}.`;
|
|
|
922
940
|
}
|
|
923
941
|
return undefined;
|
|
924
942
|
}
|
|
925
|
-
buildCondBody(body, uniqueName, indent) {
|
|
926
|
-
let code =
|
|
943
|
+
buildCondBody(body, uniqueName, indent, lowFile, highSyntax) {
|
|
944
|
+
let code = "";
|
|
927
945
|
for (const c of body.getChildren()) {
|
|
928
946
|
if (c instanceof nodes_1.TokenNode) {
|
|
929
947
|
switch (c.getFirstToken().getStr().toUpperCase()) {
|
|
930
948
|
case "WHEN":
|
|
931
|
-
code += "IF ";
|
|
949
|
+
code += indent + "IF ";
|
|
932
950
|
break;
|
|
933
951
|
case "THEN":
|
|
934
952
|
code += ".\n";
|
|
@@ -943,11 +961,14 @@ ${indentation} output = ${topTarget}.`;
|
|
|
943
961
|
else if (c.get() instanceof Expressions.Cond) {
|
|
944
962
|
code += c.concatTokens();
|
|
945
963
|
}
|
|
964
|
+
else if (c.get() instanceof Expressions.Let) {
|
|
965
|
+
code += this.outlineLet(c, indent, highSyntax, lowFile);
|
|
966
|
+
}
|
|
946
967
|
else if (c.get() instanceof Expressions.Source) {
|
|
947
968
|
code += indent + " " + uniqueName + " = " + c.concatTokens() + ".\n";
|
|
948
969
|
}
|
|
949
970
|
else {
|
|
950
|
-
throw "buildCondBody, unexpected expression";
|
|
971
|
+
throw "buildCondBody, unexpected expression, " + c.get().constructor.name;
|
|
951
972
|
}
|
|
952
973
|
}
|
|
953
974
|
code += indent + "ENDIF.\n";
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.85.
|
|
3
|
+
"version": "2.85.18",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@types/mocha": "^9.1.0",
|
|
51
51
|
"@types/node": "^17.0.17",
|
|
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",
|