@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.
Files changed (46) hide show
  1. package/build/abaplint.d.ts +7 -4
  2. package/build/src/abap/2_statements/expressions/loop_group_by.js +1 -1
  3. package/build/src/abap/2_statements/expressions/method_name.js +1 -1
  4. package/build/src/abap/5_syntax/_builtin_call.js +98 -0
  5. package/build/src/abap/5_syntax/_object_oriented.js +11 -0
  6. package/build/src/abap/5_syntax/_reserved_names.js +12 -0
  7. package/build/src/abap/5_syntax/basic_types.js +109 -5
  8. package/build/src/abap/5_syntax/expressions/_check_header_line.js +59 -0
  9. package/build/src/abap/5_syntax/expressions/_substring.js +5 -4
  10. package/build/src/abap/5_syntax/expressions/compare.js +17 -31
  11. package/build/src/abap/5_syntax/expressions/cond_body.js +7 -0
  12. package/build/src/abap/5_syntax/expressions/inline_data.js +2 -0
  13. package/build/src/abap/5_syntax/expressions/method_call_chain.js +1 -1
  14. package/build/src/abap/5_syntax/expressions/method_call_param.js +4 -0
  15. package/build/src/abap/5_syntax/expressions/method_parameters.js +4 -0
  16. package/build/src/abap/5_syntax/expressions/source.js +46 -0
  17. package/build/src/abap/5_syntax/expressions/switch_body.js +6 -0
  18. package/build/src/abap/5_syntax/expressions/type_table.js +21 -1
  19. package/build/src/abap/5_syntax/statements/class_data.js +2 -0
  20. package/build/src/abap/5_syntax/statements/data.js +2 -0
  21. package/build/src/abap/5_syntax/statements/delete_internal.js +11 -0
  22. package/build/src/abap/5_syntax/statements/insert_database.js +12 -0
  23. package/build/src/abap/5_syntax/statements/insert_internal.js +14 -2
  24. package/build/src/abap/5_syntax/statements/message.js +10 -0
  25. package/build/src/abap/5_syntax/statements/modify_internal.js +7 -0
  26. package/build/src/abap/5_syntax/statements/raise.js +5 -0
  27. package/build/src/abap/5_syntax/statements/write.js +10 -0
  28. package/build/src/abap/5_syntax/syntax.js +9 -0
  29. package/build/src/abap/types/basic/floating_point_type.js +2 -2
  30. package/build/src/abap/types/basic/hex_type.js +2 -2
  31. package/build/src/abap/types/basic/numeric_type.js +2 -2
  32. package/build/src/abap/types/basic/table_type.js +2 -1
  33. package/build/src/abap/types/method_parameters.js +8 -1
  34. package/build/src/ddic.js +9 -9
  35. package/build/src/objects/table_type.js +8 -7
  36. package/build/src/registry.js +1 -1
  37. package/build/src/rules/check_subrc.js +87 -3
  38. package/build/src/rules/commented_code.js +21 -1
  39. package/build/src/rules/forbidden_statement.js +122 -0
  40. package/build/src/rules/index.js +1 -0
  41. package/build/src/rules/loop_target_misuse.js +268 -4
  42. package/build/src/rules/obsolete_statement.js +31 -1
  43. package/build/src/rules/redundant_conversion.js +15 -3
  44. package/build/src/rules/rfc_error_handling.js +63 -13
  45. package/build/src/rules/unhandled_classic_exception.js +31 -4
  46. package/package.json +1 -1
