@abaplint/core 2.120.111 → 2.120.113
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 +7 -4
- package/build/src/abap/2_statements/expressions/loop_group_by.js +1 -1
- package/build/src/abap/2_statements/expressions/method_name.js +1 -1
- package/build/src/abap/5_syntax/_builtin_call.js +98 -0
- package/build/src/abap/5_syntax/_object_oriented.js +11 -0
- package/build/src/abap/5_syntax/_reserved_names.js +12 -0
- package/build/src/abap/5_syntax/basic_types.js +109 -5
- package/build/src/abap/5_syntax/expressions/_check_header_line.js +59 -0
- package/build/src/abap/5_syntax/expressions/_substring.js +5 -4
- package/build/src/abap/5_syntax/expressions/compare.js +17 -31
- package/build/src/abap/5_syntax/expressions/cond_body.js +7 -0
- package/build/src/abap/5_syntax/expressions/inline_data.js +2 -0
- package/build/src/abap/5_syntax/expressions/method_call_chain.js +1 -1
- package/build/src/abap/5_syntax/expressions/method_call_param.js +4 -0
- package/build/src/abap/5_syntax/expressions/method_parameters.js +4 -0
- package/build/src/abap/5_syntax/expressions/source.js +46 -0
- package/build/src/abap/5_syntax/expressions/switch_body.js +6 -0
- package/build/src/abap/5_syntax/expressions/type_table.js +21 -1
- package/build/src/abap/5_syntax/statements/class_data.js +2 -0
- package/build/src/abap/5_syntax/statements/data.js +2 -0
- package/build/src/abap/5_syntax/statements/delete_internal.js +11 -0
- package/build/src/abap/5_syntax/statements/insert_database.js +12 -0
- package/build/src/abap/5_syntax/statements/insert_internal.js +14 -2
- package/build/src/abap/5_syntax/statements/message.js +10 -0
- package/build/src/abap/5_syntax/statements/modify_internal.js +7 -0
- package/build/src/abap/5_syntax/statements/raise.js +5 -0
- package/build/src/abap/5_syntax/statements/write.js +10 -0
- package/build/src/abap/5_syntax/syntax.js +9 -0
- package/build/src/abap/types/basic/floating_point_type.js +2 -2
- package/build/src/abap/types/basic/hex_type.js +2 -2
- package/build/src/abap/types/basic/numeric_type.js +2 -2
- package/build/src/abap/types/basic/table_type.js +2 -1
- package/build/src/abap/types/method_parameters.js +8 -1
- package/build/src/ddic.js +9 -9
- package/build/src/objects/table_type.js +8 -7
- package/build/src/registry.js +1 -1
- package/build/src/rules/check_subrc.js +87 -3
- package/build/src/rules/commented_code.js +21 -1
- package/build/src/rules/forbidden_statement.js +122 -0
- package/build/src/rules/index.js +1 -0
- package/build/src/rules/loop_target_misuse.js +268 -4
- package/build/src/rules/obsolete_statement.js +31 -1
- package/build/src/rules/redundant_conversion.js +15 -3
- package/build/src/rules/rfc_error_handling.js +63 -13
- package/build/src/rules/unhandled_classic_exception.js +31 -4
- package/package.json +1 -1
|
@@ -54,6 +54,7 @@ const conv_body_1 = require("./conv_body");
|
|
|
54
54
|
const filter_body_1 = require("./filter_body");
|
|
55
55
|
const corresponding_body_1 = require("./corresponding_body");
|
|
56
56
|
const _builtin_1 = require("../_builtin");
|
|
57
|
+
const _builtin_call_1 = require("../_builtin_call");
|
|
57
58
|
const attribute_chain_1 = require("./attribute_chain");
|
|
58
59
|
const dereference_1 = require("./dereference");
|
|
59
60
|
const cast_1 = require("./cast");
|
|
@@ -73,6 +74,10 @@ const version_1 = require("../../../version");
|
|
|
73
74
|
*/
|
|
74
75
|
// TODO: refactor all these method parameters to objects, this is getting messy
|
|
75
76
|
class Source {
|
|
77
|
+
// the predicate function in this source is already reported by the caller, Source only checks its arguments
|
|
78
|
+
static predicateReported(source) {
|
|
79
|
+
this.logicalArguments.add(source);
|
|
80
|
+
}
|
|
76
81
|
static runSyntax(node, input, targetType, writeReference = false, allowGenericDeference = false, readReference = true) {
|
|
77
82
|
var _a, _b;
|
|
78
83
|
if (node === undefined) {
|
|
@@ -283,6 +288,14 @@ class Source {
|
|
|
283
288
|
if (first instanceof nodes_1.ExpressionNode) {
|
|
284
289
|
const get = first.get();
|
|
285
290
|
if (get instanceof Expressions.MethodCallChain) {
|
|
291
|
+
const predicate = this.predicateCall(node, first, input);
|
|
292
|
+
if (predicate !== undefined) {
|
|
293
|
+
const message = `Predicate function "${predicate}" can only be used in a logical expression`;
|
|
294
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, first.getFirstToken(), message));
|
|
295
|
+
// the arguments are still checked, for their own errors and references
|
|
296
|
+
method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
|
|
297
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
298
|
+
}
|
|
286
299
|
const found = method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
|
|
287
300
|
context = arithmetic === true ? this.infer(context, found, true) : found;
|
|
288
301
|
if (context === undefined) {
|
|
@@ -535,6 +548,36 @@ class Source {
|
|
|
535
548
|
}
|
|
536
549
|
return targetType;
|
|
537
550
|
}
|
|
551
|
+
// a predicate function, line_exists( ) or contains( ), is a logical expression and not a value,
|
|
552
|
+
// a system reports it as an unknown method in any operand position other than the argument of boolc( ) or xsdbool( ),
|
|
553
|
+
// which parse as method calls in releases before xsdbool( ) was added, or the bool parameter of boolx( )
|
|
554
|
+
static predicateCall(source, chain, input) {
|
|
555
|
+
var _a, _b;
|
|
556
|
+
if (input.scope.getOpenABAP()) {
|
|
557
|
+
return undefined;
|
|
558
|
+
}
|
|
559
|
+
const call = _builtin_call_1.BuiltInCall.fromChain(chain, input);
|
|
560
|
+
const name = call === undefined ? undefined : _builtin_call_1.BuiltInCall.callName(call);
|
|
561
|
+
const upper = name === null || name === void 0 ? void 0 : name.toUpperCase();
|
|
562
|
+
const param = call === null || call === void 0 ? void 0 : call.findDirectExpression(Expressions.MethodCallParam);
|
|
563
|
+
if (upper === "BOOLC" || upper === "XSDBOOL") {
|
|
564
|
+
const argument = param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.Source);
|
|
565
|
+
if (argument !== undefined) {
|
|
566
|
+
this.logicalArguments.add(argument);
|
|
567
|
+
}
|
|
568
|
+
return undefined;
|
|
569
|
+
}
|
|
570
|
+
else if (upper === "BOOLX") {
|
|
571
|
+
for (const p of ((_a = param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.ParameterListS)) === null || _a === void 0 ? void 0 : _a.findDirectExpressions(Expressions.ParameterS)) || []) {
|
|
572
|
+
const argument = p.findDirectExpression(Expressions.Source);
|
|
573
|
+
if (((_b = p.findDirectExpression(Expressions.ParameterName)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase()) === "BOOL" && argument !== undefined) {
|
|
574
|
+
this.logicalArguments.add(argument);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return undefined;
|
|
578
|
+
}
|
|
579
|
+
return _builtin_1.BuiltIn.isPredicate(name) === true && this.logicalArguments.has(source) === false ? name : undefined;
|
|
580
|
+
}
|
|
538
581
|
// "NEW ty( )->*" is a syntax error, also in releases where a method call can be dereferenced
|
|
539
582
|
static isNewObjectDereference(node, deref) {
|
|
540
583
|
var _a;
|
|
@@ -547,4 +590,7 @@ class Source {
|
|
|
547
590
|
}
|
|
548
591
|
}
|
|
549
592
|
exports.Source = Source;
|
|
593
|
+
// arguments of boolc( ), xsdbool( ) and the bool parameter of boolx( ) parsed as method calls, where a predicate function is allowed,
|
|
594
|
+
// and operands where the caller has already reported the predicate function in more specific terms
|
|
595
|
+
Source.logicalArguments = new WeakSet();
|
|
550
596
|
//# sourceMappingURL=source.js.map
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.SwitchBody = void 0;
|
|
37
37
|
const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
38
|
+
const _object_oriented_1 = require("../_object_oriented");
|
|
38
39
|
const source_1 = require("./source");
|
|
39
40
|
const _raise_message_1 = require("../_raise_message");
|
|
40
41
|
const _syntax_input_1 = require("../_syntax_input");
|
|
@@ -44,6 +45,11 @@ class SwitchBody {
|
|
|
44
45
|
if (node === undefined) {
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
48
|
+
const throwNode = node.findDirectExpression(Expressions.Throw);
|
|
49
|
+
const throwMessage = throwNode ? new _object_oriented_1.ObjectOriented(input.scope).checkClassBasedException() : undefined;
|
|
50
|
+
if (throwNode && throwMessage) {
|
|
51
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, throwNode.getFirstToken(), throwMessage));
|
|
52
|
+
}
|
|
47
53
|
for (const t of node.findDirectExpressions(Expressions.Throw)) {
|
|
48
54
|
_raise_message_1.RaiseMessage.checkThrow(t, input);
|
|
49
55
|
}
|
|
@@ -63,7 +63,9 @@ class TypeTable {
|
|
|
63
63
|
if (type === undefined) {
|
|
64
64
|
return new _typed_identifier_1.TypedIdentifier(name, input.filename, new basic_1.UnknownType("TableType, fallback"));
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
const keys = node.findAllExpressions(Expressions.TypeTableKey);
|
|
67
|
+
TypeTable.checkUniqueness(keys, type);
|
|
68
|
+
for (const tt of keys) {
|
|
67
69
|
const error = type_table_key_1.TypeTableKey.runSyntax(tt, type);
|
|
68
70
|
if (error) {
|
|
69
71
|
type = error;
|
|
@@ -71,6 +73,24 @@ class TypeTable {
|
|
|
71
73
|
}
|
|
72
74
|
return new _typed_identifier_1.TypedIdentifier(name, input.filename, type);
|
|
73
75
|
}
|
|
76
|
+
static checkUniqueness(keys, type) {
|
|
77
|
+
var _a;
|
|
78
|
+
for (const key of keys) {
|
|
79
|
+
if (key.concatTokens().toUpperCase().startsWith("WITH UNIQUE EMPTY KEY")) {
|
|
80
|
+
throw new Error("EMPTY KEY cannot be UNIQUE");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// the primary key comes first, it is unnamed or named PRIMARY_KEY
|
|
84
|
+
const first = keys[0];
|
|
85
|
+
const keyName = (_a = first === null || first === void 0 ? void 0 : first.findDirectExpression(Expressions.Field)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
86
|
+
if (type instanceof basic_1.TableType
|
|
87
|
+
&& type.getAccessType() === basic_1.TableAccessType.hashed
|
|
88
|
+
&& first !== undefined
|
|
89
|
+
&& (keyName === undefined || keyName === "PRIMARY_KEY")
|
|
90
|
+
&& first.concatTokens().toUpperCase().startsWith("WITH NON-UNIQUE ")) {
|
|
91
|
+
throw new Error("HASHED tables cannot have NON-UNIQUE key");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
74
94
|
}
|
|
75
95
|
exports.TypeTable = TypeTable;
|
|
76
96
|
//# sourceMappingURL=type_table.js.map
|
|
@@ -40,6 +40,7 @@ const data_definition_1 = require("../expressions/data_definition");
|
|
|
40
40
|
const unknown_type_1 = require("../../types/basic/unknown_type");
|
|
41
41
|
const _syntax_input_1 = require("../_syntax_input");
|
|
42
42
|
const basic_1 = require("../../types/basic");
|
|
43
|
+
const _reserved_names_1 = require("../_reserved_names");
|
|
43
44
|
class ClassData {
|
|
44
45
|
runSyntax(node, input) {
|
|
45
46
|
const dd = node.findFirstExpression(Expressions.DataDefinition);
|
|
@@ -48,6 +49,7 @@ class ClassData {
|
|
|
48
49
|
if (found === undefined) {
|
|
49
50
|
return undefined;
|
|
50
51
|
}
|
|
52
|
+
(0, _reserved_names_1.checkReservedName)(found.getToken(), input);
|
|
51
53
|
if ((found === null || found === void 0 ? void 0 : found.getType().isGeneric()) === true
|
|
52
54
|
&& (found === null || found === void 0 ? void 0 : found.getType().containsVoid()) === false) {
|
|
53
55
|
const message = "DATA definition cannot be generic, " + found.getName();
|
|
@@ -40,12 +40,14 @@ const data_definition_1 = require("../expressions/data_definition");
|
|
|
40
40
|
const unknown_type_1 = require("../../types/basic/unknown_type");
|
|
41
41
|
const _syntax_input_1 = require("../_syntax_input");
|
|
42
42
|
const basic_1 = require("../../types/basic");
|
|
43
|
+
const _reserved_names_1 = require("../_reserved_names");
|
|
43
44
|
class Data {
|
|
44
45
|
runSyntax(node, input) {
|
|
45
46
|
const name = node.findFirstExpression(Expressions.DefinitionName);
|
|
46
47
|
const dd = node.findFirstExpression(Expressions.DataDefinition);
|
|
47
48
|
if (dd) {
|
|
48
49
|
const id = data_definition_1.DataDefinition.runSyntax(dd, input);
|
|
50
|
+
(0, _reserved_names_1.checkReservedName)(id === null || id === void 0 ? void 0 : id.getToken(), input);
|
|
49
51
|
if (id && this.isOnlyDigits(id.getName()) && this.allowOnlyDigitsName(node, input) === false) {
|
|
50
52
|
const message = "not possible to have a name with only digits";
|
|
51
53
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, id.getToken(), message));
|
|
@@ -78,6 +78,17 @@ class DeleteInternal {
|
|
|
78
78
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
+
if (targetType instanceof basic_1.TableType && targetType.isWithHeader() === false) {
|
|
82
|
+
// short forms, "DELETE itab." deletes the current line inside a LOOP, otherwise both use the header line
|
|
83
|
+
const children = node.getChildren().length;
|
|
84
|
+
const short = children === 3 && input.inLoop !== true;
|
|
85
|
+
const shortTable = children === 4 && node.findDirectTokenByText("TABLE") !== undefined;
|
|
86
|
+
if (short || shortTable) {
|
|
87
|
+
const message = "Table does not have header line";
|
|
88
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
81
92
|
if (targetType instanceof basic_1.TableType) {
|
|
82
93
|
targetType = targetType.getRowType();
|
|
83
94
|
}
|
|
@@ -38,9 +38,12 @@ const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
|
38
38
|
const source_1 = require("../expressions/source");
|
|
39
39
|
const dynamic_1 = require("../expressions/dynamic");
|
|
40
40
|
const database_table_1 = require("../expressions/database_table");
|
|
41
|
+
const _syntax_input_1 = require("../_syntax_input");
|
|
42
|
+
const basic_1 = require("../../types/basic");
|
|
41
43
|
const _check_database_work_area_1 = require("../expressions/_check_database_work_area");
|
|
42
44
|
class InsertDatabase {
|
|
43
45
|
runSyntax(node, input) {
|
|
46
|
+
var _a;
|
|
44
47
|
const sourceTypes = new Map();
|
|
45
48
|
for (const s of node.findAllExpressions(Expressions.Source)) {
|
|
46
49
|
sourceTypes.set(s, source_1.Source.runSyntax(s, input));
|
|
@@ -53,6 +56,15 @@ class InsertDatabase {
|
|
|
53
56
|
}
|
|
54
57
|
const dbtab = node.findFirstExpression(Expressions.DatabaseTable);
|
|
55
58
|
if (dbtab !== undefined) {
|
|
59
|
+
// "INSERT itab." is the short form for an internal table with header line
|
|
60
|
+
const localType = node.getChildren().length === 3
|
|
61
|
+
? (_a = input.scope.findVariable(dbtab.concatTokens())) === null || _a === void 0 ? void 0 : _a.getType()
|
|
62
|
+
: undefined;
|
|
63
|
+
if (localType instanceof basic_1.TableType && localType.isWithHeader() === false) {
|
|
64
|
+
const message = "Table does not have header line";
|
|
65
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
56
68
|
const dbSource = database_table_1.DatabaseTable.runSyntax(dbtab, input);
|
|
57
69
|
(0, _check_database_work_area_1.checkDatabaseWorkArea)(node, dbSource, sourceTypes, input);
|
|
58
70
|
}
|
|
@@ -45,7 +45,7 @@ const _type_utils_1 = require("../_type_utils");
|
|
|
45
45
|
const _syntax_input_1 = require("../_syntax_input");
|
|
46
46
|
class InsertInternal {
|
|
47
47
|
runSyntax(node, input) {
|
|
48
|
-
var _a;
|
|
48
|
+
var _a, _b;
|
|
49
49
|
let targetType;
|
|
50
50
|
const t = node.findDirectExpression(Expressions.Target);
|
|
51
51
|
if (t) {
|
|
@@ -108,9 +108,21 @@ class InsertInternal {
|
|
|
108
108
|
// yea, well, INSERT doesnt convert the values automatically, like everything else?
|
|
109
109
|
error = true;
|
|
110
110
|
}
|
|
111
|
+
else if ((sourceType instanceof basic_1.StringType || sourceType instanceof basic_1.CharacterType)
|
|
112
|
+
&& ((_a = sourceType.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) !== true
|
|
113
|
+
&& (source === null || source === void 0 ? void 0 : source.findDirectExpression(Expressions.Constant)) === undefined
|
|
114
|
+
&& (targetType instanceof basic_1.IntegerType
|
|
115
|
+
|| targetType instanceof basic_1.Integer8Type
|
|
116
|
+
|| targetType instanceof basic_1.PackedType
|
|
117
|
+
|| targetType instanceof basic_1.FloatType
|
|
118
|
+
|| targetType instanceof basic_1.DecFloat16Type
|
|
119
|
+
|| targetType instanceof basic_1.DecFloat34Type)) {
|
|
120
|
+
// a character-like data object into a table with a numeric row type, no conversion
|
|
121
|
+
error = true;
|
|
122
|
+
}
|
|
111
123
|
else if (sourceType instanceof basic_1.CharacterType
|
|
112
124
|
&& targetType instanceof basic_1.CharacterType
|
|
113
|
-
&& ((
|
|
125
|
+
&& ((_b = sourceType.getAbstractTypeData()) === null || _b === void 0 ? void 0 : _b.derivedFromConstant) === true
|
|
114
126
|
&& sourceType.getLength() !== targetType.getLength()) {
|
|
115
127
|
// character literal of different length than the row type
|
|
116
128
|
error = true;
|
|
@@ -42,6 +42,7 @@ const target_1 = require("../expressions/target");
|
|
|
42
42
|
const message_source_1 = require("../expressions/message_source");
|
|
43
43
|
const _syntax_input_1 = require("../_syntax_input");
|
|
44
44
|
const _object_oriented_1 = require("../_object_oriented");
|
|
45
|
+
const _builtin_call_1 = require("../_builtin_call");
|
|
45
46
|
class Message {
|
|
46
47
|
runSyntax(node, input) {
|
|
47
48
|
const exceptionName = node.findDirectExpression(Expressions.ExceptionName);
|
|
@@ -60,7 +61,16 @@ class Message {
|
|
|
60
61
|
}
|
|
61
62
|
for (const mss of node.findDirectExpressions(Expressions.MessageSourceSource)) {
|
|
62
63
|
for (const s of mss.findDirectExpressions(Expressions.Source)) {
|
|
64
|
+
const issueCount = input.issues.length;
|
|
63
65
|
source_1.Source.runSyntax(s, input);
|
|
66
|
+
// "Arithmetic calculation not permitted here" on a system, whatever the argument
|
|
67
|
+
const call = issueCount === input.issues.length && input.scope.getOpenABAP() === false
|
|
68
|
+
? _builtin_call_1.BuiltInCall.fromSource(s, input) : undefined;
|
|
69
|
+
if (call !== undefined && _builtin_call_1.BuiltInCall.isNumeric(call)) {
|
|
70
|
+
const message = `Numeric function "${_builtin_call_1.BuiltInCall.callName(call)}" cannot be used in MESSAGE WITH`;
|
|
71
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
64
74
|
}
|
|
65
75
|
for (const s of mss.findDirectExpressions(Expressions.SimpleSource3)) {
|
|
66
76
|
source_1.Source.runSyntax(s, input);
|
|
@@ -81,6 +81,13 @@ class ModifyInternal {
|
|
|
81
81
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
+
if (node.findDirectTokenByText("FROM") === undefined
|
|
85
|
+
&& targetType.isWithHeader() === false) {
|
|
86
|
+
// short form, the header line is the work area, eg. "MODIFY itab."
|
|
87
|
+
const message = "Table does not have header line";
|
|
88
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
84
91
|
}
|
|
85
92
|
else if (targetType instanceof basic_1.StructureType) {
|
|
86
93
|
// it might originate from a TABLES statement
|
|
@@ -57,6 +57,11 @@ class Raise {
|
|
|
57
57
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, exceptionName.getFirstToken(), classicMessage));
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
+
const classBasedMessage = exceptionName === undefined && node.findDirectTokenByText("EXCEPTION")
|
|
61
|
+
? helper.checkClassBasedException() : undefined;
|
|
62
|
+
if (classBasedMessage) {
|
|
63
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), classBasedMessage));
|
|
64
|
+
}
|
|
60
65
|
const classTok = (_a = node.findDirectExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
61
66
|
const className = classTok === null || classTok === void 0 ? void 0 : classTok.getStr();
|
|
62
67
|
if (classTok && className) {
|
|
@@ -42,6 +42,7 @@ const _type_utils_1 = require("../_type_utils");
|
|
|
42
42
|
const field_chain_1 = require("../expressions/field_chain");
|
|
43
43
|
const _reference_1 = require("../_reference");
|
|
44
44
|
const _syntax_input_1 = require("../_syntax_input");
|
|
45
|
+
const _builtin_call_1 = require("../_builtin_call");
|
|
45
46
|
class Write {
|
|
46
47
|
runSyntax(node, input) {
|
|
47
48
|
// todo, more
|
|
@@ -51,7 +52,16 @@ class Write {
|
|
|
51
52
|
second = node.getChildren()[2];
|
|
52
53
|
}
|
|
53
54
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
55
|
+
const issueCount = input.issues.length;
|
|
54
56
|
const type = source_1.Source.runSyntax(s, input);
|
|
57
|
+
// "Arithmetic calculation not permitted here" on a system, while abs( x ) or lines( itab ) is fine
|
|
58
|
+
const call = s === second && issueCount === input.issues.length
|
|
59
|
+
? _builtin_call_1.BuiltInCall.fromSource(s, input) : undefined;
|
|
60
|
+
if (call !== undefined && _builtin_call_1.BuiltInCall.isNumeric(call) && _builtin_call_1.BuiltInCall.hasDataObjectArgument(call) === false) {
|
|
61
|
+
const message = `Numeric function "${_builtin_call_1.BuiltInCall.callName(call)}" in WRITE takes only a single data object as argument`;
|
|
62
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
55
65
|
if (s === second
|
|
56
66
|
&& new _type_utils_1.TypeUtils(input.scope).isCharLike(type) === false
|
|
57
67
|
&& new _type_utils_1.TypeUtils(input.scope).isHexLike(type) === false) {
|
|
@@ -361,6 +361,7 @@ class SyntaxLogic {
|
|
|
361
361
|
this.issues = [];
|
|
362
362
|
this.deferred = [];
|
|
363
363
|
this.loopTables = new _loop_table_change_1.LoopTableChange();
|
|
364
|
+
this.loopDepth = 0;
|
|
364
365
|
this.sortedLines = new _sorted_key_write_1.SortedKeyWrite();
|
|
365
366
|
this.reg.getDDICReferences().clear(this.object);
|
|
366
367
|
this.reg.getMSAGReferences().clear(this.object);
|
|
@@ -430,6 +431,10 @@ class SyntaxLogic {
|
|
|
430
431
|
const loop = node instanceof nodes_1.StructureNode
|
|
431
432
|
&& node.get() instanceof Structures.Loop
|
|
432
433
|
&& this.loopTables.push(node, this.scope);
|
|
434
|
+
const isLoop = node instanceof nodes_1.StructureNode && node.get() instanceof Structures.Loop;
|
|
435
|
+
if (isLoop) {
|
|
436
|
+
this.loopDepth++;
|
|
437
|
+
}
|
|
433
438
|
if (node instanceof nodes_1.StructureNode) {
|
|
434
439
|
this.sortedLines.enter(node, this.currentFile.getFilename());
|
|
435
440
|
}
|
|
@@ -478,6 +483,9 @@ class SyntaxLogic {
|
|
|
478
483
|
if (loop === true) {
|
|
479
484
|
this.loopTables.pop();
|
|
480
485
|
}
|
|
486
|
+
if (isLoop) {
|
|
487
|
+
this.loopDepth--;
|
|
488
|
+
}
|
|
481
489
|
if (node instanceof nodes_1.StructureNode && node.get() instanceof Structures.Loop) {
|
|
482
490
|
const loopStatement = node.findDirectStatement(Statements.Loop);
|
|
483
491
|
if (loopStatement) {
|
|
@@ -563,6 +571,7 @@ class SyntaxLogic {
|
|
|
563
571
|
filename,
|
|
564
572
|
issues: this.issues,
|
|
565
573
|
deferred: this.deferred,
|
|
574
|
+
inLoop: this.loopDepth > 0,
|
|
566
575
|
};
|
|
567
576
|
// todo, refactor
|
|
568
577
|
if (s instanceof Statements.Type) {
|
|
@@ -4,8 +4,8 @@ exports.FloatingPointType = void 0;
|
|
|
4
4
|
const _abstract_type_1 = require("./_abstract_type");
|
|
5
5
|
// this is the DDIC floating point type
|
|
6
6
|
class FloatingPointType extends _abstract_type_1.AbstractType {
|
|
7
|
-
constructor(length,
|
|
8
|
-
super({ qualifiedName:
|
|
7
|
+
constructor(length, extra) {
|
|
8
|
+
super(extra === undefined || typeof extra === "string" ? { qualifiedName: extra } : extra);
|
|
9
9
|
if (length <= 0) {
|
|
10
10
|
throw new Error("Bad LENGTH, Floating Point");
|
|
11
11
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HexType = void 0;
|
|
4
4
|
const _abstract_type_1 = require("./_abstract_type");
|
|
5
5
|
class HexType extends _abstract_type_1.AbstractType {
|
|
6
|
-
constructor(length,
|
|
7
|
-
super({ qualifiedName:
|
|
6
|
+
constructor(length, extra) {
|
|
7
|
+
super(extra === undefined || typeof extra === "string" ? { qualifiedName: extra } : extra);
|
|
8
8
|
if (length <= 0) {
|
|
9
9
|
throw new Error("Bad LENGTH, Hex");
|
|
10
10
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NumericType = void 0;
|
|
4
4
|
const _abstract_type_1 = require("./_abstract_type");
|
|
5
5
|
class NumericType extends _abstract_type_1.AbstractType {
|
|
6
|
-
constructor(length,
|
|
7
|
-
super({ qualifiedName:
|
|
6
|
+
constructor(length, extra) {
|
|
7
|
+
super(extra === undefined || typeof extra === "string" ? { qualifiedName: extra } : extra);
|
|
8
8
|
if (length <= 0) {
|
|
9
9
|
throw new Error("Bad LENGTH, Numeric");
|
|
10
10
|
}
|
|
@@ -17,11 +17,12 @@ var TableKeyType;
|
|
|
17
17
|
TableKeyType["empty"] = "EMPTY";
|
|
18
18
|
})(TableKeyType || (exports.TableKeyType = TableKeyType = {}));
|
|
19
19
|
class TableType extends _abstract_type_1.AbstractType {
|
|
20
|
-
constructor(rowType, options, qualifiedName, description) {
|
|
20
|
+
constructor(rowType, options, qualifiedName, description, ddicName) {
|
|
21
21
|
var _a;
|
|
22
22
|
super({
|
|
23
23
|
qualifiedName: qualifiedName,
|
|
24
24
|
description: description,
|
|
25
|
+
ddicName: ddicName,
|
|
25
26
|
});
|
|
26
27
|
this.rowType = rowType;
|
|
27
28
|
this.options = options;
|
|
@@ -47,6 +47,7 @@ const _reference_1 = require("../5_syntax/_reference");
|
|
|
47
47
|
const identifier_1 = require("../1_lexer/tokens/identifier");
|
|
48
48
|
const _scope_type_1 = require("../5_syntax/_scope_type");
|
|
49
49
|
const _syntax_input_1 = require("../5_syntax/_syntax_input");
|
|
50
|
+
const _reserved_names_1 = require("../5_syntax/_reserved_names");
|
|
50
51
|
// the keywords that can follow a parameter in each section, a plain parameter name is read as them
|
|
51
52
|
const KEYWORDS_AFTER = {
|
|
52
53
|
"IMPORTING": ["PREFERRED", "EXPORTING", "CHANGING", "RETURNING", "RAISING", "EXCEPTIONS"],
|
|
@@ -232,6 +233,7 @@ class MethodParameters {
|
|
|
232
233
|
if (parameter.getName().length > 30) {
|
|
233
234
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, parameter.getToken(), "Method parameter name longer than 30 characters"));
|
|
234
235
|
}
|
|
236
|
+
(0, _reserved_names_1.checkReservedName)(parameter.getToken(), input);
|
|
235
237
|
}
|
|
236
238
|
}
|
|
237
239
|
workaroundRAP(node, input, parentName) {
|
|
@@ -318,9 +320,14 @@ class MethodParameters {
|
|
|
318
320
|
const id = method_param_1.MethodParam.runSyntax(p, input, [...meta, ...extraMeta]);
|
|
319
321
|
input.scope.addIdentifier(id);
|
|
320
322
|
target.push(id);
|
|
321
|
-
|
|
323
|
+
const optionalToken = opt.findDirectTokenByText("OPTIONAL");
|
|
324
|
+
if (optionalToken) {
|
|
322
325
|
const name = target[target.length - 1].getName().toUpperCase();
|
|
323
326
|
this.optional.push(name);
|
|
327
|
+
if (opt.findFirstExpression(Expressions.Default)) {
|
|
328
|
+
const message = "Parameter \"" + id.getName() + "\" cannot have both DEFAULT and OPTIONAL";
|
|
329
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, optionalToken, message));
|
|
330
|
+
}
|
|
324
331
|
}
|
|
325
332
|
else if (opt.findFirstExpression(Expressions.Default)) {
|
|
326
333
|
const name = target[target.length - 1].getName().toUpperCase();
|
package/build/src/ddic.js
CHANGED
|
@@ -400,7 +400,7 @@ class DDIC {
|
|
|
400
400
|
if (input.length === undefined) {
|
|
401
401
|
return new Types.UnknownType(input.text + " unknown length", input.infoText);
|
|
402
402
|
}
|
|
403
|
-
return new Types.NumericType(parseInt(input.length, 10),
|
|
403
|
+
return new Types.NumericType(parseInt(input.length, 10), extra);
|
|
404
404
|
case "CHAR": // 1 <= len <= 30000 (1333 for table fields)
|
|
405
405
|
case "LCHR": // 256 <= len <= 32000
|
|
406
406
|
if (input.length === undefined) {
|
|
@@ -412,10 +412,10 @@ class DDIC {
|
|
|
412
412
|
if (input.length === undefined) {
|
|
413
413
|
return new Types.UnknownType(input.text + " unknown length", input.infoText);
|
|
414
414
|
}
|
|
415
|
-
return new Types.HexType(parseInt(input.length, 10),
|
|
415
|
+
return new Types.HexType(parseInt(input.length, 10), extra);
|
|
416
416
|
case "TIMN": // Native HANA
|
|
417
417
|
case "TIMS":
|
|
418
|
-
return new Types.TimeType(
|
|
418
|
+
return new Types.TimeType(extra); //HHMMSS
|
|
419
419
|
case "DECFLOAT16": // len = 16
|
|
420
420
|
case "DECFLOAT34": // len = 34
|
|
421
421
|
case "D16R": // len = 16
|
|
@@ -426,25 +426,25 @@ class DDIC {
|
|
|
426
426
|
if (input.length === undefined) {
|
|
427
427
|
return new Types.UnknownType(input.text + " unknown length", input.infoText);
|
|
428
428
|
}
|
|
429
|
-
return new Types.FloatingPointType(parseInt(input.length, 10),
|
|
429
|
+
return new Types.FloatingPointType(parseInt(input.length, 10), extra);
|
|
430
430
|
case "DATN": // Native HANA
|
|
431
431
|
case "DATS":
|
|
432
|
-
return new Types.DateType(
|
|
432
|
+
return new Types.DateType(extra); //YYYYMMDD
|
|
433
433
|
case "INT1":
|
|
434
434
|
case "INT2":
|
|
435
435
|
case "INT4":
|
|
436
|
-
return Types.IntegerType.get(
|
|
436
|
+
return Types.IntegerType.get(extra);
|
|
437
437
|
case "INT8":
|
|
438
|
-
return new Types.Integer8Type(
|
|
438
|
+
return new Types.Integer8Type(extra);
|
|
439
439
|
case "SSTR": // 1 <= len <= 1333
|
|
440
440
|
case "SSTRING": // 1 <= len <= 1333
|
|
441
441
|
case "STRG": // 256 <= len
|
|
442
442
|
case "STRING": // 256 <= len
|
|
443
|
-
return Types.StringType.get(
|
|
443
|
+
return Types.StringType.get(extra);
|
|
444
444
|
case "RSTR": // 256 <= len
|
|
445
445
|
case "RAWSTRING": // 256 <= len
|
|
446
446
|
case "GEOM_EWKB":
|
|
447
|
-
return Types.XStringType.get(
|
|
447
|
+
return Types.XStringType.get(extra);
|
|
448
448
|
case "D16S":
|
|
449
449
|
case "D34S":
|
|
450
450
|
case "DF16_SCL":
|
|
@@ -141,34 +141,35 @@ class TableType extends _abstract_object_1.AbstractObject {
|
|
|
141
141
|
}
|
|
142
142
|
else if (this.parsedXML.rowkind === "S") {
|
|
143
143
|
const lookup = ddic.lookupTableOrView(this.parsedXML.rowtype);
|
|
144
|
-
type = new Types.TableType(lookup.type, tableOptions, this.getName(), this.getDescription());
|
|
144
|
+
type = new Types.TableType(lookup.type, tableOptions, this.getName(), this.getDescription(), this.getName());
|
|
145
145
|
if (lookup.object) {
|
|
146
146
|
references.push({ object: lookup.object });
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
else if (this.parsedXML.rowkind === "E") {
|
|
150
150
|
const lookup = ddic.lookupDataElement(this.parsedXML.rowtype);
|
|
151
|
-
type = new Types.TableType(lookup.type, tableOptions, this.getName(), this.getDescription());
|
|
151
|
+
type = new Types.TableType(lookup.type, tableOptions, this.getName(), this.getDescription(), this.getName());
|
|
152
152
|
if (lookup.object) {
|
|
153
153
|
references.push({ object: lookup.object });
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
else if (this.parsedXML.rowkind === "L") {
|
|
157
157
|
const lookup = ddic.lookupTableType(this.parsedXML.rowtype);
|
|
158
|
-
type = new Types.TableType(lookup.type, tableOptions, this.getName(), this.getDescription());
|
|
158
|
+
type = new Types.TableType(lookup.type, tableOptions, this.getName(), this.getDescription(), this.getName());
|
|
159
159
|
if (lookup.object) {
|
|
160
160
|
references.push({ object: lookup.object });
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
else if (this.parsedXML.rowkind === "R" && this.parsedXML.rowtype === "OBJECT") {
|
|
164
|
-
type = new Types.TableType(new basic_1.GenericObjectReferenceType(), tableOptions, this.getName(), this.getDescription());
|
|
164
|
+
type = new Types.TableType(new basic_1.GenericObjectReferenceType(), tableOptions, this.getName(), this.getDescription(), this.getName());
|
|
165
165
|
}
|
|
166
166
|
else if (this.parsedXML.rowkind === "R" && this.parsedXML.rowtype === "DATA") {
|
|
167
|
-
|
|
167
|
+
const row = new basic_1.DataReference(new Types.DataType());
|
|
168
|
+
type = new Types.TableType(row, tableOptions, this.getName(), this.getDescription(), this.getName());
|
|
168
169
|
}
|
|
169
170
|
else if (this.parsedXML.rowkind === "R" && this.parsedXML.rowtype !== undefined) {
|
|
170
171
|
const lookup = ddic.lookupObject(this.parsedXML.rowtype);
|
|
171
|
-
type = new Types.TableType(lookup.type, tableOptions, this.getName(), this.getDescription());
|
|
172
|
+
type = new Types.TableType(lookup.type, tableOptions, this.getName(), this.getDescription(), this.getName());
|
|
172
173
|
if (lookup.object) {
|
|
173
174
|
references.push({ object: lookup.object });
|
|
174
175
|
}
|
|
@@ -184,7 +185,7 @@ class TableType extends _abstract_object_1.AbstractObject {
|
|
|
184
185
|
decimals: this.parsedXML.decimals,
|
|
185
186
|
infoText: this.getName(),
|
|
186
187
|
});
|
|
187
|
-
type = new Types.TableType(row, tableOptions, this.getName(), this.getDescription());
|
|
188
|
+
type = new Types.TableType(row, tableOptions, this.getName(), this.getDescription(), this.getName());
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
else {
|