@@ -2922,7 +2922,7 @@ declare type Fix = {
2922
2922
 
2923
2923
  declare class FloatingPointType extends AbstractType {
2924
2924
  private readonly length;
2925
- constructor(length: number, qualifiedName?: string);
2925
+ constructor(length: number, extra?: string | AbstractTypeData);
2926
2926
  getLength(): number;
2927
2927
  toText(): string;
2928
2928
  toABAP(): string;
@@ -3298,7 +3298,7 @@ declare class GetTime implements IStatement {
3298
3298
 
3299
3299
  declare class HexType extends AbstractType {
3300
3300
  private readonly length;
3301
- constructor(length: number, qualifiedName?: string);
3301
+ constructor(length: number, extra?: string | AbstractTypeData);
3302
3302
  getLength(): number;
3303
3303
  toText(): string;
3304
3304
  toABAP(): string;
@@ -5266,7 +5266,7 @@ declare class NumericGenericType extends AbstractType {
5266
5266
 
5267
5267
  declare class NumericType extends AbstractType {
5268
5268
  private readonly length;
5269
- constructor(length: number, qualifiedName?: string);
5269
+ constructor(length: number, extra?: string | AbstractTypeData);
5270
5270
  getLength(): number;
5271
5271
  toText(): string;
5272
5272
  toABAP(): string;
@@ -7883,6 +7883,8 @@ declare type SyntaxInput = {
7883
7883
  /** checks which can only run once the full object has been traversed, eg. PERFORM parameters,
7884
7884
  * the FORM might be defined after the PERFORM */
7885
7885
  deferred: (() => void)[];
7886
+ /** the statement is inside a LOOP structure */
7887
+ inLoop?: boolean;
7886
7888
  };
7887
7889
 
7888
7890
  export declare class SyntaxLogic {
@@ -7894,6 +7896,7 @@ export declare class SyntaxLogic {
7894
7896
  private readonly reg;
7895
7897
  private scope;
7896
7898
  private loopTables;
7899
+ private loopDepth;
7897
7900
  private currentMethod;
7898
7901
  private sortedLines;
7899
7902
  private helpers;
@@ -8007,7 +8010,7 @@ declare class TableType extends AbstractObject {
8007
8010
  declare class TableType_2 extends AbstractType {
8008
8011
  private readonly rowType;
8009
8012
  private readonly options;
8010
- constructor(rowType: AbstractType, options: ITableOptions, qualifiedName?: string, description?: string);
8013
+ constructor(rowType: AbstractType, options: ITableOptions, qualifiedName?: string, description?: string, ddicName?: string);
8011
8014
  getOptions(): ITableOptions;
8012
8015
  isWithHeader(): boolean;
8013
8016
  getAccessType(): TableAccessType | undefined;
@@ -9,7 +9,7 @@ const loop_group_by_component_1 = require("./loop_group_by_component");
9
9
  class LoopGroupBy extends combi_1.Expression {
10
10
  getRunnable() {
11
11
  const components = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), (0, combi_1.plus)(loop_group_by_component_1.LoopGroupByComponent), (0, combi_1.tok)(tokens_1.WParenRightW));
12
- const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)("ASCENDING"), (0, combi_1.optPrio)("WITHOUT MEMBERS"), loop_group_by_target_1.LoopGroupByTarget);
12
+ const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)((0, combi_1.seq)((0, combi_1.alt)("ASCENDING", "DESCENDING"), (0, combi_1.optPrio)("AS TEXT"))), (0, combi_1.optPrio)("WITHOUT MEMBERS"), loop_group_by_target_1.LoopGroupByTarget);
13
13
  return ret;
14
14
  }
15
15
  }
@@ -4,7 +4,7 @@ exports.MethodName = void 0;
4
4
  const combi_1 = require("../combi");
5
5
  class MethodName extends combi_1.Expression {
6
6
  getRunnable() {
7
- return (0, combi_1.regex)(/^(\/\w+\/)?\w+(~\w+)?$/);
7
+ return (0, combi_1.regex)(/^!?(\/\w+\/)?\w+(~\w+)?$/);
8
8
  }
9
9
  }
10
10
  exports.MethodName = MethodName;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.BuiltInCall = void 0;
37
+ const Expressions = __importStar(require("../2_statements/expressions"));
38
+ const nodes_1 = require("../nodes");
39
+ const _builtin_1 = require("./_builtin");
40
+ const _object_oriented_1 = require("./_object_oriented");
41
+ const basic_1 = require("../types/basic");
42
+ class BuiltInCall {
43
+ // the call of a built-in function that starts a method call chain, not hidden by a method of the same name
44
+ static fromChain(chain, input) {
45
+ if (chain === undefined || !(chain.get() instanceof Expressions.MethodCallChain)) {
46
+ return undefined;
47
+ }
48
+ const call = chain.getChildren()[0];
49
+ if (!(call instanceof nodes_1.ExpressionNode) || !(call.get() instanceof Expressions.MethodCall)) {
50
+ return undefined;
51
+ }
52
+ const name = this.callName(call);
53
+ // upper case, the definition is cached with the name it is first searched with
54
+ if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name.toUpperCase()) === undefined) {
55
+ return undefined;
56
+ }
57
+ const enclosing = input.scope.findClassDefinition(input.scope.getEnclosingClassName());
58
+ if (enclosing !== undefined && new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(enclosing, name).method !== undefined) {
59
+ return undefined;
60
+ }
61
+ return call;
62
+ }
63
+ // the call of a built-in function when the source is exactly that one call
64
+ static fromSource(source, input) {
65
+ const chain = source === null || source === void 0 ? void 0 : source.getChildren();
66
+ if ((chain === null || chain === void 0 ? void 0 : chain.length) !== 1 || !(chain[0] instanceof nodes_1.ExpressionNode) || chain[0].getChildren().length !== 1) {
67
+ return undefined;
68
+ }
69
+ return this.fromChain(chain[0], input);
70
+ }
71
+ static callName(call) {
72
+ var _a;
73
+ return (_a = call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens().replace(/^!/, "");
74
+ }
75
+ static isNumeric(call) {
76
+ var _a, _b, _c;
77
+ const returning = (_c = (_b = _builtin_1.BuiltIn.searchBuiltin((_a = this.callName(call)) === null || _a === void 0 ? void 0 : _a.toUpperCase())) === null || _b === void 0 ? void 0 : _b.getParameters().getReturning()) === null || _c === void 0 ? void 0 : _c.getType();
78
+ return returning instanceof basic_1.IntegerType || returning instanceof basic_1.FloatType || returning instanceof basic_1.DecFloat34Type;
79
+ }
80
+ // the call has a single argument, without a parameter name, that is a data object and not an expression
81
+ static hasDataObjectArgument(call) {
82
+ var _a;
83
+ const argument = (_a = call.findDirectExpression(Expressions.MethodCallParam)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Source);
84
+ const children = (argument === null || argument === void 0 ? void 0 : argument.getChildren()) || [];
85
+ // a literal or a text symbol, text-001
86
+ if (children.length === 1
87
+ && (children[0].get() instanceof Expressions.Constant || children[0].get() instanceof Expressions.TextElement)) {
88
+ return true;
89
+ }
90
+ // a field, a component, an offset/length or a dereference, r->*
91
+ return children.length > 0
92
+ && children[0].get() instanceof Expressions.FieldChain
93
+ && children.every(c => c.get() instanceof Expressions.FieldChain || c.get() instanceof Expressions.Dereference)
94
+ && (argument === null || argument === void 0 ? void 0 : argument.findFirstExpression(Expressions.TableExpression)) === undefined;
95
+ }
96
+ }
97
+ exports.BuiltInCall = BuiltInCall;
98
+ //# sourceMappingURL=_builtin_call.js.map
@@ -241,6 +241,17 @@ class ObjectOriented {
241
241
  }
242
242
  return undefined;
243
243
  }
244
+ // RAISE EXCEPTION and THROW are not allowed in a method whose interface declares classic EXCEPTIONS,
245
+ // not even for a CX_NO_CHECK class
246
+ checkClassBasedException() {
247
+ var _a;
248
+ const methodName = this.scope.getEnclosingMethodName();
249
+ const classDef = this.scope.findClassDefinition(this.scope.getEnclosingClassName());
250
+ if (methodName && classDef && ((_a = this.searchMethodName(classDef, methodName).method) === null || _a === void 0 ? void 0 : _a.getExceptions().length)) {
251
+ return "Old exceptions and class-based exceptions cannot be used at the same time";
252
+ }
253
+ return undefined;
254
+ }
244
255
  // SUPER-> can only call the previous implementation of the method it is used in, returns the message otherwise
245
256
  // both names are resolved in the super class, so an alias and the method it stands for are the same
246
257
  checkSuperCall(superDef, methodName) {
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkReservedName = checkReservedName;
4
+ const _syntax_input_1 = require("./_syntax_input");
5
+ /** "me" is the self reference in classes, it cannot be declared as a parameter, attribute or variable */
6
+ function checkReservedName(token, input) {
7
+ if (token === undefined || token.getStr().toLowerCase() !== "me" || input.scope.isAnyOO() === false) {
8
+ return;
9
+ }
10
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, "\"me\" is a reserved name, it cannot be declared"));
11
+ }
12
+ //# sourceMappingURL=_reserved_names.js.map
@@ -259,11 +259,47 @@ class BasicTypes {
259
259
  }
260
260
  cloneType(type, qualifiedName) {
261
261
  // nested types(containing "-") will inherit the qualified names if possible
262
- // todo, this needs to be extended to all AbstractTypes instead of just CharacterType
263
- if (type instanceof basic_1.CharacterType
264
- && qualifiedName
265
- && qualifiedName.includes("-") === false) {
266
- type = type.cloneType({ qualifiedName });
262
+ // todo, this needs to be extended to all AbstractTypes
263
+ if (!qualifiedName || qualifiedName.includes("-") === true) {
264
+ return type;
265
+ }
266
+ // TYPES creates a new type, it is no longer the DDIC type
267
+ const data = Object.assign(Object.assign({}, type.getAbstractTypeData()), { qualifiedName, ddicName: undefined });
268
+ if (type instanceof basic_1.CharacterType) {
269
+ type = new basic_1.CharacterType(type.getLength(), data);
270
+ }
271
+ else if (type instanceof Types.IntegerType) {
272
+ type = Types.IntegerType.get(data);
273
+ }
274
+ else if (type instanceof Types.StringType) {
275
+ type = Types.StringType.get(data);
276
+ }
277
+ else if (type instanceof Types.XStringType) {
278
+ type = Types.XStringType.get(data);
279
+ }
280
+ else if (type instanceof Types.Integer8Type) {
281
+ type = new Types.Integer8Type(data);
282
+ }
283
+ else if (type instanceof Types.NumericType) {
284
+ type = new Types.NumericType(type.getLength(), data);
285
+ }
286
+ else if (type instanceof Types.HexType) {
287
+ type = new Types.HexType(type.getLength(), data);
288
+ }
289
+ else if (type instanceof Types.FloatingPointType) {
290
+ type = new Types.FloatingPointType(type.getLength(), data);
291
+ }
292
+ else if (type instanceof Types.DateType) {
293
+ type = new Types.DateType(data);
294
+ }
295
+ else if (type instanceof Types.TimeType) {
296
+ type = new Types.TimeType(data);
297
+ }
298
+ else if (type instanceof basic_1.StructureType) {
299
+ type = new basic_1.StructureType(type.getComponents().slice(), qualifiedName, undefined, type.getDescription());
300
+ }
301
+ else if (type instanceof basic_1.TableType) {
302
+ type = new basic_1.TableType(type.getRowType(), type.getOptions(), qualifiedName, type.getDescription());
267
303
  }
268
304
  return type;
269
305
  }
@@ -544,6 +580,11 @@ class BasicTypes {
544
580
  if (text === undefined) {
545
581
  text = "TYPE";
546
582
  }
583
+ const additionIssue = this.checkLengthDecimals(node, text);
584
+ if (additionIssue !== undefined) {
585
+ this.input.issues.push(additionIssue);
586
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
587
+ }
547
588
  let found = undefined;
548
589
  if (this.isRAPTypeStructure(text)) {
549
590
  return Types.VoidType.get((_f = node.findFirstExpression(Expressions.TypeStructure)) === null || _f === void 0 ? void 0 : _f.concatTokens());
@@ -590,6 +631,10 @@ class BasicTypes {
590
631
  if (type === undefined) {
591
632
  return new Types.UnknownType("Type error, could not resolve \"" + name + "\", parseType");
592
633
  }
634
+ // generic tables are reported via DataReference.isGeneric()
635
+ if (type.isGeneric() === true && !(type instanceof basic_1.TableType)) {
636
+ throw new Error("LIKE REF TO not possible, \"" + name + "\" is generic");
637
+ }
593
638
  return new Types.DataReference(type, name);
594
639
  }
595
640
  else if (text === "TYPE STANDARD TABLE"
@@ -1087,6 +1132,65 @@ class BasicTypes {
1087
1132
  }
1088
1133
  throw new Error("findValue, unexpected");
1089
1134
  }
1135
+ // the LENGTH and DECIMALS additions of DATA, TYPES, CONSTANTS and STATICS, as a system checks them:
1136
+ // LENGTH only with TYPE c, n, x or p, DECIMALS only with TYPE p, also not without a TYPE addition,
1137
+ // a named type cannot be given a length either. With LIKE, a system ignores LENGTH and rejects DECIMALS
1138
+ checkLengthDecimals(node, text) {
1139
+ const length = node.findDirectExpression(Expressions.Length);
1140
+ const decimals = node.findDirectExpression(Expressions.Decimals);
1141
+ const fieldLength = node.get() instanceof Statements.Parameter
1142
+ ? undefined : node.findDirectExpression(Expressions.ConstantFieldLength);
1143
+ if (length === undefined && decimals === undefined && fieldLength === undefined) {
1144
+ return undefined;
1145
+ }
1146
+ else if (text.startsWith("LIKE")) {
1147
+ if (decimals === undefined && fieldLength === undefined) {
1148
+ return undefined;
1149
+ }
1150
+ const message = "When referencing another field (with LIKE), type and length cannot be changed";
1151
+ return (0, _syntax_input_1.syntaxIssue)(this.input, (decimals !== null && decimals !== void 0 ? decimals : node).getFirstToken(), message);
1152
+ }
1153
+ if (fieldLength !== undefined) {
1154
+ const fieldLengthIssue = this.checkFieldLength(node, text);
1155
+ if (fieldLengthIssue !== undefined) {
1156
+ return fieldLengthIssue;
1157
+ }
1158
+ }
1159
+ const builtin = text.startsWith("TYPE") ? text.substring(4).trim() : "";
1160
+ if (length !== undefined && ["C", "N", "X", "P"].includes(builtin) === false) {
1161
+ return (0, _syntax_input_1.syntaxIssue)(this.input, length.getFirstToken(), "\"LENGTH\" can only be specified for types C, N, X, or P");
1162
+ }
1163
+ else if (decimals !== undefined && builtin !== "P") {
1164
+ return (0, _syntax_input_1.syntaxIssue)(this.input, decimals.getFirstToken(), "\"DECIMALS\" can be specified only for type P");
1165
+ }
1166
+ return undefined;
1167
+ }
1168
+ // the length in brackets, "DATA foo(8) TYPE d", as a system checks it: c, n, x and p take any length,
1169
+ // d, t and f only their own length, i any length. Their allowed lengths are ignored with a warning,
1170
+ // which is an error in classes and interfaces. Any other type is an error
1171
+ checkFieldLength(node, text) {
1172
+ var _a;
1173
+ const typeNameExpression = node.findFirstExpression(Expressions.TypeName);
1174
+ const typeName = (_a = typeNameExpression === null || typeNameExpression === void 0 ? void 0 : typeNameExpression.concatTokens().toUpperCase()) !== null && _a !== void 0 ? _a : "";
1175
+ if (typeNameExpression === undefined
1176
+ || text.includes(" REF TO ")
1177
+ || ["C", "N", "X", "P"].includes(typeName)) {
1178
+ return undefined;
1179
+ }
1180
+ const token = typeNameExpression.getFirstToken();
1181
+ const ownLength = { "D": 8, "T": 6, "F": 8 };
1182
+ if (ownLength[typeName] !== undefined) {
1183
+ const length = this.findLength(node);
1184
+ if (length !== undefined && length !== ownLength[typeName]) {
1185
+ const message = "Type \"" + typeName + "\" can only have the specified length \"" + ownLength[typeName] + "\" or no length specified at all";
1186
+ return (0, _syntax_input_1.syntaxIssue)(this.input, token, message);
1187
+ }
1188
+ }
1189
+ if ((ownLength[typeName] !== undefined || typeName === "I") && this.input.scope.isAnyOO() === false) {
1190
+ return undefined;
1191
+ }
1192
+ return (0, _syntax_input_1.syntaxIssue)(this.input, token, "Lengths specified in combination with type \"" + typeName + "\" are ignored");
1193
+ }
1090
1194
  findDecimals(node) {
1091
1195
  var _a, _b, _c;
1092
1196
  const dec = (_b = (_a = node.findDirectExpression(Expressions.Decimals)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Integer)) === null || _b === void 0 ? void 0 : _b.concatTokens();
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.checkHeaderLine = checkHeaderLine;
37
+ const Expressions = __importStar(require("../../2_statements/expressions"));
38
+ const basic_1 = require("../../types/basic");
39
+ const _syntax_input_1 = require("../_syntax_input");
40
+ // A table with header line written without [] is the header line, not the table body,
41
+ // so it cannot be passed to a table typed method parameter. Returns true if an issue was reported.
42
+ function checkHeaderLine(source, sourceType, parameterType, input) {
43
+ if (source === undefined
44
+ || !(parameterType instanceof basic_1.TableType)
45
+ || !(sourceType instanceof basic_1.TableType)
46
+ || sourceType.isWithHeader() === false) {
47
+ return false;
48
+ }
49
+ const chain = source.getChildren().length === 1 ? source.findDirectExpression(Expressions.FieldChain) : undefined;
50
+ const children = (chain === null || chain === void 0 ? void 0 : chain.getChildren()) || [];
51
+ if (chain === undefined || children[children.length - 1].get() instanceof Expressions.TableBody) {
52
+ return false;
53
+ }
54
+ const name = chain.concatTokens();
55
+ const message = `"${name}" is the header line, use "${name}[]" to pass the table body`;
56
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, source.getFirstToken(), message));
57
+ return true;
58
+ }
59
+ //# sourceMappingURL=_check_header_line.js.map
@@ -52,7 +52,7 @@ function substringType(context, offset, length, node, input) {
52
52
  return context;
53
53
  }
54
54
  else if (numericName !== undefined) {
55
- const message = `Offset or length specification not possible on a field of numeric type "${numericName}"`;
55
+ const message = `Field type "${numericName}" does not permit substrings to be accessed`;
56
56
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
57
57
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
58
58
  }
@@ -81,12 +81,13 @@ function substringType(context, offset, length, node, input) {
81
81
  }
82
82
  return context;
83
83
  }
84
+ // the internal type code the ABAP syntax check names: I, 8, P, F, a (decfloat16), e (decfloat34)
84
85
  function numericTypeName(context) {
85
86
  if (context instanceof basic_1.IntegerType) {
86
87
  return "I";
87
88
  }
88
89
  else if (context instanceof basic_1.Integer8Type) {
89
- return "INT8";
90
+ return "8";
90
91
  }
91
92
  else if (context instanceof basic_1.PackedType) {
92
93
  return "P";
@@ -95,10 +96,10 @@ function numericTypeName(context) {
95
96
  return "F";
96
97
  }
97
98
  else if (context instanceof basic_1.DecFloat16Type) {
98
- return "DECFLOAT16";
99
+ return "a";
99
100
  }
100
101
  else if (context instanceof basic_1.DecFloat34Type) {
101
- return "DECFLOAT34";
102
+ return "e";
102
103
  }
103
104
  else if (context instanceof basic_1.DecFloatType) {
104
105
  return "DECFLOAT";
@@ -43,12 +43,20 @@ const _syntax_input_1 = require("../_syntax_input");
43
43
  const basic_1 = require("../../types/basic");
44
44
  const _type_utils_1 = require("../_type_utils");
45
45
  const _builtin_1 = require("../_builtin");
46
- const _object_oriented_1 = require("../_object_oriented");
46
+ const _builtin_call_1 = require("../_builtin_call");
47
47
  class Compare {
48
48
  static runSyntax(node, input) {
49
49
  var _a;
50
- const sourceTypes = [];
51
50
  const sources = node.findDirectExpressions(Expressions.Source);
51
+ // reported before the operands are checked, which then skip the more general predicate function message
52
+ const initialMessage = this.checkInitialOperand(node, input);
53
+ const predicateMessage = this.checkPredicateOperand(sources, input);
54
+ const operandMessage = initialMessage !== null && initialMessage !== void 0 ? initialMessage : predicateMessage;
55
+ if (operandMessage !== undefined) {
56
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), operandMessage));
57
+ }
58
+ // the operands are always checked, for their own errors and references
59
+ const sourceTypes = [];
52
60
  for (const t of sources) {
53
61
  sourceTypes.push(source_1.Source.runSyntax(t, input));
54
62
  }
@@ -58,14 +66,7 @@ class Compare {
58
66
  for (const t of node.findDirectExpressions(Expressions.MethodCallChain)) {
59
67
  method_call_chain_1.MethodCallChain.runSyntax(t, input);
60
68
  }
61
- const initialMessage = this.checkInitialOperand(node, input);
62
- if (initialMessage !== undefined) {
63
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), initialMessage));
64
- return;
65
- }
66
- const predicateMessage = this.checkPredicateOperand(sources, input);
67
- if (predicateMessage !== undefined) {
68
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), predicateMessage));
69
+ if (operandMessage !== undefined) {
69
70
  return;
70
71
  }
71
72
  const typeUtils = new _type_utils_1.TypeUtils(input.scope);
@@ -121,35 +122,20 @@ class Compare {
121
122
  if (input.scope.getOpenABAP()) {
122
123
  return undefined;
123
124
  }
125
+ let message = undefined;
124
126
  for (const source of sources) {
125
127
  const name = this.builtinCallName(source, input);
126
128
  if (_builtin_1.BuiltIn.isPredicate(name) === true) {
127
- return `Predicate function "${name}" cannot be the operand of a comparison`;
129
+ source_1.Source.predicateReported(source);
130
+ message = message !== null && message !== void 0 ? message : `Predicate function "${name}" cannot be the operand of a comparison`;
128
131
  }
129
132
  }
130
- return undefined;
133
+ return message;
131
134
  }
132
135
  // the name of the built-in function when the source is exactly one call of it, not hidden by a method of the same name
133
136
  static builtinCallName(source, input) {
134
- var _a;
135
- const chain = source === null || source === void 0 ? void 0 : source.getChildren();
136
- if ((chain === null || chain === void 0 ? void 0 : chain.length) !== 1 || !(chain[0] instanceof nodes_1.ExpressionNode) || !(chain[0].get() instanceof Expressions.MethodCallChain)) {
137
- return undefined;
138
- }
139
- const calls = chain[0].getChildren();
140
- if (calls.length !== 1 || !(calls[0] instanceof nodes_1.ExpressionNode) || !(calls[0].get() instanceof Expressions.MethodCall)) {
141
- return undefined;
142
- }
143
- const name = (_a = calls[0].findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
144
- if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name) === undefined) {
145
- return undefined;
146
- }
147
- // a method of the same name hides the built-in function
148
- const enclosing = input.scope.findClassDefinition(input.scope.getEnclosingClassName());
149
- if (enclosing !== undefined && new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(enclosing, name).method !== undefined) {
150
- return undefined;
151
- }
152
- return name;
137
+ const call = _builtin_call_1.BuiltInCall.fromSource(source, input);
138
+ return call === undefined ? undefined : _builtin_call_1.BuiltInCall.callName(call);
153
139
  }
154
140
  }
155
141
  exports.Compare = Compare;
@@ -35,15 +35,22 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.CondBody = 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 let_1 = require("./let");
40
41
  const cond_1 = require("./cond");
41
42
  const _raise_message_1 = require("../_raise_message");
43
+ const _syntax_input_1 = require("../_syntax_input");
42
44
  class CondBody {
43
45
  static runSyntax(node, input, targetType) {
44
46
  if (node === undefined) {
45
47
  return undefined;
46
48
  }
49
+ const throwNode = node.findDirectExpression(Expressions.Throw);
50
+ const throwMessage = throwNode ? new _object_oriented_1.ObjectOriented(input.scope).checkClassBasedException() : undefined;
51
+ if (throwNode && throwMessage) {
52
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, throwNode.getFirstToken(), throwMessage));
53
+ }
47
54
  let scoped = false;
48
55
  const l = node.findDirectExpression(Expressions.Let);
49
56
  if (l) {
@@ -50,6 +50,7 @@ const _typed_identifier_1 = require("../../types/_typed_identifier");
50
50
  const basic_1 = require("../../types/basic");
51
51
  const _reference_1 = require("../_reference");
52
52
  const _syntax_input_1 = require("../_syntax_input");
53
+ const _reserved_names_1 = require("../_reserved_names");
53
54
  class InlineData {
54
55
  static runSyntax(node, input, type) {
55
56
  var _a;
@@ -58,6 +59,7 @@ class InlineData {
58
59
  const message = "DATA name too long, " + token.getStr();
59
60
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message));
60
61
  }
62
+ (0, _reserved_names_1.checkReservedName)(token, input);
61
63
  if (token && type) {
62
64
  if (type instanceof basic_1.CSequenceType || type instanceof basic_1.CLikeType) {
63
65
  type = basic_1.StringType.get();
@@ -82,7 +82,7 @@ class MethodCallChain {
82
82
  // for built-in methods set className to undefined
83
83
  const className = context instanceof basic_1.ObjectReferenceType ? context.getIdentifierName() : undefined;
84
84
  const methodToken = (_a = current.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
85
- const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr();
85
+ const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr().replace(/^!/, "");
86
86
  const def = input.scope.findObjectDefinition(className);
87
87
  const isSuper = current === children[2]
88
88
  && first.get() instanceof Expressions.FieldChain
@@ -45,6 +45,7 @@ const _syntax_input_1 = require("../_syntax_input");
45
45
  const constant_1 = require("./constant");
46
46
  const _check_offset_length_1 = require("./_check_offset_length");
47
47
  const _check_text_symbol_1 = require("./_check_text_symbol");
48
+ const _check_header_line_1 = require("./_check_header_line");
48
49
  const _builtin_1 = require("../_builtin");
49
50
  class MethodCallParam {
50
51
  /** returns the type of the unnamed argument, if any */
@@ -122,6 +123,9 @@ class MethodCallParam {
122
123
  else if ((0, _check_text_symbol_1.checkTextSymbol)(child, targetType, input)) {
123
124
  return;
124
125
  }
126
+ else if ((0, _check_header_line_1.checkHeaderLine)(child, sourceType, targetType, input)) {
127
+ return;
128
+ }
125
129
  else if (this.isAssignable(sourceType, targetType, child, method, input) === false) {
126
130
  const message = "Method parameter type not compatible";
127
131
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -47,6 +47,7 @@ const field_chain_1 = require("./field_chain");
47
47
  const _reference_1 = require("../_reference");
48
48
  const _check_offset_length_1 = require("./_check_offset_length");
49
49
  const _check_text_symbol_1 = require("./_check_text_symbol");
50
+ const _check_header_line_1 = require("./_check_header_line");
50
51
  const _builtin_1 = require("../_builtin");
51
52
  function normalizeParameterName(name) {
52
53
  return name.replace(/^!/, "").toUpperCase();
@@ -212,6 +213,9 @@ class MethodParameters {
212
213
  if ((0, _check_text_symbol_1.checkTextSymbol)(item.source, parameter.getType(), input)) {
213
214
  return;
214
215
  }
216
+ else if ((0, _check_header_line_1.checkHeaderLine)(item.source, item.sourceType, parameter.getType(), input)) {
217
+ return;
218
+ }
215
219
  else if (assignable(item.sourceType, parameter.getType(), item.source) === false) {
216
220
  const message = "Method parameter type not compatible, " + item.name;
217
221
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));